@canonmsg/agent-sdk 12.0.0 → 12.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/README.md +97 -7
  2. package/dist/chunks/chunk-HITMISWV.js +4897 -0
  3. package/dist/chunks/{chunk-FPQFTTND.js → chunk-J63YVAKA.js} +1627 -1099
  4. package/dist/chunks/{chunk-OLJ7H4E2.js → chunk-O5C3ZGI4.js} +6363 -7011
  5. package/dist/chunks/{mls-crypto-NZDNSPAO.js → mls-crypto-ITVGUEP7.js} +3 -3
  6. package/dist/cli.js +403 -30
  7. package/dist/drivers/claude.d.ts +8 -2
  8. package/dist/drivers/codex.d.ts +11 -2
  9. package/dist/drivers/connector.d.ts +34 -0
  10. package/dist/index.d.ts +10 -2
  11. package/dist/index.js +26 -4
  12. package/dist/internal/backend-contracts/artifactActions.d.ts +0 -151
  13. package/dist/internal/backend-contracts/clientFloor.d.ts +52 -0
  14. package/dist/internal/backend-contracts/communication.d.ts +15 -0
  15. package/dist/internal/backend-contracts/connectorRelay.d.ts +179 -0
  16. package/dist/internal/backend-contracts/endpoint.d.ts +17 -0
  17. package/dist/internal/backend-contracts/endpointContentPolicy.d.ts +15 -4
  18. package/dist/internal/backend-contracts/index.d.ts +7 -1
  19. package/dist/internal/backend-contracts/media-url.d.ts +14 -0
  20. package/dist/internal/backend-contracts/message.d.ts +1 -1
  21. package/dist/internal/backend-contracts/mlsDevApplication.d.ts +90 -2
  22. package/dist/internal/backend-contracts/mlsDevCredential.d.ts +5 -2
  23. package/dist/internal/backend-contracts/mlsDevDeviceCustody.d.ts +2 -1
  24. package/dist/internal/backend-contracts/mlsDevEnrollment.d.ts +6 -2
  25. package/dist/internal/backend-contracts/mlsDevFeedReceipt.d.ts +43 -0
  26. package/dist/internal/backend-contracts/mlsDevGroup.d.ts +129 -5
  27. package/dist/internal/backend-contracts/mlsDevGroupFeed.d.ts +6 -2
  28. package/dist/internal/backend-contracts/mlsDevInteraction.d.ts +159 -0
  29. package/dist/internal/backend-contracts/mlsEnvironment.d.ts +35 -0
  30. package/dist/internal/backend-contracts/mlsPrincipalAlias.d.ts +26 -0
  31. package/dist/internal/backend-contracts/runtimeCardFields.d.ts +0 -4
  32. package/dist/internal/backend-contracts/upload-mime-types.d.ts +17 -0
  33. package/dist/internal/backend-contracts/verbContract.d.ts +23 -19
  34. package/dist/internal/backend-contracts/verbSchemas.d.ts +38 -29
  35. package/dist/internal/core/agent-profiles.d.ts +0 -4
  36. package/dist/internal/core/approval-format.d.ts +1 -5
  37. package/dist/internal/core/approval-types.d.ts +1 -2
  38. package/dist/internal/core/client.d.ts +3 -152
  39. package/dist/internal/core/constants.d.ts +0 -3
  40. package/dist/internal/core/endpoint-client.d.ts +14 -1
  41. package/dist/internal/core/execution-environment-mode.d.ts +0 -2
  42. package/dist/internal/core/gifs.d.ts +0 -6
  43. package/dist/internal/core/host-runtime.d.ts +2 -206
  44. package/dist/internal/core/index.d.ts +22 -63
  45. package/dist/internal/core/registration.d.ts +1 -17
  46. package/dist/internal/core/retry.d.ts +0 -9
  47. package/dist/internal/core/rtdb-rest.d.ts +0 -4
  48. package/dist/internal/core/runtime-cards.d.ts +0 -45
  49. package/dist/internal/core/runtime-descriptor.d.ts +1 -60
  50. package/dist/internal/core/runtime-presentation.d.ts +1 -27
  51. package/dist/internal/core/runtime-request-manager.d.ts +0 -1
  52. package/dist/internal/core/self-context.d.ts +0 -39
  53. package/dist/internal/core/silent-turn.d.ts +1 -38
  54. package/dist/internal/core/turn-protocol.d.ts +0 -5
  55. package/dist/internal/core/turn-verbosity.d.ts +5 -23
  56. package/dist/internal/core/types.d.ts +0 -292
  57. package/dist/internal/endpoint/engine.d.ts +31 -1
  58. package/dist/internal/endpoint/index.d.ts +1 -1
  59. package/dist/internal/endpoint/media.d.ts +5 -0
  60. package/dist/internal/endpoint/mls-crypto.d.ts +12 -5
  61. package/dist/internal/endpoint/mls-dev-client.d.ts +9 -1
  62. package/dist/internal/endpoint/mls-dev-device.d.ts +2 -0
  63. package/dist/internal/endpoint/mls-dev-groups.d.ts +65 -5
  64. package/dist/internal/endpoint/mls-dev-interactions.d.ts +99 -0
  65. package/dist/internal/endpoint/mls-dev-key-package-service.d.ts +13 -0
  66. package/dist/internal/endpoint/mls-dev-key-packages.d.ts +23 -3
  67. package/dist/internal/endpoint/mls-dev-text.d.ts +67 -0
  68. package/dist/internal/endpoint/mls-dev-transport.d.ts +2 -1
  69. package/dist/internal/endpoint/node-mls-custody-protocol.d.ts +5 -0
  70. package/dist/internal/endpoint/transport.d.ts +6 -1
  71. package/dist/media.js +2 -2
  72. package/dist/runner/errands.d.ts +118 -0
  73. package/dist/runner/mls.d.ts +97 -0
  74. package/dist/runner/relay.d.ts +87 -0
  75. package/dist/runner/runner.d.ts +61 -0
  76. package/dist/runner/types.d.ts +51 -4
  77. package/package.json +1 -1
  78. package/dist/chunks/chunk-6VK4UZHJ.js +0 -2806
  79. package/dist/internal/backend-contracts/workSessions.d.ts +0 -205
  80. package/dist/internal/core/agent-resolver.d.ts +0 -49
  81. package/dist/internal/core/agent-session.d.ts +0 -12
  82. package/dist/internal/core/artifacts.d.ts +0 -262
  83. package/dist/internal/core/attached-native-session.d.ts +0 -174
  84. package/dist/internal/core/attached-session-file-store.d.ts +0 -3
  85. package/dist/internal/core/control-poller.d.ts +0 -221
  86. package/dist/internal/core/exclusive-json-file-store.d.ts +0 -7
  87. package/dist/internal/core/execution-environment.d.ts +0 -55
  88. package/dist/internal/core/group-context.d.ts +0 -25
  89. package/dist/internal/core/inbound-frame.d.ts +0 -64
  90. package/dist/internal/core/local-runtime-catalog.d.ts +0 -131
  91. package/dist/internal/core/message-format.d.ts +0 -13
  92. package/dist/internal/core/native-session-interaction.d.ts +0 -44
  93. package/dist/internal/core/provenance.d.ts +0 -31
  94. package/dist/internal/core/registration-cli.d.ts +0 -40
  95. package/dist/internal/core/stream.d.ts +0 -77
  96. package/dist/internal/core/turn-output-controller.d.ts +0 -69
  97. package/dist/internal/core/typing-status-publisher.d.ts +0 -14
  98. package/dist/internal/core/work-session-provider.d.ts +0 -29
  99. package/dist/internal/core/workspace-discovery.d.ts +0 -17
