@tangle-network/agent-app 0.63.28 → 0.63.30

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 (60) hide show
  1. package/dist/{TimelineEditor-VB2UJ34D.js → TimelineEditor-MUY35ULL.js} +3 -3
  2. package/dist/app-auth/index.js +3 -3
  3. package/dist/assistant/index.js +9 -9
  4. package/dist/chat-react/index.js +3 -3
  5. package/dist/chat-routes/default-backend.d.ts +19 -2
  6. package/dist/chat-routes/hybrid-producer.d.ts +7 -2
  7. package/dist/chat-routes/index.js +4 -4
  8. package/dist/chat-routes/route-storage.d.ts +1 -1
  9. package/dist/chat-routes/router-producer.d.ts +2 -1
  10. package/dist/chat-routes/turn-route-contracts.d.ts +1 -1
  11. package/dist/chunk-53ZX7XZY.js +371 -0
  12. package/dist/chunk-53ZX7XZY.js.map +1 -0
  13. package/dist/{chunk-56JUV4DK.js → chunk-5AUZR655.js} +3335 -3020
  14. package/dist/chunk-5AUZR655.js.map +1 -0
  15. package/dist/{chunk-IVBREL7A.js → chunk-5HBIN366.js} +10 -10
  16. package/dist/{chunk-A7JD27SN.js → chunk-6UMIOEDR.js} +13 -13
  17. package/dist/{chunk-QUT3T2IN.js → chunk-L3QR274L.js} +11 -3
  18. package/dist/chunk-L3QR274L.js.map +1 -0
  19. package/dist/chunk-N425HGJW.js +261 -0
  20. package/dist/chunk-N425HGJW.js.map +1 -0
  21. package/dist/{chunk-DCJCZ7EP.js → chunk-QLZ6A73E.js} +37 -19
  22. package/dist/chunk-QLZ6A73E.js.map +1 -0
  23. package/dist/{chunk-ZZTPTCMY.js → chunk-XJXAULNI.js} +7 -7
  24. package/dist/conformance/cli.d.ts +2 -0
  25. package/dist/conformance/cli.js +67 -0
  26. package/dist/conformance/cli.js.map +1 -0
  27. package/dist/conformance/index.d.ts +3 -0
  28. package/dist/conformance/index.js +9 -0
  29. package/dist/conformance/index.js.map +1 -0
  30. package/dist/conformance/revision.d.ts +13 -0
  31. package/dist/conformance/run.d.ts +48 -0
  32. package/dist/conformance/session.d.ts +24 -0
  33. package/dist/conformance/turns.d.ts +37 -0
  34. package/dist/design-canvas/index.js +6 -6
  35. package/dist/design-canvas-react/index.js +4 -4
  36. package/dist/model-resolution/index.js +1 -1
  37. package/dist/operator/index.js +24 -252
  38. package/dist/operator/index.js.map +1 -1
  39. package/dist/platform/index.js +8 -8
  40. package/dist/public-consultation/index.d.ts +2 -2
  41. package/dist/public-consultation/index.js +4 -4
  42. package/dist/sandbox/computer-files.d.ts +67 -0
  43. package/dist/sandbox/computer-receipts.d.ts +46 -0
  44. package/dist/sandbox/computer-step.d.ts +78 -0
  45. package/dist/sandbox/index.d.ts +4 -0
  46. package/dist/sandbox/index.js +23 -1
  47. package/dist/sandbox/router-models.d.ts +26 -0
  48. package/dist/sandbox/sandbox-run-tool.d.ts +5 -4
  49. package/dist/sequences-react/index.js +3 -3
  50. package/dist/settings-react/index.js +1 -1
  51. package/dist/web-react/index.js +28 -28
  52. package/dist/workspace-react/index.js +5 -5
  53. package/package.json +8 -2
  54. package/dist/chunk-56JUV4DK.js.map +0 -1
  55. package/dist/chunk-DCJCZ7EP.js.map +0 -1
  56. package/dist/chunk-QUT3T2IN.js.map +0 -1
  57. /package/dist/{TimelineEditor-VB2UJ34D.js.map → TimelineEditor-MUY35ULL.js.map} +0 -0
  58. /package/dist/{chunk-IVBREL7A.js.map → chunk-5HBIN366.js.map} +0 -0
  59. /package/dist/{chunk-A7JD27SN.js.map → chunk-6UMIOEDR.js.map} +0 -0
  60. /package/dist/{chunk-ZZTPTCMY.js.map → chunk-XJXAULNI.js.map} +0 -0
@@ -1,12 +1,6 @@
1
1
  import {
2
2
  joinClasses
3
3
  } from "./chunk-L7MB2LLM.js";
