@standardagents/builder 0.35.3 → 0.35.5
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/built-in-routes.js +36 -26
- package/dist/built-in-routes.js.map +1 -1
- package/dist/client/{ApiKeysView-5EM1pB60.js → ApiKeysView-1dDvAxVS.js} +1 -1
- package/dist/client/CenteredContentView-DpneLOEW.js +1 -0
- package/dist/client/{CompositionView-D_M-Eajw.js → CompositionView-DvzI90K5.js} +1 -1
- package/dist/client/{ConfirmDialog.vue_vue_type_script_setup_true_lang-COlMI9pk.js → ConfirmDialog.vue_vue_type_script_setup_true_lang-DiI1fhCg.js} +1 -1
- package/dist/client/{CopyButton.vue_vue_type_script_setup_true_lang-BuKxnIzL.js → CopyButton.vue_vue_type_script_setup_true_lang-C_mtx_IO.js} +1 -1
- package/dist/client/{DataTable.vue_vue_type_script_setup_true_lang-B4G2YHdb.js → DataTable.vue_vue_type_script_setup_true_lang-xHY6L65e.js} +1 -1
- package/dist/client/{JsonViewer-BZ7Aadme.js → JsonViewer-DZk1hmoU.js} +1 -1
- package/dist/client/{LoginView-CyuV4gke.js → LoginView-Jpd6CNht.js} +1 -1
- package/dist/client/{MarketplaceView-CoHrzmNk.js → MarketplaceView-CxyxQ3eT.js} +1 -1
- package/dist/client/{Modal.vue_vue_type_script_setup_true_lang-DSajL5Fd.js → Modal.vue_vue_type_script_setup_true_lang-Be5qsOZI.js} +1 -1
- package/dist/client/{ModelModal.vue_vue_type_script_setup_true_lang-6UIPVigs.js → ModelModal.vue_vue_type_script_setup_true_lang-eYizTKcZ.js} +1 -1
- package/dist/client/{ModelsView-DFGteAQS.js → ModelsView-BU1zF5Zw.js} +1 -1
- package/dist/client/{PromptEditView-BRSrC8Jp.js → PromptEditView-BhvxR_WM.js} +1 -1
- package/dist/client/{PromptModal-BxITA4l1.js → PromptModal-D6H1VYyD.js} +1 -1
- package/dist/client/{PromptsView-C7-GT7uq.js → PromptsView-DgdRXffo.js} +1 -1
- package/dist/client/{ProvidersView-DnRgjgqa.js → ProvidersView-QcOzG7y7.js} +1 -1
- package/dist/client/ThreadInspectorPane.vue_vue_type_script_setup_true_lang-roXBQlRw.js +23 -0
- package/dist/client/{ThreadsView-TVOJzvJ4.js → ThreadsView-DmsDuS1X.js} +1 -1
- package/dist/client/{ToolsView-C2UrMMOe.js → ToolsView-Bcr6QafS.js} +1 -1
- package/dist/client/{UiCodeBlock.vue_vue_type_script_setup_true_lang-QytRm7Ql.js → UiCodeBlock.vue_vue_type_script_setup_true_lang-DjDQOYjB.js} +1 -1
- package/dist/client/{UsersView-C3_SvVDT.js → UsersView-Du7GQtro.js} +1 -1
- package/dist/client/{VariablesView-crHzb8II.js → VariablesView-DIdSMYXb.js} +1 -1
- package/dist/client/assets/{ThreadInspectorPane-B9HsKfCN.css → ThreadInspectorPane-2QOWOtet.css} +1 -1
- package/dist/client/assets/index-B-69GGhJ.css +1 -0
- package/dist/client/{check-pGlck8qX.js → check-DeHZQcv4.js} +1 -1
- package/dist/client/{chevron-right-FpPE1Obh.js → chevron-right-C8Mb0B59.js} +1 -1
- package/dist/client/{copy-Dt1FLh3s.js → copy-BxJsl-KZ.js} +1 -1
- package/dist/client/{formkit-DcZQH9-p.js → formkit-0eyyCEP_.js} +1 -1
- package/dist/client/{index-CbuxomcU.js → index-7UIZEBvt.js} +3 -3
- package/dist/client/index.html +4 -4
- package/dist/client/{package-DSNwOrcN.js → package-B9czwyIu.js} +1 -1
- package/dist/client/{plus-D0GkkdA7.js → plus-DqtuqJFm.js} +1 -1
- package/dist/client/timeAgo-CDt-vAhI.js +1 -0
- package/dist/client/{useActionFeedback-Dxh_Xp0q.js → useActionFeedback-B6UfBJ7l.js} +1 -1
- package/dist/client/{vue-KXHVRwln.js → vue-Dw7WLX4c.js} +1 -1
- package/dist/{index-DP9GxPHu.d.ts → index-BIVhZqwM.d.ts} +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +160 -2
- package/dist/index.js.map +1 -1
- package/dist/runtime.d.ts +26 -2
- package/dist/runtime.js +160 -2
- package/dist/runtime.js.map +1 -1
- package/dist/test.d.ts +1 -1
- package/package.json +5 -5
- package/dist/client/CenteredContentView-CV8QAco9.js +0 -1
- package/dist/client/ThreadInspectorPane.vue_vue_type_script_setup_true_lang-CE6qD6Zb.js +0 -22
- package/dist/client/assets/index-CPBDhUF1.css +0 -1
- package/dist/client/timeAgo-X3Xeq5Kz.js +0 -1
package/dist/runtime.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { e as ThreadEnv, A as Agent, r as ThreadMetadata, t as ToolResult, M as Message, k as ClientToolRequest, l as ClientToolResponse, m as ClientStreamRequest, n as ClientStreamResponse, w as FileRecord, F as FlowState, y as FileStats, G as GrepResult, x as AttachmentRef, J as MessageContent, E as Env, q as ThreadInstance } from './index-
|
|
2
|
-
export { f as BuilderThreadEndpointHandler, C as CLIENT_STREAM_CHUNK_BYTES, o as ClientDuplex, p as ClientForwarding, B as Controller, a as ControllerContext, u as FlowResult, D as ImageContentPart, I as ImageMetadata, L as LLMResponse, H as MultimodalContent, R as RequestContext, S as StorageBackend, v as TelemetryEvent, z as TextContentPart, b as ThreadEndpointContext, T as ToolCall, g as callClient, h as callClientStream, c as createThreadEndpointHandler, j as decodeStreamChunk, d as defineController, i as encodeStreamChunk, s as supportsClientForwarding } from './index-
|
|
1
|
+
import { e as ThreadEnv, A as Agent, r as ThreadMetadata, t as ToolResult, M as Message, k as ClientToolRequest, l as ClientToolResponse, m as ClientStreamRequest, n as ClientStreamResponse, w as FileRecord, F as FlowState, y as FileStats, G as GrepResult, x as AttachmentRef, J as MessageContent, E as Env, q as ThreadInstance } from './index-BIVhZqwM.js';
|
|
2
|
+
export { f as BuilderThreadEndpointHandler, C as CLIENT_STREAM_CHUNK_BYTES, o as ClientDuplex, p as ClientForwarding, B as Controller, a as ControllerContext, u as FlowResult, D as ImageContentPart, I as ImageMetadata, L as LLMResponse, H as MultimodalContent, R as RequestContext, S as StorageBackend, v as TelemetryEvent, z as TextContentPart, b as ThreadEndpointContext, T as ToolCall, g as callClient, h as callClientStream, c as createThreadEndpointHandler, j as decodeStreamChunk, d as defineController, i as encodeStreamChunk, s as supportsClientForwarding } from './index-BIVhZqwM.js';
|
|
3
3
|
import { CodeExecutionOptions, CodeExecutionResult, SubagentRegistryEntry, InjectMessageInput, QueueMessageInput, CredentialGrant, SkillMetadata, SkillFileInput, ModelDefinition as ModelDefinition$1, ToolArgs, PromptTextPart, PromptEnvPart, VariableDefinition, SubpromptConfig as SubpromptConfig$1, PromptToolConfig as PromptToolConfig$1, SubagentToolConfig as SubagentToolConfig$1, ReasoningConfig, SideConfig as SideConfig$1, LLMProviderInterface, ContentPart, TextPart, ImagePart, FilePart, ThreadState, NamespaceContext, DefinitionLoader } from '@standardagents/spec';
|
|
4
4
|
export { AgentType, DefinitionLoader, GlobalNamespaceContext, HookSignatures, ImageContent, ModelCapabilities, ModelProvider, NamespaceContext, PackageSignature, PackedExports, PackedMeta, PackedMetadata, PackedNamespaceContext, PromptInput, PromptTextPart, ProviderAssistantMessage, ProviderError, ProviderErrorCode, ProviderFactory, ProviderFactoryConfig, ProviderFinishReason, ProviderGeneratedImage, ProviderMessage, ProviderMessageContent, ModelCapabilities as ProviderModelCapabilities, ProviderReasoningDetail, ProviderRequest, ProviderResponse, ProviderStreamChunk, ProviderSystemMessage, ProviderTool, ProviderToolCallPart, ProviderToolMessage, ProviderToolResultContent, ProviderUsage, ProviderUserMessage, ReasoningConfig, StructuredPrompt, TextContent, Tool, ToolArgs, ToolArgsNode, ToolArgsRawShape, ToolContent, belongsToPackage, defineAgent, defineHook, defineModel, definePrompt, defineTool, isPacked, isVisibleInNamespace, mapReasoningLevel } from '@standardagents/spec';
|
|
5
5
|
import { DurableObject, WorkerEntrypoint } from 'cloudflare:workers';
|
|
@@ -428,6 +428,26 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
428
428
|
* Get the persisted resumable-subagent registry for this thread.
|
|
429
429
|
*/
|
|
430
430
|
getChildrenRegistry(_threadId: string): Promise<SubagentRegistryEntry[]>;
|
|
431
|
+
/** In-memory throttle/reentrancy guards for the stale-child reconciler. */
|
|
432
|
+
private lastChildAuditAt;
|
|
433
|
+
private childAuditInFlight;
|
|
434
|
+
/**
|
|
435
|
+
* Lazily heal registry entries stranded at a "working" status. The normal
|
|
436
|
+
* settlement chain lives only in the parent's `waitUntil`; a parent
|
|
437
|
+
* eviction/deploy/kill during a child's run leaves the entry at `running`
|
|
438
|
+
* forever and clients render an eternal spinner. On registry reads, audit
|
|
439
|
+
* old unsettled entries against the child thread's ACTUAL state and settle
|
|
440
|
+
* them — conservatively (see subagent-reconcile.ts): resumable children
|
|
441
|
+
* are never deterministically terminated.
|
|
442
|
+
*/
|
|
443
|
+
private reconcileStaleChildren;
|
|
444
|
+
/**
|
|
445
|
+
* Child-side registry settlement: called from the CHILD's own DO whenever
|
|
446
|
+
* a run ends, so the spinner clears even when the parent-held completion
|
|
447
|
+
* chain died with the parent. Only downgrades a live "working" status to
|
|
448
|
+
* idle — never clobbers terminated.
|
|
449
|
+
*/
|
|
450
|
+
settleChildRegistryIdle(_threadId: string, reference: string): Promise<void>;
|
|
431
451
|
private setChildrenRegistry;
|
|
432
452
|
upsertChildRegistry(_threadId: string, entry: SubagentRegistryEntry): Promise<void>;
|
|
433
453
|
updateChildRegistryStatus(_threadId: string, reference: string, status: string): Promise<void>;
|
|
@@ -565,6 +585,9 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
565
585
|
attachments?: unknown[];
|
|
566
586
|
terminal?: boolean;
|
|
567
587
|
}>;
|
|
588
|
+
/** Best-effort: mark this child's entry idle in its parent's registry. */
|
|
589
|
+
private settleOwnRegistryEntry;
|
|
590
|
+
private executeBlockingImpl;
|
|
568
591
|
/**
|
|
569
592
|
* Send a new message to the thread (RPC method)
|
|
570
593
|
* Enqueues the message processing to be handled by the alarm handler
|
|
@@ -785,6 +808,7 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
785
808
|
parent_log_id: string | null;
|
|
786
809
|
retry_of_log_id: string | null;
|
|
787
810
|
error: string | null;
|
|
811
|
+
error_type: string | null;
|
|
788
812
|
cost_total: number | null;
|
|
789
813
|
input_tokens: number | null;
|
|
790
814
|
cached_tokens: number | null;
|
package/dist/runtime.js
CHANGED
|
@@ -1824,6 +1824,9 @@ var init_LLMRequest = __esm({
|
|
|
1824
1824
|
try {
|
|
1825
1825
|
return await this.tryModel(context, state, context.model, startTime, void 0);
|
|
1826
1826
|
} catch (primaryError) {
|
|
1827
|
+
if (primaryError?._userStop) {
|
|
1828
|
+
throw primaryError;
|
|
1829
|
+
}
|
|
1827
1830
|
console.error(`Primary model ${context.model} failed:`, primaryError);
|
|
1828
1831
|
lastFailedLogId = primaryError?._lastLogId;
|
|
1829
1832
|
state.emitTelemetry?.({
|
|
@@ -1850,6 +1853,9 @@ var init_LLMRequest = __esm({
|
|
|
1850
1853
|
lastFailedLogId
|
|
1851
1854
|
);
|
|
1852
1855
|
} catch (fallbackError) {
|
|
1856
|
+
if (fallbackError?._userStop) {
|
|
1857
|
+
throw fallbackError;
|
|
1858
|
+
}
|
|
1853
1859
|
console.error(
|
|
1854
1860
|
`Fallback model ${fallback.fallback_model_id} failed:`,
|
|
1855
1861
|
fallbackError
|
|
@@ -1939,6 +1945,20 @@ var init_LLMRequest = __esm({
|
|
|
1939
1945
|
this.fireAsyncMetadataFetch(response, state, logId);
|
|
1940
1946
|
return { response, logId };
|
|
1941
1947
|
} catch (error2) {
|
|
1948
|
+
if (state.abortController?.signal?.aborted) {
|
|
1949
|
+
await this.logError(
|
|
1950
|
+
state,
|
|
1951
|
+
new Error("Interrupted by user"),
|
|
1952
|
+
"user_interrupted",
|
|
1953
|
+
actualModelId,
|
|
1954
|
+
startTime,
|
|
1955
|
+
logId
|
|
1956
|
+
);
|
|
1957
|
+
const stopError = new Error("aborted");
|
|
1958
|
+
stopError._lastLogId = logId;
|
|
1959
|
+
stopError._userStop = true;
|
|
1960
|
+
throw stopError;
|
|
1961
|
+
}
|
|
1942
1962
|
console.error(`Error calling ${actualModelId} (attempt ${attempts}):`, error2);
|
|
1943
1963
|
await this.logError(state, error2, "api_error", actualModelId, startTime, logId);
|
|
1944
1964
|
if (attempts < MAX_RETRIES_PER_MODEL) {
|
|
@@ -15586,6 +15606,25 @@ var migration34 = {
|
|
|
15586
15606
|
var migrations = [migration, migration2, migration3, migration4, migration5, migration6, migration7, migration8, migration9, migration10, migration11, migration12, migration13, migration14, migration15, migration16, migration17, migration18, migration19, migration20, migration21, migration22, migration23, migration24, migration25, migration26, migration27, migration28, migration29, migration30, migration31, migration32, migration33, migration34];
|
|
15587
15607
|
var LATEST_SCHEMA_VERSION = migrations.length;
|
|
15588
15608
|
|
|
15609
|
+
// src/durable-objects/subagent-reconcile.ts
|
|
15610
|
+
var CHILD_STALE_AFTER_MS = 5 * 6e4;
|
|
15611
|
+
var CHILD_AUDIT_MIN_INTERVAL_MS = 6e4;
|
|
15612
|
+
var CHILD_AUDIT_MAX_PER_SWEEP = 4;
|
|
15613
|
+
var SETTLED_STATUSES = /* @__PURE__ */ new Set(["idle", "terminated"]);
|
|
15614
|
+
function isAuditCandidate(entry, nowMs) {
|
|
15615
|
+
if (SETTLED_STATUSES.has(entry.status)) return false;
|
|
15616
|
+
const createdMs = (entry.createdAt ?? 0) / 1e3;
|
|
15617
|
+
return nowMs - createdMs >= CHILD_STALE_AFTER_MS;
|
|
15618
|
+
}
|
|
15619
|
+
function resolveStaleChildStatus(entry, child, nowMs) {
|
|
15620
|
+
if (SETTLED_STATUSES.has(entry.status)) return null;
|
|
15621
|
+
if (!child) return "terminated";
|
|
15622
|
+
if (child.terminated) return "terminated";
|
|
15623
|
+
if (child.executing) return null;
|
|
15624
|
+
if (nowMs - child.lastActivityMs < CHILD_STALE_AFTER_MS) return null;
|
|
15625
|
+
return entry.resumable ? "idle" : "terminated";
|
|
15626
|
+
}
|
|
15627
|
+
|
|
15589
15628
|
// src/durable-objects/DurableThread.ts
|
|
15590
15629
|
init_types();
|
|
15591
15630
|
|
|
@@ -17388,12 +17427,103 @@ var DurableThread = class _DurableThread extends DurableObject {
|
|
|
17388
17427
|
);
|
|
17389
17428
|
const rows = cursor.toArray();
|
|
17390
17429
|
const raw = rows[0]?.value ?? "[]";
|
|
17430
|
+
let entries;
|
|
17391
17431
|
try {
|
|
17392
17432
|
const parsed = JSON.parse(raw);
|
|
17393
|
-
|
|
17433
|
+
entries = Array.isArray(parsed) ? parsed : [];
|
|
17394
17434
|
} catch {
|
|
17395
17435
|
return [];
|
|
17396
17436
|
}
|
|
17437
|
+
return this.reconcileStaleChildren(entries);
|
|
17438
|
+
}
|
|
17439
|
+
/** In-memory throttle/reentrancy guards for the stale-child reconciler. */
|
|
17440
|
+
lastChildAuditAt = 0;
|
|
17441
|
+
childAuditInFlight = false;
|
|
17442
|
+
/**
|
|
17443
|
+
* Lazily heal registry entries stranded at a "working" status. The normal
|
|
17444
|
+
* settlement chain lives only in the parent's `waitUntil`; a parent
|
|
17445
|
+
* eviction/deploy/kill during a child's run leaves the entry at `running`
|
|
17446
|
+
* forever and clients render an eternal spinner. On registry reads, audit
|
|
17447
|
+
* old unsettled entries against the child thread's ACTUAL state and settle
|
|
17448
|
+
* them — conservatively (see subagent-reconcile.ts): resumable children
|
|
17449
|
+
* are never deterministically terminated.
|
|
17450
|
+
*/
|
|
17451
|
+
async reconcileStaleChildren(entries) {
|
|
17452
|
+
const nowMs = Date.now();
|
|
17453
|
+
if (this.childAuditInFlight) return entries;
|
|
17454
|
+
if (nowMs - this.lastChildAuditAt < CHILD_AUDIT_MIN_INTERVAL_MS) return entries;
|
|
17455
|
+
const candidates = entries.filter((entry) => isAuditCandidate(entry, nowMs));
|
|
17456
|
+
if (candidates.length === 0) return entries;
|
|
17457
|
+
this.childAuditInFlight = true;
|
|
17458
|
+
this.lastChildAuditAt = nowMs;
|
|
17459
|
+
try {
|
|
17460
|
+
const agentBuilderId = this.env.AGENT_BUILDER.idFromName("singleton");
|
|
17461
|
+
const agentBuilder = this.env.AGENT_BUILDER.get(agentBuilderId);
|
|
17462
|
+
const changed = [];
|
|
17463
|
+
for (const entry of candidates.slice(0, CHILD_AUDIT_MAX_PER_SWEEP)) {
|
|
17464
|
+
let facts = null;
|
|
17465
|
+
try {
|
|
17466
|
+
const child = await agentBuilder.getThread(entry.reference);
|
|
17467
|
+
facts = child ? {
|
|
17468
|
+
terminated: child.terminated ?? null,
|
|
17469
|
+
executing: child.executing === true,
|
|
17470
|
+
lastActivityMs: Number(child.last_activity_at ?? child.created_at ?? 0) * 1e3
|
|
17471
|
+
} : null;
|
|
17472
|
+
} catch {
|
|
17473
|
+
continue;
|
|
17474
|
+
}
|
|
17475
|
+
const resolution = resolveStaleChildStatus(entry, facts, nowMs);
|
|
17476
|
+
if (resolution) {
|
|
17477
|
+
changed.push({
|
|
17478
|
+
reference: entry.reference,
|
|
17479
|
+
status: resolution,
|
|
17480
|
+
// Settling a live one-shot child to terminated also terminates
|
|
17481
|
+
// the thread itself so registry and reality agree.
|
|
17482
|
+
terminateChild: resolution === "terminated" && facts !== null && !facts.terminated
|
|
17483
|
+
});
|
|
17484
|
+
}
|
|
17485
|
+
}
|
|
17486
|
+
if (changed.length === 0) return entries;
|
|
17487
|
+
const byRef = new Map(changed.map((c) => [c.reference, c]));
|
|
17488
|
+
const healed = entries.map(
|
|
17489
|
+
(entry) => byRef.has(entry.reference) ? { ...entry, status: byRef.get(entry.reference).status } : entry
|
|
17490
|
+
);
|
|
17491
|
+
await this.setChildrenRegistry(healed);
|
|
17492
|
+
for (const c of changed) {
|
|
17493
|
+
if (c.terminateChild) {
|
|
17494
|
+
try {
|
|
17495
|
+
const childId = this.env.AGENT_BUILDER_THREAD.idFromName(c.reference);
|
|
17496
|
+
const childStub = this.env.AGENT_BUILDER_THREAD.get(childId);
|
|
17497
|
+
await childStub.terminateThread?.(c.reference);
|
|
17498
|
+
} catch (error) {
|
|
17499
|
+
console.error("[DurableThread] Stale-child terminate failed (non-fatal):", error);
|
|
17500
|
+
}
|
|
17501
|
+
}
|
|
17502
|
+
await this.broadcastChildStatusChanged(c.reference);
|
|
17503
|
+
}
|
|
17504
|
+
console.log(
|
|
17505
|
+
`[DurableThread] Reconciled ${changed.length} stale subagent entr${changed.length === 1 ? "y" : "ies"}:`,
|
|
17506
|
+
changed.map((c) => `${c.reference.slice(0, 8)}\u2192${c.status}`).join(", ")
|
|
17507
|
+
);
|
|
17508
|
+
return healed;
|
|
17509
|
+
} finally {
|
|
17510
|
+
this.childAuditInFlight = false;
|
|
17511
|
+
}
|
|
17512
|
+
}
|
|
17513
|
+
/**
|
|
17514
|
+
* Child-side registry settlement: called from the CHILD's own DO whenever
|
|
17515
|
+
* a run ends, so the spinner clears even when the parent-held completion
|
|
17516
|
+
* chain died with the parent. Only downgrades a live "working" status to
|
|
17517
|
+
* idle — never clobbers terminated.
|
|
17518
|
+
*/
|
|
17519
|
+
async settleChildRegistryIdle(_threadId, reference) {
|
|
17520
|
+
const entries = await this.getChildrenRegistry("");
|
|
17521
|
+
const entry = entries.find((e) => e.reference === reference);
|
|
17522
|
+
if (!entry || entry.status === "terminated" || entry.status === "idle") return;
|
|
17523
|
+
await this.setChildrenRegistry(
|
|
17524
|
+
entries.map((e) => e.reference === reference ? { ...e, status: "idle" } : e)
|
|
17525
|
+
);
|
|
17526
|
+
await this.broadcastChildStatusChanged(reference);
|
|
17397
17527
|
}
|
|
17398
17528
|
async setChildrenRegistry(entries) {
|
|
17399
17529
|
await this.ctx.storage.sql.exec(
|
|
@@ -17975,6 +18105,33 @@ var DurableThread = class _DurableThread extends DurableObject {
|
|
|
17975
18105
|
* Used by blocking subagent tool calls.
|
|
17976
18106
|
*/
|
|
17977
18107
|
async executeBlocking(threadId, agentId, initial_messages, data) {
|
|
18108
|
+
try {
|
|
18109
|
+
return await this.executeBlockingImpl(threadId, agentId, initial_messages, data);
|
|
18110
|
+
} finally {
|
|
18111
|
+
this.ctx.waitUntil?.(this.settleOwnRegistryEntry(threadId));
|
|
18112
|
+
}
|
|
18113
|
+
}
|
|
18114
|
+
/** Best-effort: mark this child's entry idle in its parent's registry. */
|
|
18115
|
+
async settleOwnRegistryEntry(threadId) {
|
|
18116
|
+
try {
|
|
18117
|
+
const terminatedCursor = await this.ctx.storage.sql.exec(
|
|
18118
|
+
`SELECT value FROM execution_state WHERE key = 'terminated' LIMIT 1`
|
|
18119
|
+
);
|
|
18120
|
+
const terminated = terminatedCursor.toArray()[0]?.value;
|
|
18121
|
+
if (terminated && terminated !== "" && terminated !== "null") return;
|
|
18122
|
+
const agentBuilderId = this.env.AGENT_BUILDER.idFromName("singleton");
|
|
18123
|
+
const agentBuilder = this.env.AGENT_BUILDER.get(agentBuilderId);
|
|
18124
|
+
const meta = await agentBuilder.getThread(threadId);
|
|
18125
|
+
const parent = meta?.parent;
|
|
18126
|
+
if (!parent) return;
|
|
18127
|
+
const parentId = this.env.AGENT_BUILDER_THREAD.idFromName(parent);
|
|
18128
|
+
const parentStub = this.env.AGENT_BUILDER_THREAD.get(parentId);
|
|
18129
|
+
await parentStub.settleChildRegistryIdle?.(parent, threadId);
|
|
18130
|
+
} catch (error) {
|
|
18131
|
+
console.error("[DurableThread] Child-side registry settlement failed (non-fatal):", error);
|
|
18132
|
+
}
|
|
18133
|
+
}
|
|
18134
|
+
async executeBlockingImpl(threadId, agentId, initial_messages, data) {
|
|
17978
18135
|
await this.ensureMigrated();
|
|
17979
18136
|
await this.assertNotTerminated();
|
|
17980
18137
|
let parentThreadId = null;
|
|
@@ -19351,7 +19508,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
19351
19508
|
`
|
|
19352
19509
|
SELECT
|
|
19353
19510
|
id, message_id, provider, actual_provider, standard_agents_router_used, model, model_name, prompt_name,
|
|
19354
|
-
tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, cost_total,
|
|
19511
|
+
tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, error_type, cost_total,
|
|
19355
19512
|
input_tokens, cached_tokens, output_tokens, total_tokens,
|
|
19356
19513
|
is_complete, created_at
|
|
19357
19514
|
FROM logs
|
|
@@ -19376,6 +19533,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
19376
19533
|
parent_log_id: row.parent_log_id,
|
|
19377
19534
|
retry_of_log_id: row.retry_of_log_id,
|
|
19378
19535
|
error: row.error,
|
|
19536
|
+
error_type: row.error_type,
|
|
19379
19537
|
cost_total: row.cost_total,
|
|
19380
19538
|
input_tokens: row.input_tokens,
|
|
19381
19539
|
cached_tokens: row.cached_tokens,
|