stitchkit 0.68.11 → 0.69.0

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.
Files changed (120) hide show
  1. package/README.md +30 -1
  2. package/dist/agent-runtime/coding-tool-contract.d.ts +155 -0
  3. package/dist/agent-runtime/coding-tool-contract.d.ts.map +1 -0
  4. package/dist/agent-runtime/coding-tool-files.d.ts +3 -0
  5. package/dist/agent-runtime/coding-tool-files.d.ts.map +1 -0
  6. package/dist/agent-runtime/coding-tool-paths.d.ts +19 -0
  7. package/dist/agent-runtime/coding-tool-paths.d.ts.map +1 -0
  8. package/dist/agent-runtime/coding-tool-search-patch.d.ts +3 -0
  9. package/dist/agent-runtime/coding-tool-search-patch.d.ts.map +1 -0
  10. package/dist/agent-runtime/coding-tool-shell.d.ts +3 -0
  11. package/dist/agent-runtime/coding-tool-shell.d.ts.map +1 -0
  12. package/dist/agent-runtime/coding-tools.d.ts +17 -0
  13. package/dist/agent-runtime/coding-tools.d.ts.map +1 -0
  14. package/dist/agent-runtime/compaction.d.ts +2 -0
  15. package/dist/agent-runtime/compaction.d.ts.map +1 -1
  16. package/dist/agent-runtime/contained-files.d.ts +31 -0
  17. package/dist/agent-runtime/contained-files.d.ts.map +1 -0
  18. package/dist/agent-runtime/control-schema.d.ts +1074 -0
  19. package/dist/agent-runtime/control-schema.d.ts.map +1 -0
  20. package/dist/agent-runtime/conversations.d.ts +128 -0
  21. package/dist/agent-runtime/conversations.d.ts.map +1 -0
  22. package/dist/agent-runtime/event-schema.d.ts +96 -0
  23. package/dist/agent-runtime/event-schema.d.ts.map +1 -1
  24. package/dist/agent-runtime/harness-contract.d.ts +169 -0
  25. package/dist/agent-runtime/harness-contract.d.ts.map +1 -0
  26. package/dist/agent-runtime/harness-control.d.ts +25 -0
  27. package/dist/agent-runtime/harness-control.d.ts.map +1 -0
  28. package/dist/agent-runtime/harness-file-resources.d.ts +33 -0
  29. package/dist/agent-runtime/harness-file-resources.d.ts.map +1 -0
  30. package/dist/agent-runtime/harness-resources.d.ts +5 -0
  31. package/dist/agent-runtime/harness-resources.d.ts.map +1 -0
  32. package/dist/agent-runtime/harness.d.ts +12 -0
  33. package/dist/agent-runtime/harness.d.ts.map +1 -0
  34. package/dist/agent-runtime/history.d.ts +2 -0
  35. package/dist/agent-runtime/history.d.ts.map +1 -1
  36. package/dist/agent-runtime/models.d.ts +199 -0
  37. package/dist/agent-runtime/models.d.ts.map +1 -1
  38. package/dist/agent-runtime/prompt.d.ts +2 -0
  39. package/dist/agent-runtime/prompt.d.ts.map +1 -1
  40. package/dist/agent-runtime/run-execution.d.ts.map +1 -1
  41. package/dist/agent-runtime/runtime.d.ts +11 -3
  42. package/dist/agent-runtime/runtime.d.ts.map +1 -1
  43. package/dist/agent-runtime/schemas.d.ts +49 -0
  44. package/dist/agent-runtime/schemas.d.ts.map +1 -1
  45. package/dist/agent-runtime/sqlite.d.ts +2 -0
  46. package/dist/agent-runtime/sqlite.d.ts.map +1 -1
  47. package/dist/agent-runtime/store-driver.d.ts +61 -212
  48. package/dist/agent-runtime/store-driver.d.ts.map +1 -1
  49. package/dist/agent-runtime/store.d.ts +368 -1
  50. package/dist/agent-runtime/store.d.ts.map +1 -1
  51. package/dist/agent-runtime/terminal-commit.d.ts +12 -1
  52. package/dist/agent-runtime/terminal-commit.d.ts.map +1 -1
  53. package/dist/agent-runtime/terminal-status.d.ts +8 -0
  54. package/dist/agent-runtime/terminal-status.d.ts.map +1 -1
  55. package/dist/agent-runtime-browser.d.ts +1 -0
  56. package/dist/agent-runtime-browser.d.ts.map +1 -1
  57. package/dist/agent-runtime-browser.js +217 -1
  58. package/dist/agent-runtime-coding-tools.d.ts +2 -0
  59. package/dist/agent-runtime-coding-tools.d.ts.map +1 -0
  60. package/dist/agent-runtime-coding-tools.js +706 -0
  61. package/dist/agent-runtime-harness.d.ts +2 -0
  62. package/dist/agent-runtime-harness.d.ts.map +1 -0
  63. package/dist/agent-runtime-harness.js +700 -0
  64. package/dist/agent-runtime-openrouter.d.ts +14 -1
  65. package/dist/agent-runtime-openrouter.d.ts.map +1 -1
  66. package/dist/agent-runtime-openrouter.js +211 -0
  67. package/dist/agent-runtime-sqlite-bun.js +4 -3
  68. package/dist/agent-runtime-sqlite-node.js +4 -3
  69. package/dist/agent-runtime.d.ts +5 -3
  70. package/dist/agent-runtime.d.ts.map +1 -1
  71. package/dist/agent-runtime.js +106 -2580
  72. package/dist/application/diagnostic-journal-contract.d.ts +164 -0
  73. package/dist/application/diagnostic-journal-contract.d.ts.map +1 -0
  74. package/dist/application/diagnostic-journal-manager.d.ts +12 -0
  75. package/dist/application/diagnostic-journal-manager.d.ts.map +1 -0
  76. package/dist/application/diagnostic-journal-storage.d.ts +29 -0
  77. package/dist/application/diagnostic-journal-storage.d.ts.map +1 -0
  78. package/dist/application/diagnostic-journal.d.ts +11 -0
  79. package/dist/application/diagnostic-journal.d.ts.map +1 -0
  80. package/dist/application.d.ts +2 -0
  81. package/dist/application.d.ts.map +1 -1
  82. package/dist/application.js +561 -17
  83. package/dist/browser/socket-io.d.ts.map +1 -1
  84. package/dist/cli.js +8 -6
  85. package/dist/{index-8vpzxg55.js → index-10gbbbaa.js} +103 -2
  86. package/dist/index-3eqrkqhg.js +2565 -0
  87. package/dist/{index-hcx9yypn.js → index-444747ww.js} +7 -7
  88. package/dist/{index-hxh98zbm.js → index-d1jsvkyk.js} +1 -1
  89. package/dist/index-es0h4w26.js +63 -0
  90. package/dist/{index-grgvpbch.js → index-gqdfpv4n.js} +4 -2
  91. package/dist/{index-bt5179zb.js → index-h7ctj1kp.js} +5 -3
  92. package/dist/{index-y2ctppmg.js → index-h8vn1jcr.js} +7 -73
  93. package/dist/{index-hqza5nde.js → index-hsabxjz0.js} +78 -77
  94. package/dist/index-kg9xx84n.js +73 -0
  95. package/dist/{index-hb0mncmj.js → index-kxxyvkka.js} +2 -2
  96. package/dist/{index-2t6zt5cg.js → index-mbxds404.js} +7 -5
  97. package/dist/{index-f24xg2cw.js → index-p1be103g.js} +1 -1
  98. package/dist/{index-xyvxez9r.js → index-q7gdep2c.js} +5 -5
  99. package/dist/{index-t23p2b68.js → index-t4dpby6e.js} +1 -1
  100. package/dist/index-tg3m2ec5.js +157 -0
  101. package/dist/index-v3dpzpjw.js +92 -0
  102. package/dist/{index-eqqyd9v8.js → index-wwst0td5.js} +2 -46
  103. package/dist/{index-ysphyxax.js → index-x1th9s8c.js} +23 -2
  104. package/dist/index-xxsq3ca1.js +51 -0
  105. package/dist/{index-22tjt2rk.js → index-zh459sfj.js} +1 -1
  106. package/dist/index.js +51 -37
  107. package/dist/internal/ai-sdk-typed.d.ts +14 -0
  108. package/dist/internal/ai-sdk-typed.d.ts.map +1 -0
  109. package/dist/node.js +5 -5
  110. package/dist/observability/index.js +4 -4
  111. package/dist/realtime/request.d.ts +5 -0
  112. package/dist/realtime/request.d.ts.map +1 -1
  113. package/dist/remote.js +6 -6
  114. package/dist/server/index.js +9 -9
  115. package/dist/testing.js +5 -5
  116. package/dist/tool-invoker.js +6 -5
  117. package/dist/tools.js +21 -17
  118. package/llms-full.txt +342 -27
  119. package/package.json +10 -2
  120. package/dist/{index-pgsyp3xh.js → index-x18ndp4p.js} +3 -3
