@codelia/runtime 0.1.68 → 0.1.70
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-F7HVODBX.js +15981 -0
- package/dist/index.cjs +1413 -402
- package/dist/index.js +6 -14958
- package/dist/sdk.cjs +15937 -0
- package/dist/sdk.d.cts +287 -0
- package/dist/sdk.d.ts +287 -0
- package/dist/sdk.js +6 -0
- package/package.json +15 -10
package/dist/sdk.d.cts
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { PermissionsConfig, PermissionRule } from '@codelia/config';
|
|
2
|
+
import { SessionStateStore, RunEventStoreFactory, ToolOutputCacheStore, Tool } from '@codelia/core';
|
|
3
|
+
import { RpcNotification } from '@codelia/protocol';
|
|
4
|
+
import { ModelReasoningLevel } from '@codelia/shared-types';
|
|
5
|
+
import { TaskKind, TaskWorkspaceMode, TaskRecord, TaskState, TaskResult, TaskRegistryStore } from '@codelia/storage';
|
|
6
|
+
|
|
7
|
+
type ResolvedModelConfig = {
|
|
8
|
+
provider?: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
reasoning?: string;
|
|
11
|
+
verbosity?: string;
|
|
12
|
+
fast?: boolean;
|
|
13
|
+
experimental?: {
|
|
14
|
+
openai?: {
|
|
15
|
+
websocket_mode?: "off" | "auto" | "on";
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
type ResolvedSkillsConfig = {
|
|
20
|
+
enabled: boolean;
|
|
21
|
+
initial: {
|
|
22
|
+
maxEntries: number;
|
|
23
|
+
maxBytes: number;
|
|
24
|
+
};
|
|
25
|
+
search: {
|
|
26
|
+
defaultLimit: number;
|
|
27
|
+
maxLimit: number;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
type ResolvedExecutionEnvironmentConfig = {
|
|
31
|
+
startupChecks: {
|
|
32
|
+
enabled: boolean;
|
|
33
|
+
commands: string[][];
|
|
34
|
+
timeoutMs: number;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
type ResolvedSearchConfig = {
|
|
38
|
+
mode: "auto" | "native" | "local";
|
|
39
|
+
native: {
|
|
40
|
+
providers: string[];
|
|
41
|
+
searchContextSize?: "low" | "medium" | "high";
|
|
42
|
+
allowedDomains?: string[];
|
|
43
|
+
userLocation?: {
|
|
44
|
+
city?: string;
|
|
45
|
+
country?: string;
|
|
46
|
+
region?: string;
|
|
47
|
+
timezone?: string;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
local: {
|
|
51
|
+
backend: "ddg" | "brave";
|
|
52
|
+
braveApiKeyEnv: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
type WriteScope = "global" | "project";
|
|
56
|
+
type WriteTarget = {
|
|
57
|
+
scope: WriteScope;
|
|
58
|
+
path: string;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
type OAuthTokens = {
|
|
62
|
+
access_token: string;
|
|
63
|
+
refresh_token: string;
|
|
64
|
+
expires_at: number;
|
|
65
|
+
account_id?: string;
|
|
66
|
+
};
|
|
67
|
+
type ProviderAuth = {
|
|
68
|
+
method: "api_key";
|
|
69
|
+
api_key: string;
|
|
70
|
+
} | {
|
|
71
|
+
method: "oauth";
|
|
72
|
+
oauth: OAuthTokens;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
declare const SUPPORTED_PROVIDERS: readonly ["openai", "anthropic", "openrouter", "zai"];
|
|
76
|
+
type SupportedProvider = (typeof SUPPORTED_PROVIDERS)[number];
|
|
77
|
+
|
|
78
|
+
type TaskProcessSignal = "SIGTERM" | "SIGKILL";
|
|
79
|
+
type TaskProcessController = {
|
|
80
|
+
isProcessAlive: (pid: number) => Promise<boolean>;
|
|
81
|
+
terminateProcess: (pid: number, signal: TaskProcessSignal) => Promise<void>;
|
|
82
|
+
terminateProcessGroup: (pgid: number, signal: TaskProcessSignal) => Promise<void>;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
type TerminalTaskState = Extract<TaskState, "completed" | "failed" | "cancelled">;
|
|
86
|
+
type TaskSpawnInput = {
|
|
87
|
+
task_id?: string;
|
|
88
|
+
kind: TaskKind;
|
|
89
|
+
workspace_mode?: TaskWorkspaceMode;
|
|
90
|
+
key?: string;
|
|
91
|
+
label?: string;
|
|
92
|
+
title?: string;
|
|
93
|
+
working_directory?: string;
|
|
94
|
+
parent_session_id?: string;
|
|
95
|
+
parent_run_id?: string;
|
|
96
|
+
parent_tool_call_id?: string;
|
|
97
|
+
child_session_id?: string;
|
|
98
|
+
};
|
|
99
|
+
type TaskExecutionMetadata = {
|
|
100
|
+
executor_pid?: number;
|
|
101
|
+
executor_pgid?: number;
|
|
102
|
+
child_session_id?: string;
|
|
103
|
+
worktree_path?: string;
|
|
104
|
+
};
|
|
105
|
+
type TaskExecutionOutputStream = "stdout" | "stderr";
|
|
106
|
+
type TaskExecutionResult = {
|
|
107
|
+
state: TerminalTaskState;
|
|
108
|
+
result?: TaskResult;
|
|
109
|
+
failure_message?: string;
|
|
110
|
+
cancellation_reason?: string;
|
|
111
|
+
cleanup_reason?: string;
|
|
112
|
+
};
|
|
113
|
+
type TaskExecutionHandle = {
|
|
114
|
+
metadata?: TaskExecutionMetadata | Promise<TaskExecutionMetadata | null | undefined> | null;
|
|
115
|
+
wait: Promise<TaskExecutionResult>;
|
|
116
|
+
readOutput?: (stream: TaskExecutionOutputStream) => string | Promise<string>;
|
|
117
|
+
cancel?: (reason?: string) => Promise<void> | void;
|
|
118
|
+
};
|
|
119
|
+
type TaskExecutionStartContext = {
|
|
120
|
+
task: TaskRecord;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
type TaskManagerOptions = {
|
|
124
|
+
registry?: TaskRegistryStore;
|
|
125
|
+
runtimeId?: string;
|
|
126
|
+
ownerPid?: number;
|
|
127
|
+
now?: () => string;
|
|
128
|
+
randomId?: () => string;
|
|
129
|
+
sleep?: (ms: number) => Promise<void>;
|
|
130
|
+
pollIntervalMs?: number;
|
|
131
|
+
gracePeriodMs?: number;
|
|
132
|
+
processController?: TaskProcessController;
|
|
133
|
+
};
|
|
134
|
+
declare class TaskManager {
|
|
135
|
+
private readonly registry;
|
|
136
|
+
private readonly runtimeId;
|
|
137
|
+
private readonly ownerPid;
|
|
138
|
+
private readonly now;
|
|
139
|
+
private readonly randomId;
|
|
140
|
+
private readonly sleep;
|
|
141
|
+
private readonly pollIntervalMs;
|
|
142
|
+
private readonly gracePeriodMs;
|
|
143
|
+
private readonly processController;
|
|
144
|
+
private readonly activeTasks;
|
|
145
|
+
private mutationQueue;
|
|
146
|
+
private shuttingDown;
|
|
147
|
+
constructor(options?: TaskManagerOptions);
|
|
148
|
+
get ownerRuntimeId(): string;
|
|
149
|
+
private enqueueMutation;
|
|
150
|
+
private updateTask;
|
|
151
|
+
private finalizeTask;
|
|
152
|
+
private markRunning;
|
|
153
|
+
private applyMetadata;
|
|
154
|
+
private settleExecution;
|
|
155
|
+
private reconcileObservedTask;
|
|
156
|
+
private requireTask;
|
|
157
|
+
private terminatePersistedTask;
|
|
158
|
+
private forceTerminateIfStillAlive;
|
|
159
|
+
private cancelWithoutLocalHandle;
|
|
160
|
+
spawn(input: TaskSpawnInput, startExecution: (context: TaskExecutionStartContext) => TaskExecutionHandle | Promise<TaskExecutionHandle>): Promise<TaskRecord>;
|
|
161
|
+
list(): Promise<TaskRecord[]>;
|
|
162
|
+
status(taskId: string): Promise<TaskRecord | null>;
|
|
163
|
+
result(taskId: string): Promise<TaskResult | null>;
|
|
164
|
+
readOutput(taskId: string, stream: TaskExecutionOutputStream): Promise<string | null>;
|
|
165
|
+
wait(taskId: string, options?: {
|
|
166
|
+
signal?: AbortSignal;
|
|
167
|
+
pollIntervalMs?: number;
|
|
168
|
+
}): Promise<TaskRecord>;
|
|
169
|
+
cancel(taskId: string, options?: {
|
|
170
|
+
reason?: string;
|
|
171
|
+
}): Promise<TaskRecord>;
|
|
172
|
+
recoverOrphanedTasks(): Promise<{
|
|
173
|
+
recovered: number;
|
|
174
|
+
errors: Array<{
|
|
175
|
+
task_id: string;
|
|
176
|
+
error: string;
|
|
177
|
+
}>;
|
|
178
|
+
}>;
|
|
179
|
+
shutdown(): Promise<{
|
|
180
|
+
cancelled: number;
|
|
181
|
+
errors: Array<{
|
|
182
|
+
task_id: string;
|
|
183
|
+
error: string;
|
|
184
|
+
}>;
|
|
185
|
+
}>;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
type RuntimeEnvironmentPreset = "tui-local" | "embedded-no-local-tools";
|
|
189
|
+
type RuntimeEnvironmentInput = {
|
|
190
|
+
preset: RuntimeEnvironmentPreset;
|
|
191
|
+
} | {
|
|
192
|
+
contract: RuntimeEnvironmentContract;
|
|
193
|
+
};
|
|
194
|
+
type RuntimeEnvironmentContract = {
|
|
195
|
+
workspace: {
|
|
196
|
+
root?: string;
|
|
197
|
+
filesystem: "enabled" | "disabled";
|
|
198
|
+
process: "runtime" | "disabled";
|
|
199
|
+
};
|
|
200
|
+
context: {
|
|
201
|
+
systemPrompt: "runtime-default" | "host";
|
|
202
|
+
projectInstructions: "from-workspace" | "disabled";
|
|
203
|
+
skills: "from-config" | "disabled";
|
|
204
|
+
executionEnvironment: "from-config" | "disabled";
|
|
205
|
+
};
|
|
206
|
+
auth: {
|
|
207
|
+
model: "runtime-default" | "host";
|
|
208
|
+
};
|
|
209
|
+
config: {
|
|
210
|
+
source: "runtime-default" | "host" | "disabled";
|
|
211
|
+
};
|
|
212
|
+
tools: {
|
|
213
|
+
builtin: "full-coding-agent" | "none";
|
|
214
|
+
search: "from-config" | "disabled";
|
|
215
|
+
mcp: "from-config" | "disabled";
|
|
216
|
+
host: "enabled" | "disabled";
|
|
217
|
+
};
|
|
218
|
+
persistence: {
|
|
219
|
+
mode: "runtime" | "volatile";
|
|
220
|
+
};
|
|
221
|
+
events: {
|
|
222
|
+
live: "json-rpc" | "host";
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
type RuntimeConfigProvider = {
|
|
226
|
+
resolveModelConfig?: (workingDir?: string) => Promise<ResolvedModelConfig>;
|
|
227
|
+
resolvePermissionsConfig?: (workingDir?: string) => Promise<PermissionsConfig | undefined>;
|
|
228
|
+
resolveSearchConfig?: (workingDir?: string) => Promise<ResolvedSearchConfig>;
|
|
229
|
+
resolveSkillsConfig?: (workingDir?: string) => Promise<ResolvedSkillsConfig>;
|
|
230
|
+
resolveExecutionEnvironmentConfig?: (workingDir?: string) => Promise<ResolvedExecutionEnvironmentConfig>;
|
|
231
|
+
resolveTuiConfig?: (workingDir?: string) => Promise<{
|
|
232
|
+
theme?: string;
|
|
233
|
+
}>;
|
|
234
|
+
updateModel?: (workingDir: string | undefined, model: {
|
|
235
|
+
provider: string;
|
|
236
|
+
name: string;
|
|
237
|
+
reasoning?: ModelReasoningLevel;
|
|
238
|
+
fast?: boolean;
|
|
239
|
+
}) => Promise<WriteTarget>;
|
|
240
|
+
updateTuiTheme?: (workingDir: string | undefined, theme: string) => Promise<WriteTarget>;
|
|
241
|
+
appendPermissionAllowRules?: (workingDir: string | undefined, rules: PermissionRule[]) => Promise<void>;
|
|
242
|
+
};
|
|
243
|
+
type CredentialProvider = {
|
|
244
|
+
hasAnyAvailableAuth?: () => boolean | Promise<boolean>;
|
|
245
|
+
resolveProvider: (preferred?: string | null) => Promise<SupportedProvider>;
|
|
246
|
+
resolveProviderAuth: (provider: SupportedProvider) => Promise<ProviderAuth>;
|
|
247
|
+
getOpenAiAccessToken?: () => Promise<{
|
|
248
|
+
token: string;
|
|
249
|
+
accountId?: string;
|
|
250
|
+
}>;
|
|
251
|
+
clearAuth?: () => Promise<void>;
|
|
252
|
+
};
|
|
253
|
+
type SystemPromptProvider = {
|
|
254
|
+
loadSystemPrompt: (workingDir?: string) => Promise<string> | string;
|
|
255
|
+
};
|
|
256
|
+
type ApprovalService = unknown;
|
|
257
|
+
type PromptService = unknown;
|
|
258
|
+
type RuntimeEventSink = {
|
|
259
|
+
emit: (notification: RpcNotification) => Promise<void> | void;
|
|
260
|
+
};
|
|
261
|
+
type ToolProvider = {
|
|
262
|
+
getTools: () => Promise<Tool[]> | Tool[];
|
|
263
|
+
};
|
|
264
|
+
type RuntimeStores = {
|
|
265
|
+
sessionStateStore?: SessionStateStore;
|
|
266
|
+
runEventStoreFactory?: RunEventStoreFactory;
|
|
267
|
+
toolOutputCacheStore?: ToolOutputCacheStore | null;
|
|
268
|
+
taskManager?: TaskManager;
|
|
269
|
+
};
|
|
270
|
+
type RuntimeHostAdapters = {
|
|
271
|
+
systemPromptProvider?: SystemPromptProvider;
|
|
272
|
+
configProvider?: RuntimeConfigProvider;
|
|
273
|
+
credentialProvider?: CredentialProvider;
|
|
274
|
+
approvalService?: ApprovalService;
|
|
275
|
+
promptService?: PromptService;
|
|
276
|
+
eventSink?: RuntimeEventSink;
|
|
277
|
+
stores?: RuntimeStores;
|
|
278
|
+
toolProviders?: ToolProvider[];
|
|
279
|
+
};
|
|
280
|
+
type RuntimeOptions = {
|
|
281
|
+
environment?: RuntimeEnvironmentInput;
|
|
282
|
+
adapters?: RuntimeHostAdapters;
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
declare const startRuntime: (options?: RuntimeOptions) => Promise<void>;
|
|
286
|
+
|
|
287
|
+
export { type CredentialProvider, type RuntimeConfigProvider, type RuntimeEnvironmentContract, type RuntimeEnvironmentInput, type RuntimeEnvironmentPreset, type RuntimeEventSink, type RuntimeHostAdapters, type RuntimeOptions, type RuntimeStores, type SystemPromptProvider, type ToolProvider, startRuntime };
|
package/dist/sdk.d.ts
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { PermissionsConfig, PermissionRule } from '@codelia/config';
|
|
2
|
+
import { SessionStateStore, RunEventStoreFactory, ToolOutputCacheStore, Tool } from '@codelia/core';
|
|
3
|
+
import { RpcNotification } from '@codelia/protocol';
|
|
4
|
+
import { ModelReasoningLevel } from '@codelia/shared-types';
|
|
5
|
+
import { TaskKind, TaskWorkspaceMode, TaskRecord, TaskState, TaskResult, TaskRegistryStore } from '@codelia/storage';
|
|
6
|
+
|
|
7
|
+
type ResolvedModelConfig = {
|
|
8
|
+
provider?: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
reasoning?: string;
|
|
11
|
+
verbosity?: string;
|
|
12
|
+
fast?: boolean;
|
|
13
|
+
experimental?: {
|
|
14
|
+
openai?: {
|
|
15
|
+
websocket_mode?: "off" | "auto" | "on";
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
type ResolvedSkillsConfig = {
|
|
20
|
+
enabled: boolean;
|
|
21
|
+
initial: {
|
|
22
|
+
maxEntries: number;
|
|
23
|
+
maxBytes: number;
|
|
24
|
+
};
|
|
25
|
+
search: {
|
|
26
|
+
defaultLimit: number;
|
|
27
|
+
maxLimit: number;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
type ResolvedExecutionEnvironmentConfig = {
|
|
31
|
+
startupChecks: {
|
|
32
|
+
enabled: boolean;
|
|
33
|
+
commands: string[][];
|
|
34
|
+
timeoutMs: number;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
type ResolvedSearchConfig = {
|
|
38
|
+
mode: "auto" | "native" | "local";
|
|
39
|
+
native: {
|
|
40
|
+
providers: string[];
|
|
41
|
+
searchContextSize?: "low" | "medium" | "high";
|
|
42
|
+
allowedDomains?: string[];
|
|
43
|
+
userLocation?: {
|
|
44
|
+
city?: string;
|
|
45
|
+
country?: string;
|
|
46
|
+
region?: string;
|
|
47
|
+
timezone?: string;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
local: {
|
|
51
|
+
backend: "ddg" | "brave";
|
|
52
|
+
braveApiKeyEnv: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
type WriteScope = "global" | "project";
|
|
56
|
+
type WriteTarget = {
|
|
57
|
+
scope: WriteScope;
|
|
58
|
+
path: string;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
type OAuthTokens = {
|
|
62
|
+
access_token: string;
|
|
63
|
+
refresh_token: string;
|
|
64
|
+
expires_at: number;
|
|
65
|
+
account_id?: string;
|
|
66
|
+
};
|
|
67
|
+
type ProviderAuth = {
|
|
68
|
+
method: "api_key";
|
|
69
|
+
api_key: string;
|
|
70
|
+
} | {
|
|
71
|
+
method: "oauth";
|
|
72
|
+
oauth: OAuthTokens;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
declare const SUPPORTED_PROVIDERS: readonly ["openai", "anthropic", "openrouter", "zai"];
|
|
76
|
+
type SupportedProvider = (typeof SUPPORTED_PROVIDERS)[number];
|
|
77
|
+
|
|
78
|
+
type TaskProcessSignal = "SIGTERM" | "SIGKILL";
|
|
79
|
+
type TaskProcessController = {
|
|
80
|
+
isProcessAlive: (pid: number) => Promise<boolean>;
|
|
81
|
+
terminateProcess: (pid: number, signal: TaskProcessSignal) => Promise<void>;
|
|
82
|
+
terminateProcessGroup: (pgid: number, signal: TaskProcessSignal) => Promise<void>;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
type TerminalTaskState = Extract<TaskState, "completed" | "failed" | "cancelled">;
|
|
86
|
+
type TaskSpawnInput = {
|
|
87
|
+
task_id?: string;
|
|
88
|
+
kind: TaskKind;
|
|
89
|
+
workspace_mode?: TaskWorkspaceMode;
|
|
90
|
+
key?: string;
|
|
91
|
+
label?: string;
|
|
92
|
+
title?: string;
|
|
93
|
+
working_directory?: string;
|
|
94
|
+
parent_session_id?: string;
|
|
95
|
+
parent_run_id?: string;
|
|
96
|
+
parent_tool_call_id?: string;
|
|
97
|
+
child_session_id?: string;
|
|
98
|
+
};
|
|
99
|
+
type TaskExecutionMetadata = {
|
|
100
|
+
executor_pid?: number;
|
|
101
|
+
executor_pgid?: number;
|
|
102
|
+
child_session_id?: string;
|
|
103
|
+
worktree_path?: string;
|
|
104
|
+
};
|
|
105
|
+
type TaskExecutionOutputStream = "stdout" | "stderr";
|
|
106
|
+
type TaskExecutionResult = {
|
|
107
|
+
state: TerminalTaskState;
|
|
108
|
+
result?: TaskResult;
|
|
109
|
+
failure_message?: string;
|
|
110
|
+
cancellation_reason?: string;
|
|
111
|
+
cleanup_reason?: string;
|
|
112
|
+
};
|
|
113
|
+
type TaskExecutionHandle = {
|
|
114
|
+
metadata?: TaskExecutionMetadata | Promise<TaskExecutionMetadata | null | undefined> | null;
|
|
115
|
+
wait: Promise<TaskExecutionResult>;
|
|
116
|
+
readOutput?: (stream: TaskExecutionOutputStream) => string | Promise<string>;
|
|
117
|
+
cancel?: (reason?: string) => Promise<void> | void;
|
|
118
|
+
};
|
|
119
|
+
type TaskExecutionStartContext = {
|
|
120
|
+
task: TaskRecord;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
type TaskManagerOptions = {
|
|
124
|
+
registry?: TaskRegistryStore;
|
|
125
|
+
runtimeId?: string;
|
|
126
|
+
ownerPid?: number;
|
|
127
|
+
now?: () => string;
|
|
128
|
+
randomId?: () => string;
|
|
129
|
+
sleep?: (ms: number) => Promise<void>;
|
|
130
|
+
pollIntervalMs?: number;
|
|
131
|
+
gracePeriodMs?: number;
|
|
132
|
+
processController?: TaskProcessController;
|
|
133
|
+
};
|
|
134
|
+
declare class TaskManager {
|
|
135
|
+
private readonly registry;
|
|
136
|
+
private readonly runtimeId;
|
|
137
|
+
private readonly ownerPid;
|
|
138
|
+
private readonly now;
|
|
139
|
+
private readonly randomId;
|
|
140
|
+
private readonly sleep;
|
|
141
|
+
private readonly pollIntervalMs;
|
|
142
|
+
private readonly gracePeriodMs;
|
|
143
|
+
private readonly processController;
|
|
144
|
+
private readonly activeTasks;
|
|
145
|
+
private mutationQueue;
|
|
146
|
+
private shuttingDown;
|
|
147
|
+
constructor(options?: TaskManagerOptions);
|
|
148
|
+
get ownerRuntimeId(): string;
|
|
149
|
+
private enqueueMutation;
|
|
150
|
+
private updateTask;
|
|
151
|
+
private finalizeTask;
|
|
152
|
+
private markRunning;
|
|
153
|
+
private applyMetadata;
|
|
154
|
+
private settleExecution;
|
|
155
|
+
private reconcileObservedTask;
|
|
156
|
+
private requireTask;
|
|
157
|
+
private terminatePersistedTask;
|
|
158
|
+
private forceTerminateIfStillAlive;
|
|
159
|
+
private cancelWithoutLocalHandle;
|
|
160
|
+
spawn(input: TaskSpawnInput, startExecution: (context: TaskExecutionStartContext) => TaskExecutionHandle | Promise<TaskExecutionHandle>): Promise<TaskRecord>;
|
|
161
|
+
list(): Promise<TaskRecord[]>;
|
|
162
|
+
status(taskId: string): Promise<TaskRecord | null>;
|
|
163
|
+
result(taskId: string): Promise<TaskResult | null>;
|
|
164
|
+
readOutput(taskId: string, stream: TaskExecutionOutputStream): Promise<string | null>;
|
|
165
|
+
wait(taskId: string, options?: {
|
|
166
|
+
signal?: AbortSignal;
|
|
167
|
+
pollIntervalMs?: number;
|
|
168
|
+
}): Promise<TaskRecord>;
|
|
169
|
+
cancel(taskId: string, options?: {
|
|
170
|
+
reason?: string;
|
|
171
|
+
}): Promise<TaskRecord>;
|
|
172
|
+
recoverOrphanedTasks(): Promise<{
|
|
173
|
+
recovered: number;
|
|
174
|
+
errors: Array<{
|
|
175
|
+
task_id: string;
|
|
176
|
+
error: string;
|
|
177
|
+
}>;
|
|
178
|
+
}>;
|
|
179
|
+
shutdown(): Promise<{
|
|
180
|
+
cancelled: number;
|
|
181
|
+
errors: Array<{
|
|
182
|
+
task_id: string;
|
|
183
|
+
error: string;
|
|
184
|
+
}>;
|
|
185
|
+
}>;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
type RuntimeEnvironmentPreset = "tui-local" | "embedded-no-local-tools";
|
|
189
|
+
type RuntimeEnvironmentInput = {
|
|
190
|
+
preset: RuntimeEnvironmentPreset;
|
|
191
|
+
} | {
|
|
192
|
+
contract: RuntimeEnvironmentContract;
|
|
193
|
+
};
|
|
194
|
+
type RuntimeEnvironmentContract = {
|
|
195
|
+
workspace: {
|
|
196
|
+
root?: string;
|
|
197
|
+
filesystem: "enabled" | "disabled";
|
|
198
|
+
process: "runtime" | "disabled";
|
|
199
|
+
};
|
|
200
|
+
context: {
|
|
201
|
+
systemPrompt: "runtime-default" | "host";
|
|
202
|
+
projectInstructions: "from-workspace" | "disabled";
|
|
203
|
+
skills: "from-config" | "disabled";
|
|
204
|
+
executionEnvironment: "from-config" | "disabled";
|
|
205
|
+
};
|
|
206
|
+
auth: {
|
|
207
|
+
model: "runtime-default" | "host";
|
|
208
|
+
};
|
|
209
|
+
config: {
|
|
210
|
+
source: "runtime-default" | "host" | "disabled";
|
|
211
|
+
};
|
|
212
|
+
tools: {
|
|
213
|
+
builtin: "full-coding-agent" | "none";
|
|
214
|
+
search: "from-config" | "disabled";
|
|
215
|
+
mcp: "from-config" | "disabled";
|
|
216
|
+
host: "enabled" | "disabled";
|
|
217
|
+
};
|
|
218
|
+
persistence: {
|
|
219
|
+
mode: "runtime" | "volatile";
|
|
220
|
+
};
|
|
221
|
+
events: {
|
|
222
|
+
live: "json-rpc" | "host";
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
type RuntimeConfigProvider = {
|
|
226
|
+
resolveModelConfig?: (workingDir?: string) => Promise<ResolvedModelConfig>;
|
|
227
|
+
resolvePermissionsConfig?: (workingDir?: string) => Promise<PermissionsConfig | undefined>;
|
|
228
|
+
resolveSearchConfig?: (workingDir?: string) => Promise<ResolvedSearchConfig>;
|
|
229
|
+
resolveSkillsConfig?: (workingDir?: string) => Promise<ResolvedSkillsConfig>;
|
|
230
|
+
resolveExecutionEnvironmentConfig?: (workingDir?: string) => Promise<ResolvedExecutionEnvironmentConfig>;
|
|
231
|
+
resolveTuiConfig?: (workingDir?: string) => Promise<{
|
|
232
|
+
theme?: string;
|
|
233
|
+
}>;
|
|
234
|
+
updateModel?: (workingDir: string | undefined, model: {
|
|
235
|
+
provider: string;
|
|
236
|
+
name: string;
|
|
237
|
+
reasoning?: ModelReasoningLevel;
|
|
238
|
+
fast?: boolean;
|
|
239
|
+
}) => Promise<WriteTarget>;
|
|
240
|
+
updateTuiTheme?: (workingDir: string | undefined, theme: string) => Promise<WriteTarget>;
|
|
241
|
+
appendPermissionAllowRules?: (workingDir: string | undefined, rules: PermissionRule[]) => Promise<void>;
|
|
242
|
+
};
|
|
243
|
+
type CredentialProvider = {
|
|
244
|
+
hasAnyAvailableAuth?: () => boolean | Promise<boolean>;
|
|
245
|
+
resolveProvider: (preferred?: string | null) => Promise<SupportedProvider>;
|
|
246
|
+
resolveProviderAuth: (provider: SupportedProvider) => Promise<ProviderAuth>;
|
|
247
|
+
getOpenAiAccessToken?: () => Promise<{
|
|
248
|
+
token: string;
|
|
249
|
+
accountId?: string;
|
|
250
|
+
}>;
|
|
251
|
+
clearAuth?: () => Promise<void>;
|
|
252
|
+
};
|
|
253
|
+
type SystemPromptProvider = {
|
|
254
|
+
loadSystemPrompt: (workingDir?: string) => Promise<string> | string;
|
|
255
|
+
};
|
|
256
|
+
type ApprovalService = unknown;
|
|
257
|
+
type PromptService = unknown;
|
|
258
|
+
type RuntimeEventSink = {
|
|
259
|
+
emit: (notification: RpcNotification) => Promise<void> | void;
|
|
260
|
+
};
|
|
261
|
+
type ToolProvider = {
|
|
262
|
+
getTools: () => Promise<Tool[]> | Tool[];
|
|
263
|
+
};
|
|
264
|
+
type RuntimeStores = {
|
|
265
|
+
sessionStateStore?: SessionStateStore;
|
|
266
|
+
runEventStoreFactory?: RunEventStoreFactory;
|
|
267
|
+
toolOutputCacheStore?: ToolOutputCacheStore | null;
|
|
268
|
+
taskManager?: TaskManager;
|
|
269
|
+
};
|
|
270
|
+
type RuntimeHostAdapters = {
|
|
271
|
+
systemPromptProvider?: SystemPromptProvider;
|
|
272
|
+
configProvider?: RuntimeConfigProvider;
|
|
273
|
+
credentialProvider?: CredentialProvider;
|
|
274
|
+
approvalService?: ApprovalService;
|
|
275
|
+
promptService?: PromptService;
|
|
276
|
+
eventSink?: RuntimeEventSink;
|
|
277
|
+
stores?: RuntimeStores;
|
|
278
|
+
toolProviders?: ToolProvider[];
|
|
279
|
+
};
|
|
280
|
+
type RuntimeOptions = {
|
|
281
|
+
environment?: RuntimeEnvironmentInput;
|
|
282
|
+
adapters?: RuntimeHostAdapters;
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
declare const startRuntime: (options?: RuntimeOptions) => Promise<void>;
|
|
286
|
+
|
|
287
|
+
export { type CredentialProvider, type RuntimeConfigProvider, type RuntimeEnvironmentContract, type RuntimeEnvironmentInput, type RuntimeEnvironmentPreset, type RuntimeEventSink, type RuntimeHostAdapters, type RuntimeOptions, type RuntimeStores, type SystemPromptProvider, type ToolProvider, startRuntime };
|
package/dist/sdk.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codelia/runtime",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.70",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=20 <25"
|
|
@@ -16,21 +16,26 @@
|
|
|
16
16
|
"types": "./dist/index.d.ts",
|
|
17
17
|
"import": "./dist/index.js",
|
|
18
18
|
"require": "./dist/index.cjs"
|
|
19
|
+
},
|
|
20
|
+
"./sdk": {
|
|
21
|
+
"types": "./dist/sdk.d.ts",
|
|
22
|
+
"import": "./dist/sdk.js",
|
|
23
|
+
"require": "./dist/sdk.cjs"
|
|
19
24
|
}
|
|
20
25
|
},
|
|
21
26
|
"scripts": {
|
|
22
|
-
"build": "tsup src/index.ts --format esm,cjs --dts --clean",
|
|
27
|
+
"build": "tsup src/index.ts src/sdk.ts --format esm,cjs --dts --clean",
|
|
23
28
|
"typecheck": "tsc --noEmit"
|
|
24
29
|
},
|
|
25
30
|
"dependencies": {
|
|
26
|
-
"@codelia/config": "0.1.
|
|
27
|
-
"@codelia/config-loader": "0.1.
|
|
28
|
-
"@codelia/core": "0.1.
|
|
29
|
-
"@codelia/logger": "0.1.
|
|
30
|
-
"@codelia/model-metadata": "0.1.
|
|
31
|
-
"@codelia/protocol": "0.1.
|
|
32
|
-
"@codelia/shared-types": "0.1.
|
|
33
|
-
"@codelia/storage": "0.1.
|
|
31
|
+
"@codelia/config": "0.1.70",
|
|
32
|
+
"@codelia/config-loader": "0.1.70",
|
|
33
|
+
"@codelia/core": "0.1.70",
|
|
34
|
+
"@codelia/logger": "0.1.70",
|
|
35
|
+
"@codelia/model-metadata": "0.1.70",
|
|
36
|
+
"@codelia/protocol": "0.1.70",
|
|
37
|
+
"@codelia/shared-types": "0.1.70",
|
|
38
|
+
"@codelia/storage": "0.1.70",
|
|
34
39
|
"eventsource-parser": "^3.0.6",
|
|
35
40
|
"oauth4webapi": "^3.8.4",
|
|
36
41
|
"zod": "^4.3.5"
|