@serviceme/devtools-protocol 0.0.6 → 0.1.2
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/index.d.mts +237 -126
- package/dist/index.d.ts +237 -126
- package/dist/index.js +142 -97
- package/dist/index.mjs +129 -84
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,58 +1,87 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/scheduled-tasks.ts
|
|
2
|
+
var VALID_TASK_TYPES = [
|
|
3
|
+
"shell",
|
|
4
|
+
"http_request",
|
|
5
|
+
"github_copilot_cli"
|
|
6
|
+
];
|
|
7
|
+
var VALID_SCHEDULE_TYPES = ["cron", "interval"];
|
|
8
|
+
var VALID_TERMINAL_STATUSES = ["success", "failure", "timeout", "cancelled"];
|
|
2
9
|
function isRecord(value) {
|
|
3
10
|
return typeof value === "object" && value !== null;
|
|
4
11
|
}
|
|
5
|
-
function
|
|
6
|
-
return
|
|
12
|
+
function isScheduledTaskType(value) {
|
|
13
|
+
return typeof value === "string" && VALID_TASK_TYPES.includes(value);
|
|
14
|
+
}
|
|
15
|
+
function isScheduledTask(value) {
|
|
16
|
+
if (!isRecord(value)) return false;
|
|
17
|
+
return typeof value.id === "string" && typeof value.name === "string" && typeof value.enabled === "boolean" && VALID_SCHEDULE_TYPES.includes(value.scheduleType) && typeof value.schedule === "string" && isScheduledTaskType(value.taskType) && isRecord(value.payload) && typeof value.createdAt === "string" && typeof value.updatedAt === "string";
|
|
18
|
+
}
|
|
19
|
+
function isTaskExecutionLog(value) {
|
|
20
|
+
if (!isRecord(value)) return false;
|
|
21
|
+
return typeof value.id === "string" && typeof value.taskId === "string" && typeof value.taskName === "string" && typeof value.startedAt === "string" && typeof value.finishedAt === "string" && VALID_TERMINAL_STATUSES.includes(
|
|
22
|
+
value.status
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
function isSchedulerStatus(value) {
|
|
26
|
+
if (!isRecord(value)) return false;
|
|
27
|
+
return typeof value.running === "boolean" && typeof value.tasksRegistered === "number" && typeof value.workspacePath === "string";
|
|
7
28
|
}
|
|
8
|
-
function
|
|
9
|
-
return isRecord(value) && typeof value.
|
|
29
|
+
function isTaskExecuteResult(value) {
|
|
30
|
+
return isRecord(value) && typeof value.executionId === "string" && value.accepted === true;
|
|
10
31
|
}
|
|
11
|
-
function
|
|
12
|
-
return value ===
|
|
32
|
+
function isTaskCancelResult(value) {
|
|
33
|
+
return isRecord(value) && typeof value.executionId === "string" && typeof value.cancelled === "boolean";
|
|
13
34
|
}
|
|
14
|
-
function
|
|
15
|
-
return isRecord(value) &&
|
|
35
|
+
function isTaskListRunningResult(value) {
|
|
36
|
+
return isRecord(value) && Array.isArray(value.executions);
|
|
16
37
|
}
|
|
17
|
-
function
|
|
18
|
-
return isRecord(value) && value.
|
|
38
|
+
function isTaskStartedEventParams(value) {
|
|
39
|
+
return isRecord(value) && typeof value.executionId === "string" && typeof value.taskId === "string" && typeof value.startedAt === "string";
|
|
19
40
|
}
|
|
20
|
-
function
|
|
21
|
-
return isRecord(value) && value.
|
|
41
|
+
function isTaskOutputEventParams(value) {
|
|
42
|
+
return isRecord(value) && typeof value.executionId === "string" && (value.stream === "stdout" || value.stream === "stderr") && typeof value.data === "string";
|
|
22
43
|
}
|
|
23
|
-
function
|
|
24
|
-
return isRecord(value) &&
|
|
44
|
+
function isTaskCompletedEventParams(value) {
|
|
45
|
+
return isRecord(value) && typeof value.executionId === "string" && isTaskExecutionLog(value.log);
|
|
25
46
|
}
|
|
26
|
-
function
|
|
27
|
-
return isRecord(value) && value.
|
|
47
|
+
function isTaskFailedEventParams(value) {
|
|
48
|
+
return isRecord(value) && typeof value.executionId === "string" && (value.status === "failure" || value.status === "timeout") && (value.reason === "error" || value.reason === "timeout") && isTaskExecutionLog(value.log);
|
|
28
49
|
}
|
|
29
|
-
function
|
|
30
|
-
return
|
|
50
|
+
function isTaskCancelledEventParams(value) {
|
|
51
|
+
return isRecord(value) && typeof value.executionId === "string" && isTaskExecutionLog(value.log);
|
|
52
|
+
}
|
|
53
|
+
function isAgentSessionStatus(value) {
|
|
54
|
+
return value === "idle" || value === "running" || value === "needs-input" || value === "completed" || value === "failed" || value === "aborted";
|
|
31
55
|
}
|
|
32
56
|
|
|
33
57
|
// src/bridge.ts
|
|
34
|
-
var SERVICEME_PROTOCOL_VERSION =
|
|
58
|
+
var SERVICEME_PROTOCOL_VERSION = 2;
|
|
35
59
|
function isRecord2(value) {
|
|
36
60
|
return typeof value === "object" && value !== null;
|
|
37
61
|
}
|
|
62
|
+
function isValidProtocolVersion(value) {
|
|
63
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 1 && value <= SERVICEME_PROTOCOL_VERSION;
|
|
64
|
+
}
|
|
38
65
|
function isBridgeCapabilities(value) {
|
|
39
|
-
return isRecord2(value) && value.bridge === true && value.
|
|
66
|
+
return isRecord2(value) && value.bridge === true && value.json === 1 && value.env === 1 && (value.tasks === void 0 || value.tasks === 1);
|
|
40
67
|
}
|
|
41
68
|
var BRIDGE_METHODS = [
|
|
42
69
|
"system.hello",
|
|
43
70
|
"system.ping",
|
|
44
71
|
"system.shutdown",
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"
|
|
51
|
-
"
|
|
72
|
+
"task.execute",
|
|
73
|
+
"task.cancel",
|
|
74
|
+
"task.list-running"
|
|
75
|
+
];
|
|
76
|
+
var BRIDGE_EVENTS = [
|
|
77
|
+
"task.started",
|
|
78
|
+
"task.output",
|
|
79
|
+
"task.completed",
|
|
80
|
+
"task.failed",
|
|
81
|
+
"task.cancelled"
|
|
52
82
|
];
|
|
53
|
-
var BRIDGE_EVENTS = ["opencode.session.event"];
|
|
54
83
|
function isSystemHelloResult(value) {
|
|
55
|
-
return isRecord2(value) && typeof value.cliVersion === "string" && value.protocolVersion
|
|
84
|
+
return isRecord2(value) && typeof value.cliVersion === "string" && isValidProtocolVersion(value.protocolVersion) && isBridgeCapabilities(value.capabilities) && typeof value.pid === "number";
|
|
56
85
|
}
|
|
57
86
|
function isSystemPingResult(value) {
|
|
58
87
|
return isRecord2(value) && typeof value.now === "string";
|
|
@@ -60,21 +89,6 @@ function isSystemPingResult(value) {
|
|
|
60
89
|
function isSystemShutdownResult(value) {
|
|
61
90
|
return isRecord2(value) && value.shuttingDown === true;
|
|
62
91
|
}
|
|
63
|
-
function isOpenCodeSessionCreateResult(value) {
|
|
64
|
-
return isRecord2(value) && typeof value.sessionId === "string" && (value.title === void 0 || typeof value.title === "string") && isAgentSessionStatus(value.status);
|
|
65
|
-
}
|
|
66
|
-
function isOpenCodeSessionPromptResult(value) {
|
|
67
|
-
return isRecord2(value) && value.accepted === true && typeof value.sessionId === "string" && typeof value.promptId === "string";
|
|
68
|
-
}
|
|
69
|
-
function isOpenCodeSessionStatusResult(value) {
|
|
70
|
-
return isRecord2(value) && typeof value.sessionId === "string" && isAgentSessionStatus(value.status);
|
|
71
|
-
}
|
|
72
|
-
function isOpenCodeSessionAbortResult(value) {
|
|
73
|
-
return isRecord2(value) && value.aborted === true && typeof value.sessionId === "string";
|
|
74
|
-
}
|
|
75
|
-
function isOpenCodeSessionDisposeResult(value) {
|
|
76
|
-
return isRecord2(value) && value.disposed === true && typeof value.sessionId === "string";
|
|
77
|
-
}
|
|
78
92
|
function getBridgeResultValidator(method) {
|
|
79
93
|
switch (method) {
|
|
80
94
|
case "system.hello":
|
|
@@ -83,30 +97,28 @@ function getBridgeResultValidator(method) {
|
|
|
83
97
|
return isSystemPingResult;
|
|
84
98
|
case "system.shutdown":
|
|
85
99
|
return isSystemShutdownResult;
|
|
86
|
-
case "
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
return isOpenCodeSessionPromptResult;
|
|
93
|
-
case "opencode.session.status":
|
|
94
|
-
return isOpenCodeSessionStatusResult;
|
|
95
|
-
case "opencode.session.abort":
|
|
96
|
-
return isOpenCodeSessionAbortResult;
|
|
97
|
-
case "opencode.session.dispose":
|
|
98
|
-
return isOpenCodeSessionDisposeResult;
|
|
100
|
+
case "task.execute":
|
|
101
|
+
return isTaskExecuteResult;
|
|
102
|
+
case "task.cancel":
|
|
103
|
+
return isTaskCancelResult;
|
|
104
|
+
case "task.list-running":
|
|
105
|
+
return isTaskListRunningResult;
|
|
99
106
|
default:
|
|
100
107
|
return void 0;
|
|
101
108
|
}
|
|
102
109
|
}
|
|
103
|
-
function isOpenCodeSessionEventParams(value) {
|
|
104
|
-
return isRecord2(value) && typeof value.sessionId === "string" && (value.promptId === void 0 || typeof value.promptId === "string") && isOpenCodeAgentEvent(value.payload);
|
|
105
|
-
}
|
|
106
110
|
function getBridgeEventParamsValidator(event) {
|
|
107
111
|
switch (event) {
|
|
108
|
-
case "
|
|
109
|
-
return
|
|
112
|
+
case "task.started":
|
|
113
|
+
return isTaskStartedEventParams;
|
|
114
|
+
case "task.output":
|
|
115
|
+
return isTaskOutputEventParams;
|
|
116
|
+
case "task.completed":
|
|
117
|
+
return isTaskCompletedEventParams;
|
|
118
|
+
case "task.failed":
|
|
119
|
+
return isTaskFailedEventParams;
|
|
120
|
+
case "task.cancelled":
|
|
121
|
+
return isTaskCancelledEventParams;
|
|
110
122
|
default:
|
|
111
123
|
return void 0;
|
|
112
124
|
}
|
|
@@ -121,13 +133,13 @@ function isBridgeRequest(value) {
|
|
|
121
133
|
if (!isRecord2(value)) {
|
|
122
134
|
return false;
|
|
123
135
|
}
|
|
124
|
-
return value.protocolVersion
|
|
136
|
+
return isValidProtocolVersion(value.protocolVersion) && value.kind === "request" && typeof value.id === "string" && isBridgeMethod(value.method) && "params" in value;
|
|
125
137
|
}
|
|
126
138
|
function isBridgeResponse(value) {
|
|
127
139
|
if (!isRecord2(value)) {
|
|
128
140
|
return false;
|
|
129
141
|
}
|
|
130
|
-
if (value.protocolVersion
|
|
142
|
+
if (!isValidProtocolVersion(value.protocolVersion) || value.kind !== "response" || typeof value.id !== "string" || typeof value.ok !== "boolean") {
|
|
131
143
|
return false;
|
|
132
144
|
}
|
|
133
145
|
if (value.ok) {
|
|
@@ -139,7 +151,7 @@ function isBridgeEvent(value) {
|
|
|
139
151
|
if (!isRecord2(value)) {
|
|
140
152
|
return false;
|
|
141
153
|
}
|
|
142
|
-
return value.protocolVersion
|
|
154
|
+
return isValidProtocolVersion(value.protocolVersion) && value.kind === "event" && isBridgeEventName(value.event) && "params" in value;
|
|
143
155
|
}
|
|
144
156
|
|
|
145
157
|
// src/cli.ts
|
|
@@ -174,6 +186,14 @@ function isCliEnvelope(value) {
|
|
|
174
186
|
return "error" in value;
|
|
175
187
|
}
|
|
176
188
|
|
|
189
|
+
// src/copilot.ts
|
|
190
|
+
var COPILOT_ERROR_CODES = {
|
|
191
|
+
NOT_INSTALLED: "copilot_not_installed",
|
|
192
|
+
AUTH_REQUIRED: "copilot_auth_required",
|
|
193
|
+
EXECUTION_FAILED: "copilot_execution_failed",
|
|
194
|
+
TIMEOUT: "copilot_timeout"
|
|
195
|
+
};
|
|
196
|
+
|
|
177
197
|
// src/env.ts
|
|
178
198
|
var KNOWN_ENVIRONMENT_TOOLS = [
|
|
179
199
|
"git",
|
|
@@ -201,7 +221,9 @@ function isEnvironmentCheckResult(value) {
|
|
|
201
221
|
if (!isRecord4(value)) {
|
|
202
222
|
return false;
|
|
203
223
|
}
|
|
204
|
-
return KNOWN_ENVIRONMENT_TOOLS.every(
|
|
224
|
+
return KNOWN_ENVIRONMENT_TOOLS.every(
|
|
225
|
+
(tool) => isToolCheckResult(value[tool])
|
|
226
|
+
);
|
|
205
227
|
}
|
|
206
228
|
|
|
207
229
|
// src/errors.ts
|
|
@@ -217,8 +239,22 @@ var SERVICEME_ERROR_CODES = [
|
|
|
217
239
|
"opencode_request_failed",
|
|
218
240
|
"opencode_backend_not_running",
|
|
219
241
|
"opencode_session_not_found",
|
|
242
|
+
"copilot_not_installed",
|
|
243
|
+
"copilot_auth_required",
|
|
244
|
+
"copilot_execution_failed",
|
|
245
|
+
"copilot_timeout",
|
|
220
246
|
"json_invalid_input",
|
|
221
247
|
"env_tool_not_found",
|
|
248
|
+
"task_not_found",
|
|
249
|
+
"task_already_exists",
|
|
250
|
+
"invalid_schedule",
|
|
251
|
+
"invalid_payload",
|
|
252
|
+
"confirmation_required",
|
|
253
|
+
"workspace_not_found",
|
|
254
|
+
"daemon_not_running",
|
|
255
|
+
"executor_timeout",
|
|
256
|
+
"executor_error",
|
|
257
|
+
"task_already_running",
|
|
222
258
|
"internal_error"
|
|
223
259
|
];
|
|
224
260
|
var RETRYABLE_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
@@ -227,6 +263,8 @@ var RETRYABLE_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
|
227
263
|
"opencode_startup_timeout",
|
|
228
264
|
"opencode_request_failed",
|
|
229
265
|
"opencode_backend_not_running",
|
|
266
|
+
"copilot_timeout",
|
|
267
|
+
"executor_timeout",
|
|
230
268
|
"internal_error"
|
|
231
269
|
]);
|
|
232
270
|
function isRecord5(value) {
|
|
@@ -302,7 +340,11 @@ function normalizeServicemeError(error, fallbackCode = "internal_error") {
|
|
|
302
340
|
}
|
|
303
341
|
|
|
304
342
|
// src/image.ts
|
|
305
|
-
var SERVICEME_IMAGE_FORMATS = [
|
|
343
|
+
var SERVICEME_IMAGE_FORMATS = [
|
|
344
|
+
"jpeg",
|
|
345
|
+
"png",
|
|
346
|
+
"webp"
|
|
347
|
+
];
|
|
306
348
|
function isRecord6(value) {
|
|
307
349
|
return typeof value === "object" && value !== null;
|
|
308
350
|
}
|
|
@@ -339,7 +381,10 @@ var JSON_SORT_ALGORITHMS = [
|
|
|
339
381
|
"values",
|
|
340
382
|
"type"
|
|
341
383
|
];
|
|
342
|
-
var JSON_SORT_ORDERS = [
|
|
384
|
+
var JSON_SORT_ORDERS = [
|
|
385
|
+
"asc",
|
|
386
|
+
"desc"
|
|
387
|
+
];
|
|
343
388
|
var DEFAULT_JSON_SORT_OPTIONS = {
|
|
344
389
|
sortOrder: "asc",
|
|
345
390
|
sortAlgo: "default"
|
|
@@ -365,10 +410,10 @@ function isJsonOutputResult(value) {
|
|
|
365
410
|
|
|
366
411
|
// src/metadata.ts
|
|
367
412
|
var SERVICEME_CLI_NAME = "serviceme";
|
|
368
|
-
var SERVICEME_CLI_VERSION = "0.
|
|
413
|
+
var SERVICEME_CLI_VERSION = "0.1.2";
|
|
369
414
|
var SERVICEME_CLI_CAPABILITIES = {
|
|
370
415
|
bridge: true,
|
|
371
|
-
|
|
416
|
+
tasks: 1,
|
|
372
417
|
json: 1,
|
|
373
418
|
env: 1,
|
|
374
419
|
image: 1,
|
|
@@ -406,6 +451,7 @@ function isServiceMeProjectExtractTemplateResult(value) {
|
|
|
406
451
|
export {
|
|
407
452
|
BRIDGE_EVENTS,
|
|
408
453
|
BRIDGE_METHODS,
|
|
454
|
+
COPILOT_ERROR_CODES,
|
|
409
455
|
DEFAULT_JSON_SORT_OPTIONS,
|
|
410
456
|
JSON_SORT_ALGORITHMS,
|
|
411
457
|
JSON_SORT_ORDERS,
|
|
@@ -438,20 +484,10 @@ export {
|
|
|
438
484
|
isJsonSortOrder,
|
|
439
485
|
isJsonValidationResult,
|
|
440
486
|
isKnownEnvironmentTool,
|
|
441
|
-
isOpenCodeAgentEvent,
|
|
442
|
-
isOpenCodeServerState,
|
|
443
|
-
isOpenCodeSessionAbortResult,
|
|
444
|
-
isOpenCodeSessionCompletedEvent,
|
|
445
|
-
isOpenCodeSessionCreateResult,
|
|
446
|
-
isOpenCodeSessionDisposeResult,
|
|
447
|
-
isOpenCodeSessionErrorEvent,
|
|
448
|
-
isOpenCodeSessionEventParams,
|
|
449
|
-
isOpenCodeSessionMessageEvent,
|
|
450
|
-
isOpenCodeSessionProgressEvent,
|
|
451
|
-
isOpenCodeSessionPromptResult,
|
|
452
|
-
isOpenCodeSessionStatusEvent,
|
|
453
|
-
isOpenCodeSessionStatusResult,
|
|
454
487
|
isRetryableErrorCode,
|
|
488
|
+
isScheduledTask,
|
|
489
|
+
isScheduledTaskType,
|
|
490
|
+
isSchedulerStatus,
|
|
455
491
|
isServiceMeImageCompressOptions,
|
|
456
492
|
isServiceMeImageCompressResult,
|
|
457
493
|
isServiceMeImageFormat,
|
|
@@ -468,6 +504,15 @@ export {
|
|
|
468
504
|
isSystemHelloResult,
|
|
469
505
|
isSystemPingResult,
|
|
470
506
|
isSystemShutdownResult,
|
|
507
|
+
isTaskCancelResult,
|
|
508
|
+
isTaskCancelledEventParams,
|
|
509
|
+
isTaskCompletedEventParams,
|
|
510
|
+
isTaskExecuteResult,
|
|
511
|
+
isTaskExecutionLog,
|
|
512
|
+
isTaskFailedEventParams,
|
|
513
|
+
isTaskListRunningResult,
|
|
514
|
+
isTaskOutputEventParams,
|
|
515
|
+
isTaskStartedEventParams,
|
|
471
516
|
isToolCheckResult,
|
|
472
517
|
normalizeServicemeError
|
|
473
518
|
};
|
package/package.json
CHANGED