@plurnk/plurnk-contracts 8.0.0 → 10.0.0
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/.env.defaults +1 -19
- package/README.md +5 -6
- package/SPEC.md +100 -65
- package/dist/schema/DaemonNotificationEnvelope.json +602 -0
- package/dist/schema/FunctionalityCandidate.json +4 -0
- package/dist/schema/FunctionalityDiscoverQuery.json +12 -0
- package/dist/schema/FunctionalityDiscoverResult.json +10 -0
- package/dist/schema/FunctionalityListQuery.json +33 -0
- package/dist/schema/FunctionalityListResult.json +16 -1
- package/dist/schema/McpServerDefinition.json +1 -1
- package/dist/schema/ModelCatalogPage.json +9 -0
- package/dist/schema/PlurnkStatement.json +42 -2
- package/dist/schema/ProposalProjection.json +0 -4
- package/dist/schema/ProviderAccounting.json +3 -3
- package/dist/schema/ProviderCost.json +1 -1
- package/dist/schema/ProviderRequestAccounting.json +3 -3
- package/dist/schema/ProviderUsage.json +1 -1
- package/dist/src/ActorIdentity.d.ts +26 -0
- package/dist/src/ActorIdentity.d.ts.map +1 -0
- package/dist/src/ActorIdentity.js +179 -0
- package/dist/src/ActorIdentity.js.map +1 -0
- package/dist/src/Application.d.ts +58 -125
- package/dist/src/Application.d.ts.map +1 -1
- package/dist/src/Application.js +372 -80
- package/dist/src/Application.js.map +1 -1
- package/dist/src/ApplicationNotifications.d.ts +77 -24
- package/dist/src/ApplicationNotifications.d.ts.map +1 -1
- package/dist/src/ApplicationNotifications.js +45 -9
- package/dist/src/ApplicationNotifications.js.map +1 -1
- package/dist/src/ApplicationPort.d.ts +53 -13
- package/dist/src/ApplicationPort.d.ts.map +1 -1
- package/dist/src/ApplicationPort.js +1 -1
- package/dist/src/ApplicationPort.js.map +1 -1
- package/dist/src/ApplicationStream.d.ts +2 -2
- package/dist/src/ApplicationStream.d.ts.map +1 -1
- package/dist/src/ApplicationStream.js.map +1 -1
- package/dist/src/CollectionCommand.d.ts +33 -0
- package/dist/src/CollectionCommand.d.ts.map +1 -0
- package/dist/src/CollectionCommand.js +277 -0
- package/dist/src/CollectionCommand.js.map +1 -0
- package/dist/src/Functionality.d.ts +7 -2
- package/dist/src/Functionality.d.ts.map +1 -1
- package/dist/src/Functionality.js.map +1 -1
- package/dist/src/HttpOrigin.d.ts +79 -10
- package/dist/src/HttpOrigin.d.ts.map +1 -1
- package/dist/src/HttpOrigin.js +286 -44
- package/dist/src/HttpOrigin.js.map +1 -1
- package/dist/src/HttpPort.d.ts +35 -0
- package/dist/src/HttpPort.d.ts.map +1 -0
- package/dist/src/HttpPort.js +106 -0
- package/dist/src/HttpPort.js.map +1 -0
- package/dist/src/InteractiveCommands.d.ts +96 -0
- package/dist/src/InteractiveCommands.d.ts.map +1 -0
- package/dist/src/InteractiveCommands.js +409 -0
- package/dist/src/InteractiveCommands.js.map +1 -0
- package/dist/src/LogRow.d.ts +1 -1
- package/dist/src/LogRow.js +1 -1
- package/dist/src/LogRow.js.map +1 -1
- package/dist/src/McpWireTool.d.ts +27 -0
- package/dist/src/McpWireTool.d.ts.map +1 -0
- package/dist/src/McpWireTool.js +30 -0
- package/dist/src/McpWireTool.js.map +1 -0
- package/dist/src/OAuthClient.d.ts +64 -0
- package/dist/src/OAuthClient.d.ts.map +1 -0
- package/dist/src/OAuthClient.js +226 -0
- package/dist/src/OAuthClient.js.map +1 -0
- package/dist/src/ScheduleCommand.d.ts +60 -0
- package/dist/src/ScheduleCommand.d.ts.map +1 -0
- package/dist/src/ScheduleCommand.js +677 -0
- package/dist/src/ScheduleCommand.js.map +1 -0
- package/dist/src/SessionProjection.d.ts +91 -0
- package/dist/src/SessionProjection.d.ts.map +1 -0
- package/dist/src/SessionProjection.js +223 -0
- package/dist/src/SessionProjection.js.map +1 -0
- package/dist/src/Validator.d.ts +4 -3
- package/dist/src/Validator.d.ts.map +1 -1
- package/dist/src/Validator.js +27 -17
- package/dist/src/Validator.js.map +1 -1
- package/dist/src/index.d.ts +11 -5
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +9 -4
- package/dist/src/index.js.map +1 -1
- package/dist/src/types.generated.d.ts +814 -566
- package/dist/src/types.generated.d.ts.map +1 -1
- package/dist/src/types.generated.js.map +1 -1
- package/dist/src/types.js +1 -1
- package/dist/src/types.js.map +1 -1
- package/package.json +3 -2
- package/dist/schema/ApplicationOperationEvent.json +0 -27
- package/dist/schema/CapabilityDescriptor.json +0 -28
- package/dist/schema/CapabilityPolicy.json +0 -22
- package/dist/schema/CapabilityProjection.json +0 -14
- package/dist/schema/CapabilitySelector.json +0 -29
- package/dist/src/CapabilityAdmission.d.ts +0 -11
- package/dist/src/CapabilityAdmission.d.ts.map +0 -1
- package/dist/src/CapabilityAdmission.js +0 -108
- package/dist/src/CapabilityAdmission.js.map +0 -1
package/dist/src/Application.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { isRecord } from "./guards.js";
|
|
2
|
+
import { formatDiscoverPageFooter, formatListPageFooter, parseFamilyDiscoverArgs, parseFamilyListArgs, } from "./CollectionCommand.js";
|
|
3
|
+
import { formatScheduleRows, formatScheduleRunResult, formatScheduleStatusResult, parseScheduleFamilyArgs, } from "./ScheduleCommand.js";
|
|
2
4
|
/** {§startup-admission} Formats an operator-triggered model catalog refresh result. */
|
|
3
5
|
export const formatServiceUpdateReport = (result) => {
|
|
4
6
|
const cat = isRecord(result.catalog) ? result.catalog : {};
|
|
@@ -18,7 +20,7 @@ export const formatServiceUpdateReport = (result) => {
|
|
|
18
20
|
const verLine = `version: ${pkg}@${ver}${suffix} — to update packages, stop the daemon and run: ${upgradeCmd}`;
|
|
19
21
|
return `${catLine}\n${verLine}`;
|
|
20
22
|
};
|
|
21
|
-
/** {§acp-action-binding} Parses a family command (`mcp`, `skills`, `personas`, `env`, `schedule`) into its action kind and parameters. */
|
|
23
|
+
/** {§acp-action-binding} {§client-family-commands} Parses a family command (`mcp`, `skills`, `personas`, `members`, `env`, `schedule`) into its action kind and parameters. */
|
|
22
24
|
export const parseFamilyCommand = (family, args) => {
|
|
23
25
|
let scopePrefix = family === "env" ? "session" : "workspace";
|
|
24
26
|
const filteredArgs = [];
|
|
@@ -37,91 +39,85 @@ export const parseFamilyCommand = (family, args) => {
|
|
|
37
39
|
filteredArgs.push(tok);
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
|
-
const
|
|
42
|
+
const headArg = filteredArgs[0];
|
|
43
|
+
const isListOption = headArg !== undefined
|
|
44
|
+
&& /^--(query|state|origin|offset|limit)(?:=|$)/u.test(headArg);
|
|
45
|
+
const rawSub = isListOption ? "list" : (headArg ?? "list");
|
|
46
|
+
const rest = isListOption ? filteredArgs : filteredArgs.slice(1);
|
|
47
|
+
if (family === "schedule") {
|
|
48
|
+
return parseScheduleFamilyArgs(rawSub, rest);
|
|
49
|
+
}
|
|
41
50
|
const sub = family === "env" && rawSub === "set"
|
|
42
|
-
? "
|
|
51
|
+
? "replace"
|
|
43
52
|
: family === "env" && rawSub === "unset"
|
|
44
53
|
? "remove"
|
|
45
54
|
: rawSub;
|
|
46
|
-
const rest = filteredArgs.slice(1);
|
|
47
55
|
const actionName = `${scopePrefix}.${family}.${sub}`;
|
|
48
56
|
if (sub === "list") {
|
|
49
|
-
return { scopePrefix, sub, rest, actionName, params:
|
|
57
|
+
return { scopePrefix, sub, rest, actionName, params: parseFamilyListArgs(rest) };
|
|
50
58
|
}
|
|
51
59
|
if (sub === "discover") {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
60
|
+
return { scopePrefix, sub, rest, actionName, params: parseFamilyDiscoverArgs(family, rest) };
|
|
61
|
+
}
|
|
62
|
+
if (sub === "enable" || sub === "disable" || sub === "remove") {
|
|
63
|
+
const target = rest[0] ?? "";
|
|
64
|
+
return {
|
|
65
|
+
scopePrefix,
|
|
66
|
+
sub,
|
|
67
|
+
rest,
|
|
68
|
+
actionName,
|
|
69
|
+
params: family === "members" ? { file: target } : { alias: target },
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
if ((sub === "add" || sub === "replace") && family === "mcp") {
|
|
73
|
+
let urlFlag;
|
|
74
|
+
let commandFlag;
|
|
75
|
+
const argFlags = [];
|
|
76
|
+
const envObj = {};
|
|
55
77
|
const posArgs = [];
|
|
56
78
|
for (let i = 0; i < rest.length; i += 1) {
|
|
57
79
|
const tok = rest[i] ?? "";
|
|
58
|
-
if (tok === "--
|
|
59
|
-
|
|
80
|
+
if (tok === "--url" && rest[i + 1] !== undefined) {
|
|
81
|
+
urlFlag = rest[i + 1];
|
|
60
82
|
i += 1;
|
|
61
83
|
}
|
|
62
|
-
else if (tok.startsWith("--
|
|
63
|
-
|
|
84
|
+
else if (tok.startsWith("--url=")) {
|
|
85
|
+
urlFlag = tok.slice("--url=".length);
|
|
86
|
+
}
|
|
87
|
+
else if (tok === "--command" && rest[i + 1] !== undefined) {
|
|
88
|
+
commandFlag = rest[i + 1];
|
|
89
|
+
i += 1;
|
|
90
|
+
}
|
|
91
|
+
else if (tok.startsWith("--command=")) {
|
|
92
|
+
commandFlag = tok.slice("--command=".length);
|
|
64
93
|
}
|
|
65
|
-
else if (tok === "--
|
|
66
|
-
|
|
94
|
+
else if (tok === "--arg" && rest[i + 1] !== undefined) {
|
|
95
|
+
argFlags.push(rest[i + 1] ?? "");
|
|
67
96
|
i += 1;
|
|
68
97
|
}
|
|
69
|
-
else if (tok.startsWith("--
|
|
70
|
-
|
|
98
|
+
else if (tok.startsWith("--arg=")) {
|
|
99
|
+
argFlags.push(tok.slice("--arg=".length));
|
|
71
100
|
}
|
|
72
|
-
else if (tok === "--
|
|
73
|
-
|
|
101
|
+
else if (tok === "--env" && rest[i + 1] !== undefined) {
|
|
102
|
+
const pair = rest[i + 1] ?? "";
|
|
103
|
+
const eq = pair.indexOf("=");
|
|
104
|
+
if (eq > 0)
|
|
105
|
+
envObj[pair.slice(0, eq)] = pair.slice(eq + 1);
|
|
74
106
|
i += 1;
|
|
75
107
|
}
|
|
76
|
-
else if (tok.startsWith("--
|
|
77
|
-
|
|
108
|
+
else if (tok.startsWith("--env=")) {
|
|
109
|
+
const pair = tok.slice("--env=".length);
|
|
110
|
+
const eq = pair.indexOf("=");
|
|
111
|
+
if (eq > 0)
|
|
112
|
+
envObj[pair.slice(0, eq)] = pair.slice(eq + 1);
|
|
78
113
|
}
|
|
79
114
|
else {
|
|
80
115
|
posArgs.push(tok);
|
|
81
116
|
}
|
|
82
117
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
sub,
|
|
87
|
-
rest,
|
|
88
|
-
actionName,
|
|
89
|
-
params: {
|
|
90
|
-
...(sourceFlag !== undefined ? { source: sourceFlag } : {}),
|
|
91
|
-
...(queryFlag !== undefined ? { query: queryFlag } : {}),
|
|
92
|
-
...(ruleFlag !== undefined ? { rule: ruleFlag } : {}),
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
const query = posArgs.join(" ");
|
|
97
|
-
return {
|
|
98
|
-
scopePrefix,
|
|
99
|
-
sub,
|
|
100
|
-
rest,
|
|
101
|
-
actionName,
|
|
102
|
-
params: query.length === 0
|
|
103
|
-
? {}
|
|
104
|
-
: family === "skills"
|
|
105
|
-
? { source: query }
|
|
106
|
-
: family === "schedule"
|
|
107
|
-
? { rule: query }
|
|
108
|
-
: { query },
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
if (sub === "enable" || sub === "disable" || sub === "remove") {
|
|
112
|
-
const target = rest[0] ?? "";
|
|
113
|
-
return {
|
|
114
|
-
scopePrefix,
|
|
115
|
-
sub,
|
|
116
|
-
rest,
|
|
117
|
-
actionName,
|
|
118
|
-
params: family === "members" ? { file: target } : { alias: target },
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
if ((sub === "add" || sub === "replace") && family === "mcp") {
|
|
122
|
-
const alias = rest[0] ?? "";
|
|
123
|
-
const target = rest[1] ?? "";
|
|
124
|
-
const extraArgs = rest.slice(2);
|
|
118
|
+
const alias = posArgs[0] ?? "";
|
|
119
|
+
const target = urlFlag ?? commandFlag ?? posArgs[1] ?? "";
|
|
120
|
+
const extraArgs = argFlags.length > 0 ? argFlags : posArgs.slice(2);
|
|
125
121
|
const params = /^https?:\/\//iu.test(target)
|
|
126
122
|
? { alias, type: "streamable-http", url: target }
|
|
127
123
|
: {
|
|
@@ -129,6 +125,7 @@ export const parseFamilyCommand = (family, args) => {
|
|
|
129
125
|
type: "stdio",
|
|
130
126
|
command: target,
|
|
131
127
|
...(extraArgs.length > 0 ? { args: extraArgs } : {}),
|
|
128
|
+
...(Object.keys(envObj).length > 0 ? { env: envObj } : {}),
|
|
132
129
|
};
|
|
133
130
|
return {
|
|
134
131
|
scopePrefix,
|
|
@@ -139,8 +136,42 @@ export const parseFamilyCommand = (family, args) => {
|
|
|
139
136
|
};
|
|
140
137
|
}
|
|
141
138
|
if (sub === "skills" && family === "mcp") {
|
|
142
|
-
|
|
143
|
-
|
|
139
|
+
let serverFlag;
|
|
140
|
+
let skillFlag;
|
|
141
|
+
let includeFiles;
|
|
142
|
+
let verify;
|
|
143
|
+
const posArgs = [];
|
|
144
|
+
for (let i = 0; i < rest.length; i += 1) {
|
|
145
|
+
const tok = rest[i] ?? "";
|
|
146
|
+
if ((tok === "--server" || tok === "--alias") && rest[i + 1] !== undefined) {
|
|
147
|
+
serverFlag = rest[i + 1];
|
|
148
|
+
i += 1;
|
|
149
|
+
}
|
|
150
|
+
else if (tok.startsWith("--server=")) {
|
|
151
|
+
serverFlag = tok.slice("--server=".length);
|
|
152
|
+
}
|
|
153
|
+
else if (tok.startsWith("--alias=")) {
|
|
154
|
+
serverFlag = tok.slice("--alias=".length);
|
|
155
|
+
}
|
|
156
|
+
else if (tok === "--skill" && rest[i + 1] !== undefined) {
|
|
157
|
+
skillFlag = rest[i + 1];
|
|
158
|
+
i += 1;
|
|
159
|
+
}
|
|
160
|
+
else if (tok.startsWith("--skill=")) {
|
|
161
|
+
skillFlag = tok.slice("--skill=".length);
|
|
162
|
+
}
|
|
163
|
+
else if (tok === "--include-files") {
|
|
164
|
+
includeFiles = true;
|
|
165
|
+
}
|
|
166
|
+
else if (tok === "--verify") {
|
|
167
|
+
verify = true;
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
posArgs.push(tok);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
const server = serverFlag ?? posArgs[0] ?? "";
|
|
174
|
+
const skill = skillFlag ?? (serverFlag !== undefined ? posArgs[0] : posArgs[1]);
|
|
144
175
|
return {
|
|
145
176
|
scopePrefix,
|
|
146
177
|
sub,
|
|
@@ -149,6 +180,8 @@ export const parseFamilyCommand = (family, args) => {
|
|
|
149
180
|
params: {
|
|
150
181
|
server,
|
|
151
182
|
...(skill !== undefined && skill.length > 0 ? { skill } : {}),
|
|
183
|
+
...(includeFiles === true ? { includeFiles: true } : {}),
|
|
184
|
+
...(verify === true ? { verify: true } : {}),
|
|
152
185
|
},
|
|
153
186
|
};
|
|
154
187
|
}
|
|
@@ -173,6 +206,74 @@ export const parseFamilyCommand = (family, args) => {
|
|
|
173
206
|
};
|
|
174
207
|
}
|
|
175
208
|
if (sub === "complete" && family === "mcp") {
|
|
209
|
+
let serverFlag;
|
|
210
|
+
let promptFlag;
|
|
211
|
+
let uriFlag;
|
|
212
|
+
let nameFlag;
|
|
213
|
+
let valueFlag;
|
|
214
|
+
const posArgs = [];
|
|
215
|
+
for (let i = 0; i < rest.length; i += 1) {
|
|
216
|
+
const tok = rest[i] ?? "";
|
|
217
|
+
if ((tok === "--server" || tok === "--alias") && rest[i + 1] !== undefined) {
|
|
218
|
+
serverFlag = rest[i + 1];
|
|
219
|
+
i += 1;
|
|
220
|
+
}
|
|
221
|
+
else if (tok.startsWith("--server=")) {
|
|
222
|
+
serverFlag = tok.slice("--server=".length);
|
|
223
|
+
}
|
|
224
|
+
else if (tok.startsWith("--alias=")) {
|
|
225
|
+
serverFlag = tok.slice("--alias=".length);
|
|
226
|
+
}
|
|
227
|
+
else if (tok === "--prompt" && rest[i + 1] !== undefined) {
|
|
228
|
+
promptFlag = rest[i + 1];
|
|
229
|
+
i += 1;
|
|
230
|
+
}
|
|
231
|
+
else if (tok.startsWith("--prompt=")) {
|
|
232
|
+
promptFlag = tok.slice("--prompt=".length);
|
|
233
|
+
}
|
|
234
|
+
else if (tok === "--uri" && rest[i + 1] !== undefined) {
|
|
235
|
+
uriFlag = rest[i + 1];
|
|
236
|
+
i += 1;
|
|
237
|
+
}
|
|
238
|
+
else if (tok.startsWith("--uri=")) {
|
|
239
|
+
uriFlag = tok.slice("--uri=".length);
|
|
240
|
+
}
|
|
241
|
+
else if (tok === "--name" && rest[i + 1] !== undefined) {
|
|
242
|
+
nameFlag = rest[i + 1];
|
|
243
|
+
i += 1;
|
|
244
|
+
}
|
|
245
|
+
else if (tok.startsWith("--name=")) {
|
|
246
|
+
nameFlag = tok.slice("--name=".length);
|
|
247
|
+
}
|
|
248
|
+
else if (tok === "--value" && rest[i + 1] !== undefined) {
|
|
249
|
+
valueFlag = rest[i + 1];
|
|
250
|
+
i += 1;
|
|
251
|
+
}
|
|
252
|
+
else if (tok.startsWith("--value=")) {
|
|
253
|
+
valueFlag = tok.slice("--value=".length);
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
posArgs.push(tok);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
if (promptFlag !== undefined || uriFlag !== undefined || nameFlag !== undefined || valueFlag !== undefined || serverFlag !== undefined) {
|
|
260
|
+
const server = serverFlag ?? posArgs[0] ?? "";
|
|
261
|
+
const remPos = serverFlag !== undefined ? posArgs : posArgs.slice(1);
|
|
262
|
+
const ref = promptFlag !== undefined
|
|
263
|
+
? { type: "ref/prompt", name: promptFlag }
|
|
264
|
+
: { type: "ref/resource", uri: uriFlag ?? "" };
|
|
265
|
+
const argument = {
|
|
266
|
+
name: nameFlag ?? remPos[0] ?? "",
|
|
267
|
+
value: valueFlag ?? remPos[1] ?? "",
|
|
268
|
+
};
|
|
269
|
+
return {
|
|
270
|
+
scopePrefix,
|
|
271
|
+
sub,
|
|
272
|
+
rest,
|
|
273
|
+
actionName: "workspace.mcp.complete",
|
|
274
|
+
params: { server, ref, argument },
|
|
275
|
+
};
|
|
276
|
+
}
|
|
176
277
|
let server = "";
|
|
177
278
|
let ref = { type: "ref/prompt", name: "" };
|
|
178
279
|
let argTokens = [];
|
|
@@ -221,11 +322,19 @@ export const parseFamilyCommand = (family, args) => {
|
|
|
221
322
|
};
|
|
222
323
|
}
|
|
223
324
|
if ((sub === "add" || sub === "replace") && family === "skills") {
|
|
325
|
+
let sourceFlag;
|
|
224
326
|
let ref;
|
|
225
327
|
const posArgs = [];
|
|
226
328
|
for (let i = 0; i < rest.length; i += 1) {
|
|
227
329
|
const tok = rest[i] ?? "";
|
|
228
|
-
if (tok === "--
|
|
330
|
+
if (tok === "--source" && rest[i + 1] !== undefined) {
|
|
331
|
+
sourceFlag = rest[i + 1];
|
|
332
|
+
i += 1;
|
|
333
|
+
}
|
|
334
|
+
else if (tok.startsWith("--source=")) {
|
|
335
|
+
sourceFlag = tok.slice("--source=".length);
|
|
336
|
+
}
|
|
337
|
+
else if (tok === "--ref" && rest[i + 1] !== undefined) {
|
|
229
338
|
ref = rest[i + 1];
|
|
230
339
|
i += 1;
|
|
231
340
|
}
|
|
@@ -237,7 +346,7 @@ export const parseFamilyCommand = (family, args) => {
|
|
|
237
346
|
}
|
|
238
347
|
}
|
|
239
348
|
const alias = posArgs[0] ?? "";
|
|
240
|
-
const source = posArgs[1] ?? "";
|
|
349
|
+
const source = sourceFlag ?? posArgs[1] ?? "";
|
|
241
350
|
return {
|
|
242
351
|
scopePrefix,
|
|
243
352
|
sub,
|
|
@@ -344,20 +453,6 @@ export const parseFamilyCommand = (family, args) => {
|
|
|
344
453
|
params: { alias, value },
|
|
345
454
|
};
|
|
346
455
|
}
|
|
347
|
-
if ((sub === "add" || sub === "replace") && family === "schedule") {
|
|
348
|
-
const alias = rest[0] ?? "";
|
|
349
|
-
const sessionArg = rest[1] ?? "";
|
|
350
|
-
const rule = rest[2] ?? "";
|
|
351
|
-
const prompt = rest.slice(3).join(" ");
|
|
352
|
-
const target = sessionArg.startsWith("session://") ? sessionArg : `session://${sessionArg}`;
|
|
353
|
-
return {
|
|
354
|
-
scopePrefix,
|
|
355
|
-
sub,
|
|
356
|
-
rest,
|
|
357
|
-
actionName: `workspace.schedule.${sub}`,
|
|
358
|
-
params: { alias, rule, target, prompt },
|
|
359
|
-
};
|
|
360
|
-
}
|
|
361
456
|
return {
|
|
362
457
|
scopePrefix,
|
|
363
458
|
sub,
|
|
@@ -366,4 +461,201 @@ export const parseFamilyCommand = (family, args) => {
|
|
|
366
461
|
params: rest.length > 0 ? { args: rest } : {},
|
|
367
462
|
};
|
|
368
463
|
};
|
|
464
|
+
/** {§acp-action-binding} Formats definition rows for `list` and multi-definition `members` mutations across CLI, ACP, and Web. */
|
|
465
|
+
export const formatFamilyRows = (family, result) => {
|
|
466
|
+
if (family === "schedule") {
|
|
467
|
+
return formatScheduleRows(result);
|
|
468
|
+
}
|
|
469
|
+
const definitions = Array.isArray(result.definitions) ? result.definitions : [];
|
|
470
|
+
const footer = formatListPageFooter(result);
|
|
471
|
+
if (definitions.length === 0) {
|
|
472
|
+
return footer !== null ? `${family}: none\n${footer}\n` : `${family}: none\n`;
|
|
473
|
+
}
|
|
474
|
+
const lines = [];
|
|
475
|
+
for (const item of definitions) {
|
|
476
|
+
if (!isRecord(item)) {
|
|
477
|
+
lines.push(String(item));
|
|
478
|
+
continue;
|
|
479
|
+
}
|
|
480
|
+
const alias = typeof item.alias === "string" ? item.alias : "";
|
|
481
|
+
const state = typeof item.state === "string" ? item.state : "active";
|
|
482
|
+
const def = isRecord(item.definition) ? item.definition : {};
|
|
483
|
+
const detail = isRecord(item.detail) ? item.detail : {};
|
|
484
|
+
const type = typeof def.type === "string" ? def.type : "";
|
|
485
|
+
const target = typeof def.command === "string"
|
|
486
|
+
? def.command
|
|
487
|
+
: typeof def.url === "string"
|
|
488
|
+
? def.url
|
|
489
|
+
: typeof def.source === "string"
|
|
490
|
+
? def.source
|
|
491
|
+
: typeof def.value === "string"
|
|
492
|
+
? def.value
|
|
493
|
+
: family === "members"
|
|
494
|
+
? [
|
|
495
|
+
typeof detail.effect === "string" ? detail.effect : "",
|
|
496
|
+
typeof detail.matched === "number" ? `matched=${String(detail.matched)}` : "",
|
|
497
|
+
]
|
|
498
|
+
.filter((p) => p.length > 0)
|
|
499
|
+
.join(" ")
|
|
500
|
+
: typeof def.description === "string"
|
|
501
|
+
? def.description
|
|
502
|
+
: "";
|
|
503
|
+
const extra = family === "personas"
|
|
504
|
+
? [
|
|
505
|
+
typeof def.model === "string" && def.model.length > 0 ? `model=${def.model}` : "",
|
|
506
|
+
typeof def.effort === "string" && def.effort.length > 0 ? `effort=${def.effort}` : "",
|
|
507
|
+
]
|
|
508
|
+
.filter((p) => p.length > 0)
|
|
509
|
+
.join(" ")
|
|
510
|
+
: "";
|
|
511
|
+
const prov = isRecord(item.provenance) ? item.provenance : {};
|
|
512
|
+
const source = typeof prov.source === "string" && prov.source.length > 0 ? `source=${prov.source}` : "";
|
|
513
|
+
const rowParts = [alias, state, type, target, extra, source].filter((p) => p.length > 0);
|
|
514
|
+
lines.push(rowParts.join(" "));
|
|
515
|
+
}
|
|
516
|
+
if (footer !== null) {
|
|
517
|
+
lines.push(footer);
|
|
518
|
+
}
|
|
519
|
+
return `${lines.join("\n")}\n`;
|
|
520
|
+
};
|
|
521
|
+
/** {§acp-action-binding} Formats any family action result (`list`, `discover`, `add`, `replace`, `remove`, `enable`, `disable`, `skills`, `complete`, `oauth`, `run`, `status`) into structured human-readable text. */
|
|
522
|
+
export const formatFamilyResult = (family, actionName, params, result) => {
|
|
523
|
+
if (!isRecord(result)) {
|
|
524
|
+
return `Executed /${family}`;
|
|
525
|
+
}
|
|
526
|
+
if (actionName === "workspace.mcp.oauth.begin" || actionName === "workspace.mcp.oauth.complete") {
|
|
527
|
+
const alias = typeof result.alias === "string"
|
|
528
|
+
? result.alias
|
|
529
|
+
: typeof params.alias === "string"
|
|
530
|
+
? params.alias
|
|
531
|
+
: "";
|
|
532
|
+
if (isRecord(result.authorization) && typeof result.authorization.url === "string") {
|
|
533
|
+
return `${alias}: authorization required: ${result.authorization.url}`;
|
|
534
|
+
}
|
|
535
|
+
if (result.status === 202) {
|
|
536
|
+
return `${alias}: Sign-in accepted; tools awaiting activation.`;
|
|
537
|
+
}
|
|
538
|
+
if (result.status === 200) {
|
|
539
|
+
return `${alias} active`;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
if (isRecord(result.completion) && Array.isArray(result.completion.values)) {
|
|
543
|
+
const values = result.completion.values.filter((v) => typeof v === "string");
|
|
544
|
+
return values.length === 0 ? `${family} complete: none` : values.join("\n");
|
|
545
|
+
}
|
|
546
|
+
if (actionName === "workspace.mcp.skills") {
|
|
547
|
+
if (result.found === false) {
|
|
548
|
+
return "mcp skills: none";
|
|
549
|
+
}
|
|
550
|
+
if (isRecord(result.skill) && typeof result.skill.name === "string") {
|
|
551
|
+
return `${result.skill.name} verified`;
|
|
552
|
+
}
|
|
553
|
+
if (Array.isArray(result.skills)) {
|
|
554
|
+
if (result.skills.length === 0)
|
|
555
|
+
return "mcp skills: none";
|
|
556
|
+
return result.skills
|
|
557
|
+
.map((item) => {
|
|
558
|
+
if (!isRecord(item))
|
|
559
|
+
return String(item);
|
|
560
|
+
const name = typeof item.name === "string" ? item.name : "";
|
|
561
|
+
const summary = typeof item.description === "string" && item.description.length > 0
|
|
562
|
+
? ` ${item.description}`
|
|
563
|
+
: "";
|
|
564
|
+
return `${name}${summary}`;
|
|
565
|
+
})
|
|
566
|
+
.join("\n");
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
if (Array.isArray(result.candidates)) {
|
|
570
|
+
const footer = formatDiscoverPageFooter(result);
|
|
571
|
+
if (result.candidates.length === 0) {
|
|
572
|
+
return footer !== null ? `${family} discover: none\n${footer}` : `${family} discover: none`;
|
|
573
|
+
}
|
|
574
|
+
const lines = result.candidates.map((item) => {
|
|
575
|
+
if (!isRecord(item))
|
|
576
|
+
return String(item);
|
|
577
|
+
const alias = typeof item.alias === "string" && item.alias.length > 0 ? item.alias : "";
|
|
578
|
+
const summary = typeof item.summary === "string" && item.summary.length > 0 ? item.summary : "";
|
|
579
|
+
return alias.length > 0 && summary.length > 0
|
|
580
|
+
? `${alias} ${summary}`
|
|
581
|
+
: alias.length > 0
|
|
582
|
+
? alias
|
|
583
|
+
: summary;
|
|
584
|
+
});
|
|
585
|
+
if (footer !== null) {
|
|
586
|
+
lines.push(footer);
|
|
587
|
+
}
|
|
588
|
+
return lines.join("\n");
|
|
589
|
+
}
|
|
590
|
+
if (actionName === "workspace.schedule.run") {
|
|
591
|
+
const alias = typeof params.alias === "string" ? params.alias : "";
|
|
592
|
+
return formatScheduleRunResult(alias, result);
|
|
593
|
+
}
|
|
594
|
+
if (actionName === "workspace.schedule.status") {
|
|
595
|
+
const alias = typeof params.alias === "string" ? params.alias : "";
|
|
596
|
+
return formatScheduleStatusResult(alias, result);
|
|
597
|
+
}
|
|
598
|
+
if (result.removed === true && typeof result.alias === "string") {
|
|
599
|
+
return `${result.alias} removed`;
|
|
600
|
+
}
|
|
601
|
+
if (isRecord(result.definition) && typeof result.definition.alias === "string") {
|
|
602
|
+
return formatFamilyRows(family, { definitions: [result.definition] }).trimEnd();
|
|
603
|
+
}
|
|
604
|
+
if (Array.isArray(result.definitions)) {
|
|
605
|
+
return formatFamilyRows(family, result).trimEnd();
|
|
606
|
+
}
|
|
607
|
+
return `Executed /${family}`;
|
|
608
|
+
};
|
|
609
|
+
/** {§acp-action-binding} {§client-composer-sigils} Expands `/learn [--scope project|plurnk] [instructions]` with folder-aware skill target resolution. */
|
|
610
|
+
export const expandLearnCommand = (rawLine, options) => {
|
|
611
|
+
const trimmed = rawLine.trim();
|
|
612
|
+
if (trimmed !== "/learn" && !trimmed.startsWith("/learn ")) {
|
|
613
|
+
return null;
|
|
614
|
+
}
|
|
615
|
+
const restText = trimmed.slice("/learn".length).trim();
|
|
616
|
+
const tokens = restText.length > 0 ? restText.split(/\s+/u) : [];
|
|
617
|
+
let explicitScope;
|
|
618
|
+
const instructionTokens = [];
|
|
619
|
+
for (let i = 0; i < tokens.length; i += 1) {
|
|
620
|
+
const tok = tokens[i] ?? "";
|
|
621
|
+
if (tok === "--scope") {
|
|
622
|
+
const next = tokens[i + 1];
|
|
623
|
+
if (next === undefined || next.startsWith("--")) {
|
|
624
|
+
return { ok: false, error: "Missing /learn --scope value: expected 'project' or 'plurnk'." };
|
|
625
|
+
}
|
|
626
|
+
explicitScope = next;
|
|
627
|
+
i += 1;
|
|
628
|
+
}
|
|
629
|
+
else if (tok.startsWith("--scope=")) {
|
|
630
|
+
explicitScope = tok.slice("--scope=".length);
|
|
631
|
+
}
|
|
632
|
+
else {
|
|
633
|
+
instructionTokens.push(tok);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
if (explicitScope !== undefined && explicitScope !== "project" && explicitScope !== "plurnk") {
|
|
637
|
+
return {
|
|
638
|
+
ok: false,
|
|
639
|
+
error: `Invalid /learn scope '${explicitScope}': expected 'project' or 'plurnk'.`,
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
if (explicitScope === "project" && options?.projectRoot === null) {
|
|
643
|
+
return {
|
|
644
|
+
ok: false,
|
|
645
|
+
error: "This workspace has no project folder; use `/learn --scope plurnk` to save under $XDG_CONFIG_HOME/plurnk/skills.",
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
const scope = explicitScope ?? (options?.projectRoot === null ? "plurnk" : "project");
|
|
649
|
+
const targetPath = scope === "plurnk"
|
|
650
|
+
? "${XDG_CONFIG_HOME:-~/.config}/plurnk/skills/<name>/SKILL.md"
|
|
651
|
+
: ".agents/skills/<name>/SKILL.md";
|
|
652
|
+
const instructions = instructionTokens.join(" ");
|
|
653
|
+
const basePrompt = `Distill reusable workflow, setup, or domain knowledge from this session into an Agent Skill at \`${targetPath}\` ` +
|
|
654
|
+
"(read `mcp:///plurnk/skills.json` first, write a concise `SKILL.md` with YAML frontmatter `name` and `description`, and verify discovery with the `skills` tool).";
|
|
655
|
+
return {
|
|
656
|
+
ok: true,
|
|
657
|
+
scope,
|
|
658
|
+
prompt: instructions.length > 0 ? `${basePrompt}\n\nFocus: ${instructions}` : basePrompt,
|
|
659
|
+
};
|
|
660
|
+
};
|
|
369
661
|
//# sourceMappingURL=Application.js.map
|