@serviceme/devtools-protocol 0.1.5 → 0.1.7
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 +321 -5
- package/dist/index.d.ts +321 -5
- package/dist/index.js +252 -47
- package/dist/index.mjs +242 -47
- package/package.json +2 -1
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,87 @@
|
|
|
1
|
+
// src/agent.ts
|
|
2
|
+
var VALID_AGENT_SCOPES = ["workspace", "user"];
|
|
3
|
+
var VALID_AGENT_SCOPE_STATUSES = [
|
|
4
|
+
"absent",
|
|
5
|
+
"available",
|
|
6
|
+
"installed",
|
|
7
|
+
"blocked",
|
|
8
|
+
"conflict"
|
|
9
|
+
];
|
|
10
|
+
var VALID_AGENT_MUTATION_ACTIONS = [
|
|
11
|
+
"install",
|
|
12
|
+
"uninstall",
|
|
13
|
+
"move",
|
|
14
|
+
"removeExternal",
|
|
15
|
+
"publish",
|
|
16
|
+
"republish",
|
|
17
|
+
"submit-to-official"
|
|
18
|
+
];
|
|
19
|
+
var VALID_AGENT_TOOL_RISK_LEVELS = [
|
|
20
|
+
"high",
|
|
21
|
+
"medium",
|
|
22
|
+
"low"
|
|
23
|
+
];
|
|
24
|
+
function isRecord(value) {
|
|
25
|
+
return typeof value === "object" && value !== null;
|
|
26
|
+
}
|
|
27
|
+
function isStringArray(value) {
|
|
28
|
+
return Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
29
|
+
}
|
|
30
|
+
function isAgentScope(value) {
|
|
31
|
+
return typeof value === "string" && VALID_AGENT_SCOPES.includes(value);
|
|
32
|
+
}
|
|
33
|
+
function isAgentScopeStatus(value) {
|
|
34
|
+
return typeof value === "string" && VALID_AGENT_SCOPE_STATUSES.includes(value);
|
|
35
|
+
}
|
|
36
|
+
function isAgentMutationAction(value) {
|
|
37
|
+
return typeof value === "string" && VALID_AGENT_MUTATION_ACTIONS.includes(value);
|
|
38
|
+
}
|
|
39
|
+
function isSafeResourceId(value) {
|
|
40
|
+
if (typeof value !== "string" || value.length === 0 || value.includes("\\")) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
const segments = value.split("/");
|
|
44
|
+
if (segments.some((segment) => segment.length === 0)) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return segments.every(
|
|
48
|
+
(segment) => segment !== "." && segment !== ".." && /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(segment)
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
function isAgentScopeState(value) {
|
|
52
|
+
if (!isRecord(value)) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
return isAgentScope(value.scope) && isAgentScopeStatus(value.status) && (value.kind === void 0 || value.kind === "builtin" || value.kind === "external") && (value.path === void 0 || typeof value.path === "string") && typeof value.isInstalled === "boolean" && typeof value.canInstall === "boolean" && typeof value.canUninstall === "boolean" && typeof value.canRemove === "boolean" && typeof value.canMoveHere === "boolean" && (value.summary === void 0 || typeof value.summary === "string");
|
|
56
|
+
}
|
|
57
|
+
function isAgentMarketplaceEntry(value) {
|
|
58
|
+
if (!isRecord(value)) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
return typeof value.id === "string" && typeof value.displayName === "string" && typeof value.description === "string" && typeof value.version === "string" && typeof value.updatedAt === "string" && (value.categoryId === void 0 || typeof value.categoryId === "string") && typeof value.isCatalogAgent === "boolean" && typeof value.recommended === "boolean" && typeof value.installCount === "number" && (value.ownerScope === void 0 || isAgentScope(value.ownerScope)) && (value.ownerKind === void 0 || value.ownerKind === "builtin" || value.ownerKind === "external") && typeof value.hasConflict === "boolean" && isStringArray(value.tools) && (value.source === void 0 || value.source === "official" || value.source === "community" || value.source === "local") && (value.localAgentPath === void 0 || typeof value.localAgentPath === "string") && (value.canPublish === void 0 || typeof value.canPublish === "boolean") && isAgentScopeState(value.workspaceState) && isAgentScopeState(value.userState);
|
|
62
|
+
}
|
|
63
|
+
function isAgentMarketplaceState(value) {
|
|
64
|
+
if (!isRecord(value)) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
return typeof value.configPath === "string" && typeof value.userAgentsPath === "string" && Array.isArray(value.agents) && value.agents.every((entry) => isAgentMarketplaceEntry(entry)) && (value.installedAgentIds === void 0 || isStringArray(value.installedAgentIds)) && (value.workspaceOpen === void 0 || typeof value.workspaceOpen === "boolean");
|
|
68
|
+
}
|
|
69
|
+
function isAgentMutationRequest(value) {
|
|
70
|
+
return isRecord(value) && isSafeResourceId(value.agentId) && isAgentScope(value.targetScope) && isAgentMutationAction(value.action) && (value.confirmed === void 0 || typeof value.confirmed === "boolean");
|
|
71
|
+
}
|
|
72
|
+
function isAgentMutationResult(value) {
|
|
73
|
+
return isRecord(value) && isAgentMarketplaceState(value.state) && typeof value.agentId === "string" && isAgentScope(value.targetScope) && isAgentMutationAction(value.action) && typeof value.changed === "boolean" && (value.status === "success" || value.status === "blocked" || value.status === "requires_confirmation") && (value.message === void 0 || typeof value.message === "string") && (value.tools === void 0 || isStringArray(value.tools)) && (value.prUrl === void 0 || typeof value.prUrl === "string") && (value.fromVersion === void 0 || typeof value.fromVersion === "string") && (value.toVersion === void 0 || typeof value.toVersion === "string");
|
|
74
|
+
}
|
|
75
|
+
function isAgentToolPermission(value) {
|
|
76
|
+
return isRecord(value) && typeof value.tool === "string" && typeof value.riskLevel === "string" && VALID_AGENT_TOOL_RISK_LEVELS.includes(value.riskLevel);
|
|
77
|
+
}
|
|
78
|
+
function isAgentPermissionSummary(value) {
|
|
79
|
+
return isRecord(value) && typeof value.agentId === "string" && typeof value.agentName === "string" && Array.isArray(value.tools) && value.tools.every((tool) => isAgentToolPermission(tool)) && typeof value.highRiskCount === "number" && typeof value.mediumRiskCount === "number" && typeof value.lowRiskCount === "number";
|
|
80
|
+
}
|
|
81
|
+
function isAgentPermissionsResult(value) {
|
|
82
|
+
return isRecord(value) && typeof value.agentId === "string" && isAgentPermissionSummary(value.summary);
|
|
83
|
+
}
|
|
84
|
+
|
|
1
85
|
// src/scheduled-tasks.ts
|
|
2
86
|
var VALID_TASK_TYPES = [
|
|
3
87
|
"command",
|
|
@@ -7,64 +91,143 @@ var VALID_TASK_TYPES = [
|
|
|
7
91
|
];
|
|
8
92
|
var VALID_SCHEDULE_TYPES = ["cron", "interval"];
|
|
9
93
|
var VALID_TERMINAL_STATUSES = ["success", "failure", "timeout", "cancelled"];
|
|
10
|
-
function
|
|
94
|
+
function isRecord2(value) {
|
|
11
95
|
return typeof value === "object" && value !== null;
|
|
12
96
|
}
|
|
13
97
|
function isScheduledTaskType(value) {
|
|
14
98
|
return typeof value === "string" && VALID_TASK_TYPES.includes(value);
|
|
15
99
|
}
|
|
16
100
|
function isScheduledTask(value) {
|
|
17
|
-
if (!
|
|
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) &&
|
|
101
|
+
if (!isRecord2(value)) return false;
|
|
102
|
+
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) && isRecord2(value.payload) && typeof value.createdAt === "string" && typeof value.updatedAt === "string";
|
|
19
103
|
}
|
|
20
104
|
function isTaskExecutionLog(value) {
|
|
21
|
-
if (!
|
|
105
|
+
if (!isRecord2(value)) return false;
|
|
22
106
|
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
107
|
value.status
|
|
24
108
|
);
|
|
25
109
|
}
|
|
26
110
|
function isSchedulerStatus(value) {
|
|
27
|
-
if (!
|
|
111
|
+
if (!isRecord2(value)) return false;
|
|
28
112
|
return typeof value.running === "boolean" && typeof value.tasksRegistered === "number" && typeof value.workspacePath === "string";
|
|
29
113
|
}
|
|
30
114
|
function isTaskExecuteResult(value) {
|
|
31
|
-
return
|
|
115
|
+
return isRecord2(value) && typeof value.executionId === "string" && value.accepted === true;
|
|
32
116
|
}
|
|
33
117
|
function isTaskCancelResult(value) {
|
|
34
|
-
return
|
|
118
|
+
return isRecord2(value) && typeof value.executionId === "string" && typeof value.cancelled === "boolean";
|
|
35
119
|
}
|
|
36
120
|
function isTaskListRunningResult(value) {
|
|
37
|
-
return
|
|
121
|
+
return isRecord2(value) && Array.isArray(value.executions);
|
|
38
122
|
}
|
|
39
123
|
function isTaskStartedEventParams(value) {
|
|
40
|
-
return
|
|
124
|
+
return isRecord2(value) && typeof value.executionId === "string" && typeof value.taskId === "string" && typeof value.startedAt === "string";
|
|
41
125
|
}
|
|
42
126
|
function isTaskOutputEventParams(value) {
|
|
43
|
-
return
|
|
127
|
+
return isRecord2(value) && typeof value.executionId === "string" && (value.stream === "stdout" || value.stream === "stderr") && typeof value.data === "string";
|
|
44
128
|
}
|
|
45
129
|
function isTaskCompletedEventParams(value) {
|
|
46
|
-
return
|
|
130
|
+
return isRecord2(value) && typeof value.executionId === "string" && isTaskExecutionLog(value.log);
|
|
47
131
|
}
|
|
48
132
|
function isTaskFailedEventParams(value) {
|
|
49
|
-
return
|
|
133
|
+
return isRecord2(value) && typeof value.executionId === "string" && (value.status === "failure" || value.status === "timeout") && (value.reason === "error" || value.reason === "timeout") && isTaskExecutionLog(value.log);
|
|
50
134
|
}
|
|
51
135
|
function isTaskCancelledEventParams(value) {
|
|
52
|
-
return
|
|
136
|
+
return isRecord2(value) && typeof value.executionId === "string" && isTaskExecutionLog(value.log);
|
|
53
137
|
}
|
|
54
138
|
function isAgentSessionStatus(value) {
|
|
55
139
|
return value === "idle" || value === "running" || value === "needs-input" || value === "completed" || value === "failed" || value === "aborted";
|
|
56
140
|
}
|
|
57
141
|
|
|
142
|
+
// src/skill.ts
|
|
143
|
+
var VALID_SKILL_SCOPES = ["workspace", "user"];
|
|
144
|
+
var VALID_SKILL_SCOPE_STATUSES = [
|
|
145
|
+
"absent",
|
|
146
|
+
"available",
|
|
147
|
+
"installed",
|
|
148
|
+
"blocked",
|
|
149
|
+
"conflict"
|
|
150
|
+
];
|
|
151
|
+
var VALID_SKILL_MUTATION_ACTIONS = [
|
|
152
|
+
"install",
|
|
153
|
+
"uninstall",
|
|
154
|
+
"move",
|
|
155
|
+
"removeExternal",
|
|
156
|
+
"publish",
|
|
157
|
+
"republish",
|
|
158
|
+
"submit-to-official"
|
|
159
|
+
];
|
|
160
|
+
function isRecord3(value) {
|
|
161
|
+
return typeof value === "object" && value !== null;
|
|
162
|
+
}
|
|
163
|
+
function isSkillScope(value) {
|
|
164
|
+
return typeof value === "string" && VALID_SKILL_SCOPES.includes(value);
|
|
165
|
+
}
|
|
166
|
+
function isSkillScopeStatus(value) {
|
|
167
|
+
return typeof value === "string" && VALID_SKILL_SCOPE_STATUSES.includes(value);
|
|
168
|
+
}
|
|
169
|
+
function isSkillMutationAction(value) {
|
|
170
|
+
return typeof value === "string" && VALID_SKILL_MUTATION_ACTIONS.includes(value);
|
|
171
|
+
}
|
|
172
|
+
function isStringArray2(value) {
|
|
173
|
+
return Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
174
|
+
}
|
|
175
|
+
function isSafeResourceId2(value) {
|
|
176
|
+
if (typeof value !== "string" || value.length === 0 || value.includes("\\")) {
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
const segments = value.split("/");
|
|
180
|
+
if (segments.some((segment) => segment.length === 0)) {
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
return segments.every(
|
|
184
|
+
(segment) => segment !== "." && segment !== ".." && /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(segment)
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
function isSkillScopeState(value) {
|
|
188
|
+
if (!isRecord3(value)) {
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
return isSkillScope(value.scope) && isSkillScopeStatus(value.status) && (value.kind === void 0 || value.kind === "builtin" || value.kind === "external") && (value.path === void 0 || typeof value.path === "string") && typeof value.isInstalled === "boolean" && typeof value.canInstall === "boolean" && typeof value.canUninstall === "boolean" && typeof value.canRemove === "boolean" && typeof value.canMoveHere === "boolean" && (value.summary === void 0 || typeof value.summary === "string");
|
|
192
|
+
}
|
|
193
|
+
function isSkillMarketplaceEntry(value) {
|
|
194
|
+
if (!isRecord3(value)) {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
return typeof value.id === "string" && typeof value.displayName === "string" && typeof value.description === "string" && typeof value.version === "string" && typeof value.updatedAt === "string" && (value.categoryId === void 0 || typeof value.categoryId === "string") && (value.enabled === void 0 || typeof value.enabled === "boolean") && typeof value.isCatalogSkill === "boolean" && typeof value.recommended === "boolean" && typeof value.installCount === "number" && (value.requiresSetup === void 0 || typeof value.requiresSetup === "boolean") && (value.setupHint === void 0 || typeof value.setupHint === "string") && (value.homepage === void 0 || typeof value.homepage === "string") && (value.ownerScope === void 0 || isSkillScope(value.ownerScope)) && (value.ownerKind === void 0 || value.ownerKind === "builtin" || value.ownerKind === "external") && typeof value.hasConflict === "boolean" && (value.hasScripts === void 0 || typeof value.hasScripts === "boolean") && (value.hasHooks === void 0 || typeof value.hasHooks === "boolean") && (value.source === void 0 || value.source === "official" || value.source === "community" || value.source === "local") && (value.localSkillPath === void 0 || typeof value.localSkillPath === "string") && (value.canPublish === void 0 || typeof value.canPublish === "boolean") && isSkillScopeState(value.workspaceState) && isSkillScopeState(value.userState);
|
|
198
|
+
}
|
|
199
|
+
function isSkillMarketplaceState(value) {
|
|
200
|
+
if (!isRecord3(value)) {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
return typeof value.configPath === "string" && typeof value.userSkillsPath === "string" && Array.isArray(value.skills) && value.skills.every((entry) => isSkillMarketplaceEntry(entry)) && (value.enabledSkillIds === void 0 || isStringArray2(value.enabledSkillIds)) && (value.recommendedSkillIds === void 0 || isStringArray2(value.recommendedSkillIds)) && typeof value.onboardingRequired === "boolean" && typeof value.hasPersistedSelection === "boolean" && (value.workspaceOpen === void 0 || typeof value.workspaceOpen === "boolean");
|
|
204
|
+
}
|
|
205
|
+
function isSkillMutationRequest(value) {
|
|
206
|
+
return isRecord3(value) && isSafeResourceId2(value.skillId) && isSkillScope(value.targetScope) && isSkillMutationAction(value.action) && (value.confirmed === void 0 || typeof value.confirmed === "boolean");
|
|
207
|
+
}
|
|
208
|
+
function isSkillMutationResult(value) {
|
|
209
|
+
return isRecord3(value) && isSkillMarketplaceState(value.state) && typeof value.skillId === "string" && isSkillScope(value.targetScope) && isSkillMutationAction(value.action) && typeof value.changed === "boolean" && (value.status === "success" || value.status === "blocked" || value.status === "requires_confirmation") && (value.message === void 0 || typeof value.message === "string") && (value.hasScripts === void 0 || typeof value.hasScripts === "boolean") && (value.hasHooks === void 0 || typeof value.hasHooks === "boolean") && (value.prUrl === void 0 || typeof value.prUrl === "string") && (value.fromVersion === void 0 || typeof value.fromVersion === "string") && (value.toVersion === void 0 || typeof value.toVersion === "string");
|
|
210
|
+
}
|
|
211
|
+
function isSkillReconcileResult(value) {
|
|
212
|
+
return isRecord3(value) && isSkillMarketplaceState(value.state) && typeof value.changed === "boolean";
|
|
213
|
+
}
|
|
214
|
+
function isPublishableSkillEntry(value) {
|
|
215
|
+
return isRecord3(value) && typeof value.id === "string" && typeof value.displayName === "string" && typeof value.path === "string" && (value.version === void 0 || typeof value.version === "string");
|
|
216
|
+
}
|
|
217
|
+
function isSkillPublishableResult(value) {
|
|
218
|
+
return isRecord3(value) && Array.isArray(value.skills) && value.skills.every((entry) => isPublishableSkillEntry(entry));
|
|
219
|
+
}
|
|
220
|
+
|
|
58
221
|
// src/bridge.ts
|
|
59
222
|
var SERVICEME_PROTOCOL_VERSION = 2;
|
|
60
|
-
function
|
|
223
|
+
function isRecord4(value) {
|
|
61
224
|
return typeof value === "object" && value !== null;
|
|
62
225
|
}
|
|
63
226
|
function isValidProtocolVersion(value) {
|
|
64
227
|
return typeof value === "number" && Number.isInteger(value) && value >= 1 && value <= SERVICEME_PROTOCOL_VERSION;
|
|
65
228
|
}
|
|
66
229
|
function isBridgeCapabilities(value) {
|
|
67
|
-
return
|
|
230
|
+
return isRecord4(value) && value.bridge === true && value.json === 1 && value.env === 1 && (value.tasks === void 0 || value.tasks === 1) && (value.skills === void 0 || value.skills === 1) && (value.agents === void 0 || value.agents === 1);
|
|
68
231
|
}
|
|
69
232
|
var BRIDGE_METHODS = [
|
|
70
233
|
"system.hello",
|
|
@@ -72,7 +235,14 @@ var BRIDGE_METHODS = [
|
|
|
72
235
|
"system.shutdown",
|
|
73
236
|
"task.execute",
|
|
74
237
|
"task.cancel",
|
|
75
|
-
"task.list-running"
|
|
238
|
+
"task.list-running",
|
|
239
|
+
"skill.marketplace-state",
|
|
240
|
+
"skill.mutate",
|
|
241
|
+
"skill.reconcile",
|
|
242
|
+
"skill.publishable",
|
|
243
|
+
"agent.marketplace-state",
|
|
244
|
+
"agent.mutate",
|
|
245
|
+
"agent.permissions"
|
|
76
246
|
];
|
|
77
247
|
var BRIDGE_EVENTS = [
|
|
78
248
|
"task.started",
|
|
@@ -82,13 +252,13 @@ var BRIDGE_EVENTS = [
|
|
|
82
252
|
"task.cancelled"
|
|
83
253
|
];
|
|
84
254
|
function isSystemHelloResult(value) {
|
|
85
|
-
return
|
|
255
|
+
return isRecord4(value) && typeof value.cliVersion === "string" && isValidProtocolVersion(value.protocolVersion) && isBridgeCapabilities(value.capabilities) && typeof value.pid === "number";
|
|
86
256
|
}
|
|
87
257
|
function isSystemPingResult(value) {
|
|
88
|
-
return
|
|
258
|
+
return isRecord4(value) && typeof value.now === "string";
|
|
89
259
|
}
|
|
90
260
|
function isSystemShutdownResult(value) {
|
|
91
|
-
return
|
|
261
|
+
return isRecord4(value) && value.shuttingDown === true;
|
|
92
262
|
}
|
|
93
263
|
function getBridgeResultValidator(method) {
|
|
94
264
|
switch (method) {
|
|
@@ -104,6 +274,20 @@ function getBridgeResultValidator(method) {
|
|
|
104
274
|
return isTaskCancelResult;
|
|
105
275
|
case "task.list-running":
|
|
106
276
|
return isTaskListRunningResult;
|
|
277
|
+
case "skill.marketplace-state":
|
|
278
|
+
return isSkillMarketplaceState;
|
|
279
|
+
case "skill.mutate":
|
|
280
|
+
return isSkillMutationResult;
|
|
281
|
+
case "skill.reconcile":
|
|
282
|
+
return isSkillReconcileResult;
|
|
283
|
+
case "skill.publishable":
|
|
284
|
+
return isSkillPublishableResult;
|
|
285
|
+
case "agent.marketplace-state":
|
|
286
|
+
return isAgentMarketplaceState;
|
|
287
|
+
case "agent.mutate":
|
|
288
|
+
return isAgentMutationResult;
|
|
289
|
+
case "agent.permissions":
|
|
290
|
+
return isAgentPermissionSummary;
|
|
107
291
|
default:
|
|
108
292
|
return void 0;
|
|
109
293
|
}
|
|
@@ -131,13 +315,13 @@ function isBridgeEventName(value) {
|
|
|
131
315
|
return typeof value === "string" && BRIDGE_EVENTS.includes(value);
|
|
132
316
|
}
|
|
133
317
|
function isBridgeRequest(value) {
|
|
134
|
-
if (!
|
|
318
|
+
if (!isRecord4(value)) {
|
|
135
319
|
return false;
|
|
136
320
|
}
|
|
137
321
|
return isValidProtocolVersion(value.protocolVersion) && value.kind === "request" && typeof value.id === "string" && isBridgeMethod(value.method) && "params" in value;
|
|
138
322
|
}
|
|
139
323
|
function isBridgeResponse(value) {
|
|
140
|
-
if (!
|
|
324
|
+
if (!isRecord4(value)) {
|
|
141
325
|
return false;
|
|
142
326
|
}
|
|
143
327
|
if (!isValidProtocolVersion(value.protocolVersion) || value.kind !== "response" || typeof value.id !== "string" || typeof value.ok !== "boolean") {
|
|
@@ -149,7 +333,7 @@ function isBridgeResponse(value) {
|
|
|
149
333
|
return "error" in value;
|
|
150
334
|
}
|
|
151
335
|
function isBridgeEvent(value) {
|
|
152
|
-
if (!
|
|
336
|
+
if (!isRecord4(value)) {
|
|
153
337
|
return false;
|
|
154
338
|
}
|
|
155
339
|
return isValidProtocolVersion(value.protocolVersion) && value.kind === "event" && isBridgeEventName(value.event) && "params" in value;
|
|
@@ -157,7 +341,7 @@ function isBridgeEvent(value) {
|
|
|
157
341
|
|
|
158
342
|
// src/cli.ts
|
|
159
343
|
var SERVICEME_CLI_SCHEMA_VERSION = 1;
|
|
160
|
-
function
|
|
344
|
+
function isRecord5(value) {
|
|
161
345
|
return typeof value === "object" && value !== null;
|
|
162
346
|
}
|
|
163
347
|
function createCliSuccess(data) {
|
|
@@ -175,7 +359,7 @@ function createCliFailure(error) {
|
|
|
175
359
|
};
|
|
176
360
|
}
|
|
177
361
|
function isCliEnvelope(value) {
|
|
178
|
-
if (!
|
|
362
|
+
if (!isRecord5(value)) {
|
|
179
363
|
return false;
|
|
180
364
|
}
|
|
181
365
|
if (value.schemaVersion !== SERVICEME_CLI_SCHEMA_VERSION || typeof value.ok !== "boolean") {
|
|
@@ -207,20 +391,20 @@ var KNOWN_ENVIRONMENT_TOOLS = [
|
|
|
207
391
|
"dotnet",
|
|
208
392
|
"nuget"
|
|
209
393
|
];
|
|
210
|
-
function
|
|
394
|
+
function isRecord6(value) {
|
|
211
395
|
return typeof value === "object" && value !== null;
|
|
212
396
|
}
|
|
213
397
|
function isKnownEnvironmentTool(value) {
|
|
214
398
|
return KNOWN_ENVIRONMENT_TOOLS.includes(value);
|
|
215
399
|
}
|
|
216
400
|
function isToolCheckResult(value) {
|
|
217
|
-
if (!
|
|
401
|
+
if (!isRecord6(value)) {
|
|
218
402
|
return false;
|
|
219
403
|
}
|
|
220
404
|
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");
|
|
221
405
|
}
|
|
222
406
|
function isEnvironmentCheckResult(value) {
|
|
223
|
-
if (!
|
|
407
|
+
if (!isRecord6(value)) {
|
|
224
408
|
return false;
|
|
225
409
|
}
|
|
226
410
|
return KNOWN_ENVIRONMENT_TOOLS.every(
|
|
@@ -257,6 +441,7 @@ var SERVICEME_ERROR_CODES = [
|
|
|
257
441
|
"executor_timeout",
|
|
258
442
|
"executor_error",
|
|
259
443
|
"task_already_running",
|
|
444
|
+
"not_found",
|
|
260
445
|
"internal_error"
|
|
261
446
|
];
|
|
262
447
|
var RETRYABLE_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
@@ -269,14 +454,14 @@ var RETRYABLE_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
|
269
454
|
"executor_timeout",
|
|
270
455
|
"internal_error"
|
|
271
456
|
]);
|
|
272
|
-
function
|
|
457
|
+
function isRecord7(value) {
|
|
273
458
|
return typeof value === "object" && value !== null;
|
|
274
459
|
}
|
|
275
460
|
function isServicemeErrorCode(value) {
|
|
276
461
|
return typeof value === "string" && SERVICEME_ERROR_CODES.includes(value);
|
|
277
462
|
}
|
|
278
463
|
function isServicemeErrorDetails(value) {
|
|
279
|
-
if (!
|
|
464
|
+
if (!isRecord7(value)) {
|
|
280
465
|
return false;
|
|
281
466
|
}
|
|
282
467
|
return isServicemeErrorCode(value.code) && typeof value.message === "string" && typeof value.retryable === "boolean";
|
|
@@ -316,7 +501,7 @@ function normalizeServicemeError(error, fallbackCode = "internal_error") {
|
|
|
316
501
|
if (isServicemeErrorDetails(error)) {
|
|
317
502
|
return error;
|
|
318
503
|
}
|
|
319
|
-
if (
|
|
504
|
+
if (isRecord7(error)) {
|
|
320
505
|
const code = isServicemeErrorCode(error.code) ? error.code : fallbackCode;
|
|
321
506
|
const message = typeof error.message === "string" ? error.message : "Unexpected serviceme error.";
|
|
322
507
|
const retryable = typeof error.retryable === "boolean" ? error.retryable : isRetryableErrorCode(code);
|
|
@@ -347,32 +532,32 @@ var SERVICEME_IMAGE_FORMATS = [
|
|
|
347
532
|
"png",
|
|
348
533
|
"webp"
|
|
349
534
|
];
|
|
350
|
-
function
|
|
535
|
+
function isRecord8(value) {
|
|
351
536
|
return typeof value === "object" && value !== null;
|
|
352
537
|
}
|
|
353
538
|
function isServiceMeImageFormat(value) {
|
|
354
539
|
return typeof value === "string" && SERVICEME_IMAGE_FORMATS.includes(value);
|
|
355
540
|
}
|
|
356
541
|
function isServiceMeImageCompressOptions(value) {
|
|
357
|
-
if (!
|
|
542
|
+
if (!isRecord8(value)) {
|
|
358
543
|
return false;
|
|
359
544
|
}
|
|
360
545
|
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");
|
|
361
546
|
}
|
|
362
547
|
function isServiceMeImageCompressResult(value) {
|
|
363
|
-
if (!
|
|
548
|
+
if (!isRecord8(value)) {
|
|
364
549
|
return false;
|
|
365
550
|
}
|
|
366
551
|
return typeof value.originalSize === "number" && typeof value.compressedSize === "number" && typeof value.compressionRatio === "number" && typeof value.outputPath === "string";
|
|
367
552
|
}
|
|
368
553
|
function isServiceMeImageInfo(value) {
|
|
369
|
-
if (!
|
|
554
|
+
if (!isRecord8(value)) {
|
|
370
555
|
return false;
|
|
371
556
|
}
|
|
372
557
|
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");
|
|
373
558
|
}
|
|
374
559
|
function isServiceMeImageValidationResult(value) {
|
|
375
|
-
return
|
|
560
|
+
return isRecord8(value) && typeof value.valid === "boolean";
|
|
376
561
|
}
|
|
377
562
|
|
|
378
563
|
// src/json.ts
|
|
@@ -391,7 +576,7 @@ var DEFAULT_JSON_SORT_OPTIONS = {
|
|
|
391
576
|
sortOrder: "asc",
|
|
392
577
|
sortAlgo: "default"
|
|
393
578
|
};
|
|
394
|
-
function
|
|
579
|
+
function isRecord9(value) {
|
|
395
580
|
return typeof value === "object" && value !== null;
|
|
396
581
|
}
|
|
397
582
|
function isJsonSortAlgorithm(value) {
|
|
@@ -401,18 +586,18 @@ function isJsonSortOrder(value) {
|
|
|
401
586
|
return typeof value === "string" && JSON_SORT_ORDERS.includes(value);
|
|
402
587
|
}
|
|
403
588
|
function isJsonSortOptions(value) {
|
|
404
|
-
return
|
|
589
|
+
return isRecord9(value) && isJsonSortOrder(value.sortOrder) && isJsonSortAlgorithm(value.sortAlgo);
|
|
405
590
|
}
|
|
406
591
|
function isJsonValidationResult(value) {
|
|
407
|
-
return
|
|
592
|
+
return isRecord9(value) && typeof value.valid === "boolean" && (value.error === void 0 || typeof value.error === "string");
|
|
408
593
|
}
|
|
409
594
|
function isJsonOutputResult(value) {
|
|
410
|
-
return
|
|
595
|
+
return isRecord9(value) && typeof value.output === "string";
|
|
411
596
|
}
|
|
412
597
|
|
|
413
598
|
// src/metadata.ts
|
|
414
599
|
var SERVICEME_CLI_NAME = "serviceme";
|
|
415
|
-
var SERVICEME_CLI_VERSION = "0.1.
|
|
600
|
+
var SERVICEME_CLI_VERSION = "0.1.7";
|
|
416
601
|
var SERVICEME_CLI_CAPABILITIES = {
|
|
417
602
|
bridge: true,
|
|
418
603
|
tasks: 1,
|
|
@@ -423,32 +608,32 @@ var SERVICEME_CLI_CAPABILITIES = {
|
|
|
423
608
|
};
|
|
424
609
|
|
|
425
610
|
// src/project.ts
|
|
426
|
-
function
|
|
611
|
+
function isRecord10(value) {
|
|
427
612
|
return typeof value === "object" && value !== null;
|
|
428
613
|
}
|
|
429
614
|
function isServiceMeProjectScaffoldPruneResult(value) {
|
|
430
|
-
if (!
|
|
615
|
+
if (!isRecord10(value)) {
|
|
431
616
|
return false;
|
|
432
617
|
}
|
|
433
618
|
return typeof value.applied === "boolean" && typeof value.preset === "string" && Array.isArray(value.commands) && value.commands.every((command) => typeof command === "string");
|
|
434
619
|
}
|
|
435
620
|
function isServiceMeProjectGitInitResult(value) {
|
|
436
|
-
return
|
|
621
|
+
return isRecord10(value) && typeof value.initialized === "boolean" && typeof value.command === "string";
|
|
437
622
|
}
|
|
438
623
|
function isServiceMeProjectMakeScriptsExecutableResult(value) {
|
|
439
|
-
if (!
|
|
624
|
+
if (!isRecord10(value)) {
|
|
440
625
|
return false;
|
|
441
626
|
}
|
|
442
627
|
return typeof value.processedCount === "number" && typeof value.updatedCount === "number" && typeof value.platform === "string" && Array.isArray(value.scripts) && value.scripts.every((script) => typeof script === "string");
|
|
443
628
|
}
|
|
444
629
|
function isServiceMeProjectInstallDepsResult(value) {
|
|
445
|
-
return
|
|
630
|
+
return isRecord10(value) && typeof value.installed === "boolean" && typeof value.command === "string";
|
|
446
631
|
}
|
|
447
632
|
function isServiceMeProjectExtractTemplateInput(value) {
|
|
448
|
-
return
|
|
633
|
+
return isRecord10(value) && typeof value.extractedDirName === "string" && typeof value.projectFilePattern === "string";
|
|
449
634
|
}
|
|
450
635
|
function isServiceMeProjectExtractTemplateResult(value) {
|
|
451
|
-
return
|
|
636
|
+
return isRecord10(value) && typeof value.actualDirName === "string";
|
|
452
637
|
}
|
|
453
638
|
export {
|
|
454
639
|
BRIDGE_EVENTS,
|
|
@@ -471,6 +656,11 @@ export {
|
|
|
471
656
|
createServicemeError,
|
|
472
657
|
getBridgeEventParamsValidator,
|
|
473
658
|
getBridgeResultValidator,
|
|
659
|
+
isAgentMarketplaceState,
|
|
660
|
+
isAgentMutationRequest,
|
|
661
|
+
isAgentMutationResult,
|
|
662
|
+
isAgentPermissionSummary,
|
|
663
|
+
isAgentPermissionsResult,
|
|
474
664
|
isAgentSessionStatus,
|
|
475
665
|
isBridgeCapabilities,
|
|
476
666
|
isBridgeEvent,
|
|
@@ -503,6 +693,11 @@ export {
|
|
|
503
693
|
isServiceMeProjectScaffoldPruneResult,
|
|
504
694
|
isServicemeErrorCode,
|
|
505
695
|
isServicemeErrorDetails,
|
|
696
|
+
isSkillMarketplaceState,
|
|
697
|
+
isSkillMutationRequest,
|
|
698
|
+
isSkillMutationResult,
|
|
699
|
+
isSkillPublishableResult,
|
|
700
|
+
isSkillReconcileResult,
|
|
506
701
|
isSystemHelloResult,
|
|
507
702
|
isSystemPingResult,
|
|
508
703
|
isSystemShutdownResult,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serviceme/devtools-protocol",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Shared protocol contracts, runtime validators, and error models for SERVICEME tools.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"repository": {
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"scripts": {
|
|
41
41
|
"watch": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
42
42
|
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
43
|
+
"typecheck": "tsc --noEmit",
|
|
43
44
|
"test": "pnpm run build && node --test test/**/*.test.js",
|
|
44
45
|
"release:check": "pnpm run test && npm pack --dry-run",
|
|
45
46
|
"pack": "npm pack",
|