@standardagents/builder 0.9.9 → 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/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
@@ -8374,6 +8374,34 @@ var DurableThread = class extends DurableObject {
8374
8374
  };
8375
8375
  }
8376
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
+ }
8377
8405
  /**
8378
8406
  * Seed messages directly into the database (RPC method - for testing)
8379
8407
  * This bypasses the normal message processing flow
@@ -8384,13 +8412,14 @@ var DurableThread = class extends DurableObject {
8384
8412
  for (const msg of args.messages) {
8385
8413
  await this.ctx.storage.sql.exec(
8386
8414
  `
8387
- INSERT INTO messages (id, role, content, created_at)
8388
- VALUES (?, ?, ?, ?)
8415
+ INSERT INTO messages (id, role, content, created_at, log_id)
8416
+ VALUES (?, ?, ?, ?, ?)
8389
8417
  `,
8390
8418
  msg.id,
8391
8419
  msg.role,
8392
8420
  msg.content,
8393
- msg.created_at
8421
+ msg.created_at,
8422
+ msg.log_id ?? null
8394
8423
  );
8395
8424
  }
8396
8425
  return {
@@ -8405,6 +8434,38 @@ var DurableThread = class extends DurableObject {
8405
8434
  };
8406
8435
  }
8407
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
+ }
8408
8469
  /**
8409
8470
  * Get logs (RPC method)
8410
8471
  */
@@ -9518,6 +9579,19 @@ var DurableAgentBuilder = class extends DurableObject {
9518
9579
  this.broadcastEvent({ type: "thread_deleted", threadId: id });
9519
9580
  return true;
9520
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
+ }
9521
9595
  /**
9522
9596
  * Update a thread's agent_name (used during agent handoff).
9523
9597
  */