@linnlabs/linnkit 0.42.0 → 0.43.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 (47) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cli.cjs +12 -1
  3. package/dist/cli.cjs.map +1 -1
  4. package/dist/cli.js +12 -1
  5. package/dist/cli.js.map +1 -1
  6. package/dist/contracts/agentSpec.d.cts +5 -5
  7. package/dist/contracts/agentSpec.d.ts +5 -5
  8. package/dist/contracts/audit.d.cts +10 -10
  9. package/dist/contracts/audit.d.ts +10 -10
  10. package/dist/contracts/contextPolicy.d.cts +14 -14
  11. package/dist/contracts/contextPolicy.d.ts +14 -14
  12. package/dist/contracts/events.d.cts +117 -117
  13. package/dist/contracts/events.d.ts +117 -117
  14. package/dist/contracts/execution.d.cts +2 -2
  15. package/dist/contracts/execution.d.ts +2 -2
  16. package/dist/contracts/llm-retry.d.cts +2 -2
  17. package/dist/contracts/llm-retry.d.ts +2 -2
  18. package/dist/contracts/messages.d.cts +32 -32
  19. package/dist/contracts/messages.d.ts +32 -32
  20. package/dist/contracts/sse.d.cts +97 -97
  21. package/dist/contracts/sse.d.ts +97 -97
  22. package/dist/contracts/sub-run-trace-payload.d.cts +8 -8
  23. package/dist/contracts/sub-run-trace-payload.d.ts +8 -8
  24. package/dist/contracts/token-accounting.d.cts +12 -12
  25. package/dist/contracts/token-accounting.d.ts +12 -12
  26. package/dist/index.cjs +12 -1
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.js +12 -1
  29. package/dist/index.js.map +1 -1
  30. package/dist/quickstart.cjs +12 -1
  31. package/dist/quickstart.cjs.map +1 -1
  32. package/dist/quickstart.js +12 -1
  33. package/dist/quickstart.js.map +1 -1
  34. package/dist/runtime-kernel/events/agentEvents.d.cts +2 -2
  35. package/dist/runtime-kernel/events/agentEvents.d.ts +2 -2
  36. package/dist/runtime-kernel/graph-engine/engine.d.cts +1 -0
  37. package/dist/runtime-kernel/graph-engine/engine.d.ts +1 -0
  38. package/dist/runtime-kernel.cjs +12 -1
  39. package/dist/runtime-kernel.cjs.map +1 -1
  40. package/dist/runtime-kernel.js +12 -1
  41. package/dist/runtime-kernel.js.map +1 -1
  42. package/dist/testkit.cjs +12 -1
  43. package/dist/testkit.cjs.map +1 -1
  44. package/dist/testkit.js +12 -1
  45. package/dist/testkit.js.map +1 -1
  46. package/docs/integration/tool-development-guide.md +1 -0
  47. package/package.json +2 -2
@@ -9,14 +9,14 @@ import { SerializableJsonValue } from './json.cjs';
9
9
  */
10
10
  declare const SubRunTraceKind: z.ZodEnum<{
11
11
  error: "error";
12
+ history_summary: "history_summary";
13
+ final_answer: "final_answer";
14
+ tool_output: "tool_output";
12
15
  tool_call_decision: "tool_call_decision";
13
16
  tool_process: "tool_process";
14
- tool_output: "tool_output";
15
17
  thought_delta: "thought_delta";
16
18
  thought_complete: "thought_complete";
17
19
  final_answer_chunk: "final_answer_chunk";
18
- final_answer: "final_answer";
19
- history_summary: "history_summary";
20
20
  llm_retry: "llm_retry";
21
21
  }>;
22
22
  type SubRunTraceKind = z.infer<typeof SubRunTraceKind>;
