runwarden 0.4.0 → 0.5.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.
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { n as createDb, t as initDb } from "./init-Dm_qLwix.js";
2
+ import { n as createDb, t as initDb } from "./init-BO3OjyhV.js";
3
3
  // src/cli.ts
4
4
  const [command] = process.argv.slice(2);
5
5
  if (command !== "init") {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { LanguageModel } from "ai";
1
+ import { JSONValue, LanguageModel } from "ai";
2
2
  import { z } from "zod";
3
3
  import { NodePgDatabase } from "drizzle-orm/node-postgres";
4
4
  import { Pool } from "pg";
@@ -64,6 +64,7 @@ interface InvocationResult {
64
64
  invocationId: string;
65
65
  runId: string;
66
66
  text: string;
67
+ messages: NeutralMessage[];
67
68
  provider?: string;
68
69
  model?: string;
69
70
  }
@@ -84,10 +85,53 @@ interface InvocationRecord extends InvocationInput {
84
85
  completedAt?: Date;
85
86
  }
86
87
  type InvocationSettledListener = (invocation: InvocationRecord) => void | Promise<void>;
87
- interface NeutralMessage {
88
- role: 'user' | 'assistant' | 'system';
89
- content: string;
88
+ interface NeutralTextPart {
89
+ type: 'text';
90
+ text: string;
90
91
  }
92
+ interface NeutralToolCallPart {
93
+ type: 'tool-call';
94
+ toolCallId: string;
95
+ toolName: string;
96
+ input: unknown;
97
+ }
98
+ type NeutralToolResultOutput = {
99
+ type: 'text';
100
+ value: string;
101
+ } | {
102
+ type: 'json';
103
+ value: JSONValue;
104
+ } | {
105
+ type: 'error-text';
106
+ value: string;
107
+ } | {
108
+ type: 'error-json';
109
+ value: JSONValue;
110
+ } | {
111
+ type: 'execution-denied';
112
+ reason?: string;
113
+ };
114
+ interface NeutralToolResultPart {
115
+ type: 'tool-result';
116
+ toolCallId: string;
117
+ toolName: string;
118
+ output: NeutralToolResultOutput;
119
+ }
120
+ type NeutralContentPart = NeutralTextPart | NeutralToolCallPart;
121
+ /**
122
+ * A plain text message (the original shape) is still a valid NeutralMessage, so
123
+ * existing history loaders and callers compile and behave unchanged.
124
+ */
125
+ type NeutralMessage = {
126
+ role: 'user' | 'system';
127
+ content: string;
128
+ } | {
129
+ role: 'assistant';
130
+ content: string | readonly NeutralContentPart[];
131
+ } | {
132
+ role: 'tool';
133
+ content: readonly NeutralToolResultPart[];
134
+ };
91
135
  type RuntimeInvocationInput = InvocationInput & {
92
136
  invocationId: string;
93
137
  runId: string;
@@ -285,6 +329,25 @@ declare const invocations: import("drizzle-orm/pg-core").PgTableWithColumns<{
285
329
  identity: undefined;
286
330
  generated: undefined;
287
331
  }, {}, {}>;
332
+ resultMessages: import("drizzle-orm/pg-core").PgColumn<{
333
+ name: "result_messages";
334
+ tableName: "invocations";
335
+ dataType: "json";
336
+ columnType: "PgJsonb";
337
+ data: NeutralMessage[];
338
+ driverParam: unknown;
339
+ notNull: false;
340
+ hasDefault: false;
341
+ isPrimaryKey: false;
342
+ isAutoincrement: false;
343
+ hasRuntimeDefault: false;
344
+ enumValues: undefined;
345
+ baseColumn: never;
346
+ identity: undefined;
347
+ generated: undefined;
348
+ }, {}, {
349
+ $type: NeutralMessage[];
350
+ }>;
288
351
  idempotencyKey: import("drizzle-orm/pg-core").PgColumn<{
289
352
  name: "idempotency_key";
290
353
  tableName: "invocations";
@@ -1239,4 +1302,4 @@ export declare class FakeAgentRuntime implements AgentRuntime {
1239
1302
  export declare const RUNTIME_NAME = "runwarden";
1240
1303
  export declare const RUN_ID_HEADER = "X-Runwarden-Run-Id";
1241
1304
  export declare const ERROR_CATEGORY_META_KEY = "runwarden/error-category";
1242
- export type { AgentRuntime, AgentRuntimeErrorKind, ApprovalActionOptions, DatabaseHandle, DefineRuntimeOptions, HistoryLoader, InitOptions, InitResult, InvocationInput, InvocationRecord, InvocationResult, InvocationSettledListener, InvocationStatus, InvokeOptions, McpServerConfig, McpToolClient, McpToolSession, NativeMcpClientConfig, NeutralMessage, OpenAiCompatibleModelConfig, PendingToolCall, PolicyDecision, PolicyDecisionKind, PolicyRule, RunWorkerOptions, Runtime, RuntimeInvocationInput, RuntimeMetrics, RuntimePolicies, SystemPromptLoader, ToolCallAuditEvent, ToolCallAuditSink, ToolDefinition, WorkerHandle };
1305
+ export type { AgentRuntime, AgentRuntimeErrorKind, ApprovalActionOptions, DatabaseHandle, DefineRuntimeOptions, HistoryLoader, InitOptions, InitResult, InvocationInput, InvocationRecord, InvocationResult, InvocationSettledListener, InvocationStatus, InvokeOptions, McpServerConfig, McpToolClient, McpToolSession, NativeMcpClientConfig, NeutralContentPart, NeutralMessage, NeutralTextPart, NeutralToolCallPart, NeutralToolResultOutput, NeutralToolResultPart, OpenAiCompatibleModelConfig, PendingToolCall, PolicyDecision, PolicyDecisionKind, PolicyRule, RunWorkerOptions, Runtime, RuntimeInvocationInput, RuntimeMetrics, RuntimePolicies, SystemPromptLoader, ToolCallAuditEvent, ToolCallAuditSink, ToolDefinition, WorkerHandle };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as createDb, r as policyDecisions, t as initDb } from "./init-Dm_qLwix.js";
1
+ import { n as createDb, r as policyDecisions, t as initDb } from "./init-BO3OjyhV.js";
2
2
  import { createHash, randomUUID } from "node:crypto";
3
3
  import { sql } from "drizzle-orm";
4
4
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
@@ -27,6 +27,7 @@ function mapRow(raw) {
27
27
  orderingKey: raw.ordering_key ?? null,
28
28
  input: raw.input,
29
29
  resultText: raw.result_text ?? null,
30
+ resultMessages: raw.result_messages ?? null,
30
31
  idempotencyKey: raw.idempotency_key ?? null,
31
32
  status: raw.status,
32
33
  attemptCount: Number(raw.attempt_count),
@@ -203,6 +204,7 @@ async function markInvocationSucceeded(db, id, workerId, runId, result) {
203
204
  update agent_runtime.invocations
204
205
  set status = 'succeeded',
205
206
  result_text = ${result.resultText},
207
+ result_messages = ${result.resultMessages ? JSON.stringify(result.resultMessages) : null}::jsonb,
206
208
  provider = ${result.provider ?? null},
207
209
  model = ${result.model ?? null},
208
210
  pending_tool_call = null,
@@ -677,15 +679,120 @@ function dropBlankOptionalStringArguments(rawArguments, inputShape) {
677
679
  }
678
680
  return normalized;
679
681
  }
680
- function modelMessages(history, input) {
681
- return [...history.map((message) => ({
682
- role: message.role,
683
- content: message.content
684
- })), {
682
+ const DEFAULT_MAX_TOOL_RESULT_BYTES = 32768;
683
+ function toolResultOutputBytes(output) {
684
+ switch (output.type) {
685
+ case "text":
686
+ case "error-text": return Buffer.byteLength(output.value, "utf8");
687
+ case "json":
688
+ case "error-json": return Buffer.byteLength(JSON.stringify(output.value) ?? "", "utf8");
689
+ case "execution-denied": return Buffer.byteLength(output.reason ?? "", "utf8");
690
+ }
691
+ }
692
+ function toModelToolResultPart(part, maxToolResultBytes) {
693
+ if (toolResultOutputBytes(part.output) > maxToolResultBytes) throw new AgentRuntimeError("failure", "MCP tool result exceeded limit");
694
+ return {
695
+ type: "tool-result",
696
+ toolCallId: part.toolCallId,
697
+ toolName: part.toolName,
698
+ output: part.output
699
+ };
700
+ }
701
+ function toModelContentPart(part) {
702
+ switch (part.type) {
703
+ case "text": return {
704
+ type: "text",
705
+ text: part.text
706
+ };
707
+ case "tool-call": return {
708
+ type: "tool-call",
709
+ toolCallId: part.toolCallId,
710
+ toolName: part.toolName,
711
+ input: part.input
712
+ };
713
+ }
714
+ }
715
+ function toModelMessage(message, maxToolResultBytes) {
716
+ switch (message.role) {
717
+ case "user":
718
+ case "system": return {
719
+ role: message.role,
720
+ content: message.content
721
+ };
722
+ case "assistant": return {
723
+ role: "assistant",
724
+ content: typeof message.content === "string" ? message.content : message.content.map((part) => toModelContentPart(part))
725
+ };
726
+ case "tool": return {
727
+ role: "tool",
728
+ content: message.content.map((part) => toModelToolResultPart(part, maxToolResultBytes))
729
+ };
730
+ }
731
+ }
732
+ function modelMessages(history, input, maxToolResultBytes = DEFAULT_MAX_TOOL_RESULT_BYTES) {
733
+ return [...history.map((message) => toModelMessage(message, maxToolResultBytes)), {
685
734
  role: "user",
686
735
  content: input.prompt
687
736
  }];
688
737
  }
738
+ function toNeutralToolResultOutput(output) {
739
+ if (output.type === "content") return {
740
+ type: "text",
741
+ value: output.value.filter((part) => part.type === "text").map((part) => part.text).join("")
742
+ };
743
+ return output;
744
+ }
745
+ function toNeutralToolResultPart(part) {
746
+ return {
747
+ type: "tool-result",
748
+ toolCallId: part.toolCallId,
749
+ toolName: part.toolName,
750
+ output: toNeutralToolResultOutput(part.output)
751
+ };
752
+ }
753
+ function toNeutralContentPart(part) {
754
+ switch (part.type) {
755
+ case "text": return {
756
+ type: "text",
757
+ text: part.text
758
+ };
759
+ case "tool-call": return {
760
+ type: "tool-call",
761
+ toolCallId: part.toolCallId,
762
+ toolName: part.toolName,
763
+ input: part.input
764
+ };
765
+ default: return;
766
+ }
767
+ }
768
+ function toNeutralToolContentPart(part) {
769
+ return part.type === "tool-result" ? toNeutralToolResultPart(part) : void 0;
770
+ }
771
+ function toNeutralMessage(message) {
772
+ switch (message.role) {
773
+ case "assistant": {
774
+ if (typeof message.content === "string") return message.content.length > 0 ? {
775
+ role: "assistant",
776
+ content: message.content
777
+ } : void 0;
778
+ const parts = message.content.map(toNeutralContentPart).filter((part) => part !== void 0);
779
+ return parts.length > 0 ? {
780
+ role: "assistant",
781
+ content: parts
782
+ } : void 0;
783
+ }
784
+ case "tool": {
785
+ const parts = message.content.map(toNeutralToolContentPart).filter((part) => part !== void 0);
786
+ return parts.length > 0 ? {
787
+ role: "tool",
788
+ content: parts
789
+ } : void 0;
790
+ }
791
+ }
792
+ }
793
+ function producedNeutralMessages(messages) {
794
+ return messages.map(toNeutralMessage).filter((message) => message !== void 0);
795
+ }
689
796
  var AiSdkNativeRuntime = class {
690
797
  options;
691
798
  now;
@@ -755,7 +862,7 @@ var AiSdkNativeRuntime = class {
755
862
  },
756
863
  stopWhen: () => policy.terminalError != null
757
864
  });
758
- const messages = modelMessages(history, input);
865
+ const messages = modelMessages(history, input, this.options.policies?.maxToolResultBytes);
759
866
  let result = await agent.generate({
760
867
  messages,
761
868
  timeout: this.remaining(startedAt)
@@ -790,6 +897,10 @@ var AiSdkNativeRuntime = class {
790
897
  invocationId: input.invocationId,
791
898
  runId: input.runId,
792
899
  text,
900
+ messages: [{
901
+ role: "user",
902
+ content: input.prompt
903
+ }, ...steps.flatMap((step) => producedNeutralMessages(step.response.messages))],
793
904
  provider,
794
905
  model
795
906
  };
@@ -1045,6 +1156,7 @@ function defineRuntime(options) {
1045
1156
  invocationId,
1046
1157
  runId: row.activeRunId,
1047
1158
  text: row.resultText ?? "",
1159
+ messages: row.resultMessages ?? [],
1048
1160
  provider: row.provider ?? void 0,
1049
1161
  model: row.model ?? void 0
1050
1162
  };
@@ -1284,6 +1396,7 @@ function runWorker(options) {
1284
1396
  if (lease.isLost) return;
1285
1397
  if (await markInvocationSucceeded(db, row.id, workerId, row.activeRunId, {
1286
1398
  resultText: result.text,
1399
+ resultMessages: result.messages,
1287
1400
  provider: result.provider,
1288
1401
  model: result.model
1289
1402
  })) {
@@ -1377,10 +1490,19 @@ var FakeAgentRuntime = class {
1377
1490
  async invoke(input) {
1378
1491
  const invocationIndex = this.invocations.push(input);
1379
1492
  if (typeof this.result === "function") return this.result(input, invocationIndex);
1380
- return this.result ?? {
1493
+ if (this.result) return this.result;
1494
+ const text = `Fake runtime response to: ${input.prompt}`;
1495
+ return {
1381
1496
  invocationId: input.invocationId,
1382
1497
  runId: input.runId,
1383
- text: `Fake runtime response to: ${input.prompt}`,
1498
+ text,
1499
+ messages: [{
1500
+ role: "user",
1501
+ content: input.prompt
1502
+ }, {
1503
+ role: "assistant",
1504
+ content: text
1505
+ }],
1384
1506
  provider: "fake",
1385
1507
  model: "fake-agent-runtime"
1386
1508
  };
@@ -49,6 +49,7 @@ const invocations = runtimeSchema.table("invocations", {
49
49
  orderingKey: text("ordering_key"),
50
50
  input: jsonb("input").$type().notNull(),
51
51
  resultText: text("result_text"),
52
+ resultMessages: jsonb("result_messages").$type(),
52
53
  idempotencyKey: text("idempotency_key"),
53
54
  status: invocationStatusEnum("status").notNull().default("pending").$type(),
54
55
  attemptCount: integer("attempt_count").notNull().default(0),
@@ -0,0 +1 @@
1
+ ALTER TABLE "agent_runtime"."invocations" ADD COLUMN "result_messages" jsonb;
@@ -0,0 +1,726 @@
1
+ {
2
+ "id": "0f20ea46-9458-48db-9e27-176f7f13e19d",
3
+ "prevId": "ccda8d23-bb0e-4828-8930-dbe70db5ab2d",
4
+ "version": "7",
5
+ "dialect": "postgresql",
6
+ "tables": {
7
+ "agent_runtime.invocations": {
8
+ "name": "invocations",
9
+ "schema": "agent_runtime",
10
+ "columns": {
11
+ "id": {
12
+ "name": "id",
13
+ "type": "bigint",
14
+ "primaryKey": true,
15
+ "notNull": true,
16
+ "identity": {
17
+ "type": "always",
18
+ "name": "invocations_id_seq",
19
+ "schema": "agent_runtime",
20
+ "increment": "1",
21
+ "startWith": "1",
22
+ "minValue": "1",
23
+ "maxValue": "9223372036854775807",
24
+ "cache": "1",
25
+ "cycle": false
26
+ }
27
+ },
28
+ "scope": {
29
+ "name": "scope",
30
+ "type": "text",
31
+ "primaryKey": false,
32
+ "notNull": true
33
+ },
34
+ "conversation_id": {
35
+ "name": "conversation_id",
36
+ "type": "text",
37
+ "primaryKey": false,
38
+ "notNull": false
39
+ },
40
+ "ordering_key": {
41
+ "name": "ordering_key",
42
+ "type": "text",
43
+ "primaryKey": false,
44
+ "notNull": false
45
+ },
46
+ "input": {
47
+ "name": "input",
48
+ "type": "jsonb",
49
+ "primaryKey": false,
50
+ "notNull": true
51
+ },
52
+ "result_text": {
53
+ "name": "result_text",
54
+ "type": "text",
55
+ "primaryKey": false,
56
+ "notNull": false
57
+ },
58
+ "result_messages": {
59
+ "name": "result_messages",
60
+ "type": "jsonb",
61
+ "primaryKey": false,
62
+ "notNull": false
63
+ },
64
+ "idempotency_key": {
65
+ "name": "idempotency_key",
66
+ "type": "text",
67
+ "primaryKey": false,
68
+ "notNull": false
69
+ },
70
+ "status": {
71
+ "name": "status",
72
+ "type": "invocation_status",
73
+ "typeSchema": "agent_runtime",
74
+ "primaryKey": false,
75
+ "notNull": true,
76
+ "default": "'pending'"
77
+ },
78
+ "attempt_count": {
79
+ "name": "attempt_count",
80
+ "type": "integer",
81
+ "primaryKey": false,
82
+ "notNull": true,
83
+ "default": 0
84
+ },
85
+ "max_attempts": {
86
+ "name": "max_attempts",
87
+ "type": "integer",
88
+ "primaryKey": false,
89
+ "notNull": true,
90
+ "default": 3
91
+ },
92
+ "next_attempt_at": {
93
+ "name": "next_attempt_at",
94
+ "type": "timestamp with time zone",
95
+ "primaryKey": false,
96
+ "notNull": true,
97
+ "default": "now()"
98
+ },
99
+ "claimed_at": {
100
+ "name": "claimed_at",
101
+ "type": "timestamp with time zone",
102
+ "primaryKey": false,
103
+ "notNull": false
104
+ },
105
+ "claimed_by": {
106
+ "name": "claimed_by",
107
+ "type": "text",
108
+ "primaryKey": false,
109
+ "notNull": false
110
+ },
111
+ "lease_heartbeat_at": {
112
+ "name": "lease_heartbeat_at",
113
+ "type": "timestamp with time zone",
114
+ "primaryKey": false,
115
+ "notNull": false
116
+ },
117
+ "lease_expires_at": {
118
+ "name": "lease_expires_at",
119
+ "type": "timestamp with time zone",
120
+ "primaryKey": false,
121
+ "notNull": false
122
+ },
123
+ "active_run_id": {
124
+ "name": "active_run_id",
125
+ "type": "uuid",
126
+ "primaryKey": false,
127
+ "notNull": false
128
+ },
129
+ "active_run_registered_at": {
130
+ "name": "active_run_registered_at",
131
+ "type": "timestamp with time zone",
132
+ "primaryKey": false,
133
+ "notNull": false
134
+ },
135
+ "pending_tool_call": {
136
+ "name": "pending_tool_call",
137
+ "type": "jsonb",
138
+ "primaryKey": false,
139
+ "notNull": false
140
+ },
141
+ "started_at": {
142
+ "name": "started_at",
143
+ "type": "timestamp with time zone",
144
+ "primaryKey": false,
145
+ "notNull": false
146
+ },
147
+ "completed_at": {
148
+ "name": "completed_at",
149
+ "type": "timestamp with time zone",
150
+ "primaryKey": false,
151
+ "notNull": false
152
+ },
153
+ "failed_at": {
154
+ "name": "failed_at",
155
+ "type": "timestamp with time zone",
156
+ "primaryKey": false,
157
+ "notNull": false
158
+ },
159
+ "provider": {
160
+ "name": "provider",
161
+ "type": "text",
162
+ "primaryKey": false,
163
+ "notNull": false
164
+ },
165
+ "model": {
166
+ "name": "model",
167
+ "type": "text",
168
+ "primaryKey": false,
169
+ "notNull": false
170
+ },
171
+ "last_error_code": {
172
+ "name": "last_error_code",
173
+ "type": "text",
174
+ "primaryKey": false,
175
+ "notNull": false
176
+ },
177
+ "last_error_message": {
178
+ "name": "last_error_message",
179
+ "type": "text",
180
+ "primaryKey": false,
181
+ "notNull": false
182
+ },
183
+ "metadata": {
184
+ "name": "metadata",
185
+ "type": "jsonb",
186
+ "primaryKey": false,
187
+ "notNull": false
188
+ },
189
+ "created_at": {
190
+ "name": "created_at",
191
+ "type": "timestamp with time zone",
192
+ "primaryKey": false,
193
+ "notNull": true,
194
+ "default": "now()"
195
+ },
196
+ "updated_at": {
197
+ "name": "updated_at",
198
+ "type": "timestamp with time zone",
199
+ "primaryKey": false,
200
+ "notNull": true,
201
+ "default": "now()"
202
+ }
203
+ },
204
+ "indexes": {
205
+ "invocations_scope_idempotency_key_unique": {
206
+ "name": "invocations_scope_idempotency_key_unique",
207
+ "columns": [
208
+ {
209
+ "expression": "scope",
210
+ "isExpression": false,
211
+ "asc": true,
212
+ "nulls": "last"
213
+ },
214
+ {
215
+ "expression": "idempotency_key",
216
+ "isExpression": false,
217
+ "asc": true,
218
+ "nulls": "last"
219
+ }
220
+ ],
221
+ "isUnique": true,
222
+ "where": "\"agent_runtime\".\"invocations\".\"idempotency_key\" is not null",
223
+ "concurrently": false,
224
+ "method": "btree",
225
+ "with": {}
226
+ },
227
+ "invocations_active_run_id_unique": {
228
+ "name": "invocations_active_run_id_unique",
229
+ "columns": [
230
+ {
231
+ "expression": "active_run_id",
232
+ "isExpression": false,
233
+ "asc": true,
234
+ "nulls": "last"
235
+ }
236
+ ],
237
+ "isUnique": true,
238
+ "where": "\"agent_runtime\".\"invocations\".\"active_run_id\" is not null",
239
+ "concurrently": false,
240
+ "method": "btree",
241
+ "with": {}
242
+ },
243
+ "invocations_status_next_attempt_idx": {
244
+ "name": "invocations_status_next_attempt_idx",
245
+ "columns": [
246
+ {
247
+ "expression": "status",
248
+ "isExpression": false,
249
+ "asc": true,
250
+ "nulls": "last"
251
+ },
252
+ {
253
+ "expression": "next_attempt_at",
254
+ "isExpression": false,
255
+ "asc": true,
256
+ "nulls": "last"
257
+ }
258
+ ],
259
+ "isUnique": false,
260
+ "concurrently": false,
261
+ "method": "btree",
262
+ "with": {}
263
+ },
264
+ "invocations_status_lease_expires_idx": {
265
+ "name": "invocations_status_lease_expires_idx",
266
+ "columns": [
267
+ {
268
+ "expression": "status",
269
+ "isExpression": false,
270
+ "asc": true,
271
+ "nulls": "last"
272
+ },
273
+ {
274
+ "expression": "lease_expires_at",
275
+ "isExpression": false,
276
+ "asc": true,
277
+ "nulls": "last"
278
+ }
279
+ ],
280
+ "isUnique": false,
281
+ "concurrently": false,
282
+ "method": "btree",
283
+ "with": {}
284
+ },
285
+ "invocations_scope_status_next_attempt_idx": {
286
+ "name": "invocations_scope_status_next_attempt_idx",
287
+ "columns": [
288
+ {
289
+ "expression": "scope",
290
+ "isExpression": false,
291
+ "asc": true,
292
+ "nulls": "last"
293
+ },
294
+ {
295
+ "expression": "status",
296
+ "isExpression": false,
297
+ "asc": true,
298
+ "nulls": "last"
299
+ },
300
+ {
301
+ "expression": "next_attempt_at",
302
+ "isExpression": false,
303
+ "asc": true,
304
+ "nulls": "last"
305
+ }
306
+ ],
307
+ "isUnique": false,
308
+ "concurrently": false,
309
+ "method": "btree",
310
+ "with": {}
311
+ },
312
+ "invocations_scope_created_idx": {
313
+ "name": "invocations_scope_created_idx",
314
+ "columns": [
315
+ {
316
+ "expression": "scope",
317
+ "isExpression": false,
318
+ "asc": true,
319
+ "nulls": "last"
320
+ },
321
+ {
322
+ "expression": "created_at",
323
+ "isExpression": false,
324
+ "asc": true,
325
+ "nulls": "last"
326
+ }
327
+ ],
328
+ "isUnique": false,
329
+ "concurrently": false,
330
+ "method": "btree",
331
+ "with": {}
332
+ }
333
+ },
334
+ "foreignKeys": {},
335
+ "compositePrimaryKeys": {},
336
+ "uniqueConstraints": {},
337
+ "policies": {},
338
+ "checkConstraints": {},
339
+ "isRLSEnabled": false
340
+ },
341
+ "agent_runtime.policy_decisions": {
342
+ "name": "policy_decisions",
343
+ "schema": "agent_runtime",
344
+ "columns": {
345
+ "id": {
346
+ "name": "id",
347
+ "type": "bigint",
348
+ "primaryKey": true,
349
+ "notNull": true,
350
+ "identity": {
351
+ "type": "always",
352
+ "name": "policy_decisions_id_seq",
353
+ "schema": "agent_runtime",
354
+ "increment": "1",
355
+ "startWith": "1",
356
+ "minValue": "1",
357
+ "maxValue": "9223372036854775807",
358
+ "cache": "1",
359
+ "cycle": false
360
+ }
361
+ },
362
+ "scope": {
363
+ "name": "scope",
364
+ "type": "text",
365
+ "primaryKey": false,
366
+ "notNull": true
367
+ },
368
+ "invocation_id": {
369
+ "name": "invocation_id",
370
+ "type": "bigint",
371
+ "primaryKey": false,
372
+ "notNull": true
373
+ },
374
+ "run_id": {
375
+ "name": "run_id",
376
+ "type": "uuid",
377
+ "primaryKey": false,
378
+ "notNull": true
379
+ },
380
+ "tool_name": {
381
+ "name": "tool_name",
382
+ "type": "text",
383
+ "primaryKey": false,
384
+ "notNull": false
385
+ },
386
+ "rule": {
387
+ "name": "rule",
388
+ "type": "text",
389
+ "primaryKey": false,
390
+ "notNull": true
391
+ },
392
+ "decision": {
393
+ "name": "decision",
394
+ "type": "text",
395
+ "primaryKey": false,
396
+ "notNull": true
397
+ },
398
+ "detail": {
399
+ "name": "detail",
400
+ "type": "jsonb",
401
+ "primaryKey": false,
402
+ "notNull": false
403
+ },
404
+ "created_at": {
405
+ "name": "created_at",
406
+ "type": "timestamp with time zone",
407
+ "primaryKey": false,
408
+ "notNull": true,
409
+ "default": "now()"
410
+ }
411
+ },
412
+ "indexes": {
413
+ "policy_decisions_invocation_idx": {
414
+ "name": "policy_decisions_invocation_idx",
415
+ "columns": [
416
+ {
417
+ "expression": "invocation_id",
418
+ "isExpression": false,
419
+ "asc": true,
420
+ "nulls": "last"
421
+ }
422
+ ],
423
+ "isUnique": false,
424
+ "concurrently": false,
425
+ "method": "btree",
426
+ "with": {}
427
+ },
428
+ "policy_decisions_run_idx": {
429
+ "name": "policy_decisions_run_idx",
430
+ "columns": [
431
+ {
432
+ "expression": "run_id",
433
+ "isExpression": false,
434
+ "asc": true,
435
+ "nulls": "last"
436
+ }
437
+ ],
438
+ "isUnique": false,
439
+ "concurrently": false,
440
+ "method": "btree",
441
+ "with": {}
442
+ }
443
+ },
444
+ "foreignKeys": {
445
+ "policy_decisions_invocation_id_invocations_id_fk": {
446
+ "name": "policy_decisions_invocation_id_invocations_id_fk",
447
+ "tableFrom": "policy_decisions",
448
+ "tableTo": "invocations",
449
+ "schemaTo": "agent_runtime",
450
+ "columnsFrom": [
451
+ "invocation_id"
452
+ ],
453
+ "columnsTo": [
454
+ "id"
455
+ ],
456
+ "onDelete": "no action",
457
+ "onUpdate": "no action"
458
+ }
459
+ },
460
+ "compositePrimaryKeys": {},
461
+ "uniqueConstraints": {},
462
+ "policies": {},
463
+ "checkConstraints": {},
464
+ "isRLSEnabled": false
465
+ },
466
+ "agent_runtime.tool_call_audits": {
467
+ "name": "tool_call_audits",
468
+ "schema": "agent_runtime",
469
+ "columns": {
470
+ "id": {
471
+ "name": "id",
472
+ "type": "bigint",
473
+ "primaryKey": true,
474
+ "notNull": true,
475
+ "identity": {
476
+ "type": "always",
477
+ "name": "tool_call_audits_id_seq",
478
+ "schema": "agent_runtime",
479
+ "increment": "1",
480
+ "startWith": "1",
481
+ "minValue": "1",
482
+ "maxValue": "9223372036854775807",
483
+ "cache": "1",
484
+ "cycle": false
485
+ }
486
+ },
487
+ "invocation_id": {
488
+ "name": "invocation_id",
489
+ "type": "bigint",
490
+ "primaryKey": false,
491
+ "notNull": true
492
+ },
493
+ "scope": {
494
+ "name": "scope",
495
+ "type": "text",
496
+ "primaryKey": false,
497
+ "notNull": true
498
+ },
499
+ "run_id": {
500
+ "name": "run_id",
501
+ "type": "uuid",
502
+ "primaryKey": false,
503
+ "notNull": false
504
+ },
505
+ "tool_name": {
506
+ "name": "tool_name",
507
+ "type": "text",
508
+ "primaryKey": false,
509
+ "notNull": true
510
+ },
511
+ "idempotency_key": {
512
+ "name": "idempotency_key",
513
+ "type": "text",
514
+ "primaryKey": false,
515
+ "notNull": false
516
+ },
517
+ "status": {
518
+ "name": "status",
519
+ "type": "tool_call_status",
520
+ "typeSchema": "agent_runtime",
521
+ "primaryKey": false,
522
+ "notNull": true
523
+ },
524
+ "requested_at": {
525
+ "name": "requested_at",
526
+ "type": "timestamp with time zone",
527
+ "primaryKey": false,
528
+ "notNull": true,
529
+ "default": "now()"
530
+ },
531
+ "completed_at": {
532
+ "name": "completed_at",
533
+ "type": "timestamp with time zone",
534
+ "primaryKey": false,
535
+ "notNull": false
536
+ },
537
+ "error_code": {
538
+ "name": "error_code",
539
+ "type": "text",
540
+ "primaryKey": false,
541
+ "notNull": false
542
+ },
543
+ "request_snapshot": {
544
+ "name": "request_snapshot",
545
+ "type": "jsonb",
546
+ "primaryKey": false,
547
+ "notNull": false
548
+ },
549
+ "metadata": {
550
+ "name": "metadata",
551
+ "type": "jsonb",
552
+ "primaryKey": false,
553
+ "notNull": false
554
+ },
555
+ "created_at": {
556
+ "name": "created_at",
557
+ "type": "timestamp with time zone",
558
+ "primaryKey": false,
559
+ "notNull": true,
560
+ "default": "now()"
561
+ }
562
+ },
563
+ "indexes": {
564
+ "tool_call_audits_scope_tool_idempotency_unique": {
565
+ "name": "tool_call_audits_scope_tool_idempotency_unique",
566
+ "columns": [
567
+ {
568
+ "expression": "scope",
569
+ "isExpression": false,
570
+ "asc": true,
571
+ "nulls": "last"
572
+ },
573
+ {
574
+ "expression": "tool_name",
575
+ "isExpression": false,
576
+ "asc": true,
577
+ "nulls": "last"
578
+ },
579
+ {
580
+ "expression": "idempotency_key",
581
+ "isExpression": false,
582
+ "asc": true,
583
+ "nulls": "last"
584
+ }
585
+ ],
586
+ "isUnique": true,
587
+ "where": "\"agent_runtime\".\"tool_call_audits\".\"idempotency_key\" is not null",
588
+ "concurrently": false,
589
+ "method": "btree",
590
+ "with": {}
591
+ },
592
+ "tool_call_audits_invocation_idx": {
593
+ "name": "tool_call_audits_invocation_idx",
594
+ "columns": [
595
+ {
596
+ "expression": "invocation_id",
597
+ "isExpression": false,
598
+ "asc": true,
599
+ "nulls": "last"
600
+ }
601
+ ],
602
+ "isUnique": false,
603
+ "concurrently": false,
604
+ "method": "btree",
605
+ "with": {}
606
+ },
607
+ "tool_call_audits_run_idx": {
608
+ "name": "tool_call_audits_run_idx",
609
+ "columns": [
610
+ {
611
+ "expression": "run_id",
612
+ "isExpression": false,
613
+ "asc": true,
614
+ "nulls": "last"
615
+ }
616
+ ],
617
+ "isUnique": false,
618
+ "concurrently": false,
619
+ "method": "btree",
620
+ "with": {}
621
+ }
622
+ },
623
+ "foreignKeys": {
624
+ "tool_call_audits_invocation_id_invocations_id_fk": {
625
+ "name": "tool_call_audits_invocation_id_invocations_id_fk",
626
+ "tableFrom": "tool_call_audits",
627
+ "tableTo": "invocations",
628
+ "schemaTo": "agent_runtime",
629
+ "columnsFrom": [
630
+ "invocation_id"
631
+ ],
632
+ "columnsTo": [
633
+ "id"
634
+ ],
635
+ "onDelete": "no action",
636
+ "onUpdate": "no action"
637
+ }
638
+ },
639
+ "compositePrimaryKeys": {},
640
+ "uniqueConstraints": {},
641
+ "policies": {},
642
+ "checkConstraints": {},
643
+ "isRLSEnabled": false
644
+ },
645
+ "agent_runtime.worker_leases": {
646
+ "name": "worker_leases",
647
+ "schema": "agent_runtime",
648
+ "columns": {
649
+ "name": {
650
+ "name": "name",
651
+ "type": "text",
652
+ "primaryKey": true,
653
+ "notNull": true
654
+ },
655
+ "holder_id": {
656
+ "name": "holder_id",
657
+ "type": "text",
658
+ "primaryKey": false,
659
+ "notNull": true
660
+ },
661
+ "acquired_at": {
662
+ "name": "acquired_at",
663
+ "type": "timestamp with time zone",
664
+ "primaryKey": false,
665
+ "notNull": true,
666
+ "default": "now()"
667
+ },
668
+ "heartbeat_at": {
669
+ "name": "heartbeat_at",
670
+ "type": "timestamp with time zone",
671
+ "primaryKey": false,
672
+ "notNull": true,
673
+ "default": "now()"
674
+ },
675
+ "expires_at": {
676
+ "name": "expires_at",
677
+ "type": "timestamp with time zone",
678
+ "primaryKey": false,
679
+ "notNull": true
680
+ }
681
+ },
682
+ "indexes": {},
683
+ "foreignKeys": {},
684
+ "compositePrimaryKeys": {},
685
+ "uniqueConstraints": {},
686
+ "policies": {},
687
+ "checkConstraints": {},
688
+ "isRLSEnabled": false
689
+ }
690
+ },
691
+ "enums": {
692
+ "agent_runtime.invocation_status": {
693
+ "name": "invocation_status",
694
+ "schema": "agent_runtime",
695
+ "values": [
696
+ "pending",
697
+ "running",
698
+ "awaiting_approval",
699
+ "succeeded",
700
+ "failed",
701
+ "cancelled"
702
+ ]
703
+ },
704
+ "agent_runtime.tool_call_status": {
705
+ "name": "tool_call_status",
706
+ "schema": "agent_runtime",
707
+ "values": [
708
+ "started",
709
+ "succeeded",
710
+ "failed"
711
+ ]
712
+ }
713
+ },
714
+ "schemas": {
715
+ "agent_runtime": "agent_runtime"
716
+ },
717
+ "sequences": {},
718
+ "roles": {},
719
+ "policies": {},
720
+ "views": {},
721
+ "_meta": {
722
+ "columns": {},
723
+ "schemas": {},
724
+ "tables": {}
725
+ }
726
+ }
@@ -8,6 +8,13 @@
8
8
  "when": 1793177509604,
9
9
  "tag": "0000_init",
10
10
  "breakpoints": true
11
+ },
12
+ {
13
+ "idx": 1,
14
+ "version": "7",
15
+ "when": 1794812633156,
16
+ "tag": "0001_invocation_result_messages",
17
+ "breakpoints": true
11
18
  }
12
19
  ]
13
20
  }
package/package.json CHANGED
@@ -91,5 +91,5 @@
91
91
  "sideEffects": false,
92
92
  "type": "module",
93
93
  "types": "./dist/index.d.ts",
94
- "version": "0.4.0"
94
+ "version": "0.5.0"
95
95
  }