@tangle-network/agent-app 0.63.27 → 0.63.29

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 (72) hide show
  1. package/dist/{DesignCanvas-CFNV5JGQ.js → DesignCanvas-3DGZQOD7.js} +2 -2
  2. package/dist/{DesignCanvasEditor-KH4BDUE3.js → DesignCanvasEditor-OG4QY5WJ.js} +2 -2
  3. package/dist/{TimelineEditor-VB2UJ34D.js → TimelineEditor-MUY35ULL.js} +3 -3
  4. package/dist/app-auth/index.js +4 -4
  5. package/dist/assistant/index.js +9 -9
  6. package/dist/chat-react/index.js +3 -3
  7. package/dist/chat-routes/index.js +2 -2
  8. package/dist/chunk-53ZX7XZY.js +371 -0
  9. package/dist/chunk-53ZX7XZY.js.map +1 -0
  10. package/dist/{chunk-IVBREL7A.js → chunk-5HBIN366.js} +10 -10
  11. package/dist/{chunk-BQGJ5IDP.js → chunk-6UMIOEDR.js} +1046 -885
  12. package/dist/chunk-6UMIOEDR.js.map +1 -0
  13. package/dist/{chunk-ZNE4NYU7.js → chunk-DPTNKH22.js} +121 -2
  14. package/dist/chunk-DPTNKH22.js.map +1 -0
  15. package/dist/{chunk-Y3GO6SG3.js → chunk-F6J5J4H6.js} +22 -3
  16. package/dist/chunk-F6J5J4H6.js.map +1 -0
  17. package/dist/chunk-N425HGJW.js +261 -0
  18. package/dist/chunk-N425HGJW.js.map +1 -0
  19. package/dist/{chunk-ZZTPTCMY.js → chunk-XJXAULNI.js} +7 -7
  20. package/dist/{chunk-WTNW4NFS.js → chunk-ZD2AUFIT.js} +3 -3
  21. package/dist/conformance/cli.d.ts +2 -0
  22. package/dist/conformance/cli.js +67 -0
  23. package/dist/conformance/cli.js.map +1 -0
  24. package/dist/conformance/index.d.ts +3 -0
  25. package/dist/conformance/index.js +9 -0
  26. package/dist/conformance/index.js.map +1 -0
  27. package/dist/conformance/revision.d.ts +13 -0
  28. package/dist/conformance/run.d.ts +48 -0
  29. package/dist/conformance/session.d.ts +24 -0
  30. package/dist/conformance/turns.d.ts +37 -0
  31. package/dist/design-canvas/index.js +7 -7
  32. package/dist/design-canvas-react/engine.js +1 -1
  33. package/dist/design-canvas-react/index.js +5 -5
  34. package/dist/design-canvas-react/lazy.js +1 -1
  35. package/dist/operator/index.js +24 -252
  36. package/dist/operator/index.js.map +1 -1
  37. package/dist/platform/index.js +9 -9
  38. package/dist/public-consultation/index.d.ts +2 -2
  39. package/dist/public-consultation/index.js +2 -2
  40. package/dist/sequences/index.js +1 -1
  41. package/dist/sequences-react/index.js +3 -3
  42. package/dist/settings-react/index.js +1 -1
  43. package/dist/teams/invitations-api.js +1 -1
  44. package/dist/teams/members-api.d.ts +16 -1
  45. package/dist/teams/members-api.js +1 -1
  46. package/dist/teams-react/components/InviteTokenPage.d.ts +24 -0
  47. package/dist/teams-react/components/index.d.ts +1 -0
  48. package/dist/teams-react/index.js +40 -0
  49. package/dist/teams-react/index.js.map +1 -1
  50. package/dist/web/chat-stream-error.d.ts +63 -0
  51. package/dist/web/index.d.ts +1 -0
  52. package/dist/web/index.js +11 -1
  53. package/dist/web-react/durable-plan-flow-card.d.ts +25 -0
  54. package/dist/web-react/index.d.ts +3 -0
  55. package/dist/web-react/index.js +34 -28
  56. package/dist/web-react/sandbox-terminal-panel.d.ts +27 -0
  57. package/dist/web-react/terminal.d.ts +1 -0
  58. package/dist/web-react/terminal.js +109 -0
  59. package/dist/web-react/terminal.js.map +1 -1
  60. package/dist/web-react/use-models.d.ts +24 -0
  61. package/dist/web-react/use-plan-mode-selection.d.ts +17 -0
  62. package/dist/workspace-react/index.js +5 -5
  63. package/package.json +8 -2
  64. package/dist/chunk-BQGJ5IDP.js.map +0 -1
  65. package/dist/chunk-Y3GO6SG3.js.map +0 -1
  66. package/dist/chunk-ZNE4NYU7.js.map +0 -1
  67. /package/dist/{DesignCanvas-CFNV5JGQ.js.map → DesignCanvas-3DGZQOD7.js.map} +0 -0
  68. /package/dist/{DesignCanvasEditor-KH4BDUE3.js.map → DesignCanvasEditor-OG4QY5WJ.js.map} +0 -0
  69. /package/dist/{TimelineEditor-VB2UJ34D.js.map → TimelineEditor-MUY35ULL.js.map} +0 -0
  70. /package/dist/{chunk-IVBREL7A.js.map → chunk-5HBIN366.js.map} +0 -0
  71. /package/dist/{chunk-ZZTPTCMY.js.map → chunk-XJXAULNI.js.map} +0 -0
  72. /package/dist/{chunk-WTNW4NFS.js.map → chunk-ZD2AUFIT.js.map} +0 -0
@@ -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) ?? {