4
- import {
5
- useWorkspacePrewarmHandle
6
- } from "./chunk-2HQP2CTA.js";
7
- import {
8
- filterCommandPaletteItems
9
- } from "./chunk-SJWIZT7B.js";
10
4
  import {
11
5
  AgentSessionControls,
12
6
  acceptRejectionReason,
@@ -14,11 +8,17 @@ import {
14
8
  isAcceptedFileType,
15
9
  renamePastedImages
16
10
  } from "./chunk-KHJE7JAG.js";
11
+ import {
12
+ useWorkspacePrewarmHandle
13
+ } from "./chunk-2HQP2CTA.js";
17
14
  import {
18
15
  OVERLAY_SHADOW,
19
16
  POPOVER_OPTION_FOCUS,
20
17
  PopoverSurface
21
18
  } from "./chunk-RO25WIVS.js";
19
+ import {
20
+ filterCommandPaletteItems
21
+ } from "./chunk-SJWIZT7B.js";
22
22
  import {
23
23
  ALLOWED_ATTACHMENT_SNIFFED_MIMES,
24
24
  ATTACHMENT_ACCEPT,
@@ -1853,4 +1853,4 @@ export {
1853
1853
  ComposerModeControls,
1854
1854
  EntryComposer
1855
1855
  };
1856
- //# sourceMappingURL=chunk-ZZTPTCMY.js.map
1856
+ //# sourceMappingURL=chunk-XJXAULNI.js.map
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ checkDeployedApp
4
+ } from "../chunk-53ZX7XZY.js";
5
+ import "../chunk-N425HGJW.js";
6
+ import {
7
+ invokedAsScript
8
+ } from "../chunk-C3CAYGGQ.js";
9
+ import "../chunk-RN4WPTBH.js";
10
+
11
+ // src/conformance/cli.ts
12
+ var VALUE_FLAGS = /* @__PURE__ */ new Set(["--app-url", "--app", "--auth", "--email", "--password", "--workspace", "--computer", "--file-dir", "--turn-ms", "--expect-revision"]);
13
+ function parseConformanceArgs(argv, env = process.env) {
14
+ const flags = /* @__PURE__ */ new Map();
15
+ for (let index = 0; index < argv.length; index += 1) {
16
+ const [flag = "", inline] = argv[index].split(/=(.*)/s, 2);
17
+ if (!VALUE_FLAGS.has(flag)) throw new Error(`unknown option ${argv[index]}`);
18
+ const value = inline ?? argv[++index];
19
+ if (value === void 0 || value === "") throw new Error(`${flag} needs a value`);
20
+ flags.set(flag, value);
21
+ }
22
+ const url = flags.get("--app-url");
23
+ if (!url) throw new Error("--app-url is required");
24
+ let origin;
25
+ try {
26
+ origin = new URL(url);
27
+ } catch {
28
+ throw new Error(`--app-url is not a URL: ${url}`);
29
+ }
30
+ if (origin.protocol !== "https:") throw new Error("--app-url must be an https origin");
31
+ const mode = flags.get("--auth") ?? "password";
32
+ if (mode !== "password" && mode !== "sso") throw new Error("--auth is password or sso");
33
+ const computer = flags.get("--computer") ?? "digest";
34
+ if (computer !== "digest" && computer !== "file") throw new Error("--computer is digest or file");
35
+ const turnMs = Number(flags.get("--turn-ms") ?? 3e5);
36
+ if (!Number.isFinite(turnMs) || turnMs < 1e3) throw new Error("--turn-ms is a number of milliseconds, at least 1000");
37
+ const email = flags.get("--email") ?? env.CONFORMANCE_EMAIL?.trim();
38
+ const password = flags.get("--password") ?? env.CONFORMANCE_PASSWORD;
39
+ const operatorKey = env.CONFORMANCE_OPERATOR_KEY?.trim();
40
+ return {
41
+ app: flags.get("--app") ?? origin.hostname.split(".")[0],
42
+ origin: origin.origin,
43
+ ...email && password ? { member: { mode, email, password } } : {},
44
+ ...operatorKey ? { operatorKey } : {},
45
+ ...flags.has("--workspace") ? { workspace: flags.get("--workspace") } : {},
46
+ computer,
47
+ ...flags.has("--file-dir") ? { fileDir: flags.get("--file-dir") } : {},
48
+ turnMs,
49
+ ...flags.has("--expect-revision") ? { expectRevision: flags.get("--expect-revision") } : {}
50
+ };
51
+ }
52
+ async function main() {
53
+ let options;
54
+ try {
55
+ options = parseConformanceArgs(process.argv.slice(2));
56
+ } catch (error) {
57
+ console.error(`agent-app-conformance: ${error instanceof Error ? error.message : String(error)}`);
58
+ return 2;
59
+ }
60
+ const results = await checkDeployedApp({ ...options, onResult: (result) => process.stdout.write(`${JSON.stringify(result)}
61
+ `) });
62
+ return results.every((result) => result.status === "pass") ? 0 : 1;
63
+ }
64
+ if (invokedAsScript(import.meta.url, process.argv[1])) {
65
+ main().then((code) => process.stdout.write("", () => process.exit(code)));
66
+ }
67
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/conformance/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n/**\n * `agent-app-conformance` — the basics every deployed agent app must do, checked against its production origin:\n * sign in, read the served revision, answer a plain turn, and answer a turn only the workspace computer can.\n * It prints one JSON line per check as the check ends: app, url, check, status, ms, and the cause of a failure.\n *\n * agent-app-conformance --app-url https://gtm.tangle.tools --auth password --workspace \"GTM release canary\"\n *\n * The member comes from the environment so it never reaches a process listing:\n * CONFORMANCE_EMAIL, CONFORMANCE_PASSWORD the canary member (--email / --password are accepted but visible to `ps`)\n * CONFORMANCE_OPERATOR_KEY optional: an operator key with operator:read and operator:run;\n * without one the signed-in member mints an hour-long key and revokes it\n *\n * Options:\n * --app-url <origin> required\n * --app <label> names the app in each line (default: the origin's first host label)\n * --auth password|sso how the member signs in (default password); sso goes through Tangle Platform\n * --workspace <id|name> the canary or smoke workspace the turns run in (default: the key's only workspace)\n * --computer digest|file digest: hash a fresh nonce on the computer; file: the computer saves a file the app serves back\n * --file-dir <dir> where the file proof is saved (default proof)\n * --turn-ms <ms> the budget of each turn, a cold box included (default 300000)\n * --expect-revision <sha> fail unless the served revision matches\n *\n * Exits 0 when every check passes, 1 when any fails or is blocked, 2 on a usage error.\n */\nimport { invokedAsScript } from '../signoff/invoked-as-script.js'\nimport { checkDeployedApp, type ConformanceOptions } from './run.js'\nimport type { ComputerProof } from './turns.js'\nimport type { SignInMode } from './session.js'\n\nconst VALUE_FLAGS = new Set(['--app-url', '--app', '--auth', '--email', '--password', '--workspace', '--computer', '--file-dir', '--turn-ms', '--expect-revision'])\n\nfunction parseConformanceArgs(argv: readonly string[], env: NodeJS.ProcessEnv = process.env): ConformanceOptions {\n const flags = new Map<string, string>()\n for (let index = 0; index < argv.length; index += 1) {\n const [flag = '', inline] = argv[index]!.split(/=(.*)/s, 2)\n if (!VALUE_FLAGS.has(flag)) throw new Error(`unknown option ${argv[index]}`)\n const value = inline ?? argv[++index]\n if (value === undefined || value === '') throw new Error(`${flag} needs a value`)\n flags.set(flag, value)\n }\n const url = flags.get('--app-url')\n if (!url) throw new Error('--app-url is required')\n let origin: URL\n try { origin = new URL(url) } catch { throw new Error(`--app-url is not a URL: ${url}`) }\n if (origin.protocol !== 'https:') throw new Error('--app-url must be an https origin')\n const mode = flags.get('--auth') ?? 'password'\n if (mode !== 'password' && mode !== 'sso') throw new Error('--auth is password or sso')\n const computer = flags.get('--computer') ?? 'digest'\n if (computer !== 'digest' && computer !== 'file') throw new Error('--computer is digest or file')\n const turnMs = Number(flags.get('--turn-ms') ?? 300_000)\n if (!Number.isFinite(turnMs) || turnMs < 1_000) throw new Error('--turn-ms is a number of milliseconds, at least 1000')\n const email = flags.get('--email') ?? env.CONFORMANCE_EMAIL?.trim()\n const password = flags.get('--password') ?? env.CONFORMANCE_PASSWORD\n const operatorKey = env.CONFORMANCE_OPERATOR_KEY?.trim()\n return {\n app: flags.get('--app') ?? origin.hostname.split('.')[0]!,\n origin: origin.origin,\n ...(email && password ? { member: { mode: mode as SignInMode, email, password } } : {}),\n ...(operatorKey ? { operatorKey } : {}),\n ...(flags.has('--workspace') ? { workspace: flags.get('--workspace')! } : {}),\n computer: computer as ComputerProof,\n ...(flags.has('--file-dir') ? { fileDir: flags.get('--file-dir')! } : {}),\n turnMs,\n ...(flags.has('--expect-revision') ? { expectRevision: flags.get('--expect-revision')! } : {}),\n }\n}\n\nasync function main(): Promise<number> {\n let options: ConformanceOptions\n try {\n options = parseConformanceArgs(process.argv.slice(2))\n } catch (error) {\n console.error(`agent-app-conformance: ${error instanceof Error ? error.message : String(error)}`)\n return 2\n }\n const results = await checkDeployedApp({ ...options, onResult: result => process.stdout.write(`${JSON.stringify(result)}\\n`) })\n return results.every(result => result.status === 'pass') ? 0 : 1\n}\n\nif (invokedAsScript(import.meta.url, process.argv[1])) {\n main().then(code => process.stdout.write('', () => process.exit(code)))\n}\n"],"mappings":";;;;;;;;;;;AA8BA,IAAM,cAAc,oBAAI,IA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CAAC;AACxE;","names":[]}
@@ -0,0 +1,3 @@
1
+ export { checkDeployedApp, type CheckName, type CheckResult, type ConformanceOptions } from './run.js';
2
+ export type { SignInMode } from './session.js';
3
+ export type { ComputerProof } from './turns.js';
@@ -0,0 +1,9 @@
1
+ import {
2
+ checkDeployedApp
3
+ } from "../chunk-53ZX7XZY.js";
4
+ import "../chunk-N425HGJW.js";
5
+ import "../chunk-RN4WPTBH.js";
6
+ export {
7
+ checkDeployedApp
8
+ };
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The served revision, read the way an operator reads it: from the app's own `GET /api/health` body, or from the
3
+ * `x-<app>-revision` / `x-<app>-version` header the app puts on its responses. An app that serves neither cannot
4
+ * say what it is running, so a release cannot be told from the one before it.
5
+ */
6
+ /**
7
+ * Reads the revision, or throws a Failure naming every place it looked. `source` says where it was read, e.g.
8
+ * `GET /api/health` or `GET / x-creative-revision`.
9
+ */
10
+ export declare function readRevision(origin: string, expect?: string): Promise<{
11
+ revision: string;
12
+ source: string;
13
+ }>;
@@ -0,0 +1,48 @@
1
+ import { type SignInMode } from './session.js';
2
+ import { type ComputerProof } from './turns.js';
3
+ export type CheckName = 'sign-in' | 'revision' | 'operator-access' | 'plain-turn' | 'computer-turn' | 'key-revoke';
4
+ /**
5
+ * One check's verdict. `blocked` means an earlier check it depends on failed, so nothing was measured; a blocked
6
+ * check fails the run like a failed one, and its cause names the check that blocked it.
7
+ */
8
+ export interface CheckResult {
9
+ /** When the check started, ISO 8601. */
10
+ at: string;
11
+ app: string;
12
+ url: string;
13
+ check: CheckName;
14
+ status: 'pass' | 'fail' | 'blocked';
15
+ ms: number;
16
+ /** Why a failed or blocked check is not a pass. */
17
+ cause?: string;
18
+ /** What a passing check observed: the revision read, the thread a turn ran in. */
19
+ detail?: string;
20
+ }
21
+ export interface ConformanceOptions {
22
+ /** A label for the result lines, e.g. `gtm`. */
23
+ app: string;
24
+ /** The deployed origin, e.g. `https://gtm.tangle.tools`. */
25
+ origin: string;
26
+ /** The member that signs in. Required: sign-in is the first thing a customer does. */
27
+ member?: {
28
+ mode: SignInMode;
29
+ email: string;
30
+ password: string;
31
+ };
32
+ /** A key that already has `operator:read` and `operator:run`; without one, the signed-in member mints a one-hour key. */
33
+ operatorKey?: string;
34
+ /** Id or exact name of the workspace the turns run in: the app's canary or smoke workspace, never a customer's. */
35
+ workspace?: string;
36
+ /** `digest` hashes a fresh nonce on the workspace computer; `file` has the computer save a file the app serves back. */
37
+ computer?: ComputerProof;
38
+ /** Where the `file` proof is saved, relative to the workspace root. */
39
+ fileDir?: string;
40
+ /** The budget of each turn, a cold box included. */
41
+ turnMs?: number;
42
+ /** Fail unless the served revision starts with, or is a prefix of, this. */
43
+ expectRevision?: string;
44
+ /** Called with each result as it lands. */
45
+ onResult?(result: CheckResult): void;
46
+ }
47
+ /** Runs the checks against one deployed app and returns every result, in the order they ran. */
48
+ export declare function checkDeployedApp(options: ConformanceOptions): Promise<CheckResult[]>;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Sign-in for the conformance runner: the two ways a member reaches an agent app, and one question both answer,
3
+ * "does the app accept this session?". Nothing here is specific to an app; a product whose sign-in differs
4
+ * fails the check with the status it answered.
5
+ */
6
+ export type SignInMode = 'password' | 'sso';
7
+ /** A check failed for a reason worth reporting; its message is the cause. */
8
+ export declare class Failure extends Error {
9
+ }
10
+ export interface MemberSession {
11
+ origin: string;
12
+ /** A request to the app as the signed-in member; `path` is root-relative. */
13
+ fetch(path: string, init?: RequestInit): Promise<Response>;
14
+ }
15
+ /** Signs in and proves the app accepts the session; the detail names the proof. */
16
+ export declare function signIn(input: {
17
+ origin: string;
18
+ mode: SignInMode;
19
+ email: string;
20
+ password: string;
21
+ }): Promise<{
22
+ session: MemberSession;
23
+ detail: string;
24
+ }>;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * The conformance turns, run through the operator API every agent app mounts the same way
3
+ * (docs/operator-api.md), so one runner drives every product. The verdict is the settled turn the app stored.
4
+ *
5
+ * plain a reply with text;
6
+ * computer a turn only the workspace computer can answer: either the digest of a fresh nonce, which the model
7
+ * cannot know without running the command, or a file the computer saves that the app then serves back.
8
+ */
9
+ import { type OperatorClient } from '../operator/client.js';
10
+ import type { OperatorWorkspace } from '../operator/contract.js';
11
+ import { type MemberSession } from './session.js';
12
+ export type ComputerProof = 'digest' | 'file';
13
+ export interface OperatorAccess {
14
+ client: OperatorClient;
15
+ workspace: OperatorWorkspace;
16
+ /** The app's own account of what the key may do. */
17
+ scopes: readonly string[];
18
+ }
19
+ /** An expiring key for the signed-in member, through the route every app's API access page uses. */
20
+ export declare function mintKey(session: MemberSession): Promise<{
21
+ id: string;
22
+ key: string;
23
+ }>;
24
+ /** Revokes a key this run created. Apps accept the id in the path, or in the body of the collection route. */
25
+ export declare function revokeKey(session: MemberSession, id: string): Promise<void>;
26
+ /**
27
+ * Opens the operator API with `key` and picks the workspace the turns run in: `workspace` is its id or exact name,
28
+ * and omitted, the key must reach exactly one. `requestMs` bounds any one request, a held turn read included.
29
+ */
30
+ export declare function openOperatorAccess({ origin, key, workspace, requestMs }: {
31
+ origin: string;
32
+ key: string;
33
+ workspace: string | undefined;
34
+ requestMs: number;
35
+ }): Promise<OperatorAccess>;
36
+ export declare function plainTurn(access: OperatorAccess, turnMs: number): Promise<string>;
37
+ export declare function computerTurn(access: OperatorAccess, turnMs: number, proof: ComputerProof, fileDir: string): Promise<string>;
@@ -1,3 +1,9 @@
1
+ import {
2
+ isRecord,
3
+ objectSchema,
4
+ requireEnum,
5
+ requireMcpString
6
+ } from "../chunk-PEJ5OP5B.js";
1
7
  import {
2
8
  CHANNEL_PRESETS,
3
9
  EXPORT_PRESETS,
@@ -31,12 +37,6 @@ import {
31
37
  validateSceneOperations,
32
38
  validateSlotValue
33
39
  } from "../chunk-VCG4DQC4.js";
34
- import {
35
- isRecord,
36
- objectSchema,
37
- requireEnum,
38
- requireMcpString
39
- } from "../chunk-PEJ5OP5B.js";
40
40
  import "../chunk-DPTNKH22.js";
41
41
  import "../chunk-RN4WPTBH.js";
42
42
  import "../chunk-ALIWB2P3.js";
@@ -40,6 +40,10 @@ import {
40
40
  formatRulerLabel,
41
41
  selectTickStep
42
42
  } from "../chunk-I4CFBLSJ.js";
43
+ import {
44
+ DesignCanvasChromeLazy,
45
+ DesignCanvasLazy
46
+ } from "../chunk-ZD2AUFIT.js";
43
47
  import {
44
48
  LockGlyph
45
49
  } from "../chunk-P4RRC4AO.js";
@@ -90,10 +94,6 @@ import {
90
94
  bleedAwareExportBounds,
91
95
  scaleForPreset
92
96
  } from "../chunk-VCG4DQC4.js";
93
- import {
94
- DesignCanvasChromeLazy,
95
- DesignCanvasLazy
96
- } from "../chunk-ZD2AUFIT.js";
97
97
  import "../chunk-DPTNKH22.js";
98
98
  import "../chunk-RN4WPTBH.js";
99
99
  import "../chunk-ALIWB2P3.js";
@@ -6,7 +6,7 @@ import {
6
6
  isUpstreamUnavailable,
7
7
  readHttpStatusHint,
8
8
  runWithModelFailover
9
- } from "../chunk-QUT3T2IN.js";
9
+ } from "../chunk-L3QR274L.js";
10
10
  import {
11
11
  checkModelPolicy
12
12
  } from "../chunk-XELWWXJJ.js";
@@ -3,12 +3,25 @@ import {
3
3
  agentOperatorScopes,
4
4
  createApiKeyRequestAuth
5
5
  } from "../chunk-XB4KZVUV.js";
6
+ import {
7
+ OPERATOR_ACCESS,
8
+ OPERATOR_API_BASE_PATH,
9
+ OPERATOR_API_SCOPES,
10
+ OPERATOR_API_VERSION,
11
+ OPERATOR_ROUTES,
12
+ OPERATOR_SCOPE_DEPENDENCIES,
13
+ OPERATOR_SETTLED_STATES,
14
+ OPERATOR_TURN_CANCELLED_CODE,
15
+ OPERATOR_WORKSPACE_SCOPE_PREFIX,
16
+ createOperatorClient,
17
+ matchOperatorRoute,
18
+ operatorKeyWorkspaces,
19
+ operatorWorkspaceScope
20
+ } from "../chunk-N425HGJW.js";
6
21
  import {
7
22
  parseChatAttachmentInputs
8
23
  } from "../chunk-P7UB7ZVP.js";
9
- import {
10
- createApiKeyFetch
11
- } from "../chunk-RN4WPTBH.js";
24
+ import "../chunk-RN4WPTBH.js";
12
25
  import {
13
26
  messageHasTurnId
14
27
  } from "../chunk-YG66IHDU.js";
@@ -18,102 +31,6 @@ import {
18
31
  } from "../chunk-HY57QRRW.js";
19
32
  import "../chunk-TXD5HXLE.js";
20
33
 
21
- // src/operator/contract.ts
22
- var OPERATOR_API_VERSION = "v1";
23
- var OPERATOR_API_BASE_PATH = "/api/operator/v1";
24
- var OPERATOR_ACCESS = [
25
- {
26
- scope: "operator:read",
27
- label: "Read workspaces",
28
- description: "Read workspaces, conversations, files, approvals, scorecards, and run status."
29
- },
30
- {
31
- scope: "operator:write",
32
- label: "Create and edit",
33
- description: "Create workspaces and conversations, and write files."
34
- },
35
- {
36
- scope: "operator:run",
37
- requires: ["operator:read"],
38
- label: "Run agents",
39
- description: "Requires read access. Start, continue, and interrupt agent turns, and answer their questions and tool-permission requests. Agents can modify workspace files. Uses your plan and budget."
40
- }
41
- ];
42
- var OPERATOR_API_SCOPES = OPERATOR_ACCESS.map(({ scope }) => scope);
43
- var OPERATOR_SCOPE_DEPENDENCIES = Object.fromEntries(
44
- OPERATOR_ACCESS.flatMap((option) => "requires" in option ? [[option.scope, option.requires]] : [])
45
- );
46
- var OPERATOR_WORKSPACE_SCOPE_PREFIX = "operator:workspace:";
47
- var WORKSPACE_ID = /^[A-Za-z0-9_-]{1,128}$/;
48
- function operatorWorkspaceScope(workspaceId) {
49
- if (!WORKSPACE_ID.test(workspaceId)) throw new TypeError("Workspace ids contain only letters, digits, - and _");
50
- return `${OPERATOR_WORKSPACE_SCOPE_PREFIX}${workspaceId}`;
51
- }
52
- function operatorKeyWorkspaces(scopes) {
53
- const restricted = scopes.filter((scope) => scope.startsWith(OPERATOR_WORKSPACE_SCOPE_PREFIX));
54
- if (restricted.length === 0) return null;
55
- return restricted.map((scope) => scope.slice(OPERATOR_WORKSPACE_SCOPE_PREFIX.length)).filter((id) => WORKSPACE_ID.test(id));
56
- }
57
- var OPERATOR_SETTLED_STATES = ["succeeded", "failed"];
58
- var OPERATOR_TURN_CANCELLED_CODE = "turn.cancelled";
59
- var OPERATOR_ROUTES = [
60
- { id: "describe", method: "GET", path: "", scopes: ["operator:read"] },
61
- { id: "workspaces.list", method: "GET", path: "/workspaces", scopes: ["operator:read"] },
62
- { id: "workspaces.create", method: "POST", path: "/workspaces", scopes: ["operator:write"] },
63
- { id: "workspaces.get", method: "GET", path: "/workspaces/:workspaceId", scopes: ["operator:read"] },
64
- { id: "turns.start", method: "POST", path: "/workspaces/:workspaceId/turns", scopes: ["operator:read", "operator:run"] },
65
- { id: "threads.list", method: "GET", path: "/workspaces/:workspaceId/threads", scopes: ["operator:read"] },
66
- { id: "threads.get", method: "GET", path: "/workspaces/:workspaceId/threads/:threadId", scopes: ["operator:read"] },
67
- { id: "turns.get", method: "GET", path: "/workspaces/:workspaceId/threads/:threadId/turns/:turnId", scopes: ["operator:read"] },
68
- { id: "turns.cancel", method: "POST", path: "/workspaces/:workspaceId/threads/:threadId/turns/:turnId/cancel", scopes: ["operator:read", "operator:run"] },
69
- { id: "approvals.list", method: "GET", path: "/workspaces/:workspaceId/approvals", scopes: ["operator:read"] },
70
- { id: "journal.list", method: "GET", path: "/workspaces/:workspaceId/journal", scopes: ["operator:read"] },
71
- { id: "files.list", method: "GET", path: "/workspaces/:workspaceId/files", scopes: ["operator:read"] },
72
- { id: "files.read", method: "GET", path: "/workspaces/:workspaceId/file", scopes: ["operator:read"] },
73
- { id: "assets.read", method: "GET", path: "/workspaces/:workspaceId/assets/:assetId", scopes: ["operator:read"] },
74
- { id: "scorecard.get", method: "GET", path: "/workspaces/:workspaceId/scorecard", scopes: ["operator:read"] }
75
- ];
76
- var SEGMENT = /^[A-Za-z0-9_:.%-]{1,256}$/;
77
- function matchOperatorRoute(method, pathname, basePath = OPERATOR_API_BASE_PATH) {
78
- if (pathname !== basePath && !pathname.startsWith(`${basePath}/`)) return null;
79
- const rest = pathname.slice(basePath.length).replace(/\/$/, "");
80
- const actual = rest ? rest.split("/").slice(1) : [];
81
- for (const route of OPERATOR_ROUTES) {
82
- if (route.method !== method) continue;
83
- const pattern = route.path ? route.path.split("/").slice(1) : [];
84
- if (pattern.length !== actual.length) continue;
85
- const params = {};
86
- let matched = true;
87
- for (let index = 0; index < pattern.length; index++) {
88
- const expected = pattern[index];
89
- const segment2 = actual[index];
90
- if (expected.startsWith(":")) {
91
- if (!SEGMENT.test(segment2)) {
92
- matched = false;
93
- break;
94
- }
95
- let decoded;
96
- try {
97
- decoded = decodeURIComponent(segment2);
98
- } catch {
99
- matched = false;
100
- break;
101
- }
102
- if (!decoded || decoded.includes("/")) {
103
- matched = false;
104
- break;
105
- }
106
- params[expected.slice(1)] = decoded;
107
- } else if (expected !== segment2) {
108
- matched = false;
109
- break;
110
- }
111
- }
112
- if (matched) return { route, params };
113
- }
114
- return null;
115
- }
116
-
117
34
  // src/operator/server.ts
118
35
  var OperatorError = class extends Error {
119
36
  constructor(code, status, message, retryable = false) {
@@ -153,7 +70,7 @@ function relativePath(value, name, { allowEmpty }) {
153
70
  throw new OperatorError("operator.invalid_path", 400, `${name} must be a workspace-relative path`);
154
71
  }
155
72
  const segments = path.replace(/\/$/, "").split("/");
156
- if (segments.some((segment2) => !segment2 || segment2 === "." || segment2 === "..")) {
73
+ if (segments.some((segment) => !segment || segment === "." || segment === "..")) {
157
74
  throw new OperatorError("operator.invalid_path", 400, `${name} must be a workspace-relative path`);
158
75
  }
159
76
  return path;
@@ -415,151 +332,6 @@ function createOperatorApi(options) {
415
332
  return { matches, handle };
416
333
  }
417
334
 
418
- // src/operator/client.ts
419
- function segment(value) {
420
- return encodeURIComponent(value);
421
- }
422
- async function failure(response) {
423
- let body = {};
424
- try {
425
- body = await response.json();
426
- } catch {
427
- }
428
- return {
429
- succeeded: false,
430
- status: response.status,
431
- code: typeof body.code === "string" ? body.code : `http_${response.status}`,
432
- error: typeof body.error === "string" ? body.error : `HTTP ${response.status}`,
433
- retryable: body.retryable === true || response.status === 429 || response.status >= 500
434
- };
435
- }
436
- function transportFailure(error) {
437
- const aborted = error instanceof Error && error.name === "AbortError";
438
- return {
439
- succeeded: false,
440
- status: 0,
441
- code: aborted ? "operator.aborted" : "operator.transport_failed",
442
- // createApiKeyFetch never forwards transport diagnostics, which could carry the key.
443
- error: error instanceof Error ? error.message : "Operator transport failed",
444
- retryable: !aborted
445
- };
446
- }
447
- var SETTLED = /* @__PURE__ */ new Set(["succeeded", "failed", "input-required"]);
448
- function createOperatorClient(options) {
449
- const basePath = (options.basePath ?? OPERATOR_API_BASE_PATH).replace(/\/$/, "");
450
- const request = createApiKeyFetch({
451
- origin: options.origin,
452
- getApiKey: options.getApiKey,
453
- ...options.fetchImpl ? { fetchImpl: options.fetchImpl } : {},
454
- ...options.allowHttpLoopback ? { allowHttpLoopback: true } : {}
455
- });
456
- async function call(path, pick, init = {}) {
457
- let response;
458
- try {
459
- response = await request(`${basePath}${path}`, {
460
- ...init,
461
- headers: { accept: "application/json", ...init.body ? { "content-type": "application/json" } : {} }
462
- });
463
- } catch (error) {
464
- return transportFailure(error);
465
- }
466
- if (!response.ok) return failure(response);
467
- try {
468
- return { succeeded: true, value: pick(await response.json()) };
469
- } catch {
470
- return { succeeded: false, status: response.status, code: "operator.invalid_response", error: "The response was not the expected JSON", retryable: true };
471
- }
472
- }
473
- const query = (params) => {
474
- const search = new URLSearchParams();
475
- for (const [name, value] of Object.entries(params)) if (value !== void 0 && value !== "") search.set(name, String(value));
476
- const text2 = search.toString();
477
- return text2 ? `?${text2}` : "";
478
- };
479
- const client = {
480
- describe: () => call("", (body) => body),
481
- listWorkspaces: () => call("/workspaces", (body) => body.workspaces),
482
- createWorkspace: (input) => call("/workspaces", (body) => body.workspace, {
483
- method: "POST",
484
- body: JSON.stringify({ name: input.name })
485
- }),
486
- getWorkspace: (workspaceId) => call(`/workspaces/${segment(workspaceId)}`, (body) => body.workspace),
487
- startTurn: (workspaceId, input) => call(`/workspaces/${segment(workspaceId)}/turns`, (body) => body.turn, {
488
- method: "POST",
489
- body: JSON.stringify({ ...input, turnId: input.turnId ?? crypto.randomUUID() })
490
- }),
491
- getTurn: (workspaceId, threadId, turnId, opts = {}) => call(
492
- `/workspaces/${segment(workspaceId)}/threads/${segment(threadId)}/turns/${segment(turnId)}${query({ wait: opts.waitSeconds })}`,
493
- (body) => body.turn,
494
- opts.signal ? { signal: opts.signal } : {}
495
- ),
496
- cancelTurn: (workspaceId, threadId, turnId, opts = {}) => call(
497
- `/workspaces/${segment(workspaceId)}/threads/${segment(threadId)}/turns/${segment(turnId)}/cancel${query({ wait: opts.waitSeconds })}`,
498
- (body) => body.turn,
499
- { method: "POST", ...opts.signal ? { signal: opts.signal } : {} }
500
- ),
501
- async waitForTurn(workspaceId, threadId, turnId, opts) {
502
- const deadline = Date.now() + opts.timeoutMs;
503
- const waitSeconds = opts.waitSeconds ?? 25;
504
- let last = null;
505
- while (true) {
506
- const remaining = Math.floor((deadline - Date.now()) / 1e3);
507
- const started = Date.now();
508
- last = await client.getTurn(workspaceId, threadId, turnId, {
509
- waitSeconds: Math.max(0, Math.min(waitSeconds, remaining)),
510
- ...opts.signal ? { signal: opts.signal } : {}
511
- });
512
- if (!last.succeeded) {
513
- if (!last.retryable || Date.now() >= deadline || opts.signal?.aborted) return last;
514
- await new Promise((resolve) => setTimeout(resolve, Math.min(5e3, Math.max(0, deadline - Date.now()))));
515
- continue;
516
- }
517
- if (SETTLED.has(last.value.state) || last.value.approvals.length > 0) return last;
518
- if (Date.now() >= deadline || opts.signal?.aborted) return last;
519
- if (Date.now() - started < 1e3) {
520
- await new Promise((resolve) => setTimeout(resolve, Math.min(2e3, Math.max(0, deadline - Date.now()))));
521
- }
522
- }
523
- },
524
- listThreads: (workspaceId, q = {}) => call(
525
- `/workspaces/${segment(workspaceId)}/threads${query({ cursor: q.cursor, limit: q.limit })}`,
526
- (body) => ({ threads: body.threads, nextCursor: body.nextCursor ?? null })
527
- ),
528
- getThread: (workspaceId, threadId) => call(
529
- `/workspaces/${segment(workspaceId)}/threads/${segment(threadId)}`,
530
- (body) => ({ thread: body.thread, latestTurn: body.latestTurn ?? null })
531
- ),
532
- listApprovals: (workspaceId) => call(`/workspaces/${segment(workspaceId)}/approvals`, (body) => body.approvals),
533
- listJournal: (workspaceId, q = {}) => call(
534
- `/workspaces/${segment(workspaceId)}/journal${query({ days: q.days })}`,
535
- (body) => body.entries
536
- ),
537
- listFiles: (workspaceId, q = {}) => call(
538
- `/workspaces/${segment(workspaceId)}/files${query({ prefix: q.prefix })}`,
539
- (body) => body.files
540
- ),
541
- readFile: (workspaceId, path) => call(
542
- `/workspaces/${segment(workspaceId)}/file${query({ path })}`,
543
- (body) => body.file
544
- ),
545
- async readAsset(workspaceId, assetId, init = {}) {
546
- let response;
547
- try {
548
- response = await request(`${basePath}/workspaces/${segment(workspaceId)}/assets/${segment(assetId)}`, init.signal ? { signal: init.signal } : {});
549
- } catch (error) {
550
- return transportFailure(error);
551
- }
552
- if (!response.ok) return failure(response);
553
- return { succeeded: true, value: response };
554
- },
555
- getScorecard: (workspaceId, q = {}) => call(
556
- `/workspaces/${segment(workspaceId)}/scorecard${query({ days: q.days })}`,
557
- (body) => body.scorecard
558
- )
559
- };
560
- return client;
561
- }
562
-
563
335
  // src/operator/chat-adapter.ts
564
336
  var iso = (value) => {
565
337
  if (value === null || value === void 0) return void 0;
@@ -684,10 +456,10 @@ function createChatOperatorAdapter(options) {
684
456
  const usage = operatorTurnUsage(assistant, { inputIncludesCache: options.inputIncludesCache ?? "unknown" });
685
457
  if (usage) turn.usage = usage;
686
458
  if (state !== "working" && terminal) {
687
- const failure2 = (options.failureOf ?? defaultFailure)(assistant) ?? (status === "error" ? { code: "turn.error", message: "The turn failed; retained text may be partial" } : null);
688
- if (failure2) {
459
+ const failure = (options.failureOf ?? defaultFailure)(assistant) ?? (status === "error" ? { code: "turn.error", message: "The turn failed; retained text may be partial" } : null);
460
+ if (failure) {
689
461
  state = "failed";
690
- turn.failure = failure2;
462
+ turn.failure = failure;
691
463
  } else if (assistant.content.trim()) {
692
464
  state = "succeeded";
693
465
  turn.reply = { content: assistant.content, mediaType: "text/markdown" };
@@ -779,15 +551,15 @@ function createChatOperatorAdapter(options) {
779
551
  if (!response.ok) {
780
552
  const body = await response.json().catch(() => ({}));
781
553
  const nested = body.error && typeof body.error === "object" ? body.error : {};
782
- const failure2 = {
554
+ const failure = {
783
555
  code: typeof body.code === "string" ? body.code : typeof nested.code === "string" ? nested.code : `operator.chat_${response.status}`,
784
556
  message: typeof body.error === "string" ? body.error : typeof nested.message === "string" ? nested.message : "The app refused the turn"
785
557
  };
786
558
  if (options.admissions) {
787
- await options.admissions.recordRefusal(ctx, target, failure2);
788
- return admittedTurn(ctx, workspace.id, input.turnId, { threadId, refusal: failure2 });
559
+ await options.admissions.recordRefusal(ctx, target, failure);
560
+ return admittedTurn(ctx, workspace.id, input.turnId, { threadId, refusal: failure });
789
561
  }
790
- throw new OperatorError(failure2.code, response.status, failure2.message, response.status === 429 || response.status >= 500);
562
+ throw new OperatorError(failure.code, response.status, failure.message, response.status === 429 || response.status >= 500);
791
563
  }
792
564
  await drain(response, ctx.request.signal);
793
565
  return await turnOf(ctx, workspace.id, threadId, input.turnId) ?? {