@codelia/runtime 0.1.80 → 0.1.81

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/sdk.d.cts CHANGED
@@ -1,8 +1,8 @@
1
- import { PermissionsConfig, PermissionRule } from '@codelia/config';
1
+ import { PermissionsConfig, SubagentConfig, PermissionRule } from '@codelia/config';
2
2
  import { SessionStateStore, RunEventStoreFactory, ToolOutputCacheStore, Tool } from '@codelia/core';
3
3
  import { RpcNotification } from '@codelia/protocol';
4
- import { ModelReasoningLevel } from '@codelia/shared-types';
5
- import { TaskKind, TaskWorkspaceMode, TaskRecord, TaskState, TaskResult, TaskRegistryStore } from '@codelia/storage';
4
+ import { SubagentLineage, ApprovalMode, AgentMessage, ModelReasoningLevel } from '@codelia/shared-types';
5
+ import { TaskResult, TaskState, TaskRecord, TaskKind, TaskWorkspaceMode, TaskRegistryStore } from '@codelia/storage';
6
6
 
7
7
  type ResolvedModelConfig = {
8
8
  provider?: string;
@@ -86,15 +86,9 @@ type ProviderAuth = {
86
86
  declare const SUPPORTED_PROVIDERS: readonly ["openai", "anthropic", "openrouter", "moonshot", "zai", "xai"];
87
87
  type SupportedProvider = (typeof SUPPORTED_PROVIDERS)[number];
88
88
 
89
- type TaskProcessSignal = "SIGTERM" | "SIGKILL";
90
- type TaskProcessController = {
91
- isProcessAlive: (pid: number) => Promise<boolean>;
92
- terminateProcess: (pid: number, signal: TaskProcessSignal) => Promise<void>;
93
- terminateProcessGroup: (pgid: number, signal: TaskProcessSignal) => Promise<void>;
94
- };
95
-
96
89
  type TerminalTaskState = Extract<TaskState, "completed" | "failed" | "cancelled">;
97
90
  type TaskSpawnInput = {
91
+ subagent?: TaskRecord["subagent"];
98
92
  task_id?: string;
99
93
  kind: TaskKind;
100
94
  workspace_mode?: TaskWorkspaceMode;
@@ -108,6 +102,8 @@ type TaskSpawnInput = {
108
102
  child_session_id?: string;
109
103
  };
110
104
  type TaskExecutionMetadata = {
105
+ usage?: TaskResult["usage"];
106
+ executor_identity?: string;
111
107
  executor_pid?: number;
112
108
  executor_pgid?: number;
113
109
  child_session_id?: string;
@@ -140,6 +136,46 @@ type TaskExecutionStartContext = {
140
136
  task: TaskRecord;
141
137
  };
142
138
 
139
+ /** prepare must not start work; TaskManager registers this handle before start. */
140
+ type PreparedTaskExecution = TaskExecutionHandle & {
141
+ cancel(reason?: string): Promise<void>;
142
+ start(control: {
143
+ persistExecutor(metadata: TaskExecutionMetadata): Promise<void>;
144
+ running(metadata: TaskExecutionMetadata): Promise<void>;
145
+ }): Promise<void>;
146
+ };
147
+
148
+ type SubagentLaunchInput = {
149
+ version: 1;
150
+ task_id: string;
151
+ lineage: SubagentLineage;
152
+ prompt: string;
153
+ workspace_root: string;
154
+ model: ResolvedModelConfig;
155
+ permission: {
156
+ tool_allowlist: string[];
157
+ workspace_access: "read-only" | "read-write";
158
+ approval_mode: ApprovalMode;
159
+ parent_permissions?: PermissionsConfig;
160
+ max_steps: number;
161
+ timeout_seconds?: number;
162
+ };
163
+ };
164
+ type SubagentChannel = {
165
+ request(operation: "send" | "receive" | "list" | "shell" | "edit" | "write", params: unknown, signal?: AbortSignal): Promise<unknown>;
166
+ };
167
+ type SubagentExecutorFactory = {
168
+ isAvailable(): boolean;
169
+ prepare(input: SubagentLaunchInput, channel?: SubagentChannel): PreparedTaskExecution;
170
+ };
171
+
172
+ type TaskProcessSignal = "SIGTERM" | "SIGKILL";
173
+ type TaskProcessController = {
174
+ isProcessAlive: (pid: number) => Promise<boolean>;
175
+ terminateProcess: (pid: number, signal: TaskProcessSignal) => Promise<void>;
176
+ terminateProcessGroup: (pgid: number, signal: TaskProcessSignal) => Promise<void>;
177
+ };
178
+
143
179
  type TaskManagerOptions = {
144
180
  registry?: TaskRegistryStore;
145
181
  runtimeId?: string;
@@ -178,6 +214,9 @@ declare class TaskManager {
178
214
  private forceTerminateIfStillAlive;
179
215
  private cancelWithoutLocalHandle;
180
216
  spawn(input: TaskSpawnInput, startExecution: (context: TaskExecutionStartContext) => TaskExecutionHandle | Promise<TaskExecutionHandle>): Promise<TaskRecord>;
217
+ /** Admit a prepared executor atomically with respect to shutdown and cancellation. */
218
+ spawnPrepared(input: TaskSpawnInput, handle: PreparedTaskExecution, signal?: AbortSignal): Promise<TaskRecord>;
219
+ appendMessage(taskId: string, message: AgentMessage): Promise<void>;
181
220
  list(): Promise<TaskRecord[]>;
182
221
  status(taskId: string): Promise<TaskRecord | null>;
183
222
  result(taskId: string): Promise<TaskResult | null>;
@@ -251,6 +290,7 @@ type RuntimeEnvironmentContract = {
251
290
  };
252
291
  };
253
292
  type RuntimeConfigProvider = {
293
+ resolveSubagentConfig?: (workingDir?: string) => Promise<SubagentConfig | undefined>;
254
294
  resolveModelConfig?: (workingDir?: string) => Promise<ResolvedModelConfig>;
255
295
  resolvePermissionsConfig?: (workingDir?: string) => Promise<PermissionsConfig | undefined>;
256
296
  resolveSearchConfig?: (workingDir?: string) => Promise<ResolvedSearchConfig>;
@@ -296,6 +336,7 @@ type RuntimeStores = {
296
336
  taskManager?: TaskManager;
297
337
  };
298
338
  type RuntimeHostAdapters = {
339
+ subagentExecutorFactory?: SubagentExecutorFactory;
299
340
  systemPromptProvider?: SystemPromptProvider;
300
341
  configProvider?: RuntimeConfigProvider;
301
342
  credentialProvider?: CredentialProvider;
@@ -312,4 +353,4 @@ type RuntimeOptions = {
312
353
 
313
354
  declare const startRuntime: (options?: RuntimeOptions) => Promise<void>;
314
355
 
315
- export { type CredentialProvider, type RuntimeConfigProvider, type RuntimeEnvironmentContract, type RuntimeEnvironmentInput, type RuntimeEnvironmentPreset, type RuntimeEventSink, type RuntimeHostAdapters, type RuntimeOptions, type RuntimeStores, type SystemPromptProvider, type ToolProvider, startRuntime };
356
+ export { type CredentialProvider, type PreparedTaskExecution, type RuntimeConfigProvider, type RuntimeEnvironmentContract, type RuntimeEnvironmentInput, type RuntimeEnvironmentPreset, type RuntimeEventSink, type RuntimeHostAdapters, type RuntimeOptions, type RuntimeStores, type SubagentChannel, type SubagentExecutorFactory, type SubagentLaunchInput, type SystemPromptProvider, type ToolProvider, startRuntime };
package/dist/sdk.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { PermissionsConfig, PermissionRule } from '@codelia/config';
1
+ import { PermissionsConfig, SubagentConfig, PermissionRule } from '@codelia/config';
2
2
  import { SessionStateStore, RunEventStoreFactory, ToolOutputCacheStore, Tool } from '@codelia/core';
3
3
  import { RpcNotification } from '@codelia/protocol';
4
- import { ModelReasoningLevel } from '@codelia/shared-types';
5
- import { TaskKind, TaskWorkspaceMode, TaskRecord, TaskState, TaskResult, TaskRegistryStore } from '@codelia/storage';
4
+ import { SubagentLineage, ApprovalMode, AgentMessage, ModelReasoningLevel } from '@codelia/shared-types';
5
+ import { TaskResult, TaskState, TaskRecord, TaskKind, TaskWorkspaceMode, TaskRegistryStore } from '@codelia/storage';
6
6
 
7
7
  type ResolvedModelConfig = {
8
8
  provider?: string;
@@ -86,15 +86,9 @@ type ProviderAuth = {
86
86
  declare const SUPPORTED_PROVIDERS: readonly ["openai", "anthropic", "openrouter", "moonshot", "zai", "xai"];
87
87
  type SupportedProvider = (typeof SUPPORTED_PROVIDERS)[number];
88
88
 
89
- type TaskProcessSignal = "SIGTERM" | "SIGKILL";
90
- type TaskProcessController = {
91
- isProcessAlive: (pid: number) => Promise<boolean>;
92
- terminateProcess: (pid: number, signal: TaskProcessSignal) => Promise<void>;
93
- terminateProcessGroup: (pgid: number, signal: TaskProcessSignal) => Promise<void>;
94
- };
95
-
96
89
  type TerminalTaskState = Extract<TaskState, "completed" | "failed" | "cancelled">;
97
90
  type TaskSpawnInput = {
91
+ subagent?: TaskRecord["subagent"];
98
92
  task_id?: string;
99
93
  kind: TaskKind;
100
94
  workspace_mode?: TaskWorkspaceMode;
@@ -108,6 +102,8 @@ type TaskSpawnInput = {
108
102
  child_session_id?: string;
109
103
  };
110
104
  type TaskExecutionMetadata = {
105
+ usage?: TaskResult["usage"];
106
+ executor_identity?: string;
111
107
  executor_pid?: number;
112
108
  executor_pgid?: number;
113
109
  child_session_id?: string;
@@ -140,6 +136,46 @@ type TaskExecutionStartContext = {
140
136
  task: TaskRecord;
141
137
  };
142
138
 
139
+ /** prepare must not start work; TaskManager registers this handle before start. */
140
+ type PreparedTaskExecution = TaskExecutionHandle & {
141
+ cancel(reason?: string): Promise<void>;
142
+ start(control: {
143
+ persistExecutor(metadata: TaskExecutionMetadata): Promise<void>;
144
+ running(metadata: TaskExecutionMetadata): Promise<void>;
145
+ }): Promise<void>;
146
+ };
147
+
148
+ type SubagentLaunchInput = {
149
+ version: 1;
150
+ task_id: string;
151
+ lineage: SubagentLineage;
152
+ prompt: string;
153
+ workspace_root: string;
154
+ model: ResolvedModelConfig;
155
+ permission: {
156
+ tool_allowlist: string[];
157
+ workspace_access: "read-only" | "read-write";
158
+ approval_mode: ApprovalMode;
159
+ parent_permissions?: PermissionsConfig;
160
+ max_steps: number;
161
+ timeout_seconds?: number;
162
+ };
163
+ };
164
+ type SubagentChannel = {
165
+ request(operation: "send" | "receive" | "list" | "shell" | "edit" | "write", params: unknown, signal?: AbortSignal): Promise<unknown>;
166
+ };
167
+ type SubagentExecutorFactory = {
168
+ isAvailable(): boolean;
169
+ prepare(input: SubagentLaunchInput, channel?: SubagentChannel): PreparedTaskExecution;
170
+ };
171
+
172
+ type TaskProcessSignal = "SIGTERM" | "SIGKILL";
173
+ type TaskProcessController = {
174
+ isProcessAlive: (pid: number) => Promise<boolean>;
175
+ terminateProcess: (pid: number, signal: TaskProcessSignal) => Promise<void>;
176
+ terminateProcessGroup: (pgid: number, signal: TaskProcessSignal) => Promise<void>;
177
+ };
178
+
143
179
  type TaskManagerOptions = {
144
180
  registry?: TaskRegistryStore;
145
181
  runtimeId?: string;
@@ -178,6 +214,9 @@ declare class TaskManager {
178
214
  private forceTerminateIfStillAlive;
179
215
  private cancelWithoutLocalHandle;
180
216
  spawn(input: TaskSpawnInput, startExecution: (context: TaskExecutionStartContext) => TaskExecutionHandle | Promise<TaskExecutionHandle>): Promise<TaskRecord>;
217
+ /** Admit a prepared executor atomically with respect to shutdown and cancellation. */
218
+ spawnPrepared(input: TaskSpawnInput, handle: PreparedTaskExecution, signal?: AbortSignal): Promise<TaskRecord>;
219
+ appendMessage(taskId: string, message: AgentMessage): Promise<void>;
181
220
  list(): Promise<TaskRecord[]>;
182
221
  status(taskId: string): Promise<TaskRecord | null>;
183
222
  result(taskId: string): Promise<TaskResult | null>;
@@ -251,6 +290,7 @@ type RuntimeEnvironmentContract = {
251
290
  };
252
291
  };
253
292
  type RuntimeConfigProvider = {
293
+ resolveSubagentConfig?: (workingDir?: string) => Promise<SubagentConfig | undefined>;
254
294
  resolveModelConfig?: (workingDir?: string) => Promise<ResolvedModelConfig>;
255
295
  resolvePermissionsConfig?: (workingDir?: string) => Promise<PermissionsConfig | undefined>;
256
296
  resolveSearchConfig?: (workingDir?: string) => Promise<ResolvedSearchConfig>;
@@ -296,6 +336,7 @@ type RuntimeStores = {
296
336
  taskManager?: TaskManager;
297
337
  };
298
338
  type RuntimeHostAdapters = {
339
+ subagentExecutorFactory?: SubagentExecutorFactory;
299
340
  systemPromptProvider?: SystemPromptProvider;
300
341
  configProvider?: RuntimeConfigProvider;
301
342
  credentialProvider?: CredentialProvider;
@@ -312,4 +353,4 @@ type RuntimeOptions = {
312
353
 
313
354
  declare const startRuntime: (options?: RuntimeOptions) => Promise<void>;
314
355
 
315
- export { type CredentialProvider, type RuntimeConfigProvider, type RuntimeEnvironmentContract, type RuntimeEnvironmentInput, type RuntimeEnvironmentPreset, type RuntimeEventSink, type RuntimeHostAdapters, type RuntimeOptions, type RuntimeStores, type SystemPromptProvider, type ToolProvider, startRuntime };
356
+ export { type CredentialProvider, type PreparedTaskExecution, type RuntimeConfigProvider, type RuntimeEnvironmentContract, type RuntimeEnvironmentInput, type RuntimeEnvironmentPreset, type RuntimeEventSink, type RuntimeHostAdapters, type RuntimeOptions, type RuntimeStores, type SubagentChannel, type SubagentExecutorFactory, type SubagentLaunchInput, type SystemPromptProvider, type ToolProvider, startRuntime };
package/dist/sdk.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  startRuntime
3
- } from "./chunk-J73OBTWI.js";
3
+ } from "./chunk-KI7RKJNA.js";
4
+ import "./chunk-227ALRI4.js";
4
5
  export {
5
6
  startRuntime
6
7
  };