@standardagents/builder 0.11.9 → 0.11.10
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 +21 -1
- 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 +58 -15
- 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
|
@@ -4902,6 +4902,7 @@ var init_FlowEngine = __esm({
|
|
|
4902
4902
|
messageHistory: [],
|
|
4903
4903
|
sequence: stateInput.sequence || {
|
|
4904
4904
|
queue: [],
|
|
4905
|
+
queuedTools: [],
|
|
4905
4906
|
isHandling: false
|
|
4906
4907
|
},
|
|
4907
4908
|
active: stateInput.active || {
|
|
@@ -5035,6 +5036,22 @@ var init_FlowEngine = __esm({
|
|
|
5035
5036
|
if (toolsToExecute && toolsToExecute.length > 0 || state.sequence.queue.length > 0) {
|
|
5036
5037
|
await ToolExecutor.executeSequence(state, toolsToExecute || []);
|
|
5037
5038
|
}
|
|
5039
|
+
if (state.sequence.queuedTools.length > 0 && state.currentLogId) {
|
|
5040
|
+
const queuedToolsJson = JSON.stringify(state.sequence.queuedTools);
|
|
5041
|
+
await state.storage.sql.exec(
|
|
5042
|
+
`UPDATE logs SET queued_tools = ?1 WHERE id = ?2`,
|
|
5043
|
+
queuedToolsJson,
|
|
5044
|
+
state.currentLogId
|
|
5045
|
+
);
|
|
5046
|
+
if (state.emitLog) {
|
|
5047
|
+
state.emitLog({
|
|
5048
|
+
type: "log_queued_tools",
|
|
5049
|
+
log_id: state.currentLogId,
|
|
5050
|
+
queued_tools: queuedToolsJson
|
|
5051
|
+
});
|
|
5052
|
+
}
|
|
5053
|
+
state.sequence.queuedTools = [];
|
|
5054
|
+
}
|
|
5038
5055
|
if (await state.thread.instance.shouldStop() || state.abortController?.signal.aborted) {
|
|
5039
5056
|
throw new Error("aborted");
|
|
5040
5057
|
}
|
|
@@ -6874,9 +6891,12 @@ function queueTool(flow, toolName, args = {}) {
|
|
|
6874
6891
|
name: toolName,
|
|
6875
6892
|
arguments: JSON.stringify(args)
|
|
6876
6893
|
},
|
|
6877
|
-
forceAllow: true
|
|
6894
|
+
forceAllow: true,
|
|
6895
|
+
queued_at: Date.now() * 1e3
|
|
6896
|
+
// Microseconds to match other timestamps
|
|
6878
6897
|
};
|
|
6879
6898
|
flow.sequence.queue.push(toolCall);
|
|
6899
|
+
flow.sequence.queuedTools.push(toolCall);
|
|
6880
6900
|
}
|
|
6881
6901
|
async function injectMessage(flow, options) {
|
|
6882
6902
|
const messageId = options.id ?? crypto.randomUUID();
|
|
@@ -12294,8 +12314,24 @@ var migration22 = {
|
|
|
12294
12314
|
}
|
|
12295
12315
|
};
|
|
12296
12316
|
|
|
12317
|
+
// src/durable-objects/migrations/023_add_queued_tools.ts
|
|
12318
|
+
var migration23 = {
|
|
12319
|
+
version: 23,
|
|
12320
|
+
async up(sql) {
|
|
12321
|
+
await sql.exec(`
|
|
12322
|
+
ALTER TABLE messages ADD COLUMN queued_tools TEXT
|
|
12323
|
+
`);
|
|
12324
|
+
await sql.exec(`
|
|
12325
|
+
ALTER TABLE logs ADD COLUMN queued_tools TEXT
|
|
12326
|
+
`);
|
|
12327
|
+
await sql.exec(`
|
|
12328
|
+
UPDATE _metadata SET value = '23' WHERE key = 'schema_version'
|
|
12329
|
+
`);
|
|
12330
|
+
}
|
|
12331
|
+
};
|
|
12332
|
+
|
|
12297
12333
|
// 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];
|
|
12334
|
+
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
12335
|
var LATEST_SCHEMA_VERSION = migrations.length;
|
|
12300
12336
|
|
|
12301
12337
|
// src/durable-objects/DurableThread.ts
|
|
@@ -12879,9 +12915,9 @@ var DurableThread = class extends DurableObject {
|
|
|
12879
12915
|
* Each migration is run in order, starting from the current version + 1.
|
|
12880
12916
|
*/
|
|
12881
12917
|
async runMigrations(fromVersion) {
|
|
12882
|
-
for (const
|
|
12883
|
-
if (
|
|
12884
|
-
await
|
|
12918
|
+
for (const migration26 of migrations) {
|
|
12919
|
+
if (migration26.version > fromVersion) {
|
|
12920
|
+
await migration26.up(this.ctx.storage.sql);
|
|
12885
12921
|
}
|
|
12886
12922
|
}
|
|
12887
12923
|
}
|
|
@@ -13087,7 +13123,7 @@ var DurableThread = class extends DurableObject {
|
|
|
13087
13123
|
);
|
|
13088
13124
|
const logsCursor = await this.ctx.storage.sql.exec(
|
|
13089
13125
|
`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
|
|
13126
|
+
queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, cost_total, is_complete, created_at
|
|
13091
13127
|
FROM logs WHERE is_complete = 1 ORDER BY created_at DESC LIMIT 50`
|
|
13092
13128
|
);
|
|
13093
13129
|
for (const logRow of logsCursor) {
|
|
@@ -13102,6 +13138,8 @@ var DurableThread = class extends DurableObject {
|
|
|
13102
13138
|
model_name: logRow.model_name,
|
|
13103
13139
|
prompt_name: logRow.prompt_name,
|
|
13104
13140
|
tools_called: logRow.tools_called,
|
|
13141
|
+
queued_tools: logRow.queued_tools,
|
|
13142
|
+
provider_tools: logRow.provider_tools,
|
|
13105
13143
|
parent_log_id: logRow.parent_log_id,
|
|
13106
13144
|
retry_of_log_id: logRow.retry_of_log_id,
|
|
13107
13145
|
error: logRow.error,
|
|
@@ -13381,7 +13419,7 @@ var DurableThread = class extends DurableObject {
|
|
|
13381
13419
|
`
|
|
13382
13420
|
SELECT
|
|
13383
13421
|
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,
|
|
13422
|
+
tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, cost_total,
|
|
13385
13423
|
is_complete, created_at, request_body
|
|
13386
13424
|
FROM logs
|
|
13387
13425
|
ORDER BY created_at ${order}
|
|
@@ -13399,6 +13437,7 @@ var DurableThread = class extends DurableObject {
|
|
|
13399
13437
|
model_name: row.model_name,
|
|
13400
13438
|
prompt_name: row.prompt_name,
|
|
13401
13439
|
tools_called: row.tools_called,
|
|
13440
|
+
queued_tools: row.queued_tools,
|
|
13402
13441
|
provider_tools: row.provider_tools,
|
|
13403
13442
|
parent_log_id: row.parent_log_id,
|
|
13404
13443
|
retry_of_log_id: row.retry_of_log_id,
|
|
@@ -13431,7 +13470,7 @@ var DurableThread = class extends DurableObject {
|
|
|
13431
13470
|
reasoning_tokens, total_tokens, latency_ms, time_to_first_token_ms,
|
|
13432
13471
|
finish_reason, error, error_type, cost_input, cost_output, cost_total,
|
|
13433
13472
|
message_history_length, tools_available, prompt_name, tools_called,
|
|
13434
|
-
provider_tools, parent_log_id, tools_schema, system_prompt,
|
|
13473
|
+
queued_tools, provider_tools, parent_log_id, tools_schema, system_prompt,
|
|
13435
13474
|
errors, retry_of_log_id, tool_results, is_complete, created_at
|
|
13436
13475
|
FROM logs
|
|
13437
13476
|
WHERE id = ?
|
|
@@ -13484,6 +13523,7 @@ var DurableThread = class extends DurableObject {
|
|
|
13484
13523
|
tools_available: row.tools_available,
|
|
13485
13524
|
prompt_name: row.prompt_name,
|
|
13486
13525
|
tools_called: row.tools_called,
|
|
13526
|
+
queued_tools: row.queued_tools,
|
|
13487
13527
|
provider_tools: row.provider_tools,
|
|
13488
13528
|
parent_log_id: row.parent_log_id,
|
|
13489
13529
|
tools_schema: row.tools_schema,
|
|
@@ -14781,7 +14821,7 @@ var DurableThread = class extends DurableObject {
|
|
|
14781
14821
|
};
|
|
14782
14822
|
|
|
14783
14823
|
// src/durable-objects/agentbuilder-migrations/0001_initial.ts
|
|
14784
|
-
var
|
|
14824
|
+
var migration24 = {
|
|
14785
14825
|
version: 1,
|
|
14786
14826
|
async up(sql) {
|
|
14787
14827
|
sql.exec(`
|
|
@@ -14880,7 +14920,7 @@ var migration23 = {
|
|
|
14880
14920
|
};
|
|
14881
14921
|
|
|
14882
14922
|
// src/durable-objects/agentbuilder-migrations/0002_add_tenvs_properties.ts
|
|
14883
|
-
var
|
|
14923
|
+
var migration25 = {
|
|
14884
14924
|
version: 2,
|
|
14885
14925
|
async up(sql) {
|
|
14886
14926
|
sql.exec(`ALTER TABLE threads ADD COLUMN tenvs TEXT`);
|
|
@@ -14892,7 +14932,7 @@ var migration24 = {
|
|
|
14892
14932
|
};
|
|
14893
14933
|
|
|
14894
14934
|
// src/durable-objects/agentbuilder-migrations/index.ts
|
|
14895
|
-
var migrations2 = [
|
|
14935
|
+
var migrations2 = [migration24, migration25];
|
|
14896
14936
|
var LATEST_SCHEMA_VERSION2 = 2;
|
|
14897
14937
|
|
|
14898
14938
|
// src/utils/crypto.ts
|
|
@@ -15069,9 +15109,9 @@ var DurableAgentBuilder = class extends DurableObject {
|
|
|
15069
15109
|
}
|
|
15070
15110
|
}
|
|
15071
15111
|
async runMigrations(fromVersion) {
|
|
15072
|
-
for (const
|
|
15073
|
-
if (
|
|
15074
|
-
await
|
|
15112
|
+
for (const migration26 of migrations2) {
|
|
15113
|
+
if (migration26.version > fromVersion) {
|
|
15114
|
+
await migration26.up(this.ctx.storage.sql);
|
|
15075
15115
|
}
|
|
15076
15116
|
}
|
|
15077
15117
|
}
|
|
@@ -15855,9 +15895,12 @@ var FlowStateSdk = class _FlowStateSdk {
|
|
|
15855
15895
|
name: toolName,
|
|
15856
15896
|
arguments: JSON.stringify(args)
|
|
15857
15897
|
},
|
|
15858
|
-
forceAllow: true
|
|
15898
|
+
forceAllow: true,
|
|
15899
|
+
queued_at: Date.now() * 1e3
|
|
15900
|
+
// Microseconds to match other timestamps
|
|
15859
15901
|
};
|
|
15860
15902
|
flow.sequence.queue.push(toolCall);
|
|
15903
|
+
flow.sequence.queuedTools.push(toolCall);
|
|
15861
15904
|
}
|
|
15862
15905
|
/**
|
|
15863
15906
|
* Inject a message into the thread without triggering execution
|