@@ -33,25 +33,25 @@ declare const SubRunTracePayload: z.ZodObject<{
33
33
  source_event_id: z.ZodString;
34
34
  kind: z.ZodEnum<{
35
35
  error: "error";
36
+ history_summary: "history_summary";
37
+ final_answer: "final_answer";
38
+ tool_output: "tool_output";
36
39
  tool_call_decision: "tool_call_decision";
37
40
  tool_process: "tool_process";
38
- tool_output: "tool_output";
39
41
  thought_delta: "thought_delta";
40
42
  thought_complete: "thought_complete";
41
43
  final_answer_chunk: "final_answer_chunk";
42
- final_answer: "final_answer";
43
- history_summary: "history_summary";
44
44
  llm_retry: "llm_retry";
45
45
  }>;
46
46
  retry: z.ZodOptional<z.ZodObject<{
47
47
  retry_id: z.ZodString;
48
48
  status: z.ZodEnum<{
49
+ failed: "failed";
50
+ cancelled: "cancelled";
49
51
  waiting: "waiting";
50
52
  retrying: "retrying";
51
53
  succeeded: "succeeded";
52
54
  exhausted: "exhausted";
53
- failed: "failed";
54
- cancelled: "cancelled";
55
55
  }>;
56
56
  category: z.ZodEnum<{
57
57
  output: "output";
@@ -9,14 +9,14 @@ import { SerializableJsonValue } from './json.js';
9
9
  */
10
10
  declare const SubRunTraceKind: z.ZodEnum<{
11
11
  error: "error";
12
+ history_summary: "history_summary";
13
+ final_answer: "final_answer";
14
+ tool_output: "tool_output";
12
15
  tool_call_decision: "tool_call_decision";
13
16
  tool_process: "tool_process";
14
- tool_output: "tool_output";
15
17
  thought_delta: "thought_delta";
16
18
  thought_complete: "thought_complete";
17
19
  final_answer_chunk: "final_answer_chunk";
18
- final_answer: "final_answer";
19
- history_summary: "history_summary";
20
20
  llm_retry: "llm_retry";
21
21
  }>;
22
22
  type SubRunTraceKind = z.infer<typeof SubRunTraceKind>;
@@ -33,25 +33,25 @@ declare const SubRunTracePayload: z.ZodObject<{
33
33
  source_event_id: z.ZodString;
34
34
  kind: z.ZodEnum<{
35
35
  error: "error";
36
+ history_summary: "history_summary";
37
+ final_answer: "final_answer";
38
+ tool_output: "tool_output";
36
39
  tool_call_decision: "tool_call_decision";
37
40
  tool_process: "tool_process";
38
- tool_output: "tool_output";
39
41
  thought_delta: "thought_delta";
40
42
  thought_complete: "thought_complete";
41
43
  final_answer_chunk: "final_answer_chunk";
42
- final_answer: "final_answer";
43
- history_summary: "history_summary";
44
44
  llm_retry: "llm_retry";
45
45
  }>;
46
46
  retry: z.ZodOptional<z.ZodObject<{
47
47
  retry_id: z.ZodString;
48
48
  status: z.ZodEnum<{
49
+ failed: "failed";
50
+ cancelled: "cancelled";
49
51
  waiting: "waiting";
50
52
  retrying: "retrying";
51
53
  succeeded: "succeeded";
52
54
  exhausted: "exhausted";
53
- failed: "failed";
54
- cancelled: "cancelled";
55
55
  }>;
56
56
  category: z.ZodEnum<{
57
57
  output: "output";
@@ -6,11 +6,11 @@ declare const TokenLedgerEntryKind: z.ZodEnum<{
6
6
  }>;
7
7
  type TokenLedgerEntryKind = z.infer<typeof TokenLedgerEntryKind>;
8
8
  declare const ContextTokenComponentKind: z.ZodEnum<{
9
- user: "user";
10
9
  system: "system";
11
- other: "other";
12
- tool: "tool";
10
+ user: "user";
13
11
  assistant: "assistant";
12
+ tool: "tool";
13
+ other: "other";
14
14
  "context-injection": "context-injection";
15
15
  "history-summary": "history-summary";
16
16
  "working-memory": "working-memory";
@@ -33,11 +33,11 @@ type TokenUsageTotals = z.infer<typeof TokenUsageTotals>;
33
33
  declare const ContextTokenComponent: z.ZodObject<{
34
34
  componentId: z.ZodString;
35
35
  kind: z.ZodEnum<{
36
- user: "user";
37
36
  system: "system";
38
- other: "other";
39
- tool: "tool";
37
+ user: "user";
40
38
  assistant: "assistant";
39
+ tool: "tool";
40
+ other: "other";
41
41
  "context-injection": "context-injection";
42
42
  "history-summary": "history-summary";
43
43
  "working-memory": "working-memory";
@@ -149,11 +149,11 @@ declare const ContextComponentTokenLedgerEntry: z.ZodObject<{
149
149
  components: z.ZodArray<z.ZodObject<{
150
150
  componentId: z.ZodString;
151
151
  kind: z.ZodEnum<{
152
- user: "user";
153
152
  system: "system";
154
- other: "other";
155
- tool: "tool";
153
+ user: "user";
156
154
  assistant: "assistant";
155
+ tool: "tool";
156
+ other: "other";
157
157
  "context-injection": "context-injection";
158
158
  "history-summary": "history-summary";
159
159
  "working-memory": "working-memory";
@@ -265,11 +265,11 @@ declare const TokenLedgerEntry: z.ZodDiscriminatedUnion<[z.ZodObject<{
265
265
  components: z.ZodArray<z.ZodObject<{
266
266
  componentId: z.ZodString;
267
267
  kind: z.ZodEnum<{
268
- user: "user";
269
268
  system: "system";
270
- other: "other";
271
- tool: "tool";
269
+ user: "user";
272
270
  assistant: "assistant";
271
+ tool: "tool";
272
+ other: "other";
273
273
  "context-injection": "context-injection";
274
274
  "history-summary": "history-summary";
275
275
  "working-memory": "working-memory";
@@ -6,11 +6,11 @@ declare const TokenLedgerEntryKind: z.ZodEnum<{
6
6
  }>;
7
7
  type TokenLedgerEntryKind = z.infer<typeof TokenLedgerEntryKind>;
8
8
  declare const ContextTokenComponentKind: z.ZodEnum<{
9
- user: "user";
10
9
  system: "system";
11
- other: "other";
12
- tool: "tool";
10
+ user: "user";
13
11
  assistant: "assistant";
12
+ tool: "tool";
13
+ other: "other";
14
14
  "context-injection": "context-injection";
15
15
  "history-summary": "history-summary";
16
16
  "working-memory": "working-memory";
@@ -33,11 +33,11 @@ type TokenUsageTotals = z.infer<typeof TokenUsageTotals>;
33
33
  declare const ContextTokenComponent: z.ZodObject<{
34
34
  componentId: z.ZodString;
35
35
  kind: z.ZodEnum<{
36
- user: "user";
37
36
  system: "system";
38
- other: "other";
39
- tool: "tool";
37
+ user: "user";
40
38
  assistant: "assistant";
39
+ tool: "tool";
40
+ other: "other";
41
41
  "context-injection": "context-injection";
42
42
  "history-summary": "history-summary";
43
43
  "working-memory": "working-memory";
@@ -149,11 +149,11 @@ declare const ContextComponentTokenLedgerEntry: z.ZodObject<{
149
149
  components: z.ZodArray<z.ZodObject<{
150
150
  componentId: z.ZodString;
151
151
  kind: z.ZodEnum<{
152
- user: "user";
153
152
  system: "system";
154
- other: "other";
155
- tool: "tool";
153
+ user: "user";
156
154
  assistant: "assistant";
155
+ tool: "tool";
156
+ other: "other";
157
157
  "context-injection": "context-injection";
158
158
  "history-summary": "history-summary";
159
159
  "working-memory": "working-memory";
@@ -265,11 +265,11 @@ declare const TokenLedgerEntry: z.ZodDiscriminatedUnion<[z.ZodObject<{
265
265
  components: z.ZodArray<z.ZodObject<{
266
266
  componentId: z.ZodString;
267
267
  kind: z.ZodEnum<{
268
- user: "user";
269
268
  system: "system";
270
- other: "other";
271
- tool: "tool";
269
+ user: "user";
272
270
  assistant: "assistant";
271
+ tool: "tool";
272
+ other: "other";
273
273
  "context-injection": "context-injection";
274
274
  "history-summary": "history-summary";
275
275
  "working-memory": "working-memory";
package/dist/index.cjs CHANGED
@@ -4024,6 +4024,16 @@ function mergeResumeSessionLocal(persistedLocal, localPatch) {
4024
4024
  }
4025
4025
  };
4026
4026
  }
4027
+ function resolveResumeNodeId(local, requested) {
4028
+ const pending = local?.pendingToolCalls;
4029
+ if (!Array.isArray(pending) || pending.length === 0) return requested ?? "llm";
4030
+ if (requested !== void 0 && requested !== "tool") {
4031
+ throw new Error(
4032
+ `Graph resume must first run ${pending.length} pending tool call(s) from the interrupted batch: requested node=${requested}`
4033
+ );
4034
+ }
4035
+ return "tool";
4036
+ }
4027
4037
  var GraphExecutor = class {
4028
4038
  constructor(checkpointer, config = {}) {
4029
4039
  this.checkpointer = checkpointer;
@@ -4136,13 +4146,14 @@ var GraphExecutor = class {
4136
4146
  );
4137
4147
  }
4138
4148
  const resumedLocal = mergeResumeSessionLocal(current.local, input.localPatch);
4149
+ const nodeId = resolveResumeNodeId(resumedLocal, input.nodeId);
4139
4150
  if (this.executionCheckpointPort && current.local?.executorLocal) {
4140
4151
  resumedLocal.executorLocal = { ...current.local.executorLocal };
4141
4152
  }
4142
4153
  this.ephemeralLocals.set(checkpointKey, resumedLocal);
4143
4154
  await this.commitCheckpoint(checkpointKey, {
4144
4155
  ...current,
4145
- nodeId: input.nodeId ?? "llm",
4156
+ nodeId,
4146
4157
  ...this.executionCheckpointPort ? { executionStatus: "ready" } : {},
4147
4158
  revision: currentRevision + 1,
4148
4159
  local: sanitizeCheckpointLocal(resumedLocal)