@linnlabs/linnkit 0.34.0 → 0.35.1

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 (49) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cli.cjs +11 -2
  3. package/dist/cli.cjs.map +1 -1
  4. package/dist/cli.js +11 -2
  5. package/dist/cli.js.map +1 -1
  6. package/dist/contracts/agentSpec.d.cts +30 -30
  7. package/dist/contracts/agentSpec.d.ts +30 -30
  8. package/dist/contracts/audit.d.cts +32 -32
  9. package/dist/contracts/audit.d.ts +32 -32
  10. package/dist/contracts/contextPolicy.d.cts +36 -36
  11. package/dist/contracts/contextPolicy.d.ts +36 -36
  12. package/dist/contracts/events.d.cts +1113 -1113
  13. package/dist/contracts/events.d.ts +1113 -1113
  14. package/dist/contracts/execution.d.cts +8 -8
  15. package/dist/contracts/execution.d.ts +8 -8
  16. package/dist/contracts/messages.d.cts +1178 -1178
  17. package/dist/contracts/messages.d.ts +1178 -1178
  18. package/dist/contracts/provider-continuation.d.cts +28 -28
  19. package/dist/contracts/provider-continuation.d.ts +28 -28
  20. package/dist/contracts/sse.d.cts +897 -897
  21. package/dist/contracts/sse.d.ts +897 -897
  22. package/dist/contracts/sub-run-trace-payload.d.cts +26 -26
  23. package/dist/contracts/sub-run-trace-payload.d.ts +26 -26
  24. package/dist/contracts/token-accounting.d.cts +38 -38
  25. package/dist/contracts/token-accounting.d.ts +38 -38
  26. package/dist/index.cjs +19 -6
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.js +19 -6
  29. package/dist/index.js.map +1 -1
  30. package/dist/quickstart.cjs +11 -2
  31. package/dist/quickstart.cjs.map +1 -1
  32. package/dist/quickstart.js +11 -2
  33. package/dist/quickstart.js.map +1 -1
  34. package/dist/runtime-kernel/child-runs/childRunInvoker.d.cts +5 -0
  35. package/dist/runtime-kernel/child-runs/childRunInvoker.d.ts +5 -0
  36. package/dist/runtime-kernel/events/agentEvents.d.cts +172 -172
  37. package/dist/runtime-kernel/events/agentEvents.d.ts +172 -172
  38. package/dist/runtime-kernel/run-supervisor/definitions/runSupervisorContracts.d.cts +1 -0
  39. package/dist/runtime-kernel/run-supervisor/definitions/runSupervisorContracts.d.ts +1 -0
  40. package/dist/runtime-kernel.cjs +19 -6
  41. package/dist/runtime-kernel.cjs.map +1 -1
  42. package/dist/runtime-kernel.js +19 -6
  43. package/dist/runtime-kernel.js.map +1 -1
  44. package/dist/testkit.cjs +19 -6
  45. package/dist/testkit.cjs.map +1 -1
  46. package/dist/testkit.js +19 -6
  47. package/dist/testkit.js.map +1 -1
  48. package/docs/integration/child-runs.md +8 -0
  49. package/package.json +1 -1
@@ -141,6 +141,7 @@ interface RunSupervisor<TRequest extends RunRequestSnapshot = RunRequestSnapshot
141
141
  readonly expectedExecutionId?: ExecutionId;
142
142
  readonly eventBus: EventBus;
143
143
  readonly executionId: ExecutionId;
144
+ readonly parentSignal?: AbortSignal;
144
145
  }): Promise<RunHandle<TRequest>>;
145
146
  claimResume(runId: RunId, interaction: RunResumeInteraction, eventBus: EventBus, parentSignal?: AbortSignal): Promise<RunResumeClaim<TRequest>>;
146
147
  runTree(rootRunId: RunId): Promise<never>;
@@ -141,6 +141,7 @@ interface RunSupervisor<TRequest extends RunRequestSnapshot = RunRequestSnapshot
141
141
  readonly expectedExecutionId?: ExecutionId;
142
142
  readonly eventBus: EventBus;
143
143
  readonly executionId: ExecutionId;
144
+ readonly parentSignal?: AbortSignal;
144
145
  }): Promise<RunHandle<TRequest>>;
145
146
  claimResume(runId: RunId, interaction: RunResumeInteraction, eventBus: EventBus, parentSignal?: AbortSignal): Promise<RunResumeClaim<TRequest>>;
