@codelia/runtime 0.1.80 → 0.1.82
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/chunk-CGWVQ7AE.js +4504 -0
- package/dist/{chunk-J73OBTWI.js → chunk-WA2KLV6H.js} +3888 -4877
- package/dist/index.cjs +7430 -4100
- package/dist/index.js +2 -1
- package/dist/sdk.cjs +7430 -4100
- package/dist/sdk.d.cts +57 -13
- package/dist/sdk.d.ts +57 -13
- package/dist/sdk.js +2 -1
- package/dist/subagents/child-entry.cjs +3821 -0
- package/dist/subagents/child-entry.d.cts +2 -0
- package/dist/subagents/child-entry.d.ts +2 -0
- package/dist/subagents/child-entry.js +596 -0
- package/package.json +11 -10
package/dist/sdk.d.cts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _codelia_config from '@codelia/config';
|
|
2
|
+
import { PermissionsConfig, SubagentConfig, PermissionRule } from '@codelia/config';
|
|
2
3
|
import { SessionStateStore, RunEventStoreFactory, ToolOutputCacheStore, Tool } from '@codelia/core';
|
|
3
4
|
import { RpcNotification } from '@codelia/protocol';
|
|
4
|
-
import { ModelReasoningLevel } from '@codelia/shared-types';
|
|
5
|
-
import {
|
|
5
|
+
import { SubagentLineage, ApprovalMode, AgentMessage, ModelReasoningLevel } from '@codelia/shared-types';
|
|
6
|
+
import { TaskResult, TaskState, TaskRecord, TaskKind, TaskWorkspaceMode, TaskRegistryStore } from '@codelia/storage';
|
|
6
7
|
|
|
7
8
|
type ResolvedModelConfig = {
|
|
9
|
+
providers?: _codelia_config.CodeliaConfig["providers"];
|
|
8
10
|
provider?: string;
|
|
9
11
|
name?: string;
|
|
10
12
|
reasoning?: string;
|
|
@@ -83,18 +85,11 @@ type ProviderAuth = {
|
|
|
83
85
|
oauth: OAuthTokens;
|
|
84
86
|
};
|
|
85
87
|
|
|
86
|
-
|
|
87
|
-
type SupportedProvider = (typeof SUPPORTED_PROVIDERS)[number];
|
|
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
|
-
};
|
|
88
|
+
type SupportedProvider = string;
|
|
95
89
|
|
|
96
90
|
type TerminalTaskState = Extract<TaskState, "completed" | "failed" | "cancelled">;
|
|
97
91
|
type TaskSpawnInput = {
|
|
92
|
+
subagent?: TaskRecord["subagent"];
|
|
98
93
|
task_id?: string;
|
|
99
94
|
kind: TaskKind;
|
|
100
95
|
workspace_mode?: TaskWorkspaceMode;
|
|
@@ -108,6 +103,8 @@ type TaskSpawnInput = {
|
|
|
108
103
|
child_session_id?: string;
|
|
109
104
|
};
|
|
110
105
|
type TaskExecutionMetadata = {
|
|
106
|
+
usage?: TaskResult["usage"];
|
|
107
|
+
executor_identity?: string;
|
|
111
108
|
executor_pid?: number;
|
|
112
109
|
executor_pgid?: number;
|
|
113
110
|
child_session_id?: string;
|
|
@@ -140,6 +137,46 @@ type TaskExecutionStartContext = {
|
|
|
140
137
|
task: TaskRecord;
|
|
141
138
|
};
|
|
142
139
|
|
|
140
|
+
/** prepare must not start work; TaskManager registers this handle before start. */
|
|
141
|
+
type PreparedTaskExecution = TaskExecutionHandle & {
|
|
142
|
+
cancel(reason?: string): Promise<void>;
|
|
143
|
+
start(control: {
|
|
144
|
+
persistExecutor(metadata: TaskExecutionMetadata): Promise<void>;
|
|
145
|
+
running(metadata: TaskExecutionMetadata): Promise<void>;
|
|
146
|
+
}): Promise<void>;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
type SubagentLaunchInput = {
|
|
150
|
+
version: 1;
|
|
151
|
+
task_id: string;
|
|
152
|
+
lineage: SubagentLineage;
|
|
153
|
+
prompt: string;
|
|
154
|
+
workspace_root: string;
|
|
155
|
+
model: ResolvedModelConfig;
|
|
156
|
+
permission: {
|
|
157
|
+
tool_allowlist: string[];
|
|
158
|
+
workspace_access: "read-only" | "read-write";
|
|
159
|
+
approval_mode: ApprovalMode;
|
|
160
|
+
parent_permissions?: PermissionsConfig;
|
|
161
|
+
max_steps: number;
|
|
162
|
+
timeout_seconds?: number;
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
type SubagentChannel = {
|
|
166
|
+
request(operation: "send" | "receive" | "list" | "shell" | "edit" | "write", params: unknown, signal?: AbortSignal): Promise<unknown>;
|
|
167
|
+
};
|
|
168
|
+
type SubagentExecutorFactory = {
|
|
169
|
+
isAvailable(): boolean;
|
|
170
|
+
prepare(input: SubagentLaunchInput, channel?: SubagentChannel): PreparedTaskExecution;
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
type TaskProcessSignal = "SIGTERM" | "SIGKILL";
|
|
174
|
+
type TaskProcessController = {
|
|
175
|
+
isProcessAlive: (pid: number) => Promise<boolean>;
|
|
176
|
+
terminateProcess: (pid: number, signal: TaskProcessSignal) => Promise<void>;
|
|
177
|
+
terminateProcessGroup: (pgid: number, signal: TaskProcessSignal) => Promise<void>;
|
|
178
|
+
};
|
|
179
|
+
|
|
143
180
|
type TaskManagerOptions = {
|
|
144
181
|
registry?: TaskRegistryStore;
|
|
145
182
|
runtimeId?: string;
|
|
@@ -178,6 +215,9 @@ declare class TaskManager {
|
|
|
178
215
|
private forceTerminateIfStillAlive;
|
|
179
216
|
private cancelWithoutLocalHandle;
|
|
180
217
|
spawn(input: TaskSpawnInput, startExecution: (context: TaskExecutionStartContext) => TaskExecutionHandle | Promise<TaskExecutionHandle>): Promise<TaskRecord>;
|
|
218
|
+
/** Admit a prepared executor atomically with respect to shutdown and cancellation. */
|
|
219
|
+
spawnPrepared(input: TaskSpawnInput, handle: PreparedTaskExecution, signal?: AbortSignal): Promise<TaskRecord>;
|
|
220
|
+
appendMessage(taskId: string, message: AgentMessage): Promise<void>;
|
|
181
221
|
list(): Promise<TaskRecord[]>;
|
|
182
222
|
status(taskId: string): Promise<TaskRecord | null>;
|
|
183
223
|
result(taskId: string): Promise<TaskResult | null>;
|
|
@@ -251,6 +291,7 @@ type RuntimeEnvironmentContract = {
|
|
|
251
291
|
};
|
|
252
292
|
};
|
|
253
293
|
type RuntimeConfigProvider = {
|
|
294
|
+
resolveSubagentConfig?: (workingDir?: string) => Promise<SubagentConfig | undefined>;
|
|
254
295
|
resolveModelConfig?: (workingDir?: string) => Promise<ResolvedModelConfig>;
|
|
255
296
|
resolvePermissionsConfig?: (workingDir?: string) => Promise<PermissionsConfig | undefined>;
|
|
256
297
|
resolveSearchConfig?: (workingDir?: string) => Promise<ResolvedSearchConfig>;
|
|
@@ -277,6 +318,8 @@ type CredentialProvider = {
|
|
|
277
318
|
accountId?: string;
|
|
278
319
|
}>;
|
|
279
320
|
clearAuth?: () => Promise<void>;
|
|
321
|
+
/** Scoped logout must never fall back to clearing all credentials. */
|
|
322
|
+
clearProviderAuth?: (provider: string) => Promise<void>;
|
|
280
323
|
};
|
|
281
324
|
type SystemPromptProvider = {
|
|
282
325
|
loadSystemPrompt: (workingDir?: string) => Promise<string> | string;
|
|
@@ -296,6 +339,7 @@ type RuntimeStores = {
|
|
|
296
339
|
taskManager?: TaskManager;
|
|
297
340
|
};
|
|
298
341
|
type RuntimeHostAdapters = {
|
|
342
|
+
subagentExecutorFactory?: SubagentExecutorFactory;
|
|
299
343
|
systemPromptProvider?: SystemPromptProvider;
|
|
300
344
|
configProvider?: RuntimeConfigProvider;
|
|
301
345
|
credentialProvider?: CredentialProvider;
|
|
@@ -312,4 +356,4 @@ type RuntimeOptions = {
|
|
|
312
356
|
|
|
313
357
|
declare const startRuntime: (options?: RuntimeOptions) => Promise<void>;
|
|
314
358
|
|
|
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 };
|
|
359
|
+
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,10 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _codelia_config from '@codelia/config';
|
|
2
|
+
import { PermissionsConfig, SubagentConfig, PermissionRule } from '@codelia/config';
|
|
2
3
|
import { SessionStateStore, RunEventStoreFactory, ToolOutputCacheStore, Tool } from '@codelia/core';
|
|
3
4
|
import { RpcNotification } from '@codelia/protocol';
|
|
4
|
-
import { ModelReasoningLevel } from '@codelia/shared-types';
|
|
5
|
-
import {
|
|
5
|
+
import { SubagentLineage, ApprovalMode, AgentMessage, ModelReasoningLevel } from '@codelia/shared-types';
|
|
6
|
+
import { TaskResult, TaskState, TaskRecord, TaskKind, TaskWorkspaceMode, TaskRegistryStore } from '@codelia/storage';
|
|
6
7
|
|
|
7
8
|
type ResolvedModelConfig = {
|
|
9
|
+
providers?: _codelia_config.CodeliaConfig["providers"];
|
|
8
10
|
provider?: string;
|
|
9
11
|
name?: string;
|
|
10
12
|
reasoning?: string;
|
|
@@ -83,18 +85,11 @@ type ProviderAuth = {
|
|
|
83
85
|
oauth: OAuthTokens;
|
|
84
86
|
};
|
|
85
87
|
|
|
86
|
-
|
|
87
|
-
type SupportedProvider = (typeof SUPPORTED_PROVIDERS)[number];
|
|
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
|
-
};
|
|
88
|
+
type SupportedProvider = string;
|
|
95
89
|
|
|
96
90
|
type TerminalTaskState = Extract<TaskState, "completed" | "failed" | "cancelled">;
|
|
97
91
|
type TaskSpawnInput = {
|
|
92
|
+
subagent?: TaskRecord["subagent"];
|
|
98
93
|
task_id?: string;
|
|
99
94
|
kind: TaskKind;
|
|
100
95
|
workspace_mode?: TaskWorkspaceMode;
|
|
@@ -108,6 +103,8 @@ type TaskSpawnInput = {
|
|
|
108
103
|
child_session_id?: string;
|
|
109
104
|
};
|
|
110
105
|
type TaskExecutionMetadata = {
|
|
106
|
+
usage?: TaskResult["usage"];
|
|
107
|
+
executor_identity?: string;
|
|
111
108
|
executor_pid?: number;
|
|
112
109
|
executor_pgid?: number;
|
|
113
110
|
child_session_id?: string;
|
|
@@ -140,6 +137,46 @@ type TaskExecutionStartContext = {
|
|
|
140
137
|
task: TaskRecord;
|
|
141
138
|
};
|
|
142
139
|
|
|
140
|
+
/** prepare must not start work; TaskManager registers this handle before start. */
|
|
141
|
+
type PreparedTaskExecution = TaskExecutionHandle & {
|
|
142
|
+
cancel(reason?: string): Promise<void>;
|
|
143
|
+
start(control: {
|
|
144
|
+
persistExecutor(metadata: TaskExecutionMetadata): Promise<void>;
|
|
145
|
+
running(metadata: TaskExecutionMetadata): Promise<void>;
|
|
146
|
+
}): Promise<void>;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
type SubagentLaunchInput = {
|
|
150
|
+
version: 1;
|
|
151
|
+
task_id: string;
|
|
152
|
+
lineage: SubagentLineage;
|
|
153
|
+
prompt: string;
|
|
154
|
+
workspace_root: string;
|
|
155
|
+
model: ResolvedModelConfig;
|
|
156
|
+
permission: {
|
|
157
|
+
tool_allowlist: string[];
|
|
158
|
+
workspace_access: "read-only" | "read-write";
|
|
159
|
+
approval_mode: ApprovalMode;
|
|
160
|
+
parent_permissions?: PermissionsConfig;
|
|
161
|
+
max_steps: number;
|
|
162
|
+
timeout_seconds?: number;
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
type SubagentChannel = {
|
|
166
|
+
request(operation: "send" | "receive" | "list" | "shell" | "edit" | "write", params: unknown, signal?: AbortSignal): Promise<unknown>;
|
|
167
|
+
};
|
|
168
|
+
type SubagentExecutorFactory = {
|
|
169
|
+
isAvailable(): boolean;
|
|
170
|
+
prepare(input: SubagentLaunchInput, channel?: SubagentChannel): PreparedTaskExecution;
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
type TaskProcessSignal = "SIGTERM" | "SIGKILL";
|
|
174
|
+
type TaskProcessController = {
|
|
175
|
+
isProcessAlive: (pid: number) => Promise<boolean>;
|
|
176
|
+
terminateProcess: (pid: number, signal: TaskProcessSignal) => Promise<void>;
|
|
177
|
+
terminateProcessGroup: (pgid: number, signal: TaskProcessSignal) => Promise<void>;
|
|
178
|
+
};
|
|
179
|
+
|
|
143
180
|
type TaskManagerOptions = {
|
|
144
181
|
registry?: TaskRegistryStore;
|
|
145
182
|
runtimeId?: string;
|
|
@@ -178,6 +215,9 @@ declare class TaskManager {
|
|
|
178
215
|
private forceTerminateIfStillAlive;
|
|
179
216
|
private cancelWithoutLocalHandle;
|
|
180
217
|
spawn(input: TaskSpawnInput, startExecution: (context: TaskExecutionStartContext) => TaskExecutionHandle | Promise<TaskExecutionHandle>): Promise<TaskRecord>;
|
|
218
|
+
/** Admit a prepared executor atomically with respect to shutdown and cancellation. */
|
|
219
|
+
spawnPrepared(input: TaskSpawnInput, handle: PreparedTaskExecution, signal?: AbortSignal): Promise<TaskRecord>;
|
|
220
|
+
appendMessage(taskId: string, message: AgentMessage): Promise<void>;
|
|
181
221
|
list(): Promise<TaskRecord[]>;
|
|
182
222
|
status(taskId: string): Promise<TaskRecord | null>;
|
|
183
223
|
result(taskId: string): Promise<TaskResult | null>;
|
|
@@ -251,6 +291,7 @@ type RuntimeEnvironmentContract = {
|
|
|
251
291
|
};
|
|
252
292
|
};
|
|
253
293
|
type RuntimeConfigProvider = {
|
|
294
|
+
resolveSubagentConfig?: (workingDir?: string) => Promise<SubagentConfig | undefined>;
|
|
254
295
|
resolveModelConfig?: (workingDir?: string) => Promise<ResolvedModelConfig>;
|
|
255
296
|
resolvePermissionsConfig?: (workingDir?: string) => Promise<PermissionsConfig | undefined>;
|
|
256
297
|
resolveSearchConfig?: (workingDir?: string) => Promise<ResolvedSearchConfig>;
|
|
@@ -277,6 +318,8 @@ type CredentialProvider = {
|
|
|
277
318
|
accountId?: string;
|
|
278
319
|
}>;
|
|
279
320
|
clearAuth?: () => Promise<void>;
|
|
321
|
+
/** Scoped logout must never fall back to clearing all credentials. */
|
|
322
|
+
clearProviderAuth?: (provider: string) => Promise<void>;
|
|
280
323
|
};
|
|
281
324
|
type SystemPromptProvider = {
|
|
282
325
|
loadSystemPrompt: (workingDir?: string) => Promise<string> | string;
|
|
@@ -296,6 +339,7 @@ type RuntimeStores = {
|
|
|
296
339
|
taskManager?: TaskManager;
|
|
297
340
|
};
|
|
298
341
|
type RuntimeHostAdapters = {
|
|
342
|
+
subagentExecutorFactory?: SubagentExecutorFactory;
|
|
299
343
|
systemPromptProvider?: SystemPromptProvider;
|
|
300
344
|
configProvider?: RuntimeConfigProvider;
|
|
301
345
|
credentialProvider?: CredentialProvider;
|
|
@@ -312,4 +356,4 @@ type RuntimeOptions = {
|
|
|
312
356
|
|
|
313
357
|
declare const startRuntime: (options?: RuntimeOptions) => Promise<void>;
|
|
314
358
|
|
|
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 };
|
|
359
|
+
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 };
|