@standardagents/builder 0.9.8 → 0.9.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 +73 -1
- package/dist/built-in-routes.js.map +1 -1
- package/dist/client/assets/index.css +1 -1
- package/dist/client/index.js +19 -19
- package/dist/client/vendor.js +1 -1
- package/dist/client/vue.js +1 -35
- package/dist/index.d.ts +37 -0
- package/dist/index.js +97 -48
- package/dist/index.js.map +1 -1
- package/dist/plugin.js +20 -45
- package/dist/plugin.js.map +1 -1
- package/package.json +4 -2
package/dist/index.d.ts
CHANGED
|
@@ -904,6 +904,16 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
904
904
|
success: boolean;
|
|
905
905
|
error: any;
|
|
906
906
|
}>;
|
|
907
|
+
/**
|
|
908
|
+
* Update a message's content (RPC method)
|
|
909
|
+
*/
|
|
910
|
+
updateMessageContent(messageId: string, content: string): Promise<{
|
|
911
|
+
success: boolean;
|
|
912
|
+
error?: undefined;
|
|
913
|
+
} | {
|
|
914
|
+
success: boolean;
|
|
915
|
+
error: any;
|
|
916
|
+
}>;
|
|
907
917
|
/**
|
|
908
918
|
* Seed messages directly into the database (RPC method - for testing)
|
|
909
919
|
* This bypasses the normal message processing flow
|
|
@@ -914,6 +924,7 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
914
924
|
role: string;
|
|
915
925
|
content: string;
|
|
916
926
|
created_at: number;
|
|
927
|
+
log_id?: string | null;
|
|
917
928
|
}>;
|
|
918
929
|
}): Promise<{
|
|
919
930
|
success: boolean;
|
|
@@ -924,6 +935,27 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
924
935
|
error: any;
|
|
925
936
|
count?: undefined;
|
|
926
937
|
}>;
|
|
938
|
+
/**
|
|
939
|
+
* Seed a log directly into the database (RPC method - for testing)
|
|
940
|
+
* This bypasses the normal log creation flow
|
|
941
|
+
*/
|
|
942
|
+
seedLog(args: {
|
|
943
|
+
id: string;
|
|
944
|
+
message_id: string;
|
|
945
|
+
provider: string;
|
|
946
|
+
model: string;
|
|
947
|
+
created_at: number;
|
|
948
|
+
is_complete?: boolean;
|
|
949
|
+
prompt_name?: string;
|
|
950
|
+
}): Promise<{
|
|
951
|
+
success: boolean;
|
|
952
|
+
id: string;
|
|
953
|
+
error?: undefined;
|
|
954
|
+
} | {
|
|
955
|
+
success: boolean;
|
|
956
|
+
error: any;
|
|
957
|
+
id?: undefined;
|
|
958
|
+
}>;
|
|
927
959
|
/**
|
|
928
960
|
* Get logs (RPC method)
|
|
929
961
|
*/
|
|
@@ -1254,6 +1286,11 @@ declare class DurableAgentBuilder<Env extends AgentBuilderEnv = AgentBuilderEnv>
|
|
|
1254
1286
|
* Delete a thread from the registry.
|
|
1255
1287
|
*/
|
|
1256
1288
|
deleteThread(id: string): Promise<boolean>;
|
|
1289
|
+
/**
|
|
1290
|
+
* Delete all threads from the registry.
|
|
1291
|
+
* Useful for clearing test data between test runs.
|
|
1292
|
+
*/
|
|
1293
|
+
deleteAllThreads(): Promise<number>;
|
|
1257
1294
|
/**
|
|
1258
1295
|
* Update a thread's agent_name (used during agent handoff).
|
|
1259
1296
|
*/
|
package/dist/index.js
CHANGED
|
@@ -5848,71 +5848,46 @@ function agentbuilder(options = {}) {
|
|
|
5848
5848
|
}
|
|
5849
5849
|
return {
|
|
5850
5850
|
name: "vite-plugin-agent",
|
|
5851
|
-
config(
|
|
5852
|
-
const depsToInclude = [
|
|
5853
|
-
"openai",
|
|
5854
|
-
"zod",
|
|
5855
|
-
"@standardagents/builder/runtime",
|
|
5856
|
-
"@standardagents/builder/built-in-routes"
|
|
5857
|
-
];
|
|
5851
|
+
config() {
|
|
5858
5852
|
const depsToExclude = [
|
|
5853
|
+
"@standardagents/builder",
|
|
5854
|
+
"@standardagents/builder/runtime",
|
|
5855
|
+
"@standardagents/builder/built-in-routes",
|
|
5859
5856
|
"@standardagents/builder/mcp"
|
|
5860
5857
|
];
|
|
5861
|
-
const environments = {};
|
|
5862
|
-
if (config.environments) {
|
|
5863
|
-
for (const envName of Object.keys(config.environments)) {
|
|
5864
|
-
environments[envName] = {
|
|
5865
|
-
optimizeDeps: {
|
|
5866
|
-
include: depsToInclude,
|
|
5867
|
-
exclude: depsToExclude
|
|
5868
|
-
}
|
|
5869
|
-
};
|
|
5870
|
-
}
|
|
5871
|
-
}
|
|
5872
5858
|
return {
|
|
5873
|
-
// Root optimizeDeps for client environment
|
|
5874
5859
|
optimizeDeps: {
|
|
5875
|
-
//
|
|
5876
|
-
//
|
|
5877
|
-
// These are discovered dynamically by the virtual modules, so we need to
|
|
5878
|
-
// tell Vite about them ahead of time.
|
|
5879
|
-
include: depsToInclude,
|
|
5860
|
+
// Exclude our packages from pre-bundling - they contain cloudflare:workers imports
|
|
5861
|
+
// that cannot be resolved during dependency optimization
|
|
5880
5862
|
exclude: depsToExclude
|
|
5881
5863
|
},
|
|
5882
|
-
// Also configure for environments (Cloudflare worker uses a custom environment)
|
|
5883
|
-
environments,
|
|
5884
5864
|
ssr: {
|
|
5885
|
-
//
|
|
5886
|
-
|
|
5887
|
-
//
|
|
5888
|
-
|
|
5865
|
+
// Only MCP should be external (not used in worker)
|
|
5866
|
+
external: ["@standardagents/builder/mcp"],
|
|
5867
|
+
// noExternal ensures Vite transforms these instead of leaving as external
|
|
5868
|
+
// The Cloudflare plugin handles the actual bundling and knows about cloudflare:workers
|
|
5869
|
+
noExternal: [
|
|
5870
|
+
"@standardagents/builder",
|
|
5871
|
+
"@standardagents/builder/runtime",
|
|
5872
|
+
"@standardagents/builder/built-in-routes"
|
|
5873
|
+
]
|
|
5889
5874
|
},
|
|
5890
5875
|
build: {
|
|
5891
5876
|
rollupOptions: {
|
|
5892
|
-
|
|
5893
|
-
// Note: @standardagents/builder, @standardagents/builder/runtime, built-in-routes, and rou3
|
|
5894
|
-
// are NOT external - they must be bundled into the worker for Cloudflare Workers runtime
|
|
5895
|
-
external: depsToExclude
|
|
5877
|
+
external: ["@standardagents/builder/mcp"]
|
|
5896
5878
|
}
|
|
5897
5879
|
}
|
|
5898
5880
|
};
|
|
5899
5881
|
},
|
|
5900
|
-
//
|
|
5882
|
+
// Apply exclusions to ALL environments including Cloudflare worker
|
|
5901
5883
|
configEnvironment(name, config) {
|
|
5902
|
-
const depsToInclude = [
|
|
5903
|
-
"openai",
|
|
5904
|
-
"zod",
|
|
5905
|
-
"@standardagents/builder/runtime",
|
|
5906
|
-
"@standardagents/builder/built-in-routes"
|
|
5907
|
-
];
|
|
5908
5884
|
const depsToExclude = [
|
|
5885
|
+
"@standardagents/builder",
|
|
5886
|
+
"@standardagents/builder/runtime",
|
|
5887
|
+
"@standardagents/builder/built-in-routes",
|
|
5909
5888
|
"@standardagents/builder/mcp"
|
|
5910
5889
|
];
|
|
5911
5890
|
config.optimizeDeps = config.optimizeDeps || {};
|
|
5912
|
-
config.optimizeDeps.include = [
|
|
5913
|
-
...config.optimizeDeps.include || [],
|
|
5914
|
-
...depsToInclude.filter((dep) => !config.optimizeDeps?.include?.includes(dep))
|
|
5915
|
-
];
|
|
5916
5891
|
config.optimizeDeps.exclude = [
|
|
5917
5892
|
...config.optimizeDeps.exclude || [],
|
|
5918
5893
|
...depsToExclude.filter((dep) => !config.optimizeDeps?.exclude?.includes(dep))
|
|
@@ -8399,6 +8374,34 @@ var DurableThread = class extends DurableObject {
|
|
|
8399
8374
|
};
|
|
8400
8375
|
}
|
|
8401
8376
|
}
|
|
8377
|
+
/**
|
|
8378
|
+
* Update a message's content (RPC method)
|
|
8379
|
+
*/
|
|
8380
|
+
async updateMessageContent(messageId, content) {
|
|
8381
|
+
await this.ensureMigrated();
|
|
8382
|
+
try {
|
|
8383
|
+
const checkResult = await this.ctx.storage.sql.exec(
|
|
8384
|
+
`SELECT id FROM messages WHERE id = ?`,
|
|
8385
|
+
messageId
|
|
8386
|
+
);
|
|
8387
|
+
const messageExists = checkResult.toArray().length > 0;
|
|
8388
|
+
if (!messageExists) {
|
|
8389
|
+
return { success: false, error: "Message not found" };
|
|
8390
|
+
}
|
|
8391
|
+
await this.ctx.storage.sql.exec(
|
|
8392
|
+
`UPDATE messages SET content = ? WHERE id = ?`,
|
|
8393
|
+
content,
|
|
8394
|
+
messageId
|
|
8395
|
+
);
|
|
8396
|
+
return { success: true };
|
|
8397
|
+
} catch (error) {
|
|
8398
|
+
console.error("Error in updateMessageContent:", error);
|
|
8399
|
+
return {
|
|
8400
|
+
success: false,
|
|
8401
|
+
error: error.message || "Failed to update message"
|
|
8402
|
+
};
|
|
8403
|
+
}
|
|
8404
|
+
}
|
|
8402
8405
|
/**
|
|
8403
8406
|
* Seed messages directly into the database (RPC method - for testing)
|
|
8404
8407
|
* This bypasses the normal message processing flow
|
|
@@ -8409,13 +8412,14 @@ var DurableThread = class extends DurableObject {
|
|
|
8409
8412
|
for (const msg of args.messages) {
|
|
8410
8413
|
await this.ctx.storage.sql.exec(
|
|
8411
8414
|
`
|
|
8412
|
-
INSERT INTO messages (id, role, content, created_at)
|
|
8413
|
-
VALUES (?, ?, ?, ?)
|
|
8415
|
+
INSERT INTO messages (id, role, content, created_at, log_id)
|
|
8416
|
+
VALUES (?, ?, ?, ?, ?)
|
|
8414
8417
|
`,
|
|
8415
8418
|
msg.id,
|
|
8416
8419
|
msg.role,
|
|
8417
8420
|
msg.content,
|
|
8418
|
-
msg.created_at
|
|
8421
|
+
msg.created_at,
|
|
8422
|
+
msg.log_id ?? null
|
|
8419
8423
|
);
|
|
8420
8424
|
}
|
|
8421
8425
|
return {
|
|
@@ -8430,6 +8434,38 @@ var DurableThread = class extends DurableObject {
|
|
|
8430
8434
|
};
|
|
8431
8435
|
}
|
|
8432
8436
|
}
|
|
8437
|
+
/**
|
|
8438
|
+
* Seed a log directly into the database (RPC method - for testing)
|
|
8439
|
+
* This bypasses the normal log creation flow
|
|
8440
|
+
*/
|
|
8441
|
+
async seedLog(args) {
|
|
8442
|
+
await this.ensureMigrated();
|
|
8443
|
+
try {
|
|
8444
|
+
await this.ctx.storage.sql.exec(
|
|
8445
|
+
`
|
|
8446
|
+
INSERT INTO logs (id, message_id, provider, model, is_complete, prompt_name, created_at)
|
|
8447
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
8448
|
+
`,
|
|
8449
|
+
args.id,
|
|
8450
|
+
args.message_id,
|
|
8451
|
+
args.provider,
|
|
8452
|
+
args.model,
|
|
8453
|
+
args.is_complete ? 1 : 0,
|
|
8454
|
+
args.prompt_name ?? null,
|
|
8455
|
+
args.created_at
|
|
8456
|
+
);
|
|
8457
|
+
return {
|
|
8458
|
+
success: true,
|
|
8459
|
+
id: args.id
|
|
8460
|
+
};
|
|
8461
|
+
} catch (error) {
|
|
8462
|
+
console.error("Error in seedLog:", error);
|
|
8463
|
+
return {
|
|
8464
|
+
success: false,
|
|
8465
|
+
error: error.message || "Failed to seed log"
|
|
8466
|
+
};
|
|
8467
|
+
}
|
|
8468
|
+
}
|
|
8433
8469
|
/**
|
|
8434
8470
|
* Get logs (RPC method)
|
|
8435
8471
|
*/
|
|
@@ -9543,6 +9579,19 @@ var DurableAgentBuilder = class extends DurableObject {
|
|
|
9543
9579
|
this.broadcastEvent({ type: "thread_deleted", threadId: id });
|
|
9544
9580
|
return true;
|
|
9545
9581
|
}
|
|
9582
|
+
/**
|
|
9583
|
+
* Delete all threads from the registry.
|
|
9584
|
+
* Useful for clearing test data between test runs.
|
|
9585
|
+
*/
|
|
9586
|
+
async deleteAllThreads() {
|
|
9587
|
+
await this.ensureMigrated();
|
|
9588
|
+
const countCursor = await this.ctx.storage.sql.exec(
|
|
9589
|
+
`SELECT COUNT(*) as count FROM threads`
|
|
9590
|
+
);
|
|
9591
|
+
const count = countCursor.one().count;
|
|
9592
|
+
await this.ctx.storage.sql.exec(`DELETE FROM threads`);
|
|
9593
|
+
return count;
|
|
9594
|
+
}
|
|
9546
9595
|
/**
|
|
9547
9596
|
* Update a thread's agent_name (used during agent handoff).
|
|
9548
9597
|
*/
|