@@ -1,6 +1,15 @@
1
+ import { type ConnectorRelayPage, type ConnectorRelaySent } from '../internal/backend-contracts/index.js';
1
2
  import { type CanonEndpoint, type CanonRuntimeDescriptor, type CommunicateInput, type CommunicateResult } from '../internal/core/index.js';
3
+ import { type RunnerMlsOptions } from './mls.js';
2
4
  import { type RuntimeDriver } from './types.js';
3
5
  export interface RunnerOptions {
6
+ /** Canon refused this runner for good (its client floor, mls-cutover-operator.md §2 15b); the CLI stops and exits. */
7
+ onFatal?(error: Error): void;
8
+ /** How the runner names itself to Canon's client floor (`X-Canon-Client`); the CLI passes agent-sdk's version. */
9
+ client?: {
10
+ kind: 'runner';
11
+ version: string;
12
+ };
4
13
  apiKey: string;
5
14
  environmentId: string;
6
15
  /** CANON_HOME: a private 0700 directory, checked before anything is opened. */
@@ -13,12 +22,48 @@ export interface RunnerOptions {
13
22
  /** Test-only origin overrides (the CLI's CANON_BASE_URL and CANON_STREAM_URL). */
14
23
  baseUrl?: string;
15
24
  streamUrl?: string;
25
+ /**
26
+ * The agent's MLS device (Dev only, spec §6): issuer pins and custody, from `loadMlsDevConfiguration`. With it the
27
+ * runner takes part in encrypted rooms; without it each encrypted room is refused, once, in the log. An injected
28
+ * `endpoint` that already has an MLS device counts as configured. `close` runs last on shutdown.
29
+ */
30
+ mls?: RunnerMlsOptions;
31
+ /**
32
+ * Relay mode, the class-C relay (spec §11.4): only encrypted rooms are served, which is what lets a `remote` driver
33
+ * (the connector) into them. Plaintext input is cancelled with no turn (the connector's own installation serves it),
34
+ * control hints are read only for encrypted rooms, no runtime descriptor is published, and `relayRead` and `relaySend`
35
+ * serve the relay channel. It needs the agent's MLS device.
36
+ */
37
+ relay?: boolean;
38
+ /** The engine's installation: the relay's reserved one, from its configuration. A store opened under another refuses to start. */
39
+ installationId?: string;
40
+ /**
41
+ * Team rooms: agents the owner trusts. A message from one of them counts as the owner's for tool permissions (the
42
+ * drivers' guards read `TurnInputMessage.trustedAgent`) only in a room that holds no one but this agent, its owner and
43
+ * listed agents, all of which Canon confirms at the start of the turn are active agents of this agent's own owner; in
44
+ * a plaintext room only for a final its runner marked as answering the owner or confirmed teammates alone, and in an
45
+ * encrypted room never with a relay device in the group. A `remote` runtime has no tools on this host: a relay ignores it.
46
+ */
47
+ trustedAgents?: string[];
48
+ /**
49
+ * Encrypted rooms (§6): how many messages from other agents that @mention this agent a room may wake it with before a
50
+ * person's message is admitted there again (default 6; 0 never wakes on an agent). Past the cap they are settled with
51
+ * no turn, logged once. Plaintext rooms are Canon's to dispatch (RUN-29).
52
+ */
53
+ agentTurnCap?: number;
54
+ /** Encrypted rooms: names besides the agent's display name and id that @mention it, such as a role (`@engineer`). */
55
+ mentionAliases?: string[];
16
56
  /** How long an aborted turn may take to settle before its session is reset (default 10 s). */
17
57
  abortGraceMs?: number;
18
58
  /** A turn with no text or activity for this long fails (default 30 min); the clock waits while an `ask` is pending. */
19
59
  noProgressMs?: number;
20
60
  /** How long an `ask` waits for its answer before it expires (default 1 h; an expired approval is a denial). */
21
61
  askExpiryMs?: number;
62
+ /**
63
+ * Encrypted rooms (encrypted-interactions.md §3): whether an approval the runtime's harness marked `risk: 'destructive'`
64
+ * may offer the owner a session rule. Off by default, so each such action asks; other approvals keep session rules.
65
+ */
66
+ sessionApprovalForDestructive?: boolean;
22
67
  /** How long running turns may finish on shutdown before they are aborted (default 10 s). */
23
68
  shutdownGraceMs?: number;
24
69
  /** Never receives prompt or reply text. */
@@ -31,6 +76,22 @@ export interface Runner {
31
76
  stop(): Promise<void>;
32
77
  /** A proactive send outside any turn (cron): the `communicate` tool's handler, under the runner's identity. */
33
78
  communicate(input: CommunicateInput): Promise<CommunicateResult>;
79
+ /**
80
+ * Relay mode (§11.6): an encrypted room's history as this device verified it and Canon accepted it, newest first, cut
81
+ * to the channel's response budget. `deadline` (epoch ms, default the channel's answer budget) bounds the read.
82
+ */
83
+ relayRead(conversationId: string, page?: {
84
+ limit?: number;
85
+ before?: string;
86
+ deadline?: number;
87
+ }): Promise<ConnectorRelayPage>;
88
+ /**
89
+ * Relay mode (§11.6): encrypted text to a room outside any turn, journaled first; the same `messageId` is the same
90
+ * message. It answers by `deadline`: `pending` only once journaled, a busy refusal (nothing journaled) before that.
91
+ */
92
+ relaySend(conversationId: string, messageId: string, text: string, options?: {
93
+ deadline?: number;
94
+ }): Promise<ConnectorRelaySent>;
34
95
  }
35
96
  /** RUN-27: generated once from the driver's declarations; no static capability table. */
36
97
  export declare function runtimeDescriptor(driver: RuntimeDriver): CanonRuntimeDescriptor;
@@ -5,7 +5,7 @@ import type { MediaAttachment } from '../internal/core/index.js';
5
5
  * the claude and codex drivers pass the conformance suite.
6
6
  */
7
7
  export interface RuntimeDriver {
8
- readonly name: 'code' | 'claude' | 'codex' | 'hermes';
8
+ readonly name: 'code' | 'claude' | 'codex' | 'connector';
9
9
  /** Input to the generated runtime descriptor; never a static table. */
10
10
  readonly capabilities: DriverCapabilities;
11
11
  runTurn(turn: DriverTurn): Promise<DriverResult>;
@@ -34,6 +34,12 @@ export interface DriverTurn {
34
34
  state: DriverState;
35
35
  /** Runner tools bound to this turn by a per-turn token. */
36
36
  tools: TurnTools;
37
+ /**
38
+ * For a `remote` runtime, before its input first leaves this host (the connector's claim): the runner reads the
39
+ * agent's membership, and an encrypted room's audience, from Canon now and counts the pickup as progress (RUN-12).
40
+ * It rejects, and ends the turn, when the agent may no longer act on this input; a transient failure only rejects.
41
+ */
42
+ confirmPickup(): Promise<void>;
37
43
  }
38
44
  /** `reply: null` is deliberate silence. */
39
45
  export interface DriverResult {
@@ -56,6 +62,12 @@ export interface DriverCapabilities {
56
62
  outboundFiles: {
57
63
  roots: string[];
58
64
  } | false;
65
+ /**
66
+ * The runtime runs off the runner's host (the class-C connector, spec §11.3): it gets no local files (inbound
67
+ * attachments are named in the prompt, never materialized), and since its plaintext leaves this host, the runner
68
+ * takes it into encrypted rooms only in relay mode, whose installation discloses that.
69
+ */
70
+ remote?: boolean;
59
71
  /** Across rooms; runner default 8. */
60
72
  maxConcurrentTurns?: number;
61
73
  }
@@ -67,9 +79,9 @@ export type ActivityEvent = {
67
79
  };
68
80
  export type AskRequest =
69
81
  /**
70
- * `scopeKey`: what a session approval covers, e.g. the runtime's tool name. Asks with the same key share the owner's
71
- * session rule; without one, a rule covers only this exact title. A key of letters, digits, `_`, `:` and `-` (up to
72
- * 64) is kept as the card's tool name and compared without regard to case; any other key is hashed.
82
+ * `scopeKey`: what a session approval covers, e.g. the exact call (a tool and its whole input). Asks with the same key
83
+ * share the owner's session rule; without one, a rule covers only this exact title. A key of letters, digits, `_`, `:`
84
+ * and `-` (up to 64) is kept as the card's tool name and compared without regard to case; any other key is hashed.
73
85
  */
74
86
  {
75
87
  kind: 'approve';
@@ -140,6 +152,13 @@ export interface TurnInputMessage {
140
152
  readonly senderName?: string;
141
153
  readonly senderType: 'human' | 'ai_agent';
142
154
  readonly isOwner: boolean;
155
+ /**
156
+ * Set only on a message from an agent the owner listed as trusted (`RunnerOptions.trustedAgents`), in a room of the
157
+ * owner's agents that Canon confirmed at this turn's start (see `trustedAgents` for the whole rule). Drivers treat such
158
+ * a message as the owner's for tool permissions; it is never the owner (`isOwner` stays false), and approvals still go
159
+ * to the owner.
160
+ */
161
+ readonly trustedAgent?: true;
143
162
  readonly text: string;
144
163
  readonly contentType: string;
145
164
  readonly attachments: ReadonlyArray<MediaAttachment>;
@@ -156,13 +175,41 @@ export interface TurnInput {
156
175
  readonly name?: string;
157
176
  readonly type: 'human' | 'ai_agent';
158
177
  readonly isOwner: boolean;
178
+ readonly trustedAgent?: true;
159
179
  };
160
180
  /** This turn's inputs, oldest first. */
161
181
  readonly messages: ReadonlyArray<TurnInputMessage>;
162
182
  /** For drivers without session memory: up to 20 earlier messages since the agent's admission, oldest first. */
163
183
  readonly history: ReadonlyArray<TurnInputMessage>;
184
+ /**
185
+ * The owner's private notes for this turn (`canon-agent tell`, spec §12.3), oldest first, also at the head of `prompt`:
186
+ * context from the machine the runner runs on, never a message in the conversation. They do not change whose turn it is.
187
+ */
188
+ readonly ownerNotes?: ReadonlyArray<string>;
189
+ /**
190
+ * An errand turn (`canon-agent errand`, spec §12.6): the owner's errand, also in `prompt`. Its one message is the owner's,
191
+ * written by the runner; its final is the report to the owner.
192
+ */
193
+ readonly errand?: ErrandFacts;
194
+ /** Open errands that brought the agent into this conversation (§12.6), also at the head of `prompt`. */
195
+ readonly errands?: ReadonlyArray<ErrandFacts>;
196
+ }
197
+ /** An errand as a turn sees it: why the owner sent the agent, what to do, the recipient and the origin conversation. */
198
+ export interface ErrandFacts {
199
+ readonly id: string;
200
+ readonly why: string;
201
+ readonly instruction: string;
202
+ readonly to: string;
203
+ readonly origin?: string;
164
204
  }
165
205
  /** Thrown by a driver whose native session is unusable: the turn fails and the runner resets the session. */
166
206
  export declare class DriverSessionError extends Error {
167
207
  name: string;
168
208
  }
209
+ /** A relay channel refusal (spec §11.6): the channel answers Functions with this status and code. */
210
+ export declare class ConnectorRelayError extends Error {
211
+ readonly status: 400 | 403 | 404 | 409 | 503;
212
+ readonly code: string;
213
+ name: string;
214
+ constructor(status: 400 | 403 | 404 | 409 | 503, code: string, message: string);
215
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canonmsg/agent-sdk",
3
- "version": "12.0.0",
3
+ "version": "12.2.0",
4
4
  "description": "Canon Agent SDK — build AI agents that participate in Canon conversations",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",