@intentic/extension-api 1.432.0 → 1.433.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.
package/src/testing.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { mkdtemp, rm } from "node:fs/promises";
2
2
  import { tmpdir } from "node:os";
3
3
  import { join } from "node:path";
4
- import { type DeclaredPermissions, declaredReachOf, type ExtensionReach, extensionRouteReach } from "@intentic/extension-manifest/permissions";
4
+ import { type DeclaredPermissions, declaredReachOf, type ExtensionDeclaredReach, type ExtensionReach, extensionRouteReach } from "@intentic/extension-manifest/permissions";
5
5
  import { type PublicRouteContribution, publicRouteAutomationOf, publicRouteFor } from "@intentic/extension-manifest";
6
6
  import {
7
7
  type ExtensionActivity,
@@ -32,8 +32,25 @@ import {
32
32
  ExtensionWorkHoldSchema,
33
33
  NO_TOOL_GRANTS,
34
34
  readCallerClaim,
35
+ ExtensionIdentitySignSchema,
36
+ type ExtensionIdentitySigned,
37
+ extensionIdentitySignUrl,
38
+ extensionIdentityUrl,
35
39
  } from "@intentic/sandbox-contract/extension-protocol";
36
40
  import { EXTENSION_TOKEN_HEADER } from "@intentic/sandbox-contract/headers";
41
+ import {
42
+ canonicalBytes,
43
+ EXTENSION_SIGN_PAYLOAD_MAX_BYTES,
44
+ type ExtensionSignPayload,
45
+ extensionSignDomain,
46
+ extensionSignProblem,
47
+ generateKeySet,
48
+ type S2sKeySet,
49
+ secretKeysOf,
50
+ signExtensionPayload,
51
+ signIdentity,
52
+ } from "@intentic/sandbox-contract/s2s";
53
+ import type { SandboxIdentity } from "@intentic/sandbox-contract/schemas/s2s";
37
54
  import { activateServerModule, createServerApi, deactivateWithin, healthWithin } from "./runtime.js";
38
55
  import { type FakeSleep, fakeSleep } from "./sleep-fake.js";
39
56
  import type {
@@ -171,6 +188,10 @@ export interface FakeExtension {
171
188
  // (2026-11-27) Hosted sleep (`api.sleep`): `now()` tells every before-sleep watch and resolves with how many answered
172
189
  // ready, `boot` is what `api.sleep.boot()` answers, and `wakeUrls` every URL handed out (sleep-fake.ts).
173
190
  readonly sleep: Omit<FakeSleep, "door">;
191
+ // (2026-11-28) This sandbox's identity (`api.identity`): a real key set made on the first ask, the document it signed,
192
+ // and every record signed through it (fakeIdentity below). Verify what the backend was handed with the contract's
193
+ // `verifyExtensionPayload` against `identity.document().keys`.
194
+ readonly identity: FakeIdentity;
174
195
  // (2026-11-26) The job's end once its work told it, as `wait` hands it to the agent.
175
196
  jobEnd(id: string): Promise<JobEnd>;
176
197
  // (2026-11-26) The agent or a person stopping the job: its work's signal aborts.
@@ -435,6 +456,76 @@ const fakeTurn = (options: FakeExtensionOptions, declared: readonly string[]) =>
435
456
  };
436
457
  };
437
458
 
459
+ // (2026-11-28) The daemon's side of `api.identity` for `fakeExtensionApi` (below): a real hybrid key set, made on
460
+ // the first ask (an ML-DSA key costs milliseconds no other suite should pay), a document it signs, and signatures made
461
+ // with it under the extension's own domain, refused as the daemon refuses them. So a test verifies what its backend was
462
+ // handed with the contract's own `verifyExtensionPayload` against `document.keys`, as a far sandbox would.
463
+
464
+ // Who the fake sandbox is in its document.
465
+ export const FAKE_SANDBOX_IDENTITY = { sandbox: "fake", name: "Fake sandbox", host: "sandbox-fake.sbx.test" } as const;
466
+
467
+ // A record the extension had signed, as the daemon took it.
468
+ export interface FakeSigned {
469
+ readonly purpose: string;
470
+ readonly payload: ExtensionSignPayload;
471
+ readonly domain: string;
472
+ }
473
+
474
+ export interface FakeIdentity {
475
+ // The fake sandbox's signed document: the one `api.identity.document()` answers and whose keys verify every signature.
476
+ document(): SandboxIdentity;
477
+ // Its key set, secret half included: a test signing as a far sandbox, or checking by hand.
478
+ keySet(): S2sKeySet;
479
+ // Every record signed, in order.
480
+ readonly signed: readonly FakeSigned[];
481
+ }
482
+
483
+ const fakeIdentity = (id: string, declared: ExtensionDeclaredReach) => {
484
+ let made: { readonly keySet: S2sKeySet; readonly document: SandboxIdentity } | undefined;
485
+ const ensure = (): { readonly keySet: S2sKeySet; readonly document: SandboxIdentity } => {
486
+ if (made === undefined) {
487
+ const keySet = generateKeySet();
488
+ made = { keySet, document: signIdentity({ ...FAKE_SANDBOX_IDENTITY, domains: [], issuedAt: Date.now() }, keySet) };
489
+ }
490
+ return made;
491
+ };
492
+ const signed: FakeSigned[] = [];
493
+
494
+ // The two doors as the daemon answers them (own-identity.ts), undefined for a request that is for neither.
495
+ const door = async (request: Request, url: URL): Promise<Response | undefined> => {
496
+ if (request.method === "GET" && url.pathname === extensionIdentityUrl()) {
497
+ return json(ensure().document);
498
+ }
499
+ if (request.method !== "POST" || url.pathname !== extensionIdentitySignUrl()) {
500
+ return undefined;
501
+ }
502
+ if (!declared.identity.includes("sign")) {
503
+ return json({ error: `extension "${id}" did not declare permissions.identity ["sign"], so it signs nothing as this sandbox` }, 403);
504
+ }
505
+ // allow(silent-catch): a body that is not JSON is no record to sign, which the schema refuses just below
506
+ const asked = ExtensionIdentitySignSchema.safeParse(await request.json().catch(() => undefined));
507
+ if (!asked.success) {
508
+ return json({ error: "not a record to sign: the body is { purpose, payload }, the payload any JSON value" }, 400);
509
+ }
510
+ const { purpose, payload } = asked.data;
511
+ const problem = extensionSignProblem(id, purpose);
512
+ if (problem !== undefined) {
513
+ return json({ error: problem }, 400);
514
+ }
515
+ if (canonicalBytes(payload).length > EXTENSION_SIGN_PAYLOAD_MAX_BYTES) {
516
+ return json({ error: `a record to sign is at most ${EXTENSION_SIGN_PAYLOAD_MAX_BYTES} bytes of canonical JSON` }, 413);
517
+ }
518
+ const { keySet, document } = ensure();
519
+ const domain = extensionSignDomain(id, purpose);
520
+ signed.push({ purpose, payload, domain });
521
+ const sig = signExtensionPayload(id, purpose, payload, secretKeysOf(keySet.secret));
522
+ return json({ domain, sig, fingerprint: document.fingerprint, document } satisfies ExtensionIdentitySigned);
523
+ };
524
+
525
+ const identity: FakeIdentity = { document: () => ensure().document, keySet: () => ensure().keySet, signed };
526
+ return { door, identity };
527
+ };
528
+
438
529
  export const fakeExtensionApi = async (options: FakeExtensionOptions): Promise<FakeExtension> => {
439
530
  const made: string[] = [];
440
531
  const dirOf = async (given: string | undefined, label: string): Promise<string> => {
@@ -456,6 +547,7 @@ export const fakeExtensionApi = async (options: FakeExtensionOptions): Promise<F
456
547
  const activities: ExtensionActivity[] = [];
457
548
  const turn = fakeTurn(options, declared.turn);
458
549
  const sleeping = fakeSleep(id, options.manifest.contributes?.publicRoutes ?? []);
550
+ const identity = fakeIdentity(id, declared);
459
551
  let settings: ExtensionSettingValues = { ...options.settings };
460
552
  // Every event stream the extension holds open, each written to by `emit`. A frame sent while none is open waits for
461
553
  // the next one: the runtime opens its stream a moment after the first listener registers, and a test that listens
@@ -528,7 +620,9 @@ export const fakeExtensionApi = async (options: FakeExtensionOptions): Promise<F
528
620
  activities.push(row.data);
529
621
  return json({ ok: true });
530
622
  }
531
- return (await sleeping.door(request, url, signal)) ?? (request.method === "POST" ? await turn.door(request, url) : undefined);
623
+ return (
624
+ (await sleeping.door(request, url, signal)) ?? (await identity.door(request, url)) ?? (request.method === "POST" ? await turn.door(request, url) : undefined)
625
+ );
532
626
  };
533
627
 
534
628
  const eventStream = (signal: AbortSignal | null): Response => {
@@ -620,6 +714,7 @@ export const fakeExtensionApi = async (options: FakeExtensionOptions): Promise<F
620
714
  return turn.jobs();
621
715
  },
622
716
  sleep: sleeping,
717
+ identity: identity.identity,
623
718
  jobEnd: turn.jobEnd,
624
719
  stopJob: turn.stopJob,
625
720
  activate: async (module) => {
package/src/version.ts CHANGED
@@ -150,4 +150,23 @@
150
150
  // `api.sleep.heard()` answers those notes for the extension's own connections, once. A processor path may sit under a
151
151
  // `when` over the card's answers. Additive: a manifest that declares none of it is unchanged, and `fakeExtensionApi`
152
152
  // models `heard` (`sleep.heard`). The recorded surface grows the manifest schema.
153
- export const extensionApiVersion = "2.58.0";
153
+ // 2.59.0 (2026-11-27) adds a third kind of stranger a listener may declare, `contact` (a sandbox that is not a contact yet
154
+ // asking to become one), held to the owner's floor for a contact request, which holds by default; the daemon's own
155
+ // `s2s` source (what other sandboxes send) declares it. A trigger source's `strangers` and an agent's needs carry it
156
+ // too (a `contact` need, raised when an agent would make or accept a contact). Additive: a manifest without it is
157
+ // unchanged. The recorded surface grows the manifest schema and the wire's agents, automations and terminal schemas.
158
+ // 2.60.0 (2026-11-28) lets an extension sign as this sandbox and carry out an approval a person co-signed with a passkey.
159
+ // `api.identity.document()` answers the sandbox's public identity document (`GET /extension/identity`, undeclared), and
160
+ // `api.identity.sign(purpose, payload)` has the daemon sign a JSON record with the sandbox's key, which the extension
161
+ // never holds (`POST /extension/identity/sign`, a power declared as `permissions.identity: ["sign"]` and refused
162
+ // undeclared): a hybrid signature over the payload's canonical JSON under `ext:<publisher.name>/<purpose>`, answered with
163
+ // the domain, the fingerprint and the document whose keys verify it. Rejected: handing an extension a delegated key,
164
+ // which the daemon could not take back. The wire grows by the s2s primitives and shapes
165
+ // (`@intentic/sandbox-contract/s2s`, `.../schemas/s2s`), so an extension verifies a foreign document and what it signed
166
+ // (`verifyIdentity`, `verifyExtensionPayload`, `verifyPasskeyCosign`, and the `attestations` an identity document may
167
+ // carry, with `verifyAttestation`) without the daemon. An action item may ask for a
168
+ // passkey (`cosign: "offered" | "required"`); a yes given with one hands the performer `ApprovedAction.cosign`, the
169
+ // person's assertion over the sandbox, the item and its digest. Additive: a manifest that declares none of it and an item
170
+ // without `cosign` are unchanged, and `fakeExtensionApi` signs with a real key set (`identity`). The recorded surface
171
+ // grows `serverApi`, the manifest schema, the wire's approvals and extension-protocol schemas, and the two s2s subpaths.
172
+ export const extensionApiVersion = "2.60.0";
package/src/wire.ts CHANGED
@@ -25,6 +25,9 @@ export const EXTENSION_WIRE = [
25
25
  "@intentic/sandbox-contract/policy/keyring-origins",
26
26
  "@intentic/sandbox-contract/policy/role-capability",
27
27
  "@intentic/sandbox-contract/protocol/doors/listener-protocol",
28
+ // (2026-11-28, 2.60.0) The s2s primitives and shapes, so an extension verifies a foreign sandbox's identity document
29
+ // and the records it signed (`verifyIdentity`, `verifyExtensionPayload`) without the daemon.
30
+ "@intentic/sandbox-contract/s2s",
28
31
  "@intentic/sandbox-contract/schemas/access-profiles",
29
32
  "@intentic/sandbox-contract/schemas/activity",
30
33
  "@intentic/sandbox-contract/schemas/agent",
@@ -39,6 +42,7 @@ export const EXTENSION_WIRE = [
39
42
  "@intentic/sandbox-contract/schemas/ports",
40
43
  "@intentic/sandbox-contract/schemas/public",
41
44
  "@intentic/sandbox-contract/schemas/roles",
45
+ "@intentic/sandbox-contract/schemas/s2s",
42
46
  "@intentic/sandbox-contract/schemas/services",
43
47
  "@intentic/sandbox-contract/schemas/share",
44
48
  "@intentic/sandbox-contract/schemas/shared",