@rynx-ai/workspace 0.1.9
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/agent-execution.d.ts +290 -0
- package/dist/agent-execution.js +8 -0
- package/dist/agent-options.d.ts +26 -0
- package/dist/agent-options.js +106 -0
- package/dist/agent-scheduler.d.ts +149 -0
- package/dist/agent-scheduler.js +1 -0
- package/dist/device-protocol.d.ts +322 -0
- package/dist/device-protocol.js +326 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/skill-name.d.ts +6 -0
- package/dist/skill-name.js +21 -0
- package/dist/skill-path.d.ts +7 -0
- package/dist/skill-path.js +27 -0
- package/dist/types.d.ts +824 -0
- package/dist/types.js +2 -0
- package/package.json +25 -0
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import type { WorkspaceAgentRuntimeId } from "./agent-options.js";
|
|
2
|
+
import type { WorkspaceAgentPlacement, WorkspaceAgentSkillRevisionRef } from "./types.js";
|
|
3
|
+
export declare const WORKSPACE_AGENT_EXECUTION_SPEC_VERSION: 1;
|
|
4
|
+
export declare const WORKSPACE_AGENT_ENVIRONMENT_SPEC_VERSION: 1;
|
|
5
|
+
/**
|
|
6
|
+
* Version 1 always creates one independent persistent Workdir. Repository and
|
|
7
|
+
* Artifact inputs intentionally remain an empty, versioned extension point.
|
|
8
|
+
*/
|
|
9
|
+
export interface WorkspaceAgentRunEnvironmentSpecV1 {
|
|
10
|
+
schemaVersion: typeof WORKSPACE_AGENT_ENVIRONMENT_SPEC_VERSION;
|
|
11
|
+
workdir: {
|
|
12
|
+
sources: [];
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export type WorkspaceAgentRunStatus = "queued" | "running" | "cancelling" | "idle" | "failed" | "blocked" | "abandoned" | "cancelled";
|
|
16
|
+
export type WorkspaceAgentTurnStatus = "queued" | "offered" | "assigned" | "preparing" | "running" | "cancelling" | "completed" | "failed" | "execution_unknown" | "cancelled";
|
|
17
|
+
export type WorkspaceAgentTurnWaitReason = "fixed_device_offline" | "fixed_device_busy" | "fixed_device_incompatible" | "waiting_device" | "no_compatible_device" | "waiting_capacity";
|
|
18
|
+
export type WorkspaceAgentAttemptStatus = "assigned" | "preparing" | "running" | "cancelling" | "completed" | "failed" | "execution_unknown" | "cancelled";
|
|
19
|
+
/** Product surface that owns and presents this Agent Session. */
|
|
20
|
+
export type WorkspaceAgentRunOrigin = {
|
|
21
|
+
type: "agent_test";
|
|
22
|
+
};
|
|
23
|
+
/** AgentRun.id is the only product-facing Session ID. */
|
|
24
|
+
export interface WorkspaceAgentRun {
|
|
25
|
+
id: string;
|
|
26
|
+
workspaceId: string;
|
|
27
|
+
agentId: string;
|
|
28
|
+
agentRevisionId: string;
|
|
29
|
+
origin: WorkspaceAgentRunOrigin;
|
|
30
|
+
/** `idle` means the Session has no active Turn and may accept a follow-up.
|
|
31
|
+
* The latest Turn retains its own independent completed/failed outcome. */
|
|
32
|
+
status: WorkspaceAgentRunStatus;
|
|
33
|
+
pinnedDeviceId?: string;
|
|
34
|
+
activeTurnId?: string;
|
|
35
|
+
environment: WorkspaceAgentRunEnvironmentSpecV1;
|
|
36
|
+
createdByOpenId?: string;
|
|
37
|
+
createdByName?: string;
|
|
38
|
+
createdAt: string;
|
|
39
|
+
updatedAt: string;
|
|
40
|
+
/** Time the latest active Turn or terminal Session transition settled. */
|
|
41
|
+
settledAt?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface WorkspaceAgentRunTurn {
|
|
44
|
+
id: string;
|
|
45
|
+
workspaceId: string;
|
|
46
|
+
runId: string;
|
|
47
|
+
sequence: number;
|
|
48
|
+
kind: "initial" | "follow_up";
|
|
49
|
+
message: string;
|
|
50
|
+
status: WorkspaceAgentTurnStatus;
|
|
51
|
+
waitReason?: WorkspaceAgentTurnWaitReason;
|
|
52
|
+
/** Durable automatic-retry gate. The scheduler must not offer before it. */
|
|
53
|
+
retryNotBefore?: string;
|
|
54
|
+
currentAttemptId?: string;
|
|
55
|
+
createdByOpenId?: string;
|
|
56
|
+
createdByName?: string;
|
|
57
|
+
createdAt: string;
|
|
58
|
+
updatedAt: string;
|
|
59
|
+
completedAt?: string;
|
|
60
|
+
/** Durable execution output projected from this Turn's terminal event. */
|
|
61
|
+
result?: WorkspaceAgentTurnResult;
|
|
62
|
+
}
|
|
63
|
+
export interface WorkspaceAgentTurnResult {
|
|
64
|
+
finalResponse?: string;
|
|
65
|
+
artifactKeys?: string[];
|
|
66
|
+
}
|
|
67
|
+
export interface WorkspaceAgentRunAttempt {
|
|
68
|
+
id: string;
|
|
69
|
+
workspaceId: string;
|
|
70
|
+
runId: string;
|
|
71
|
+
turnId: string;
|
|
72
|
+
attemptNumber: number;
|
|
73
|
+
deviceId: string;
|
|
74
|
+
status: WorkspaceAgentAttemptStatus;
|
|
75
|
+
errorCode?: string;
|
|
76
|
+
errorMessage?: string;
|
|
77
|
+
createdAt: string;
|
|
78
|
+
updatedAt: string;
|
|
79
|
+
startedAt?: string;
|
|
80
|
+
completedAt?: string;
|
|
81
|
+
}
|
|
82
|
+
export interface WorkspaceAgentRunCancellation {
|
|
83
|
+
requestId: string;
|
|
84
|
+
workspaceId: string;
|
|
85
|
+
runId: string;
|
|
86
|
+
reason: string;
|
|
87
|
+
outcome: "pending" | "applied" | "too_late" | "unknown";
|
|
88
|
+
createdAt: string;
|
|
89
|
+
resolvedAt?: string;
|
|
90
|
+
}
|
|
91
|
+
export type WorkspaceAgentInteractionStatus = "pending" | "resolving" | "resolved" | "cancelled" | "expired";
|
|
92
|
+
export interface WorkspaceAgentInteractionOption {
|
|
93
|
+
value: string;
|
|
94
|
+
label: string;
|
|
95
|
+
description?: string;
|
|
96
|
+
}
|
|
97
|
+
export type WorkspaceAgentInteractionField = {
|
|
98
|
+
id: string;
|
|
99
|
+
type: "text";
|
|
100
|
+
label: string;
|
|
101
|
+
description?: string;
|
|
102
|
+
required?: boolean;
|
|
103
|
+
secret?: boolean;
|
|
104
|
+
multiline?: boolean;
|
|
105
|
+
placeholder?: string;
|
|
106
|
+
} | {
|
|
107
|
+
id: string;
|
|
108
|
+
type: "select";
|
|
109
|
+
label: string;
|
|
110
|
+
description?: string;
|
|
111
|
+
required?: boolean;
|
|
112
|
+
multiple?: boolean;
|
|
113
|
+
allowOther?: boolean;
|
|
114
|
+
options: WorkspaceAgentInteractionOption[];
|
|
115
|
+
};
|
|
116
|
+
export interface WorkspaceAgentInteractionAction {
|
|
117
|
+
id: string;
|
|
118
|
+
label: string;
|
|
119
|
+
description?: string;
|
|
120
|
+
style?: "primary" | "secondary" | "danger";
|
|
121
|
+
requiresAnswers: boolean;
|
|
122
|
+
}
|
|
123
|
+
/** Product-safe projection of a provider-neutral Session interaction. */
|
|
124
|
+
export interface WorkspaceAgentInteractionRequest {
|
|
125
|
+
interactionId: string;
|
|
126
|
+
kind: "question" | "permission" | "form";
|
|
127
|
+
title: string;
|
|
128
|
+
description?: string;
|
|
129
|
+
fields: WorkspaceAgentInteractionField[];
|
|
130
|
+
actions: WorkspaceAgentInteractionAction[];
|
|
131
|
+
context?: {
|
|
132
|
+
summary?: string;
|
|
133
|
+
toolName?: string;
|
|
134
|
+
command?: string;
|
|
135
|
+
cwd?: string;
|
|
136
|
+
diff?: string;
|
|
137
|
+
};
|
|
138
|
+
createdAt: string;
|
|
139
|
+
}
|
|
140
|
+
export type WorkspaceAgentInteractionAnswer = string | string[];
|
|
141
|
+
/** Answers are command-only input. Durable public projections expose actionId only. */
|
|
142
|
+
export interface WorkspaceAgentInteractionResolution {
|
|
143
|
+
actionId: string;
|
|
144
|
+
answers?: Record<string, WorkspaceAgentInteractionAnswer>;
|
|
145
|
+
}
|
|
146
|
+
export interface WorkspaceAgentInteraction {
|
|
147
|
+
id: string;
|
|
148
|
+
workspaceId: string;
|
|
149
|
+
runId: string;
|
|
150
|
+
turnId: string;
|
|
151
|
+
attemptId: string;
|
|
152
|
+
status: WorkspaceAgentInteractionStatus;
|
|
153
|
+
request: WorkspaceAgentInteractionRequest;
|
|
154
|
+
resolvedActionId?: string;
|
|
155
|
+
resolvedByOpenId?: string;
|
|
156
|
+
resolvedByName?: string;
|
|
157
|
+
resolutionError?: string;
|
|
158
|
+
createdAt: string;
|
|
159
|
+
updatedAt: string;
|
|
160
|
+
resolvedAt?: string;
|
|
161
|
+
}
|
|
162
|
+
export interface WorkspaceResolveAgentInteractionInput {
|
|
163
|
+
workspaceId: string;
|
|
164
|
+
runId: string;
|
|
165
|
+
interactionId: string;
|
|
166
|
+
requestId: string;
|
|
167
|
+
resolution: WorkspaceAgentInteractionResolution;
|
|
168
|
+
resolvedBy?: {
|
|
169
|
+
openId: string;
|
|
170
|
+
name?: string;
|
|
171
|
+
email?: string;
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
export type WorkspaceResolveAgentInteractionResult = {
|
|
175
|
+
status: "created" | "replayed";
|
|
176
|
+
interaction: WorkspaceAgentInteraction;
|
|
177
|
+
deviceId: string;
|
|
178
|
+
} | {
|
|
179
|
+
status: "not_found";
|
|
180
|
+
} | {
|
|
181
|
+
status: "conflict" | "invalid";
|
|
182
|
+
error: string;
|
|
183
|
+
};
|
|
184
|
+
export interface WorkspaceAgentRunEvent {
|
|
185
|
+
id: string;
|
|
186
|
+
workspaceId: string;
|
|
187
|
+
runId: string;
|
|
188
|
+
sequence: number;
|
|
189
|
+
turnId?: string;
|
|
190
|
+
attemptId?: string;
|
|
191
|
+
attemptSequence?: number;
|
|
192
|
+
type: string;
|
|
193
|
+
data: Record<string, unknown>;
|
|
194
|
+
occurredAt: string;
|
|
195
|
+
}
|
|
196
|
+
export interface WorkspaceAgentRunTurnPage {
|
|
197
|
+
turns: WorkspaceAgentRunTurn[];
|
|
198
|
+
attempts: WorkspaceAgentRunAttempt[];
|
|
199
|
+
interactions: WorkspaceAgentInteraction[];
|
|
200
|
+
turnPage: {
|
|
201
|
+
hasMore: boolean;
|
|
202
|
+
/** Exclusive Turn sequence cursor for the next older page. */
|
|
203
|
+
nextBeforeSequence?: number;
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
export interface WorkspaceAgentRunDetail extends WorkspaceAgentRun, WorkspaceAgentRunTurnPage {
|
|
207
|
+
cancellations: WorkspaceAgentRunCancellation[];
|
|
208
|
+
/** Durable SSE cursor captured with this detail snapshot. */
|
|
209
|
+
latestEventSequence: number;
|
|
210
|
+
}
|
|
211
|
+
export interface WorkspaceCreateAgentRunInput {
|
|
212
|
+
workspaceId: string;
|
|
213
|
+
agentId: string;
|
|
214
|
+
origin: WorkspaceAgentRunOrigin;
|
|
215
|
+
/** Initial Session binding. Automatic placement is pinned after assignment. */
|
|
216
|
+
placement: WorkspaceAgentPlacement;
|
|
217
|
+
requestId: string;
|
|
218
|
+
message: string;
|
|
219
|
+
createdBy?: {
|
|
220
|
+
openId: string;
|
|
221
|
+
name?: string;
|
|
222
|
+
email?: string;
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
export type WorkspaceCreateAgentRunResult = {
|
|
226
|
+
status: "created" | "replayed";
|
|
227
|
+
run: WorkspaceAgentRunDetail;
|
|
228
|
+
} | {
|
|
229
|
+
status: "not_found";
|
|
230
|
+
} | {
|
|
231
|
+
status: "invalid";
|
|
232
|
+
error: string;
|
|
233
|
+
};
|
|
234
|
+
export interface WorkspaceAppendAgentRunTurnInput {
|
|
235
|
+
workspaceId: string;
|
|
236
|
+
runId: string;
|
|
237
|
+
requestId: string;
|
|
238
|
+
message: string;
|
|
239
|
+
createdBy?: {
|
|
240
|
+
openId: string;
|
|
241
|
+
name?: string;
|
|
242
|
+
email?: string;
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
export type WorkspaceAppendAgentRunTurnResult = {
|
|
246
|
+
status: "created" | "replayed";
|
|
247
|
+
run: WorkspaceAgentRunDetail;
|
|
248
|
+
} | {
|
|
249
|
+
status: "not_found";
|
|
250
|
+
} | {
|
|
251
|
+
status: "conflict" | "invalid";
|
|
252
|
+
error: string;
|
|
253
|
+
};
|
|
254
|
+
/** Explicit operator recovery for an Attempt whose execution outcome cannot
|
|
255
|
+
* be proven. Abandoning never rolls back filesystem or external effects. */
|
|
256
|
+
export interface WorkspaceResolveBlockedAgentRunInput {
|
|
257
|
+
workspaceId: string;
|
|
258
|
+
runId: string;
|
|
259
|
+
requestId: string;
|
|
260
|
+
action: "abandon";
|
|
261
|
+
}
|
|
262
|
+
export type WorkspaceResolveBlockedAgentRunResult = {
|
|
263
|
+
status: "abandoned" | "replayed";
|
|
264
|
+
run: WorkspaceAgentRunDetail;
|
|
265
|
+
} | {
|
|
266
|
+
status: "not_found";
|
|
267
|
+
} | {
|
|
268
|
+
status: "conflict" | "invalid";
|
|
269
|
+
error: string;
|
|
270
|
+
};
|
|
271
|
+
/** Immutable payload sent only after a Daemon accepts an Offer. */
|
|
272
|
+
export interface WorkspaceAgentExecutionSpecV1 {
|
|
273
|
+
schemaVersion: typeof WORKSPACE_AGENT_EXECUTION_SPEC_VERSION;
|
|
274
|
+
runId: string;
|
|
275
|
+
turnId: string;
|
|
276
|
+
attemptId: string;
|
|
277
|
+
agentRevisionId: string;
|
|
278
|
+
agent: {
|
|
279
|
+
name: string;
|
|
280
|
+
description?: string;
|
|
281
|
+
instructions: string;
|
|
282
|
+
runtime: WorkspaceAgentRuntimeId;
|
|
283
|
+
model: string;
|
|
284
|
+
reasoningEffort?: string;
|
|
285
|
+
skills: WorkspaceAgentSkillRevisionRef[];
|
|
286
|
+
};
|
|
287
|
+
environment: WorkspaceAgentRunEnvironmentSpecV1;
|
|
288
|
+
message: string;
|
|
289
|
+
}
|
|
290
|
+
export declare function emptyWorkspaceAgentRunEnvironment(): WorkspaceAgentRunEnvironmentSpecV1;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const WORKSPACE_AGENT_EXECUTION_SPEC_VERSION = 1;
|
|
2
|
+
export const WORKSPACE_AGENT_ENVIRONMENT_SPEC_VERSION = 1;
|
|
3
|
+
export function emptyWorkspaceAgentRunEnvironment() {
|
|
4
|
+
return {
|
|
5
|
+
schemaVersion: WORKSPACE_AGENT_ENVIRONMENT_SPEC_VERSION,
|
|
6
|
+
workdir: { sources: [] },
|
|
7
|
+
};
|
|
8
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { WorkspaceAgentModelOption, WorkspaceAgentReasoningOption } from "./types.js";
|
|
2
|
+
export type WorkspaceAgentRuntimeId = "codex" | "traex" | "claude";
|
|
3
|
+
export declare const WORKSPACE_AGENT_RUNTIME_IDS: readonly WorkspaceAgentRuntimeId[];
|
|
4
|
+
export interface WorkspaceAgentRuntimeProfile {
|
|
5
|
+
id: WorkspaceAgentRuntimeId;
|
|
6
|
+
displayName: string;
|
|
7
|
+
defaultBinary: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const WORKSPACE_AGENT_RUNTIME_PROFILES: Record<WorkspaceAgentRuntimeId, WorkspaceAgentRuntimeProfile>;
|
|
10
|
+
export interface WorkspaceAgentModelEnv {
|
|
11
|
+
CODEX_MODEL?: string;
|
|
12
|
+
TRAEX_MODEL?: string;
|
|
13
|
+
TRAECLI_MODEL?: string;
|
|
14
|
+
CLAUDE_MODEL?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function isWorkspaceAgentRuntimeId(value: unknown): value is WorkspaceAgentRuntimeId;
|
|
17
|
+
export declare function getWorkspaceAgentRuntimeProfile(id: WorkspaceAgentRuntimeId): WorkspaceAgentRuntimeProfile;
|
|
18
|
+
export declare function workspaceAgentModelOptions(runtime: string, env?: WorkspaceAgentModelEnv): WorkspaceAgentModelOption[];
|
|
19
|
+
export declare function workspaceReasoningLabel(value: string): string;
|
|
20
|
+
export declare function workspaceAgentReasoningOptions(runtime: string, model: string): WorkspaceAgentReasoningOption[];
|
|
21
|
+
export interface WorkspaceAgentRuntimeCandidate {
|
|
22
|
+
runtime: string;
|
|
23
|
+
models?: WorkspaceAgentModelOption[];
|
|
24
|
+
}
|
|
25
|
+
/** Hard compatibility predicate used before a device receives a targeted Offer. */
|
|
26
|
+
export declare function workspaceRuntimeSupportsAgent(candidate: WorkspaceAgentRuntimeCandidate, runtime: WorkspaceAgentRuntimeId, model: string, reasoningEffort?: string): boolean;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
export const WORKSPACE_AGENT_RUNTIME_IDS = ["codex", "traex", "claude"];
|
|
2
|
+
export const WORKSPACE_AGENT_RUNTIME_PROFILES = {
|
|
3
|
+
codex: {
|
|
4
|
+
id: "codex",
|
|
5
|
+
displayName: "Codex",
|
|
6
|
+
defaultBinary: "codex",
|
|
7
|
+
},
|
|
8
|
+
traex: {
|
|
9
|
+
id: "traex",
|
|
10
|
+
displayName: "Traex",
|
|
11
|
+
defaultBinary: "traex",
|
|
12
|
+
},
|
|
13
|
+
claude: {
|
|
14
|
+
id: "claude",
|
|
15
|
+
displayName: "Claude Code",
|
|
16
|
+
defaultBinary: "claude",
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
export function isWorkspaceAgentRuntimeId(value) {
|
|
20
|
+
return value === "codex" || value === "traex" || value === "claude";
|
|
21
|
+
}
|
|
22
|
+
export function getWorkspaceAgentRuntimeProfile(id) {
|
|
23
|
+
return WORKSPACE_AGENT_RUNTIME_PROFILES[id];
|
|
24
|
+
}
|
|
25
|
+
export function workspaceAgentModelOptions(runtime, env = {}) {
|
|
26
|
+
if (!isWorkspaceAgentRuntimeId(runtime))
|
|
27
|
+
return [];
|
|
28
|
+
if (runtime === "claude")
|
|
29
|
+
return claudeModelOptions(env.CLAUDE_MODEL);
|
|
30
|
+
const model = runtime === "traex"
|
|
31
|
+
? env.TRAEX_MODEL?.trim() || env.TRAECLI_MODEL?.trim()
|
|
32
|
+
: env.CODEX_MODEL?.trim() || "gpt-5.5";
|
|
33
|
+
return model
|
|
34
|
+
? [
|
|
35
|
+
{
|
|
36
|
+
id: model,
|
|
37
|
+
label: model,
|
|
38
|
+
isDefault: true,
|
|
39
|
+
},
|
|
40
|
+
]
|
|
41
|
+
: [];
|
|
42
|
+
}
|
|
43
|
+
const CLAUDE_DEFAULT_MODEL = "claude-sonnet-4-6";
|
|
44
|
+
const CLAUDE_MODEL_IDS = [
|
|
45
|
+
{ id: "claude-opus-4-8", label: "Claude Opus 4.8" },
|
|
46
|
+
{ id: "claude-sonnet-4-6", label: "Claude Sonnet 4.6" },
|
|
47
|
+
{ id: "claude-haiku-4-5", label: "Claude Haiku 4.5" },
|
|
48
|
+
{ id: "claude-opus-4-7", label: "Claude Opus 4.7" },
|
|
49
|
+
{ id: "claude-opus-4-6", label: "Claude Opus 4.6" },
|
|
50
|
+
{ id: "claude-fable-5", label: "Claude Fable 5" },
|
|
51
|
+
];
|
|
52
|
+
function claudeModelOptions(configuredModel) {
|
|
53
|
+
const defaultModel = configuredModel?.trim() || CLAUDE_DEFAULT_MODEL;
|
|
54
|
+
const known = new Set(CLAUDE_MODEL_IDS.map((model) => model.id));
|
|
55
|
+
const models = known.has(defaultModel)
|
|
56
|
+
? CLAUDE_MODEL_IDS
|
|
57
|
+
: [{ id: defaultModel, label: defaultModel }, ...CLAUDE_MODEL_IDS];
|
|
58
|
+
return models.map((model) => ({
|
|
59
|
+
id: model.id,
|
|
60
|
+
label: model.label,
|
|
61
|
+
isDefault: model.id === defaultModel,
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
const REASONING_LABELS = {
|
|
65
|
+
none: "None",
|
|
66
|
+
minimal: "Minimal",
|
|
67
|
+
low: "Low",
|
|
68
|
+
medium: "Medium",
|
|
69
|
+
high: "High",
|
|
70
|
+
xhigh: "Extra high",
|
|
71
|
+
max: "Max",
|
|
72
|
+
ultra: "Ultra",
|
|
73
|
+
};
|
|
74
|
+
export function workspaceReasoningLabel(value) {
|
|
75
|
+
return REASONING_LABELS[value] ?? value;
|
|
76
|
+
}
|
|
77
|
+
export function workspaceAgentReasoningOptions(runtime, model) {
|
|
78
|
+
const values = runtime === "claude"
|
|
79
|
+
? model.toLowerCase().includes("opus")
|
|
80
|
+
? ["low", "medium", "high", "xhigh"]
|
|
81
|
+
: ["low", "medium", "high"]
|
|
82
|
+
: runtime === "codex" || runtime === "traex"
|
|
83
|
+
? ["none", "minimal", "low", "medium", "high", "xhigh"]
|
|
84
|
+
: [];
|
|
85
|
+
return values.map((value) => ({
|
|
86
|
+
value,
|
|
87
|
+
label: workspaceReasoningLabel(value),
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
/** Hard compatibility predicate used before a device receives a targeted Offer. */
|
|
91
|
+
export function workspaceRuntimeSupportsAgent(candidate, runtime, model, reasoningEffort) {
|
|
92
|
+
if (candidate.runtime !== runtime)
|
|
93
|
+
return false;
|
|
94
|
+
const models = candidate.models?.length
|
|
95
|
+
? candidate.models
|
|
96
|
+
: workspaceAgentModelOptions(runtime);
|
|
97
|
+
const selected = models.find((option) => option.id === model);
|
|
98
|
+
if (!selected)
|
|
99
|
+
return false;
|
|
100
|
+
if (!reasoningEffort)
|
|
101
|
+
return true;
|
|
102
|
+
const efforts = selected.supportedReasoningEfforts?.length
|
|
103
|
+
? selected.supportedReasoningEfforts
|
|
104
|
+
: workspaceAgentReasoningOptions(runtime, model);
|
|
105
|
+
return efforts.some((option) => option.value === reasoningEffort);
|
|
106
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import type { WorkspaceAgentAttemptEventMessage, WorkspaceAgentInteractionResolveAckMessage, WorkspaceAgentInteractionResolveMessage, WorkspaceAgentTurnAssignAckMessage, WorkspaceAgentTurnAssignMessage, WorkspaceAgentTurnCancelAckMessage, WorkspaceAgentTurnCancelMessage, WorkspaceAgentTurnOfferBusyReason, WorkspaceAgentTurnOfferMessage } from "./device-protocol.js";
|
|
2
|
+
import type { WorkspaceAgentTurnWaitReason } from "./agent-execution.js";
|
|
3
|
+
export interface WorkspaceAgentSchedulableTurn {
|
|
4
|
+
workspaceId: string;
|
|
5
|
+
runId: string;
|
|
6
|
+
turnId: string;
|
|
7
|
+
agentId: string;
|
|
8
|
+
agentRevisionId: string;
|
|
9
|
+
pinnedDeviceId?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface WorkspaceAgentOutboxCommand {
|
|
12
|
+
id: string;
|
|
13
|
+
workspaceId: string;
|
|
14
|
+
deviceId: string;
|
|
15
|
+
attemptId?: string;
|
|
16
|
+
kind: "turn.assign" | "turn.cancel" | "interaction.resolve";
|
|
17
|
+
payload: WorkspaceAgentTurnAssignMessage | WorkspaceAgentTurnCancelMessage | WorkspaceAgentInteractionResolveMessage;
|
|
18
|
+
state: "pending" | "sent" | "acked" | "cancelled";
|
|
19
|
+
availableAt: string;
|
|
20
|
+
sendAttempts: number;
|
|
21
|
+
lastError?: string;
|
|
22
|
+
createdAt: string;
|
|
23
|
+
updatedAt: string;
|
|
24
|
+
sentAt?: string;
|
|
25
|
+
ackedAt?: string;
|
|
26
|
+
}
|
|
27
|
+
/** Durable operations required by the Server scheduler. Live socket presence
|
|
28
|
+
* and candidate ranking deliberately remain outside this interface. */
|
|
29
|
+
export interface WorkspaceAgentSchedulerPlane {
|
|
30
|
+
listAgentSchedulableTurns(input?: {
|
|
31
|
+
workspaceId?: string;
|
|
32
|
+
limit?: number;
|
|
33
|
+
now?: string;
|
|
34
|
+
}): WorkspaceAgentSchedulableTurn[];
|
|
35
|
+
markAgentTurnWaiting(input: {
|
|
36
|
+
workspaceId: string;
|
|
37
|
+
runId: string;
|
|
38
|
+
turnId: string;
|
|
39
|
+
reason: WorkspaceAgentTurnWaitReason;
|
|
40
|
+
}): "committed" | "duplicate" | "stale";
|
|
41
|
+
createAgentTurnOffer(input: {
|
|
42
|
+
id?: string;
|
|
43
|
+
workspaceId: string;
|
|
44
|
+
runId: string;
|
|
45
|
+
turnId: string;
|
|
46
|
+
deviceId: string;
|
|
47
|
+
expiresAt: string;
|
|
48
|
+
}): {
|
|
49
|
+
status: "created" | "replayed";
|
|
50
|
+
message: WorkspaceAgentTurnOfferMessage;
|
|
51
|
+
} | {
|
|
52
|
+
status: "not_found" | "conflict" | "invalid";
|
|
53
|
+
error: string;
|
|
54
|
+
};
|
|
55
|
+
acceptAgentTurnOffer(input: {
|
|
56
|
+
workspaceId: string;
|
|
57
|
+
deviceId: string;
|
|
58
|
+
offerId: string;
|
|
59
|
+
daemonInstanceId: string;
|
|
60
|
+
permitId: string;
|
|
61
|
+
leaseMs: number;
|
|
62
|
+
}): {
|
|
63
|
+
status: "assigned" | "replayed";
|
|
64
|
+
command: WorkspaceAgentTurnAssignMessage;
|
|
65
|
+
} | {
|
|
66
|
+
status: "expired" | "stale" | "conflict";
|
|
67
|
+
error: string;
|
|
68
|
+
};
|
|
69
|
+
markAgentTurnOfferBusy(input: {
|
|
70
|
+
workspaceId: string;
|
|
71
|
+
deviceId: string;
|
|
72
|
+
offerId: string;
|
|
73
|
+
daemonInstanceId: string;
|
|
74
|
+
reason: WorkspaceAgentTurnOfferBusyReason;
|
|
75
|
+
}): "committed" | "duplicate" | "expired" | "stale";
|
|
76
|
+
expireAgentTurnOffers(input?: {
|
|
77
|
+
workspaceId?: string;
|
|
78
|
+
now?: string;
|
|
79
|
+
}): number;
|
|
80
|
+
listAgentOutboxCommands(input: {
|
|
81
|
+
workspaceId: string;
|
|
82
|
+
deviceId: string;
|
|
83
|
+
daemonInstanceId: string;
|
|
84
|
+
/** Recovery-only: include acknowledged Assignments that still belong to
|
|
85
|
+
* the current leased Attempt for this exact daemon process instance. */
|
|
86
|
+
includeAcknowledgedAssignments?: boolean;
|
|
87
|
+
limit?: number;
|
|
88
|
+
now?: string;
|
|
89
|
+
}): WorkspaceAgentOutboxCommand[];
|
|
90
|
+
markAgentOutboxCommandSent(input: {
|
|
91
|
+
workspaceId: string;
|
|
92
|
+
deviceId: string;
|
|
93
|
+
commandId: string;
|
|
94
|
+
error?: string;
|
|
95
|
+
}): "sent" | "stale";
|
|
96
|
+
acknowledgeAgentTurnAssignment(input: {
|
|
97
|
+
workspaceId: string;
|
|
98
|
+
deviceId: string;
|
|
99
|
+
ack: WorkspaceAgentTurnAssignAckMessage;
|
|
100
|
+
}): "committed" | "duplicate" | "stale";
|
|
101
|
+
requestAgentTurnCancellation(input: {
|
|
102
|
+
workspaceId: string;
|
|
103
|
+
runId: string;
|
|
104
|
+
requestId: string;
|
|
105
|
+
reason: string;
|
|
106
|
+
}): {
|
|
107
|
+
status: "created" | "replayed";
|
|
108
|
+
command: WorkspaceAgentTurnCancelMessage;
|
|
109
|
+
} | {
|
|
110
|
+
status: "cancelled";
|
|
111
|
+
} | {
|
|
112
|
+
status: "not_found" | "not_active" | "stale" | "conflict";
|
|
113
|
+
error: string;
|
|
114
|
+
};
|
|
115
|
+
acknowledgeAgentTurnCancellation(input: {
|
|
116
|
+
workspaceId: string;
|
|
117
|
+
deviceId: string;
|
|
118
|
+
ack: WorkspaceAgentTurnCancelAckMessage;
|
|
119
|
+
}): "committed" | "duplicate" | "stale";
|
|
120
|
+
acknowledgeAgentInteractionResolution(input: {
|
|
121
|
+
workspaceId: string;
|
|
122
|
+
deviceId: string;
|
|
123
|
+
ack: WorkspaceAgentInteractionResolveAckMessage;
|
|
124
|
+
}): "committed" | "duplicate" | "stale";
|
|
125
|
+
renewAgentAttemptLease(input: {
|
|
126
|
+
workspaceId: string;
|
|
127
|
+
deviceId: string;
|
|
128
|
+
attemptId: string;
|
|
129
|
+
assignmentEpoch: number;
|
|
130
|
+
leaseToken: string;
|
|
131
|
+
daemonInstanceId: string;
|
|
132
|
+
leaseMs: number;
|
|
133
|
+
}): {
|
|
134
|
+
disposition: "renewed" | "stale";
|
|
135
|
+
leaseExpiresAt?: string;
|
|
136
|
+
};
|
|
137
|
+
commitAgentAttemptEvent(input: {
|
|
138
|
+
workspaceId: string;
|
|
139
|
+
deviceId: string;
|
|
140
|
+
event: WorkspaceAgentAttemptEventMessage;
|
|
141
|
+
}): {
|
|
142
|
+
disposition: "committed" | "duplicate" | "stale" | "rejected";
|
|
143
|
+
runSequence?: number;
|
|
144
|
+
};
|
|
145
|
+
expireAgentAttemptLeases(input?: {
|
|
146
|
+
workspaceId?: string;
|
|
147
|
+
now?: string;
|
|
148
|
+
}): number;
|
|
149
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|