@serviceme/devtools-protocol 0.0.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/LICENSE.md +46 -0
- package/README.md +21 -0
- package/dist/bridge.d.ts +159 -0
- package/dist/bridge.js +139 -0
- package/dist/bridge.js.map +1 -0
- package/dist/cli.d.ts +16 -0
- package/dist/cli.js +31 -0
- package/dist/cli.js.map +1 -0
- package/dist/env.d.ts +12 -0
- package/dist/env.js +32 -0
- package/dist/env.js.map +1 -0
- package/dist/errors.d.ts +25 -0
- package/dist/errors.js +98 -0
- package/dist/errors.js.map +1 -0
- package/dist/image.d.ts +31 -0
- package/dist/image.js +43 -0
- package/dist/image.js.map +1 -0
- package/dist/index.d.mts +358 -0
- package/dist/index.d.ts +358 -0
- package/dist/index.js +565 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +473 -0
- package/dist/json.d.ts +20 -0
- package/dist/json.js +33 -0
- package/dist/json.js.map +1 -0
- package/dist/metadata.d.ts +10 -0
- package/dist/metadata.js +11 -0
- package/dist/metadata.js.map +1 -0
- package/dist/opencode.d.ts +46 -0
- package/dist/opencode.js +58 -0
- package/dist/opencode.js.map +1 -0
- package/dist/project.d.ts +32 -0
- package/dist/project.js +37 -0
- package/dist/project.js.map +1 -0
- package/package.json +48 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
// src/opencode.ts
|
|
2
|
+
function isRecord(value) {
|
|
3
|
+
return typeof value === "object" && value !== null;
|
|
4
|
+
}
|
|
5
|
+
function isAgentSessionStatus(value) {
|
|
6
|
+
return value === "idle" || value === "running" || value === "needs-input" || value === "completed" || value === "failed" || value === "aborted";
|
|
7
|
+
}
|
|
8
|
+
function isOpenCodeServerState(value) {
|
|
9
|
+
return isRecord(value) && typeof value.available === "boolean" && typeof value.running === "boolean" && typeof value.healthy === "boolean" && typeof value.installUrl === "string" && (value.pid === void 0 || typeof value.pid === "number") && (value.port === void 0 || typeof value.port === "number");
|
|
10
|
+
}
|
|
11
|
+
function isMetadata(value) {
|
|
12
|
+
return value === void 0 || isRecord(value);
|
|
13
|
+
}
|
|
14
|
+
function isOpenCodeSessionStatusEvent(value) {
|
|
15
|
+
return isRecord(value) && value.type === "status" && isAgentSessionStatus(value.status) && isMetadata(value.metadata);
|
|
16
|
+
}
|
|
17
|
+
function isOpenCodeSessionProgressEvent(value) {
|
|
18
|
+
return isRecord(value) && value.type === "progress" && typeof value.text === "string" && isMetadata(value.metadata);
|
|
19
|
+
}
|
|
20
|
+
function isOpenCodeSessionMessageEvent(value) {
|
|
21
|
+
return isRecord(value) && value.type === "message" && typeof value.text === "string" && isMetadata(value.metadata);
|
|
22
|
+
}
|
|
23
|
+
function isOpenCodeSessionErrorEvent(value) {
|
|
24
|
+
return isRecord(value) && value.type === "error" && typeof value.text === "string" && isMetadata(value.metadata);
|
|
25
|
+
}
|
|
26
|
+
function isOpenCodeSessionCompletedEvent(value) {
|
|
27
|
+
return isRecord(value) && value.type === "completed" && isMetadata(value.metadata);
|
|
28
|
+
}
|
|
29
|
+
function isOpenCodeAgentEvent(value) {
|
|
30
|
+
return isOpenCodeSessionStatusEvent(value) || isOpenCodeSessionProgressEvent(value) || isOpenCodeSessionMessageEvent(value) || isOpenCodeSessionErrorEvent(value) || isOpenCodeSessionCompletedEvent(value);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// src/bridge.ts
|
|
34
|
+
var SERVICEME_PROTOCOL_VERSION = 1;
|
|
35
|
+
function isRecord2(value) {
|
|
36
|
+
return typeof value === "object" && value !== null;
|
|
37
|
+
}
|
|
38
|
+
function isBridgeCapabilities(value) {
|
|
39
|
+
return isRecord2(value) && value.bridge === true && value.opencode === 1 && value.json === 1 && value.env === 1;
|
|
40
|
+
}
|
|
41
|
+
var BRIDGE_METHODS = [
|
|
42
|
+
"system.hello",
|
|
43
|
+
"system.ping",
|
|
44
|
+
"system.shutdown",
|
|
45
|
+
"opencode.server.ensure",
|
|
46
|
+
"opencode.server.status",
|
|
47
|
+
"opencode.session.create",
|
|
48
|
+
"opencode.session.prompt",
|
|
49
|
+
"opencode.session.status",
|
|
50
|
+
"opencode.session.abort",
|
|
51
|
+
"opencode.session.dispose"
|
|
52
|
+
];
|
|
53
|
+
var BRIDGE_EVENTS = ["opencode.session.event"];
|
|
54
|
+
function isSystemHelloResult(value) {
|
|
55
|
+
return isRecord2(value) && typeof value.cliVersion === "string" && value.protocolVersion === SERVICEME_PROTOCOL_VERSION && isBridgeCapabilities(value.capabilities) && typeof value.pid === "number";
|
|
56
|
+
}
|
|
57
|
+
function isSystemPingResult(value) {
|
|
58
|
+
return isRecord2(value) && typeof value.now === "string";
|
|
59
|
+
}
|
|
60
|
+
function isSystemShutdownResult(value) {
|
|
61
|
+
return isRecord2(value) && value.shuttingDown === true;
|
|
62
|
+
}
|
|
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
|
+
function getBridgeResultValidator(method) {
|
|
79
|
+
switch (method) {
|
|
80
|
+
case "system.hello":
|
|
81
|
+
return isSystemHelloResult;
|
|
82
|
+
case "system.ping":
|
|
83
|
+
return isSystemPingResult;
|
|
84
|
+
case "system.shutdown":
|
|
85
|
+
return isSystemShutdownResult;
|
|
86
|
+
case "opencode.server.ensure":
|
|
87
|
+
case "opencode.server.status":
|
|
88
|
+
return isOpenCodeServerState;
|
|
89
|
+
case "opencode.session.create":
|
|
90
|
+
return isOpenCodeSessionCreateResult;
|
|
91
|
+
case "opencode.session.prompt":
|
|
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;
|
|
99
|
+
default:
|
|
100
|
+
return void 0;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
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
|
+
function getBridgeEventParamsValidator(event) {
|
|
107
|
+
switch (event) {
|
|
108
|
+
case "opencode.session.event":
|
|
109
|
+
return isOpenCodeSessionEventParams;
|
|
110
|
+
default:
|
|
111
|
+
return void 0;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function isBridgeMethod(value) {
|
|
115
|
+
return typeof value === "string" && BRIDGE_METHODS.includes(value);
|
|
116
|
+
}
|
|
117
|
+
function isBridgeEventName(value) {
|
|
118
|
+
return typeof value === "string" && BRIDGE_EVENTS.includes(value);
|
|
119
|
+
}
|
|
120
|
+
function isBridgeRequest(value) {
|
|
121
|
+
if (!isRecord2(value)) {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
return value.protocolVersion === SERVICEME_PROTOCOL_VERSION && value.kind === "request" && typeof value.id === "string" && isBridgeMethod(value.method) && "params" in value;
|
|
125
|
+
}
|
|
126
|
+
function isBridgeResponse(value) {
|
|
127
|
+
if (!isRecord2(value)) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
if (value.protocolVersion !== SERVICEME_PROTOCOL_VERSION || value.kind !== "response" || typeof value.id !== "string" || typeof value.ok !== "boolean") {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
if (value.ok) {
|
|
134
|
+
return "result" in value;
|
|
135
|
+
}
|
|
136
|
+
return "error" in value;
|
|
137
|
+
}
|
|
138
|
+
function isBridgeEvent(value) {
|
|
139
|
+
if (!isRecord2(value)) {
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
return value.protocolVersion === SERVICEME_PROTOCOL_VERSION && value.kind === "event" && isBridgeEventName(value.event) && "params" in value;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// src/cli.ts
|
|
146
|
+
var SERVICEME_CLI_SCHEMA_VERSION = 1;
|
|
147
|
+
function isRecord3(value) {
|
|
148
|
+
return typeof value === "object" && value !== null;
|
|
149
|
+
}
|
|
150
|
+
function createCliSuccess(data) {
|
|
151
|
+
return {
|
|
152
|
+
schemaVersion: SERVICEME_CLI_SCHEMA_VERSION,
|
|
153
|
+
ok: true,
|
|
154
|
+
data
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
function createCliFailure(error) {
|
|
158
|
+
return {
|
|
159
|
+
schemaVersion: SERVICEME_CLI_SCHEMA_VERSION,
|
|
160
|
+
ok: false,
|
|
161
|
+
error
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function isCliEnvelope(value) {
|
|
165
|
+
if (!isRecord3(value)) {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
if (value.schemaVersion !== SERVICEME_CLI_SCHEMA_VERSION || typeof value.ok !== "boolean") {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
if (value.ok) {
|
|
172
|
+
return "data" in value;
|
|
173
|
+
}
|
|
174
|
+
return "error" in value;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// src/env.ts
|
|
178
|
+
var KNOWN_ENVIRONMENT_TOOLS = [
|
|
179
|
+
"git",
|
|
180
|
+
"node",
|
|
181
|
+
"npm",
|
|
182
|
+
"pnpm",
|
|
183
|
+
"nvm",
|
|
184
|
+
"nrm",
|
|
185
|
+
"dotnet",
|
|
186
|
+
"nuget"
|
|
187
|
+
];
|
|
188
|
+
function isRecord4(value) {
|
|
189
|
+
return typeof value === "object" && value !== null;
|
|
190
|
+
}
|
|
191
|
+
function isKnownEnvironmentTool(value) {
|
|
192
|
+
return KNOWN_ENVIRONMENT_TOOLS.includes(value);
|
|
193
|
+
}
|
|
194
|
+
function isToolCheckResult(value) {
|
|
195
|
+
if (!isRecord4(value)) {
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
return typeof value.installed === "boolean" && (value.version === void 0 || typeof value.version === "string") && (value.path === void 0 || typeof value.path === "string") && (value.error === void 0 || typeof value.error === "string");
|
|
199
|
+
}
|
|
200
|
+
function isEnvironmentCheckResult(value) {
|
|
201
|
+
if (!isRecord4(value)) {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
return KNOWN_ENVIRONMENT_TOOLS.every((tool) => isToolCheckResult(value[tool]));
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// src/errors.ts
|
|
208
|
+
var SERVICEME_ERROR_CODES = [
|
|
209
|
+
"protocol_mismatch",
|
|
210
|
+
"cli_not_found",
|
|
211
|
+
"cli_start_failed",
|
|
212
|
+
"command_timeout",
|
|
213
|
+
"request_cancelled",
|
|
214
|
+
"invalid_params",
|
|
215
|
+
"opencode_not_installed",
|
|
216
|
+
"opencode_startup_timeout",
|
|
217
|
+
"opencode_request_failed",
|
|
218
|
+
"opencode_backend_not_running",
|
|
219
|
+
"opencode_session_not_found",
|
|
220
|
+
"json_invalid_input",
|
|
221
|
+
"env_tool_not_found",
|
|
222
|
+
"internal_error"
|
|
223
|
+
];
|
|
224
|
+
var RETRYABLE_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
225
|
+
"command_timeout",
|
|
226
|
+
"request_cancelled",
|
|
227
|
+
"opencode_startup_timeout",
|
|
228
|
+
"opencode_request_failed",
|
|
229
|
+
"opencode_backend_not_running",
|
|
230
|
+
"internal_error"
|
|
231
|
+
]);
|
|
232
|
+
function isRecord5(value) {
|
|
233
|
+
return typeof value === "object" && value !== null;
|
|
234
|
+
}
|
|
235
|
+
function isServicemeErrorCode(value) {
|
|
236
|
+
return typeof value === "string" && SERVICEME_ERROR_CODES.includes(value);
|
|
237
|
+
}
|
|
238
|
+
function isServicemeErrorDetails(value) {
|
|
239
|
+
if (!isRecord5(value)) {
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
242
|
+
return isServicemeErrorCode(value.code) && typeof value.message === "string" && typeof value.retryable === "boolean";
|
|
243
|
+
}
|
|
244
|
+
function isRetryableErrorCode(code) {
|
|
245
|
+
return RETRYABLE_ERROR_CODES.has(code);
|
|
246
|
+
}
|
|
247
|
+
var ServicemeProtocolError = class extends Error {
|
|
248
|
+
constructor(input) {
|
|
249
|
+
super(input.message);
|
|
250
|
+
this.name = "ServicemeProtocolError";
|
|
251
|
+
this.code = input.code;
|
|
252
|
+
this.retryable = input.retryable ?? isRetryableErrorCode(input.code);
|
|
253
|
+
this.details = input.details;
|
|
254
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
255
|
+
}
|
|
256
|
+
toJSON() {
|
|
257
|
+
return {
|
|
258
|
+
code: this.code,
|
|
259
|
+
message: this.message,
|
|
260
|
+
retryable: this.retryable,
|
|
261
|
+
details: this.details
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
function createServicemeError(code, message, details) {
|
|
266
|
+
return new ServicemeProtocolError({
|
|
267
|
+
code,
|
|
268
|
+
message,
|
|
269
|
+
details
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
function normalizeServicemeError(error, fallbackCode = "internal_error") {
|
|
273
|
+
if (error instanceof ServicemeProtocolError) {
|
|
274
|
+
return error.toJSON();
|
|
275
|
+
}
|
|
276
|
+
if (isServicemeErrorDetails(error)) {
|
|
277
|
+
return error;
|
|
278
|
+
}
|
|
279
|
+
if (isRecord5(error)) {
|
|
280
|
+
const code = isServicemeErrorCode(error.code) ? error.code : fallbackCode;
|
|
281
|
+
const message = typeof error.message === "string" ? error.message : "Unexpected serviceme error.";
|
|
282
|
+
const retryable = typeof error.retryable === "boolean" ? error.retryable : isRetryableErrorCode(code);
|
|
283
|
+
return {
|
|
284
|
+
code,
|
|
285
|
+
message,
|
|
286
|
+
retryable,
|
|
287
|
+
details: error.details
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
if (error instanceof Error) {
|
|
291
|
+
return {
|
|
292
|
+
code: fallbackCode,
|
|
293
|
+
message: error.message,
|
|
294
|
+
retryable: isRetryableErrorCode(fallbackCode)
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
return {
|
|
298
|
+
code: fallbackCode,
|
|
299
|
+
message: typeof error === "string" ? error : "Unexpected serviceme error.",
|
|
300
|
+
retryable: isRetryableErrorCode(fallbackCode)
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// src/image.ts
|
|
305
|
+
var SERVICEME_IMAGE_FORMATS = ["jpeg", "png", "webp"];
|
|
306
|
+
function isRecord6(value) {
|
|
307
|
+
return typeof value === "object" && value !== null;
|
|
308
|
+
}
|
|
309
|
+
function isServiceMeImageFormat(value) {
|
|
310
|
+
return typeof value === "string" && SERVICEME_IMAGE_FORMATS.includes(value);
|
|
311
|
+
}
|
|
312
|
+
function isServiceMeImageCompressOptions(value) {
|
|
313
|
+
if (!isRecord6(value)) {
|
|
314
|
+
return false;
|
|
315
|
+
}
|
|
316
|
+
return typeof value.quality === "number" && typeof value.replaceOriginImage === "boolean" && (value.outputPath === void 0 || typeof value.outputPath === "string") && (value.format === void 0 || isServiceMeImageFormat(value.format)) && (value.sharpModulePath === void 0 || typeof value.sharpModulePath === "string") && (value.minimumCompressionRatio === void 0 || typeof value.minimumCompressionRatio === "number");
|
|
317
|
+
}
|
|
318
|
+
function isServiceMeImageCompressResult(value) {
|
|
319
|
+
if (!isRecord6(value)) {
|
|
320
|
+
return false;
|
|
321
|
+
}
|
|
322
|
+
return typeof value.originalSize === "number" && typeof value.compressedSize === "number" && typeof value.compressionRatio === "number" && typeof value.outputPath === "string";
|
|
323
|
+
}
|
|
324
|
+
function isServiceMeImageInfo(value) {
|
|
325
|
+
if (!isRecord6(value)) {
|
|
326
|
+
return false;
|
|
327
|
+
}
|
|
328
|
+
return typeof value.width === "number" && typeof value.height === "number" && typeof value.format === "string" && typeof value.size === "number" && (value.colorSpace === void 0 || typeof value.colorSpace === "string");
|
|
329
|
+
}
|
|
330
|
+
function isServiceMeImageValidationResult(value) {
|
|
331
|
+
return isRecord6(value) && typeof value.valid === "boolean";
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// src/json.ts
|
|
335
|
+
var JSON_SORT_ALGORITHMS = [
|
|
336
|
+
"default",
|
|
337
|
+
"keyLength",
|
|
338
|
+
"alphaNum",
|
|
339
|
+
"values",
|
|
340
|
+
"type"
|
|
341
|
+
];
|
|
342
|
+
var JSON_SORT_ORDERS = ["asc", "desc"];
|
|
343
|
+
var DEFAULT_JSON_SORT_OPTIONS = {
|
|
344
|
+
sortOrder: "asc",
|
|
345
|
+
sortAlgo: "default"
|
|
346
|
+
};
|
|
347
|
+
function isRecord7(value) {
|
|
348
|
+
return typeof value === "object" && value !== null;
|
|
349
|
+
}
|
|
350
|
+
function isJsonSortAlgorithm(value) {
|
|
351
|
+
return typeof value === "string" && JSON_SORT_ALGORITHMS.includes(value);
|
|
352
|
+
}
|
|
353
|
+
function isJsonSortOrder(value) {
|
|
354
|
+
return typeof value === "string" && JSON_SORT_ORDERS.includes(value);
|
|
355
|
+
}
|
|
356
|
+
function isJsonSortOptions(value) {
|
|
357
|
+
return isRecord7(value) && isJsonSortOrder(value.sortOrder) && isJsonSortAlgorithm(value.sortAlgo);
|
|
358
|
+
}
|
|
359
|
+
function isJsonValidationResult(value) {
|
|
360
|
+
return isRecord7(value) && typeof value.valid === "boolean" && (value.error === void 0 || typeof value.error === "string");
|
|
361
|
+
}
|
|
362
|
+
function isJsonOutputResult(value) {
|
|
363
|
+
return isRecord7(value) && typeof value.output === "string";
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// src/metadata.ts
|
|
367
|
+
var SERVICEME_CLI_NAME = "serviceme";
|
|
368
|
+
var SERVICEME_CLI_VERSION = "0.0.1";
|
|
369
|
+
var SERVICEME_CLI_CAPABILITIES = {
|
|
370
|
+
bridge: true,
|
|
371
|
+
opencode: 1,
|
|
372
|
+
json: 1,
|
|
373
|
+
env: 1,
|
|
374
|
+
image: 1,
|
|
375
|
+
project: 1
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
// src/project.ts
|
|
379
|
+
function isRecord8(value) {
|
|
380
|
+
return typeof value === "object" && value !== null;
|
|
381
|
+
}
|
|
382
|
+
function isServiceMeProjectScaffoldPruneResult(value) {
|
|
383
|
+
if (!isRecord8(value)) {
|
|
384
|
+
return false;
|
|
385
|
+
}
|
|
386
|
+
return typeof value.applied === "boolean" && typeof value.preset === "string" && Array.isArray(value.commands) && value.commands.every((command) => typeof command === "string");
|
|
387
|
+
}
|
|
388
|
+
function isServiceMeProjectGitInitResult(value) {
|
|
389
|
+
return isRecord8(value) && typeof value.initialized === "boolean" && typeof value.command === "string";
|
|
390
|
+
}
|
|
391
|
+
function isServiceMeProjectMakeScriptsExecutableResult(value) {
|
|
392
|
+
if (!isRecord8(value)) {
|
|
393
|
+
return false;
|
|
394
|
+
}
|
|
395
|
+
return typeof value.processedCount === "number" && typeof value.updatedCount === "number" && typeof value.platform === "string" && Array.isArray(value.scripts) && value.scripts.every((script) => typeof script === "string");
|
|
396
|
+
}
|
|
397
|
+
function isServiceMeProjectInstallDepsResult(value) {
|
|
398
|
+
return isRecord8(value) && typeof value.installed === "boolean" && typeof value.command === "string";
|
|
399
|
+
}
|
|
400
|
+
function isServiceMeProjectExtractTemplateInput(value) {
|
|
401
|
+
return isRecord8(value) && typeof value.extractedDirName === "string" && typeof value.projectFilePattern === "string";
|
|
402
|
+
}
|
|
403
|
+
function isServiceMeProjectExtractTemplateResult(value) {
|
|
404
|
+
return isRecord8(value) && typeof value.actualDirName === "string";
|
|
405
|
+
}
|
|
406
|
+
export {
|
|
407
|
+
BRIDGE_EVENTS,
|
|
408
|
+
BRIDGE_METHODS,
|
|
409
|
+
DEFAULT_JSON_SORT_OPTIONS,
|
|
410
|
+
JSON_SORT_ALGORITHMS,
|
|
411
|
+
JSON_SORT_ORDERS,
|
|
412
|
+
KNOWN_ENVIRONMENT_TOOLS,
|
|
413
|
+
SERVICEME_CLI_CAPABILITIES,
|
|
414
|
+
SERVICEME_CLI_NAME,
|
|
415
|
+
SERVICEME_CLI_SCHEMA_VERSION,
|
|
416
|
+
SERVICEME_CLI_VERSION,
|
|
417
|
+
SERVICEME_ERROR_CODES,
|
|
418
|
+
SERVICEME_IMAGE_FORMATS,
|
|
419
|
+
SERVICEME_PROTOCOL_VERSION,
|
|
420
|
+
ServicemeProtocolError,
|
|
421
|
+
createCliFailure,
|
|
422
|
+
createCliSuccess,
|
|
423
|
+
createServicemeError,
|
|
424
|
+
getBridgeEventParamsValidator,
|
|
425
|
+
getBridgeResultValidator,
|
|
426
|
+
isAgentSessionStatus,
|
|
427
|
+
isBridgeCapabilities,
|
|
428
|
+
isBridgeEvent,
|
|
429
|
+
isBridgeEventName,
|
|
430
|
+
isBridgeMethod,
|
|
431
|
+
isBridgeRequest,
|
|
432
|
+
isBridgeResponse,
|
|
433
|
+
isCliEnvelope,
|
|
434
|
+
isEnvironmentCheckResult,
|
|
435
|
+
isJsonOutputResult,
|
|
436
|
+
isJsonSortAlgorithm,
|
|
437
|
+
isJsonSortOptions,
|
|
438
|
+
isJsonSortOrder,
|
|
439
|
+
isJsonValidationResult,
|
|
440
|
+
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
|
+
isRetryableErrorCode,
|
|
455
|
+
isServiceMeImageCompressOptions,
|
|
456
|
+
isServiceMeImageCompressResult,
|
|
457
|
+
isServiceMeImageFormat,
|
|
458
|
+
isServiceMeImageInfo,
|
|
459
|
+
isServiceMeImageValidationResult,
|
|
460
|
+
isServiceMeProjectExtractTemplateInput,
|
|
461
|
+
isServiceMeProjectExtractTemplateResult,
|
|
462
|
+
isServiceMeProjectGitInitResult,
|
|
463
|
+
isServiceMeProjectInstallDepsResult,
|
|
464
|
+
isServiceMeProjectMakeScriptsExecutableResult,
|
|
465
|
+
isServiceMeProjectScaffoldPruneResult,
|
|
466
|
+
isServicemeErrorCode,
|
|
467
|
+
isServicemeErrorDetails,
|
|
468
|
+
isSystemHelloResult,
|
|
469
|
+
isSystemPingResult,
|
|
470
|
+
isSystemShutdownResult,
|
|
471
|
+
isToolCheckResult,
|
|
472
|
+
normalizeServicemeError
|
|
473
|
+
};
|
package/dist/json.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type JsonSortAlgorithm = "default" | "keyLength" | "alphaNum" | "values" | "type";
|
|
2
|
+
export type JsonSortOrder = "asc" | "desc";
|
|
3
|
+
export declare const JSON_SORT_ALGORITHMS: readonly ["default", "keyLength", "alphaNum", "values", "type"];
|
|
4
|
+
export declare const JSON_SORT_ORDERS: readonly ["asc", "desc"];
|
|
5
|
+
export interface JsonSortOptions {
|
|
6
|
+
sortOrder: JsonSortOrder;
|
|
7
|
+
sortAlgo: JsonSortAlgorithm;
|
|
8
|
+
}
|
|
9
|
+
export interface JsonValidationResult {
|
|
10
|
+
valid: boolean;
|
|
11
|
+
error?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const DEFAULT_JSON_SORT_OPTIONS: JsonSortOptions;
|
|
14
|
+
export declare function isJsonSortAlgorithm(value: unknown): value is JsonSortAlgorithm;
|
|
15
|
+
export declare function isJsonSortOrder(value: unknown): value is JsonSortOrder;
|
|
16
|
+
export declare function isJsonSortOptions(value: unknown): value is JsonSortOptions;
|
|
17
|
+
export declare function isJsonValidationResult(value: unknown): value is JsonValidationResult;
|
|
18
|
+
export declare function isJsonOutputResult(value: unknown): value is {
|
|
19
|
+
output: string;
|
|
20
|
+
};
|
package/dist/json.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export const JSON_SORT_ALGORITHMS = [
|
|
2
|
+
"default",
|
|
3
|
+
"keyLength",
|
|
4
|
+
"alphaNum",
|
|
5
|
+
"values",
|
|
6
|
+
"type",
|
|
7
|
+
];
|
|
8
|
+
export const JSON_SORT_ORDERS = ["asc", "desc"];
|
|
9
|
+
export const DEFAULT_JSON_SORT_OPTIONS = {
|
|
10
|
+
sortOrder: "asc",
|
|
11
|
+
sortAlgo: "default",
|
|
12
|
+
};
|
|
13
|
+
function isRecord(value) {
|
|
14
|
+
return typeof value === "object" && value !== null;
|
|
15
|
+
}
|
|
16
|
+
export function isJsonSortAlgorithm(value) {
|
|
17
|
+
return typeof value === "string" && JSON_SORT_ALGORITHMS.includes(value);
|
|
18
|
+
}
|
|
19
|
+
export function isJsonSortOrder(value) {
|
|
20
|
+
return typeof value === "string" && JSON_SORT_ORDERS.includes(value);
|
|
21
|
+
}
|
|
22
|
+
export function isJsonSortOptions(value) {
|
|
23
|
+
return (isRecord(value) && isJsonSortOrder(value.sortOrder) && isJsonSortAlgorithm(value.sortAlgo));
|
|
24
|
+
}
|
|
25
|
+
export function isJsonValidationResult(value) {
|
|
26
|
+
return (isRecord(value) &&
|
|
27
|
+
typeof value.valid === "boolean" &&
|
|
28
|
+
(value.error === undefined || typeof value.error === "string"));
|
|
29
|
+
}
|
|
30
|
+
export function isJsonOutputResult(value) {
|
|
31
|
+
return isRecord(value) && typeof value.output === "string";
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=json.js.map
|
package/dist/json.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,oBAAoB,GAAG;IACnC,SAAS;IACT,WAAW;IACX,UAAU;IACV,QAAQ;IACR,MAAM;CAC0C,CAAC;AAElD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,CAA6C,CAAC;AAY5F,MAAM,CAAC,MAAM,yBAAyB,GAAoB;IACzD,SAAS,EAAE,KAAK;IAChB,QAAQ,EAAE,SAAS;CACnB,CAAC;AAEF,SAAS,QAAQ,CAAC,KAAc;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,KAAc;IACjD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,oBAAoB,CAAC,QAAQ,CAAC,KAA0B,CAAC,CAAC;AAC/F,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAAc;IAC7C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,gBAAgB,CAAC,QAAQ,CAAC,KAAsB,CAAC,CAAC;AACvF,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC/C,OAAO,CACN,QAAQ,CAAC,KAAK,CAAC,IAAI,eAAe,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,mBAAmB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAC1F,CAAC;AACH,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,KAAc;IACpD,OAAO,CACN,QAAQ,CAAC,KAAK,CAAC;QACf,OAAO,KAAK,CAAC,KAAK,KAAK,SAAS;QAChC,CAAC,KAAK,CAAC,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,CAAC,CAC9D,CAAC;AACH,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAChD,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ,CAAC;AAC5D,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const SERVICEME_CLI_NAME = "serviceme";
|
|
2
|
+
export declare const SERVICEME_CLI_VERSION = "0.0.1";
|
|
3
|
+
export declare const SERVICEME_CLI_CAPABILITIES: {
|
|
4
|
+
readonly bridge: true;
|
|
5
|
+
readonly opencode: 1;
|
|
6
|
+
readonly json: 1;
|
|
7
|
+
readonly env: 1;
|
|
8
|
+
readonly image: 1;
|
|
9
|
+
readonly project: 1;
|
|
10
|
+
};
|
package/dist/metadata.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const SERVICEME_CLI_NAME = "serviceme";
|
|
2
|
+
export const SERVICEME_CLI_VERSION = "0.0.1";
|
|
3
|
+
export const SERVICEME_CLI_CAPABILITIES = {
|
|
4
|
+
bridge: true,
|
|
5
|
+
opencode: 1,
|
|
6
|
+
json: 1,
|
|
7
|
+
env: 1,
|
|
8
|
+
image: 1,
|
|
9
|
+
project: 1,
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../src/metadata.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG,WAAW,CAAC;AAC9C,MAAM,CAAC,MAAM,qBAAqB,GAAG,OAAO,CAAC;AAE7C,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACzC,MAAM,EAAE,IAAI;IACZ,QAAQ,EAAE,CAAC;IACX,IAAI,EAAE,CAAC;IACP,GAAG,EAAE,CAAC;IACN,KAAK,EAAE,CAAC;IACR,OAAO,EAAE,CAAC;CACD,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export type AgentSessionStatus = "idle" | "running" | "needs-input" | "completed" | "failed" | "aborted";
|
|
2
|
+
export interface OpenCodeRuntimeOptions {
|
|
3
|
+
workspaceRoot?: string;
|
|
4
|
+
startupTimeoutMs?: number;
|
|
5
|
+
}
|
|
6
|
+
export interface OpenCodeServerState {
|
|
7
|
+
available: boolean;
|
|
8
|
+
running: boolean;
|
|
9
|
+
healthy: boolean;
|
|
10
|
+
installUrl: string;
|
|
11
|
+
pid?: number;
|
|
12
|
+
port?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface OpenCodeSessionStatusEvent {
|
|
15
|
+
type: "status";
|
|
16
|
+
status: AgentSessionStatus;
|
|
17
|
+
metadata?: Record<string, unknown>;
|
|
18
|
+
}
|
|
19
|
+
export interface OpenCodeSessionProgressEvent {
|
|
20
|
+
type: "progress";
|
|
21
|
+
text: string;
|
|
22
|
+
metadata?: Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
export interface OpenCodeSessionMessageEvent {
|
|
25
|
+
type: "message";
|
|
26
|
+
text: string;
|
|
27
|
+
metadata?: Record<string, unknown>;
|
|
28
|
+
}
|
|
29
|
+
export interface OpenCodeSessionErrorEvent {
|
|
30
|
+
type: "error";
|
|
31
|
+
text: string;
|
|
32
|
+
metadata?: Record<string, unknown>;
|
|
33
|
+
}
|
|
34
|
+
export interface OpenCodeSessionCompletedEvent {
|
|
35
|
+
type: "completed";
|
|
36
|
+
metadata?: Record<string, unknown>;
|
|
37
|
+
}
|
|
38
|
+
export type OpenCodeAgentEvent = OpenCodeSessionStatusEvent | OpenCodeSessionProgressEvent | OpenCodeSessionMessageEvent | OpenCodeSessionErrorEvent | OpenCodeSessionCompletedEvent;
|
|
39
|
+
export declare function isAgentSessionStatus(value: unknown): value is AgentSessionStatus;
|
|
40
|
+
export declare function isOpenCodeServerState(value: unknown): value is OpenCodeServerState;
|
|
41
|
+
export declare function isOpenCodeSessionStatusEvent(value: unknown): value is OpenCodeSessionStatusEvent;
|
|
42
|
+
export declare function isOpenCodeSessionProgressEvent(value: unknown): value is OpenCodeSessionProgressEvent;
|
|
43
|
+
export declare function isOpenCodeSessionMessageEvent(value: unknown): value is OpenCodeSessionMessageEvent;
|
|
44
|
+
export declare function isOpenCodeSessionErrorEvent(value: unknown): value is OpenCodeSessionErrorEvent;
|
|
45
|
+
export declare function isOpenCodeSessionCompletedEvent(value: unknown): value is OpenCodeSessionCompletedEvent;
|
|
46
|
+
export declare function isOpenCodeAgentEvent(value: unknown): value is OpenCodeAgentEvent;
|
package/dist/opencode.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
function isRecord(value) {
|
|
2
|
+
return typeof value === "object" && value !== null;
|
|
3
|
+
}
|
|
4
|
+
export function isAgentSessionStatus(value) {
|
|
5
|
+
return (value === "idle" ||
|
|
6
|
+
value === "running" ||
|
|
7
|
+
value === "needs-input" ||
|
|
8
|
+
value === "completed" ||
|
|
9
|
+
value === "failed" ||
|
|
10
|
+
value === "aborted");
|
|
11
|
+
}
|
|
12
|
+
export function isOpenCodeServerState(value) {
|
|
13
|
+
return (isRecord(value) &&
|
|
14
|
+
typeof value.available === "boolean" &&
|
|
15
|
+
typeof value.running === "boolean" &&
|
|
16
|
+
typeof value.healthy === "boolean" &&
|
|
17
|
+
typeof value.installUrl === "string" &&
|
|
18
|
+
(value.pid === undefined || typeof value.pid === "number") &&
|
|
19
|
+
(value.port === undefined || typeof value.port === "number"));
|
|
20
|
+
}
|
|
21
|
+
function isMetadata(value) {
|
|
22
|
+
return value === undefined || isRecord(value);
|
|
23
|
+
}
|
|
24
|
+
export function isOpenCodeSessionStatusEvent(value) {
|
|
25
|
+
return (isRecord(value) &&
|
|
26
|
+
value.type === "status" &&
|
|
27
|
+
isAgentSessionStatus(value.status) &&
|
|
28
|
+
isMetadata(value.metadata));
|
|
29
|
+
}
|
|
30
|
+
export function isOpenCodeSessionProgressEvent(value) {
|
|
31
|
+
return (isRecord(value) &&
|
|
32
|
+
value.type === "progress" &&
|
|
33
|
+
typeof value.text === "string" &&
|
|
34
|
+
isMetadata(value.metadata));
|
|
35
|
+
}
|
|
36
|
+
export function isOpenCodeSessionMessageEvent(value) {
|
|
37
|
+
return (isRecord(value) &&
|
|
38
|
+
value.type === "message" &&
|
|
39
|
+
typeof value.text === "string" &&
|
|
40
|
+
isMetadata(value.metadata));
|
|
41
|
+
}
|
|
42
|
+
export function isOpenCodeSessionErrorEvent(value) {
|
|
43
|
+
return (isRecord(value) &&
|
|
44
|
+
value.type === "error" &&
|
|
45
|
+
typeof value.text === "string" &&
|
|
46
|
+
isMetadata(value.metadata));
|
|
47
|
+
}
|
|
48
|
+
export function isOpenCodeSessionCompletedEvent(value) {
|
|
49
|
+
return isRecord(value) && value.type === "completed" && isMetadata(value.metadata);
|
|
50
|
+
}
|
|
51
|
+
export function isOpenCodeAgentEvent(value) {
|
|
52
|
+
return (isOpenCodeSessionStatusEvent(value) ||
|
|
53
|
+
isOpenCodeSessionProgressEvent(value) ||
|
|
54
|
+
isOpenCodeSessionMessageEvent(value) ||
|
|
55
|
+
isOpenCodeSessionErrorEvent(value) ||
|
|
56
|
+
isOpenCodeSessionCompletedEvent(value));
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=opencode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opencode.js","sourceRoot":"","sources":["../src/opencode.ts"],"names":[],"mappings":"AA0DA,SAAS,QAAQ,CAAC,KAAc;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,KAAc;IAClD,OAAO,CACN,KAAK,KAAK,MAAM;QAChB,KAAK,KAAK,SAAS;QACnB,KAAK,KAAK,aAAa;QACvB,KAAK,KAAK,WAAW;QACrB,KAAK,KAAK,QAAQ;QAClB,KAAK,KAAK,SAAS,CACnB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,KAAc;IACnD,OAAO,CACN,QAAQ,CAAC,KAAK,CAAC;QACf,OAAO,KAAK,CAAC,SAAS,KAAK,SAAS;QACpC,OAAO,KAAK,CAAC,OAAO,KAAK,SAAS;QAClC,OAAO,KAAK,CAAC,OAAO,KAAK,SAAS;QAClC,OAAO,KAAK,CAAC,UAAU,KAAK,QAAQ;QACpC,CAAC,KAAK,CAAC,GAAG,KAAK,SAAS,IAAI,OAAO,KAAK,CAAC,GAAG,KAAK,QAAQ,CAAC;QAC1D,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAC5D,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CAAC,KAAc;IACjC,OAAO,KAAK,KAAK,SAAS,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,KAAc;IAC1D,OAAO,CACN,QAAQ,CAAC,KAAK,CAAC;QACf,KAAK,CAAC,IAAI,KAAK,QAAQ;QACvB,oBAAoB,CAAC,KAAK,CAAC,MAAM,CAAC;QAClC,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,CAC1B,CAAC;AACH,CAAC;AAED,MAAM,UAAU,8BAA8B,CAAC,KAAc;IAC5D,OAAO,CACN,QAAQ,CAAC,KAAK,CAAC;QACf,KAAK,CAAC,IAAI,KAAK,UAAU;QACzB,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;QAC9B,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,CAC1B,CAAC;AACH,CAAC;AAED,MAAM,UAAU,6BAA6B,CAAC,KAAc;IAC3D,OAAO,CACN,QAAQ,CAAC,KAAK,CAAC;QACf,KAAK,CAAC,IAAI,KAAK,SAAS;QACxB,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;QAC9B,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,CAC1B,CAAC;AACH,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,KAAc;IACzD,OAAO,CACN,QAAQ,CAAC,KAAK,CAAC;QACf,KAAK,CAAC,IAAI,KAAK,OAAO;QACtB,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;QAC9B,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,CAC1B,CAAC;AACH,CAAC;AAED,MAAM,UAAU,+BAA+B,CAC9C,KAAc;IAEd,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,IAAI,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AACpF,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,KAAc;IAClD,OAAO,CACN,4BAA4B,CAAC,KAAK,CAAC;QACnC,8BAA8B,CAAC,KAAK,CAAC;QACrC,6BAA6B,CAAC,KAAK,CAAC;QACpC,2BAA2B,CAAC,KAAK,CAAC;QAClC,+BAA+B,CAAC,KAAK,CAAC,CACtC,CAAC;AACH,CAAC"}
|