Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@copass/core

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@copass/core - npm Package Compare versions

Comparing version
0.6.3
to
0.8.0
+130
-7
dist/index.js

@@ -1192,2 +1192,90 @@ // src/auth/api-key.ts

// src/resources/compute.ts
var BASE4 = "/api/v1/storage/sandboxes";
function computeBase(sandboxId) {
return `${BASE4}/${sandboxId}/compute`;
}
var ComputeResource = class extends BaseResource {
/** List curated compute templates available for this sandbox. */
async listTemplates(sandboxId, options = {}) {
return this.get(
`${computeBase(sandboxId)}/templates`,
{ query: { provider: options.provider } }
);
}
/**
* Provision a new compute session. Returns the platform-issued
* `session_id` — pass it to subsequent `/exec` / `/health` /
* `stopSession` calls.
*
* Throws on:
* - 402 — insufficient credits (`InsufficientCreditsError`)
* - 403 — kill-switch engaged (`ComputeKillSwitchPausedError`)
* - 404 — unknown template
* - 409 — per-user concurrency cap exceeded
* - 502 — vendor SDK error
*/
async createSession(sandboxId, request) {
return this.post(
`${computeBase(sandboxId)}/sessions`,
request
);
}
/**
* List compute sessions for this (user, sandbox). Defaults to
* active sessions; pass `include_stopped: true` to also see
* terminal-state rows.
*/
async listSessions(sandboxId, options = {}) {
return this.get(
`${computeBase(sandboxId)}/sessions`,
{
query: {
include_stopped: options.include_stopped ? "true" : void 0,
limit: options.limit !== void 0 ? String(options.limit) : void 0
}
}
);
}
/** Fetch one compute session by its platform `session_id`. */
async getSession(sandboxId, sessionId) {
return this.get(
`${computeBase(sandboxId)}/sessions/${sessionId}`
);
}
/**
* Stop a compute session and bill the elapsed compute time.
*
* Idempotent — a session already in a terminal state returns
* `status='stopped'` without re-calling the provider or re-billing.
*/
async stopSession(sandboxId, sessionId) {
return this.delete(
`${computeBase(sandboxId)}/sessions/${sessionId}`
);
}
/**
* Run a single-shot command inside a provisioned sandbox.
*
* A non-zero `exit_code` on the returned shape is the user's
* command failing — the call still returns 200 (no throw). Provider
* / billing failures throw via the standard `CopassApiError` path.
*/
async exec(sandboxId, sessionId, request) {
return this.post(
`${computeBase(sandboxId)}/sessions/${sessionId}/exec`,
request
);
}
/**
* Best-effort liveness check on a compute session. Sessions in
* terminal row states short-circuit without a provider round-trip.
*/
async sessionHealth(sandboxId, sessionId) {
return this.get(
`${computeBase(sandboxId)}/sessions/${sessionId}/health`
);
}
};
// src/util/sse.ts

@@ -1259,5 +1347,5 @@ async function* parseSSE(response) {

// src/resources/concierge.ts
var BASE4 = "/api/v1/storage/sandboxes";
var BASE5 = "/api/v1/storage/sandboxes";
function conciergeBase(sandboxId) {
return `${BASE4}/${sandboxId}/concierge`;
return `${BASE5}/${sandboxId}/concierge`;
}

@@ -1326,3 +1414,6 @@ var ConciergeResource = class extends BaseResource {

storage_only: options.storageOnly,
project_id: options.projectId ?? this.projectId
project_id: options.projectId ?? this.projectId,
occurred_at: options.occurredAt,
speaker: options.speaker,
participants: options.participants
});

@@ -1375,5 +1466,7 @@ }

turns;
participants;
constructor(options) {
super(options);
this.turns = [...options.initialTurns ?? []];
this.participants = options.participants ? Object.freeze([...options.participants]) : void 0;
}

@@ -1385,6 +1478,22 @@ /**

* wanting fire-and-forget can drop the `await` or wrap in `void`.
*
* The turn's `name` (if set) is forwarded as the envelope's
* `speaker` field; absent `name` falls back to the capitalized
* `role` (`'user'` → `'User'`, `'assistant'` → `'Assistant'`). The
* `${role}: ${content}` content-prefix munging the prior version
* used has been retired — the wire body is now the message
* `content` verbatim, with `speaker` riding on the envelope.
*
* Participants come from the call-site override if set, otherwise
* from the window's constructor-time roster, otherwise omitted.
*/
async addTurn(turn) {
async addTurn(turn, options = {}) {
this.turns.push(turn);
await this.push(`${turn.role}: ${turn.content}`, { sourceType: "conversation" });
const speaker = turn.name ?? capitalizeRole(turn.role);
const participants = options.participants ?? (this.participants ? [...this.participants] : void 0);
await this.push(turn.content, {
sourceType: "conversation",
speaker,
participants
});
}

@@ -1400,2 +1509,6 @@ /** Current turn log — returned as a defensive copy so callers can't mutate internal state. */

};
function capitalizeRole(role) {
if (!role) return role;
return role[0].toUpperCase() + role.slice(1);
}

