@tangle-network/agent-app 0.63.28 → 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.
- package/dist/{TimelineEditor-VB2UJ34D.js → TimelineEditor-MUY35ULL.js} +3 -3
- package/dist/app-auth/index.js +3 -3
- package/dist/assistant/index.js +9 -9
- package/dist/chat-react/index.js +3 -3
- package/dist/chat-routes/index.js +1 -1
- package/dist/chunk-53ZX7XZY.js +371 -0
- package/dist/chunk-53ZX7XZY.js.map +1 -0
- package/dist/{chunk-IVBREL7A.js → chunk-5HBIN366.js} +10 -10
- package/dist/{chunk-A7JD27SN.js → chunk-6UMIOEDR.js} +13 -13
- package/dist/chunk-N425HGJW.js +261 -0
- package/dist/chunk-N425HGJW.js.map +1 -0
- package/dist/{chunk-ZZTPTCMY.js → chunk-XJXAULNI.js} +7 -7
- package/dist/conformance/cli.d.ts +2 -0
- package/dist/conformance/cli.js +67 -0
- package/dist/conformance/cli.js.map +1 -0
- package/dist/conformance/index.d.ts +3 -0
- package/dist/conformance/index.js +9 -0
- package/dist/conformance/index.js.map +1 -0
- package/dist/conformance/revision.d.ts +13 -0
- package/dist/conformance/run.d.ts +48 -0
- package/dist/conformance/session.d.ts +24 -0
- package/dist/conformance/turns.d.ts +37 -0
- package/dist/design-canvas/index.js +6 -6
- package/dist/design-canvas-react/index.js +4 -4
- package/dist/operator/index.js +24 -252
- package/dist/operator/index.js.map +1 -1
- package/dist/platform/index.js +8 -8
- package/dist/public-consultation/index.d.ts +2 -2
- package/dist/public-consultation/index.js +1 -1
- package/dist/sequences-react/index.js +3 -3
- package/dist/settings-react/index.js +1 -1
- package/dist/web-react/index.js +28 -28
- package/dist/workspace-react/index.js +5 -5
- package/package.json +8 -2
- /package/dist/{TimelineEditor-VB2UJ34D.js.map → TimelineEditor-MUY35ULL.js.map} +0 -0
- /package/dist/{chunk-IVBREL7A.js.map → chunk-5HBIN366.js.map} +0 -0
- /package/dist/{chunk-A7JD27SN.js.map → chunk-6UMIOEDR.js.map} +0 -0
- /package/dist/{chunk-ZZTPTCMY.js.map → chunk-XJXAULNI.js.map} +0 -0
|
@@ -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";
|
package/dist/operator/index.js
CHANGED
|
@@ -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((
|
|
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
|
|
688
|
-
if (
|
|
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 =
|
|
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
|
|
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,
|
|
788
|
-
return admittedTurn(ctx, workspace.id, input.turnId, { threadId, refusal:
|
|
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(
|
|
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) ?? {
|