@standardagents/builder 0.11.9 → 0.11.11
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 +24 -2
- package/dist/built-in-routes.js.map +1 -1
- package/dist/client/assets/index.css +1 -1
- package/dist/client/index.js +21 -21
- package/dist/client/vendor.js +1 -1
- package/dist/client/vue.js +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +61 -16
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -212,6 +212,7 @@ interface ToolCall {
|
|
|
212
212
|
arguments: string;
|
|
213
213
|
};
|
|
214
214
|
forceAllow?: boolean;
|
|
215
|
+
queued_at?: number;
|
|
215
216
|
}
|
|
216
217
|
/**
|
|
217
218
|
* Thread metadata from DurableAgentBuilder
|
|
@@ -415,6 +416,7 @@ interface FlowState {
|
|
|
415
416
|
extraMessages: Message[];
|
|
416
417
|
sequence: {
|
|
417
418
|
queue: ToolCall[];
|
|
419
|
+
queuedTools: ToolCall[];
|
|
418
420
|
isHandling: boolean;
|
|
419
421
|
};
|
|
420
422
|
active: FlowCallWithRetries;
|
|
@@ -711,6 +713,7 @@ interface LogData {
|
|
|
711
713
|
tools_available?: number;
|
|
712
714
|
prompt_name?: string;
|
|
713
715
|
tools_called?: string;
|
|
716
|
+
queued_tools?: string;
|
|
714
717
|
actual_provider?: string | null;
|
|
715
718
|
parent_log_id?: string | null;
|
|
716
719
|
tools_schema?: string | null;
|
|
@@ -1424,6 +1427,7 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
1424
1427
|
model_name: string | null;
|
|
1425
1428
|
prompt_name: string | null;
|
|
1426
1429
|
tools_called: string | null;
|
|
1430
|
+
queued_tools: string | null;
|
|
1427
1431
|
provider_tools: string | null;
|
|
1428
1432
|
parent_log_id: string | null;
|
|
1429
1433
|
retry_of_log_id: string | null;
|
|
@@ -1471,6 +1475,7 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
1471
1475
|
tools_available: number | null;
|
|
1472
1476
|
prompt_name: string | null;
|
|
1473
1477
|
tools_called: string | null;
|
|
1478
|
+
queued_tools: string | null;
|
|
1474
1479
|
provider_tools: string | null;
|
|
1475
1480
|
parent_log_id: string | null;
|
|
1476
1481
|
tools_schema: string | null;
|
package/dist/index.js
CHANGED
|
@@ -2712,7 +2712,9 @@ var init_ToolExecutor = __esm({
|
|
|
2712
2712
|
agentConfig: promptAgent,
|
|
2713
2713
|
storage: state.storage,
|
|
2714
2714
|
env: state.env,
|
|
2715
|
-
|
|
2715
|
+
// Use root thread ID - sub-prompts share the parent's thread
|
|
2716
|
+
// Messages are namespaced by depth and prompt, not by threadId
|
|
2717
|
+
threadId: state.rootState?.threadId || state.threadId,
|
|
2716
2718
|
thread: state.thread,
|
|
2717
2719
|
// Pass through parent thread instance and metadata
|
|
2718
2720
|
context: {
|
|
@@ -4902,6 +4904,7 @@ var init_FlowEngine = __esm({
|
|
|
4902
4904
|
messageHistory: [],
|
|
4903
4905
|
sequence: stateInput.sequence || {
|
|
4904
4906
|
queue: [],
|
|
4907
|
+
queuedTools: [],
|
|
4905
4908
|
isHandling: false
|
|
4906
4909
|
},
|
|
4907
4910
|
active: stateInput.active || {
|
|
@@ -5035,6 +5038,22 @@ var init_FlowEngine = __esm({
|
|
|
5035
5038
|
if (toolsToExecute && toolsToExecute.length > 0 || state.sequence.queue.length > 0) {
|
|
5036
5039
|
await ToolExecutor.executeSequence(state, toolsToExecute || []);
|
|
5037
5040
|
}
|
|
5041
|
+
if (state.sequence.queuedTools.length > 0 && state.currentLogId) {
|
|
5042
|
+
const queuedToolsJson = JSON.stringify(state.sequence.queuedTools);
|
|
5043
|
+
await state.storage.sql.exec(
|
|
5044
|
+
`UPDATE logs SET queued_tools = ?1 WHERE id = ?2`,
|
|
5045
|
+
queuedToolsJson,
|
|
5046
|
+
state.currentLogId
|
|
5047
|
+
);
|
|
5048
|
+
if (state.emitLog) {
|
|
5049
|
+
state.emitLog({
|
|
5050
|
+
type: "log_queued_tools",
|
|
5051
|
+
log_id: state.currentLogId,
|
|
5052
|
+
queued_tools: queuedToolsJson
|
|
5053
|
+
});
|
|
5054
|
+
}
|
|
5055
|
+
state.sequence.queuedTools = [];
|
|
5056
|
+
}
|
|
5038
5057
|
if (await state.thread.instance.shouldStop() || state.abortController?.signal.aborted) {
|
|
5039
5058
|
throw new Error("aborted");
|
|
5040
5059
|
}
|
|
@@ -6874,9 +6893,12 @@ function queueTool(flow, toolName, args = {}) {
|
|
|
6874
6893
|
name: toolName,
|
|
6875
6894
|
arguments: JSON.stringify(args)
|
|
6876
6895
|
},
|
|
6877
|
-
forceAllow: true
|
|
6896
|
+
forceAllow: true,
|
|
6897
|
+
queued_at: Date.now() * 1e3
|
|
6898
|
+
// Microseconds to match other timestamps
|
|
6878
6899
|
};
|
|
6879
6900
|
flow.sequence.queue.push(toolCall);
|
|
6901
|
+
flow.sequence.queuedTools.push(toolCall);
|
|
6880
6902
|
}
|
|
6881
6903
|
async function injectMessage(flow, options) {
|
|
6882
6904
|
const messageId = options.id ?? crypto.randomUUID();
|
|
@@ -12294,8 +12316,24 @@ var migration22 = {
|
|
|
12294
12316
|
}
|
|
12295
12317
|
};
|
|
12296
12318
|
|
|
12319
|
+
// src/durable-objects/migrations/023_add_queued_tools.ts
|
|
12320
|
+
var migration23 = {
|
|
12321
|
+
version: 23,
|
|
12322
|
+
async up(sql) {
|
|
12323
|
+
await sql.exec(`
|
|
12324
|
+
ALTER TABLE messages ADD COLUMN queued_tools TEXT
|
|
12325
|
+
`);
|
|
12326
|
+
await sql.exec(`
|
|
12327
|
+
ALTER TABLE logs ADD COLUMN queued_tools TEXT
|
|
12328
|
+
`);
|
|
12329
|
+
await sql.exec(`
|
|
12330
|
+
UPDATE _metadata SET value = '23' WHERE key = 'schema_version'
|
|
12331
|
+
`);
|
|
12332
|
+
}
|
|
12333
|
+
};
|
|
12334
|
+
|
|
12297
12335
|
// src/durable-objects/migrations/index.ts
|
|
12298
|
-
var migrations = [migration, migration2, migration3, migration4, migration5, migration6, migration7, migration8, migration9, migration10, migration11, migration12, migration13, migration14, migration15, migration16, migration17, migration18, migration19, migration20, migration21, migration22];
|
|
12336
|
+
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];
|
|
12299
12337
|
var LATEST_SCHEMA_VERSION = migrations.length;
|
|
12300
12338
|
|
|
12301
12339
|
// src/durable-objects/DurableThread.ts
|
|
@@ -12879,9 +12917,9 @@ var DurableThread = class extends DurableObject {
|
|
|
12879
12917
|
* Each migration is run in order, starting from the current version + 1.
|
|
12880
12918
|
*/
|
|
12881
12919
|
async runMigrations(fromVersion) {
|
|
12882
|
-
for (const
|
|
12883
|
-
if (
|
|
12884
|
-
await
|
|
12920
|
+
for (const migration26 of migrations) {
|
|
12921
|
+
if (migration26.version > fromVersion) {
|
|
12922
|
+
await migration26.up(this.ctx.storage.sql);
|
|
12885
12923
|
}
|
|
12886
12924
|
}
|
|
12887
12925
|
}
|
|
@@ -13087,7 +13125,7 @@ var DurableThread = class extends DurableObject {
|
|
|
13087
13125
|
);
|
|
13088
13126
|
const logsCursor = await this.ctx.storage.sql.exec(
|
|
13089
13127
|
`SELECT id, message_id, provider, model, model_name, prompt_name, tools_called,
|
|
13090
|
-
parent_log_id, retry_of_log_id, error, cost_total, is_complete, created_at
|
|
13128
|
+
queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, cost_total, is_complete, created_at
|
|
13091
13129
|
FROM logs WHERE is_complete = 1 ORDER BY created_at DESC LIMIT 50`
|
|
13092
13130
|
);
|
|
13093
13131
|
for (const logRow of logsCursor) {
|
|
@@ -13102,6 +13140,8 @@ var DurableThread = class extends DurableObject {
|
|
|
13102
13140
|
model_name: logRow.model_name,
|
|
13103
13141
|
prompt_name: logRow.prompt_name,
|
|
13104
13142
|
tools_called: logRow.tools_called,
|
|
13143
|
+
queued_tools: logRow.queued_tools,
|
|
13144
|
+
provider_tools: logRow.provider_tools,
|
|
13105
13145
|
parent_log_id: logRow.parent_log_id,
|
|
13106
13146
|
retry_of_log_id: logRow.retry_of_log_id,
|
|
13107
13147
|
error: logRow.error,
|
|
@@ -13381,7 +13421,7 @@ var DurableThread = class extends DurableObject {
|
|
|
13381
13421
|
`
|
|
13382
13422
|
SELECT
|
|
13383
13423
|
id, message_id, provider, actual_provider, model, model_name, prompt_name,
|
|
13384
|
-
tools_called, provider_tools, parent_log_id, retry_of_log_id, error, cost_total,
|
|
13424
|
+
tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, cost_total,
|
|
13385
13425
|
is_complete, created_at, request_body
|
|
13386
13426
|
FROM logs
|
|
13387
13427
|
ORDER BY created_at ${order}
|
|
@@ -13399,6 +13439,7 @@ var DurableThread = class extends DurableObject {
|
|
|
13399
13439
|
model_name: row.model_name,
|
|
13400
13440
|
prompt_name: row.prompt_name,
|
|
13401
13441
|
tools_called: row.tools_called,
|
|
13442
|
+
queued_tools: row.queued_tools,
|
|
13402
13443
|
provider_tools: row.provider_tools,
|
|
13403
13444
|
parent_log_id: row.parent_log_id,
|
|
13404
13445
|
retry_of_log_id: row.retry_of_log_id,
|
|
@@ -13431,7 +13472,7 @@ var DurableThread = class extends DurableObject {
|
|
|
13431
13472
|
reasoning_tokens, total_tokens, latency_ms, time_to_first_token_ms,
|
|
13432
13473
|
finish_reason, error, error_type, cost_input, cost_output, cost_total,
|
|
13433
13474
|
message_history_length, tools_available, prompt_name, tools_called,
|
|
13434
|
-
provider_tools, parent_log_id, tools_schema, system_prompt,
|
|
13475
|
+
queued_tools, provider_tools, parent_log_id, tools_schema, system_prompt,
|
|
13435
13476
|
errors, retry_of_log_id, tool_results, is_complete, created_at
|
|
13436
13477
|
FROM logs
|
|
13437
13478
|
WHERE id = ?
|
|
@@ -13484,6 +13525,7 @@ var DurableThread = class extends DurableObject {
|
|
|
13484
13525
|
tools_available: row.tools_available,
|
|
13485
13526
|
prompt_name: row.prompt_name,
|
|
13486
13527
|
tools_called: row.tools_called,
|
|
13528
|
+
queued_tools: row.queued_tools,
|
|
13487
13529
|
provider_tools: row.provider_tools,
|
|
13488
13530
|
parent_log_id: row.parent_log_id,
|
|
13489
13531
|
tools_schema: row.tools_schema,
|
|
@@ -14781,7 +14823,7 @@ var DurableThread = class extends DurableObject {
|
|
|
14781
14823
|
};
|
|
14782
14824
|
|
|
14783
14825
|
// src/durable-objects/agentbuilder-migrations/0001_initial.ts
|
|
14784
|
-
var
|
|
14826
|
+
var migration24 = {
|
|
14785
14827
|
version: 1,
|
|
14786
14828
|
async up(sql) {
|
|
14787
14829
|
sql.exec(`
|
|
@@ -14880,7 +14922,7 @@ var migration23 = {
|
|
|
14880
14922
|
};
|
|
14881
14923
|
|
|
14882
14924
|
// src/durable-objects/agentbuilder-migrations/0002_add_tenvs_properties.ts
|
|
14883
|
-
var
|
|
14925
|
+
var migration25 = {
|
|
14884
14926
|
version: 2,
|
|
14885
14927
|
async up(sql) {
|
|
14886
14928
|
sql.exec(`ALTER TABLE threads ADD COLUMN tenvs TEXT`);
|
|
@@ -14892,7 +14934,7 @@ var migration24 = {
|
|
|
14892
14934
|
};
|
|
14893
14935
|
|
|
14894
14936
|
// src/durable-objects/agentbuilder-migrations/index.ts
|
|
14895
|
-
var migrations2 = [
|
|
14937
|
+
var migrations2 = [migration24, migration25];
|
|
14896
14938
|
var LATEST_SCHEMA_VERSION2 = 2;
|
|
14897
14939
|
|
|
14898
14940
|
// src/utils/crypto.ts
|
|
@@ -15069,9 +15111,9 @@ var DurableAgentBuilder = class extends DurableObject {
|
|
|
15069
15111
|
}
|
|
15070
15112
|
}
|
|
15071
15113
|
async runMigrations(fromVersion) {
|
|
15072
|
-
for (const
|
|
15073
|
-
if (
|
|
15074
|
-
await
|
|
15114
|
+
for (const migration26 of migrations2) {
|
|
15115
|
+
if (migration26.version > fromVersion) {
|
|
15116
|
+
await migration26.up(this.ctx.storage.sql);
|
|
15075
15117
|
}
|
|
15076
15118
|
}
|
|
15077
15119
|
}
|
|
@@ -15855,9 +15897,12 @@ var FlowStateSdk = class _FlowStateSdk {
|
|
|
15855
15897
|
name: toolName,
|
|
15856
15898
|
arguments: JSON.stringify(args)
|
|
15857
15899
|
},
|
|
15858
|
-
forceAllow: true
|
|
15900
|
+
forceAllow: true,
|
|
15901
|
+
queued_at: Date.now() * 1e3
|
|
15902
|
+
// Microseconds to match other timestamps
|
|
15859
15903
|
};
|
|
15860
15904
|
flow.sequence.queue.push(toolCall);
|
|
15905
|
+
flow.sequence.queuedTools.push(toolCall);
|
|
15861
15906
|
}
|
|
15862
15907
|
/**
|
|
15863
15908
|
* Inject a message into the thread without triggering execution
|