146
147
  runTree(rootRunId: RunId): Promise<never>;
@@ -2992,13 +2992,21 @@ var GraphExecutor = class {
2992
2992
  if (existing) {
2993
2993
  throw new Error(`Graph checkpoint already exists: ${checkpointKey}`);
2994
2994
  }
2995
- this.ephemeralLocals.set(checkpointKey, { ...local });
2995
+ const initialLocal = this.executionCheckpointPort ? {
2996
+ ...local,
2997
+ executorLocal: {
2998
+ ...isRecord4(local.executorLocal) ? local.executorLocal : {},
2999
+ stepCount: 0,
3000
+ maxSteps: options.maxSteps ?? this.config.maxSteps
3001
+ }
3002
+ } : local;
3003
+ this.ephemeralLocals.set(checkpointKey, { ...initialLocal });
2996
3004
  await this.commitCheckpoint(checkpointKey, {
2997
3005
  nodeId,
2998
3006
  ...this.executionCheckpointPort ? { executionStatus: "ready" } : {},
2999
3007
  revision: 1,
3000
3008
  schemaVersion: ENGINE_STATE_SCHEMA_VERSION,
3001
- local: sanitizeCheckpointLocal(local)
3009
+ local: sanitizeCheckpointLocal(initialLocal)
3002
3010
  });
3003
3011
  return this.runUntilYieldQueued(
3004
3012
  checkpointKey,
@@ -12007,10 +12015,10 @@ var ChildRunInvoker = class {
12007
12015
  runtimeEventSink,
12008
12016
  runtimeEventCommitPort,
12009
12017
  seedHistoryEvents,
12010
- maxSteps = 8,
12011
12018
  modelId,
12012
12019
  abortSignal
12013
12020
  } = config;
12021
+ const maxSteps = config.initialInput?.request.maxSteps ?? config.maxSteps ?? 8;
12014
12022
  const childRunId = runId ?? generateRunId();
12015
12023
  const internalCheckpointKey = childRunId;
12016
12024
  const resolvedParentRunId = parentRunId ?? parentToolContext.runId;
@@ -12055,7 +12063,8 @@ var ChildRunInvoker = class {
12055
12063
  if (config.persistence?.expectedRevision !== void 0) {
12056
12064
  return this.continueChild(config, childRunId, runtimeConversationId);
12057
12065
  }
12058
- const turnId = generateTurnId();
12066
+ const turnId = config.initialInput?.turnId ?? generateTurnId();
12067
+ if (config.initialInput && (!turnId.trim() || config.initialInput.request.query !== userMessage || config.initialInput.request.promptKey !== agentConfig.promptKey || !config.initialInput.request.model_id)) throw new Error("Child initial input does not match the admitted invocation");
12059
12068
  logger17.info(`\u542F\u52A8 child-run: ${agentConfig.id}`, {
12060
12069
  conversationId: runtimeConversationId,
12061
12070
  checkpointKey: internalCheckpointKey,
@@ -12072,11 +12081,14 @@ var ChildRunInvoker = class {
12072
12081
  });
12073
12082
  const admittedChildUserInput = runtimeEventSink(childUserInput, "ChildRunInvoker.user_input");
12074
12083
  const childModelId = resolveChildRunModelId({
12075
- explicitModelId: modelId,
12084
+ explicitModelId: config.initialInput?.request.model_id ?? modelId,
12076
12085
  agentConfig,
12077
12086
  resolveDefaultModelId: () => this.modelResolver.resolveModelId()
12078
12087
  });
12079
- const request = {
12088
+ const request = config.initialInput ? {
12089
+ ...config.initialInput.request,
12090
+ currentUserEventId: admittedChildUserInput.id
12091
+ } : {
12080
12092
  query: userMessage,
12081
12093
  currentUserEventId: admittedChildUserInput.id,
12082
12094
  promptKey: agentConfig.promptKey,
@@ -13987,6 +13999,7 @@ var DefaultRunSupervisor = class {
13987
13999
  metadata: { ...record.metadata, executionId: input.executionId }
13988
14000
  });
13989
14001
  const controller = new AbortController();
14002
+ forwardParentAbortSignal(controller, input.parentSignal);
13990
14003
  handle.replaceExecutionAbortController(controller, input.executionId);
13991
14004
  handle.attachTransportEventBus(input.eventBus);
13992
14005
  this.controllers.set(input.runId, controller);