@@ -1,16 +1,18 @@
1
1
  import {
2
2
  AgentAdmissionReceiptSchema,
3
+ AgentConversationMessagePageSchema,
4
+ AgentConversationPageSchema,
3
5
  AgentHistoryMutationSchema,
4
6
  AgentRecoverableDescriptorSchema,
5
7
  AgentRecoverablePageSchema,
6
8
  AgentRuntimeHeadSchema,
7
9
  AgentStoredRunSchema,
8
10
  createAgentRuntimeStore
9
- } from "./index-hqza5nde.js";
11
+ } from "./index-hsabxjz0.js";
10
12
  import {
11
13
  AgentMessageSchema,
12
14
  AgentRunSchema
13
- } from "./index-ysphyxax.js";
15
+ } from "./index-x1th9s8c.js";
14
16
 
15
17
  // src/agent-runtime/sqlite.ts
16
18
  import { z } from "zod";
@@ -35,6 +37,15 @@ var RecoverableRowSchema = z.object({
35
37
  });
36
38
  var MetaRowSchema = z.object({ value: z.string() });
37
39
  var TableRowSchema = z.object({ name: z.string() });
40
+ var ConversationHeadRowSchema = z.object({
41
+ conversation_id: z.string(),
42
+ version: z.number().int().nonnegative()
43
+ });
44
+ var CountRowSchema = z.object({ count: z.number().int().nonnegative() });
45
+ var MessagePageRowSchema = z.object({
46
+ position: z.number().int().nonnegative(),
47
+ payload: z.string()
48
+ });
38
49
  var SCHEMA_VERSION = 1;
