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