@@ -1421,3 +1534,4 @@ // src/context-window/resource.ts

dataSourceId: source.data_source_id,
projectId: options.project_id
projectId: options.project_id,
participants: options.participants
});

@@ -1439,3 +1553,4 @@ }

projectId: options.project_id,
initialTurns: options.initialTurns
initialTurns: options.initialTurns,
participants: options.participants
});

@@ -1463,2 +1578,8 @@ }

/**
* Public Compute Router (ADR 0020) — provision sandboxes from
* curated templates, run shell commands, stream health, stop on
* demand. Decoupled from the agent runtime.
*/
compute;
/**
* Copass Concierge — per-user platform agent for managing your

@@ -1491,2 +1612,3 @@ * Copass setup conversationally. `test()` for one-shot runs;

this.agents = new AgentsResource(http);
this.compute = new ComputeResource(http);
this.concierge = new ConciergeResource(http);

@@ -1773,2 +1895,3 @@ this.contextWindow = new ContextWindowResource(this);

BearerAuthProvider,
ComputeResource,
ConciergeResource,

@@ -1775,0 +1898,0 @@ ContextWindow,

+2
-2
{
"name": "@copass/core",
"version": "0.6.3",
"version": "0.8.0",
"description": "Core client SDK for the Copass platform",

@@ -64,3 +64,3 @@ "publishConfig": {

},
"gitHead": "89abb7a320314feed66ff82fcb251f41ad2a70cb"
"gitHead": "9d619cc3e016244aa2d1245973c702e38f7dac17"
}

@@ -35,2 +35,75 @@ # @copass/harness

## Conversation metadata: speaker, participants, timestamp
The ingest envelope carries optional metadata that travels alongside
the content. Set them when the data is conversation-shaped so the
platform can attribute and order content correctly.
| Field | Where | What it means |
|---|---|---|
| `occurred_at` | `IngestTextRequest`, `BaseDataSource.push`, `client.sources.ingest` | ISO 8601 timestamp anchoring this payload to a real-world moment. |
| `speaker` | Same | Name of the participant who uttered this payload. Caller-decided literal (`'User'`, `'Assistant'`, `'Alice'`, an email address, …). |
| `participants` | Same | Roster of participants present in this artifact. Per-message — pass the snapshot at the time of utterance. |
| `source_type` | Same | Hint describing the payload kind. Conventional values: `'text'`, `'markdown'`, `'code'`, `'json'` (content-shape) or `'conversation'`, `'ticket'`, `'email'`, `'note'` (artifact-kind). Free-form string. |
### Direct API
```typescript
await client.ingest.text({
text: 'Hey Alice, did you finish the report?',
source_type: 'conversation',
speaker: 'Bob',
participants: ['Alice', 'Bob'],
occurred_at: '2026-05-08T15:30:00Z',
});
```
### Through a `ContextWindow`
For a chat-style agent, set the participant roster once at window
construction; it forwards on every `addTurn` call. Set
`ChatMessage.name` when you want a richer speaker than the role-derived
default (`'User'` / `'Assistant'`):
```typescript
const window = await client.contextWindow.create({
sandbox_id,
participants: ['User', 'Alice'], // default roster, applied on every turn
});
// Role-only — speaker derived as capitalized role.
await window.addTurn({ role: 'user', content: 'Hey Alice…' });
// Named participant — `name` overrides the role-derived speaker.
await window.addTurn({
role: 'user',
content: '…thanks!',
name: 'Bob',
});
// Per-call override — use when the roster shifts mid-conversation.
await window.addTurn(
{ role: 'assistant', content: '…' },
{ participants: ['User', 'Alice', 'Bob', 'Carol'] },
);
```
### Through a `BaseDataSource` subclass
```typescript
class SlackChannelSource extends BaseDataSource {
async pushMessage(msg: SlackMessage) {
await this.push(msg.text, {
sourceType: 'conversation',
speaker: msg.authorName,
participants: msg.channel.memberNames,
occurredAt: msg.postedAtIso,
});
}
}
```
Existing callers that don't pass any of these fields keep working —
all four are optional.
## Documentation

@@ -37,0 +110,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display