39
50
  var TABLES = [
40
51
  "stitchkit_agent_runtime_heads",
@@ -70,6 +81,22 @@ function recoveryCursor(conversationId, runId) {
70
81
  function parseRecoveryCursor(cursor) {
71
82
  return z.tuple([z.string().min(1), z.string().min(1)]).parse(parseJson(cursor));
72
83
  }
84
+ function conversationCursor(conversationId) {
85
+ return encodeJson([conversationId]);
86
+ }
87
+ function parseConversationCursor(cursor) {
88
+ return z.tuple([z.string().min(1)]).parse(parseJson(cursor))[0];
89
+ }
90
+ function messageCursor(position) {
91
+ return encodeJson([position]);
92
+ }
93
+ function parseMessageCursor(cursor) {
94
+ return z.tuple([z.int().nonnegative()]).parse(parseJson(cursor))[0];
95
+ }
96
+ function messagePreview(message) {
97
+ const text = message.parts.find((part) => part.type === "text");
98
+ return text?.type === "text" ? text.text.slice(0, 160) : message.role;
99
+ }
73
100
  function initializeAgentRuntimeSqlite(database) {
74
101
  const existing = database.prepare(`SELECT name FROM sqlite_master WHERE type = 'table' AND name LIKE 'stitchkit_agent_runtime_%' ORDER BY name`).all().map((row) => TableRowSchema.parse(row).name);
75
102
  const hasMeta = existing.includes("stitchkit_agent_runtime_meta");
@@ -389,6 +416,80 @@ function createSqliteAgentRuntimeStore(config) {
389
416
  };
390
417
  return {
391
418
  store: createAgentRuntimeStore(driver),
419
+ conversations: {
420
+ list: (input) => serial(async () => {
421
+ if (!Number.isSafeInteger(input.limit) || input.limit < 1 || input.limit > 1000) {
422
+ throw new TypeError("Conversation page limit must be between 1 and 1000");
423
+ }
424
+ const cursor = input.cursor ? parseConversationCursor(input.cursor) : undefined;
425
+ const search = input.search?.trim();
426
+ const clauses = [
427
+ ...cursor ? ["conversation_id > ?"] : [],
428
+ ...search ? ["instr(conversation_id, ?) > 0"] : []
429
+ ];
430
+ const parameters = [
431
+ ...cursor ? [cursor] : [],
432
+ ...search ? [search] : [],
433
+ input.limit + 1
434
+ ];
435
+ const rows = database.prepare(`
436
+ SELECT conversation_id, version FROM stitchkit_agent_runtime_heads
437
+ ${clauses.length > 0 ? `WHERE ${clauses.join(" AND ")}` : ""}
438
+ ORDER BY conversation_id ASC LIMIT ?
439
+ `).all(...parameters).map((row) => ConversationHeadRowSchema.parse(row));
440
+ const hasMore = rows.length > input.limit;
441
+ const pageRows = rows.slice(0, input.limit);
442
+ const items = pageRows.map((row) => {
443
+ const latestRaw = database.prepare(`
444
+ SELECT position, payload FROM stitchkit_agent_runtime_messages
445
+ WHERE conversation_id = ? AND active = 1
446
+ ORDER BY position DESC LIMIT 1
447
+ `).get(row.conversation_id);
448
+ if (missing(latestRaw)) {
449
+ throw new Error("Agent conversation head has no active history");
450
+ }
451
+ const latest = AgentMessageSchema.parse(parseJson(MessagePageRowSchema.parse(latestRaw).payload));
452
+ const active = CountRowSchema.parse(database.prepare(`
453
+ SELECT count(*) AS count FROM stitchkit_agent_runtime_runs
454
+ WHERE conversation_id = ?
455
+ AND state IN ('queued', 'running', 'interrupt_requested')
456
+ `).get(row.conversation_id));
457
+ return {
458
+ conversationId: row.conversation_id,
459
+ version: row.version,
460
+ updatedAt: latest.updatedAt,
461
+ preview: messagePreview(latest),
462
+ activeRuns: active.count
463
+ };
464
+ });
465
+ const last = pageRows.at(-1);
466
+ return AgentConversationPageSchema.parse({
467
+ items,
468
+ ...hasMore && last ? { nextCursor: conversationCursor(last.conversation_id) } : {}
469
+ });
470
+ }),
471
+ messages: (input) => serial(async () => {
472
+ if (!Number.isSafeInteger(input.limit) || input.limit < 1 || input.limit > 1000) {
473
+ throw new TypeError("Conversation message page limit must be between 1 and 1000");
474
+ }
475
+ const cursor = input.cursor ? parseMessageCursor(input.cursor) : undefined;
476
+ const before = input.direction === "before";
477
+ const rows = database.prepare(`
478
+ SELECT position, payload FROM stitchkit_agent_runtime_messages
479
+ WHERE conversation_id = ? AND active = 1
480
+ ${cursor === undefined ? "" : before ? "AND position < ?" : "AND position > ?"}
481
+ ORDER BY position ${before ? "DESC" : "ASC"} LIMIT ?
482
+ `).all(input.conversationId, ...cursor === undefined ? [] : [cursor], input.limit + 1).map((row) => MessagePageRowSchema.parse(row));
483
+ const hasMore = rows.length > input.limit;
484
+ const pageRows = rows.slice(0, input.limit);
485
+ const ordered = before ? [...pageRows].reverse() : pageRows;
486
+ const boundary = pageRows.at(-1);
487
+ return AgentConversationMessagePageSchema.parse({
488
+ items: ordered.map((row) => AgentMessageSchema.parse(parseJson(row.payload))),
489
+ ...hasMore && boundary ? { nextCursor: messageCursor(boundary.position) } : {}
490
+ });
491
+ })
492
+ },
392
493
  async close() {
393
494
  if (closed)
394
495
  return;