@squadrules/mcp 5.12.1 → 5.13.1
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/.tsbuildinfo +1 -1
- package/dist/embed-docs/mem/README.md +12 -12
- package/dist/embed-docs/mem/adapter-migration.md +7 -7
- package/dist/embed-docs/mem/author-adapter.md +4 -4
- package/dist/embed-docs/mem/bulk-insert-adapters-via-cli.md +1 -1
- package/dist/embed-docs/mem/challenge-type-guide.md +35 -25
- package/dist/embed-docs/mem/critic-loop-guide.md +14 -15
- package/dist/embed-docs/mem/critic-loop.md +3 -3
- package/dist/embed-docs/mem/protocol-linking-guide.md +13 -14
- package/dist/embed-docs/mem/refine-search.md +1 -1
- package/dist/resources/embedded-mcp-resources.js +9 -9
- package/dist/resources/embedded-mcp-resources.js.map +1 -1
- package/dist/services/memory/validate-protocol-structure.d.ts.map +1 -1
- package/dist/services/memory/validate-protocol-structure.js +39 -17
- package/dist/services/memory/validate-protocol-structure.js.map +1 -1
- package/dist/services/proof-of-work-store.d.ts +4 -5
- package/dist/services/proof-of-work-store.d.ts.map +1 -1
- package/dist/services/proof-of-work-store.js.map +1 -1
- package/dist/tools/forward-contract-match.d.ts +20 -0
- package/dist/tools/forward-contract-match.d.ts.map +1 -0
- package/dist/tools/forward-contract-match.js +45 -0
- package/dist/tools/forward-contract-match.js.map +1 -0
- package/dist/tools/forward-helpers.js +2 -2
- package/dist/tools/forward-helpers.js.map +1 -1
- package/dist/tools/forward-trace.d.ts.map +1 -1
- package/dist/tools/forward-trace.js +5 -8
- package/dist/tools/forward-trace.js.map +1 -1
- package/dist/tools/forward-view.d.ts.map +1 -1
- package/dist/tools/forward-view.js +5 -7
- package/dist/tools/forward-view.js.map +1 -1
- package/dist/tools/forward_schema.d.ts +25 -25
- package/dist/tools/forward_schema.d.ts.map +1 -1
- package/dist/tools/forward_schema.js +16 -24
- package/dist/tools/forward_schema.js.map +1 -1
- package/dist/tools/next-pow-challenge-shape.d.ts.map +1 -1
- package/dist/tools/next-pow-challenge-shape.js +43 -12
- package/dist/tools/next-pow-challenge-shape.js.map +1 -1
- package/dist/tools/next-pow-helpers.d.ts.map +1 -1
- package/dist/tools/next-pow-helpers.js +19 -14
- package/dist/tools/next-pow-helpers.js.map +1 -1
- package/dist/tools/next-previous-step.js +4 -4
- package/dist/tools/next-previous-step.js.map +1 -1
- package/dist/tools/next-proof-types.d.ts +2 -4
- package/dist/tools/next-proof-types.d.ts.map +1 -1
- package/dist/tools/next_schema.d.ts +20 -18
- package/dist/tools/next_schema.d.ts.map +1 -1
- package/dist/tools/next_schema.js +11 -13
- package/dist/tools/next_schema.js.map +1 -1
- package/dist/tools/squadrules-challenge-display.d.ts.map +1 -1
- package/dist/tools/squadrules-challenge-display.js +8 -11
- package/dist/tools/squadrules-challenge-display.js.map +1 -1
- package/dist/tools/tool-registry.d.ts +12 -11
- package/dist/tools/tool-registry.d.ts.map +1 -1
- package/dist/types/memory.d.ts +7 -5
- package/dist/types/memory.d.ts.map +1 -1
- package/dist/ui/assets/{AccountPage-BhneCJCw.js → AccountPage-Dx42Ohh5.js} +1 -1
- package/dist/ui/assets/ChallengeCard-CdDjzVMc.js +1 -0
- package/dist/ui/assets/{ProtocolDetailPage-kPGgNobg.js → ProtocolDetailPage-DaLHkEk6.js} +1 -1
- package/dist/ui/assets/ProtocolEditPage-si6FjgFJ.js +5 -0
- package/dist/ui/assets/RunGuidedPage-51zvt69k.js +1 -0
- package/dist/ui/assets/{SkillBundlePage-DV9CXjfI.js → SkillBundlePage-DjISl_TJ.js} +1 -1
- package/dist/ui/assets/{export-skill-zip-seCWjJSV.js → export-skill-zip-CHfMqCRE.js} +1 -1
- package/dist/ui/assets/index-CLF3sr9I.css +2 -0
- package/dist/ui/assets/{index-rCZd_925.js → index-v9_N37Or.js} +3 -3
- package/dist/ui/index.html +2 -2
- package/package.json +1 -1
- package/dist/tools/mcp-contract-match.d.ts +0 -21
- package/dist/tools/mcp-contract-match.d.ts.map +0 -1
- package/dist/tools/mcp-contract-match.js +0 -78
- package/dist/tools/mcp-contract-match.js.map +0 -1
- package/dist/ui/assets/ChallengeCard-DVXo4j0b.js +0 -1
- package/dist/ui/assets/ProtocolEditPage-IvFbUiUS.js +0 -5
- package/dist/ui/assets/RunGuidedPage-Db_CQ-9q.js +0 -1
- package/dist/ui/assets/index-BGjXjHf7.css +0 -2
|
@@ -10,7 +10,7 @@ const layerUriSchema = z
|
|
|
10
10
|
.string()
|
|
11
11
|
.regex(/^squadrules:\/\/layer\/[0-9a-f-]{36}(?:\?execution_id=[0-9a-f-]{36})?$/i, 'must match squadrules://layer/{uuid}[?execution_id={uuid}]');
|
|
12
12
|
export const solutionSchema = z.object({
|
|
13
|
-
type: z.enum(['shell', '
|
|
13
|
+
type: z.enum(['shell', 'forward', 'user_input', 'comment', 'subagent']).describe('Must match challenge.type'),
|
|
14
14
|
nonce: z.string().optional().describe('Echo nonce from challenge'),
|
|
15
15
|
proof_hash: z.string().optional().describe('Echo proof_hash from previous challenge or response'),
|
|
16
16
|
shell: z.object({
|
|
@@ -19,10 +19,8 @@ export const solutionSchema = z.object({
|
|
|
19
19
|
stderr: z.string().optional(),
|
|
20
20
|
duration_seconds: z.number().optional()
|
|
21
21
|
}).optional(),
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
arguments: z.any().optional(),
|
|
25
|
-
result: z.any(),
|
|
22
|
+
forward: z.object({
|
|
23
|
+
target: z.string(),
|
|
26
24
|
success: z.boolean()
|
|
27
25
|
}).optional(),
|
|
28
26
|
user_input: z.object({
|
|
@@ -31,10 +29,10 @@ export const solutionSchema = z.object({
|
|
|
31
29
|
}).optional(),
|
|
32
30
|
comment: z.object({ text: z.string() }).optional(),
|
|
33
31
|
subagent: z.object({ report: z.string() }).optional()
|
|
34
|
-
}).refine((data) => !!(data.shell || data.
|
|
32
|
+
}).refine((data) => !!(data.shell || data.forward || data.user_input || data.comment || data.subagent), { message: 'At least one type-specific field (shell, forward, user_input, comment, or subagent) must be provided' }).refine((data) => {
|
|
35
33
|
if (data.type === 'shell' && !data.shell)
|
|
36
34
|
return false;
|
|
37
|
-
if (data.type === '
|
|
35
|
+
if (data.type === 'forward' && !data.forward)
|
|
38
36
|
return false;
|
|
39
37
|
if (data.type === 'user_input' && !data.user_input)
|
|
40
38
|
return false;
|
|
@@ -45,7 +43,7 @@ export const solutionSchema = z.object({
|
|
|
45
43
|
return true;
|
|
46
44
|
}, { message: 'The type-specific field must match the solution type' });
|
|
47
45
|
export const challengeSchema = z.object({
|
|
48
|
-
type: z.enum(['shell', '
|
|
46
|
+
type: z.enum(['shell', 'forward', 'user_input', 'comment', 'subagent']),
|
|
49
47
|
description: z.string(),
|
|
50
48
|
nonce: z.string().optional().describe('Echo back as solution.nonce'),
|
|
51
49
|
proof_hash: z.string().optional().describe('Echo back as solution.proof_hash'),
|
|
@@ -59,9 +57,8 @@ export const challengeSchema = z.object({
|
|
|
59
57
|
/** Server-computed display line for agents/UI. */
|
|
60
58
|
invocation_display: z.string().optional()
|
|
61
59
|
}).optional(),
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
arguments: z.record(z.string(), z.unknown()).optional(),
|
|
60
|
+
forward: z.object({
|
|
61
|
+
target: z.string(),
|
|
65
62
|
expected_result: z.any().optional()
|
|
66
63
|
}).optional(),
|
|
67
64
|
user_input: z.object({
|
|
@@ -71,12 +68,13 @@ export const challengeSchema = z.object({
|
|
|
71
68
|
min_length: z.number().optional()
|
|
72
69
|
}).optional(),
|
|
73
70
|
subagent: z.object({
|
|
74
|
-
context: z.string().optional()
|
|
71
|
+
context: z.string().optional(),
|
|
72
|
+
mcp: z.array(z.object({ tool_name: z.string(), arguments: z.record(z.string(), z.unknown()).optional() })).optional()
|
|
75
73
|
}).optional()
|
|
76
74
|
});
|
|
77
75
|
export const nextInputSchema = z.object({
|
|
78
76
|
uri: layerUriSchema.describe('Current layer URI (from next_action of previous response)'),
|
|
79
|
-
solution: solutionSchema.describe('Proof matching challenge.type: shell/
|
|
77
|
+
solution: solutionSchema.describe('Proof matching challenge.type: shell/forward/user_input/comment/subagent')
|
|
80
78
|
});
|
|
81
79
|
export const nextOutputSchema = z.object({
|
|
82
80
|
must_obey: z.boolean().describe('true for success and recoverable errors, false after max retries'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next_schema.js","sourceRoot":"","sources":["../../src/tools/next_schema.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE,MAAM,cAAc,GAAG,CAAC;KACrB,MAAM,EAAE;KACR,KAAK,CACJ,yEAAyE,EACzE,4DAA4D,CAC7D,CAAC;AAEJ,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"next_schema.js","sourceRoot":"","sources":["../../src/tools/next_schema.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE,MAAM,cAAc,GAAG,CAAC;KACrB,MAAM,EAAE;KACR,KAAK,CACJ,yEAAyE,EACzE,4DAA4D,CAC7D,CAAC;AAEJ,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,2BAA2B,CAAC;IAC7G,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,2BAA2B,CAAC;IAClE,UAAU,EAAE,CA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.ts","sourceRoot":"","sources":["../../src/tools/squadrules-challenge-display.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAmB,MAAM,oBAAoB,CAAC;AAkBjF,qGAAqG;AACrG,wBAAgB,6BAA6B,CAAC,KAAK,CAAC,EAAE,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"squadrules-challenge-display.d.ts","sourceRoot":"","sources":["../../src/tools/squadrules-challenge-display.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAmB,MAAM,oBAAoB,CAAC;AAkBjF,qGAAqG;AACrG,wBAAgB,6BAA6B,CAAC,KAAK,CAAC,EAAE,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA8DpG"}
|
|
@@ -6,7 +6,7 @@ function shellQuoteForDesc(s) {
|
|
|
6
6
|
return s.replace(/[`$\\]/g, '');
|
|
7
7
|
}
|
|
8
8
|
function isAllowedStoredChallengeType(t) {
|
|
9
|
-
return t === 'shell' || t === '
|
|
9
|
+
return t === 'shell' || t === 'forward' || t === 'user_input' || t === 'comment';
|
|
10
10
|
}
|
|
11
11
|
/** Build challenge shape from proof only (no nonce, no store). For read-only display e.g. export. */
|
|
12
12
|
export function buildChallengeShapeForDisplay(proof) {
|
|
@@ -52,16 +52,13 @@ export function buildChallengeShapeForDisplay(proof) {
|
|
|
52
52
|
shellOut['invocation_display'] = invocationLine;
|
|
53
53
|
result['shell'] = shellOut;
|
|
54
54
|
}
|
|
55
|
-
else if (proofType === '
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (proof.mcp?.arguments !== undefined)
|
|
63
|
-
mcpOut['arguments'] = proof.mcp.arguments;
|
|
64
|
-
result['mcp'] = mcpOut;
|
|
55
|
+
else if (proofType === 'forward') {
|
|
56
|
+
const target = proof.forward?.target || 'No target specified';
|
|
57
|
+
result['description'] = `Forward to adapter ${target}. You MUST actually call the forward tool with this target and report the real result; do not fabricate.`;
|
|
58
|
+
const fwdOut = { target };
|
|
59
|
+
if (proof.forward?.expected_result !== undefined)
|
|
60
|
+
fwdOut['expected_result'] = proof.forward.expected_result;
|
|
61
|
+
result['forward'] = fwdOut;
|
|
65
62
|
}
|
|
66
63
|
else if (proofType === 'user_input') {
|
|
67
64
|
const prompt = proof.user_input?.prompt || 'Confirm completion';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"squadrules-challenge-display.js","sourceRoot":"","sources":["../../src/tools/squadrules-challenge-display.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EACL,uBAAuB,EACvB,+BAA+B,EAC/B,wBAAwB,EACzB,MAAM,iCAAiC,CAAC;AAEzC,0DAA0D;AAC1D,SAAS,iBAAiB,CAAC,CAAS;IAClC,OAAO,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;AAClC,CAAC;AAED,SAAS,4BAA4B,CAAC,CAAU;IAC9C,OAAO,CAAC,KAAK,OAAO,IAAI,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"squadrules-challenge-display.js","sourceRoot":"","sources":["../../src/tools/squadrules-challenge-display.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EACL,uBAAuB,EACvB,+BAA+B,EAC/B,wBAAwB,EACzB,MAAM,iCAAiC,CAAC;AAEzC,0DAA0D;AAC1D,SAAS,iBAAiB,CAAC,CAAS;IAClC,OAAO,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;AAClC,CAAC;AAED,SAAS,4BAA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G,KAAK,CAAC,OAAO,EAAE,MAAM,IAAI,qBAAqB,CAAC;YAC9D,MAAM,CAAC,aAAa,CAAC,GAAG,sBAAsB,MAAM,0GAA0G,CAAC;YAC/J,MAAM,MAAM,GAA4B,EAAE,MAAM,EAAE,CAAC;YACnD,IAAI,KAAK,CAAC,OAAO,EAAE,eAAe,KAAK,SAAS;gBAAE,MAAM,CAAC,iBAAiB,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC;YAC5G,MAAM,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC;QAC7B,CAAC;aAAM,IAAI,SAAS,KAAK,YAAY,EAAE,CAAC;YACtC,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,EAAE,MAAM,IAAI,oBAAoB,CAAC;YAChE,MAAM,CAAC,aAAa,CAAC,GAAG,sBAAsB,MAAM,wHAAwH,CAAC;YAC7K,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,CAAC;QACpC,CAAC;aAAM,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YACnC,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,EAAE,UAAU,IAAI,EAAE,CAAC;YAClD,MAAM,CAAC,aAAa,CAAC,GAAG,2CAA2C,SAAS,iGAAiG,CAAC;YAC9K,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;QAChD,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACL,IAAI,EAAE,SAA4B;QAClC,WAAW,EAAE,8HAA8H;KAC5I,CAAC;IACF,IAAI,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC;IAClC,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -142,7 +142,7 @@ export declare const SQUADRULES_TOOL_REGISTRY: readonly [{
|
|
|
142
142
|
solution: import("zod").ZodOptional<import("zod").ZodPreprocess<import("zod").ZodObject<{
|
|
143
143
|
type: import("zod").ZodEnum<{
|
|
144
144
|
shell: "shell";
|
|
145
|
-
|
|
145
|
+
forward: "forward";
|
|
146
146
|
user_input: "user_input";
|
|
147
147
|
comment: "comment";
|
|
148
148
|
subagent: "subagent";
|
|
@@ -161,10 +161,8 @@ export declare const SQUADRULES_TOOL_REGISTRY: readonly [{
|
|
|
161
161
|
stderr: import("zod").ZodOptional<import("zod").ZodString>;
|
|
162
162
|
duration_seconds: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
163
163
|
}, import("zod/v4/core").$strip>>;
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
arguments: import("zod").ZodOptional<import("zod").ZodAny>;
|
|
167
|
-
result: import("zod").ZodAny;
|
|
164
|
+
forward: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
165
|
+
target: import("zod").ZodString;
|
|
168
166
|
success: import("zod").ZodBoolean;
|
|
169
167
|
}, import("zod/v4/core").$strip>>;
|
|
170
168
|
user_input: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
@@ -196,7 +194,7 @@ export declare const SQUADRULES_TOOL_REGISTRY: readonly [{
|
|
|
196
194
|
contract: import("zod").ZodObject<{
|
|
197
195
|
type: import("zod").ZodEnum<{
|
|
198
196
|
shell: "shell";
|
|
199
|
-
|
|
197
|
+
forward: "forward";
|
|
200
198
|
user_input: "user_input";
|
|
201
199
|
comment: "comment";
|
|
202
200
|
subagent: "subagent";
|
|
@@ -209,9 +207,8 @@ export declare const SQUADRULES_TOOL_REGISTRY: readonly [{
|
|
|
209
207
|
cmd: import("zod").ZodString;
|
|
210
208
|
timeout_seconds: import("zod").ZodNumber;
|
|
211
209
|
}, import("zod/v4/core").$strip>>;
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
arguments: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
210
|
+
forward: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
211
|
+
target: import("zod").ZodString;
|
|
215
212
|
expected_result: import("zod").ZodOptional<import("zod").ZodAny>;
|
|
216
213
|
}, import("zod/v4/core").$strip>>;
|
|
217
214
|
user_input: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
@@ -222,6 +219,10 @@ export declare const SQUADRULES_TOOL_REGISTRY: readonly [{
|
|
|
222
219
|
}, import("zod/v4/core").$strip>>;
|
|
223
220
|
subagent: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
224
221
|
context: import("zod").ZodString;
|
|
222
|
+
mcp: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
|
|
223
|
+
tool_name: import("zod").ZodString;
|
|
224
|
+
arguments: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
225
|
+
}, import("zod/v4/core").$strip>>>;
|
|
225
226
|
}, import("zod/v4/core").$strip>>;
|
|
226
227
|
}, import("zod/v4/core").$strip>;
|
|
227
228
|
next_action: import("zod").ZodString;
|
|
@@ -247,7 +248,7 @@ export declare const SQUADRULES_TOOL_REGISTRY: readonly [{
|
|
|
247
248
|
solution_template: import("zod").ZodObject<{
|
|
248
249
|
type: import("zod").ZodEnum<{
|
|
249
250
|
shell: "shell";
|
|
250
|
-
|
|
251
|
+
forward: "forward";
|
|
251
252
|
user_input: "user_input";
|
|
252
253
|
comment: "comment";
|
|
253
254
|
subagent: "subagent";
|
|
@@ -261,7 +262,7 @@ export declare const SQUADRULES_TOOL_REGISTRY: readonly [{
|
|
|
261
262
|
proof_hash: import("zod").ZodOptional<import("zod").ZodString>;
|
|
262
263
|
evidence: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
263
264
|
shell: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
264
|
-
|
|
265
|
+
forward: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
265
266
|
user_input: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
266
267
|
comment: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
267
268
|
}, import("zod/v4/core").$strict>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-registry.d.ts","sourceRoot":"","sources":["../../src/tools/tool-registry.ts"],"names":[],"mappings":"AAeA;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB
|
|
1
|
+
{"version":3,"file":"tool-registry.d.ts","sourceRoot":"","sources":["../../src/tools/tool-registry.ts"],"names":[],"mappings":"AAeA;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkE3B,CAAC;AAEX,6CAA6C;AAC7C,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnF,sDAAsD;AACtD,eAAO,MAAM,qBAAqB,EAAE,SAAS,kBAAkB,EAE9D,CAAC"}
|
package/dist/types/memory.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export interface AdapterInfo {
|
|
|
10
10
|
/** Slug of the chain entry-point adapter. When set, `activate` collapses this adapter's URI to the root. */
|
|
11
11
|
chain_root?: string;
|
|
12
12
|
}
|
|
13
|
-
export type InferenceContractType = 'shell' | '
|
|
13
|
+
export type InferenceContractType = 'shell' | 'forward' | 'user_input' | 'comment' | 'subagent';
|
|
14
14
|
export interface InferenceContractDefinition {
|
|
15
15
|
type?: InferenceContractType;
|
|
16
16
|
required: boolean;
|
|
@@ -25,10 +25,8 @@ export interface InferenceContractDefinition {
|
|
|
25
25
|
args?: string[];
|
|
26
26
|
workdir?: string;
|
|
27
27
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
/** When set (including `{}`), submission must supply a plain object `solution.mcp.arguments` matching these keys (subset semantics). */
|
|
31
|
-
arguments?: Record<string, unknown>;
|
|
28
|
+
forward?: {
|
|
29
|
+
target: string;
|
|
32
30
|
expected_result?: unknown;
|
|
33
31
|
};
|
|
34
32
|
user_input?: {
|
|
@@ -39,6 +37,10 @@ export interface InferenceContractDefinition {
|
|
|
39
37
|
};
|
|
40
38
|
subagent?: {
|
|
41
39
|
context?: string;
|
|
40
|
+
mcp?: Array<{
|
|
41
|
+
tool_name: string;
|
|
42
|
+
arguments?: Record<string, unknown>;
|
|
43
|
+
}>;
|
|
42
44
|
};
|
|
43
45
|
}
|
|
44
46
|
export interface TensorValue {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/types/memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAE/E,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,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|
|
|
1
|
-
import{g as e,y as t}from"./vendor-xESPQGR9.js";import{t as n}from"./react-BvB9BS1T.js";import{n as r,r as i,t as a}from"./index-
|
|
1
|
+
import{g as e,y as t}from"./vendor-xESPQGR9.js";import{t as n}from"./react-BvB9BS1T.js";import{n as r,r as i,t as a}from"./index-v9_N37Or.js";import{t as o}from"./api-BgTb-tmJ.js";async function s(){let e=await o(`/api/me`);if(!e.ok){let t=await e.json().catch(()=>({})),n=Error(t.message??e.statusText);throw n.statusCode=e.status,n}return e.json()}function c(){return e({queryKey:[`me`],queryFn:s,retry:!1})}var l=n(),u={light:`account.themeOptionLight`,dark:`account.themeOptionDark`};function d(e){if(e.name&&e.name.trim().length>0)return e.name;let t=[e.given_name,e.family_name].filter(e=>typeof e==`string`&&e.trim().length>0);return t.length>0?t.join(` `):e.preferred_username&&e.preferred_username.length>0?e.preferred_username:e.sub}function f(){let{t:e}=t(),{data:n,isLoading:o,isError:s}=c(),{preference:f,setPreference:p}=i();return o?(0,l.jsx)(`p`,{className:`text-[var(--color-text-muted)]`,children:e(`account.loading`)}):s||!n?(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h1`,{className:`text-[var(--color-text-heading)] text-2xl font-semibold mb-4`,children:e(`account.title`)}),(0,l.jsx)(`p`,{className:`text-[var(--color-text-muted)]`,children:e(`account.notSignedIn`)}),(0,l.jsx)(`a`,{href:`/auth/callback`,className:`mt-4 min-h-[44px] min-w-[44px] inline-flex items-center justify-center px-4 py-2 rounded-[var(--radius-md)] font-medium bg-[var(--color-primary)] text-white no-underline hover:bg-[var(--color-primary-hover)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`,children:e(`account.signIn`)})]}):(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h1`,{className:`text-[var(--color-text-heading)] text-2xl font-semibold mb-6`,children:e(`account.title`)}),(0,l.jsx)(`p`,{className:`text-[var(--color-text-muted)] mb-6`,children:e(`account.intro`)}),(0,l.jsxs)(`div`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] p-6`,children:[(0,l.jsxs)(`div`,{className:`mb-6 rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] p-4`,children:[(0,l.jsx)(`h2`,{className:`mb-1 text-base font-semibold text-[var(--color-text-heading)]`,children:e(`account.themeTitle`)}),(0,l.jsx)(`p`,{className:`mb-3 text-sm text-[var(--color-text-muted)]`,children:e(`account.themeDescription`)}),(0,l.jsx)(`label`,{htmlFor:`account-theme-preference`,className:`sr-only`,children:e(`account.themePreferenceLabel`)}),(0,l.jsxs)(`select`,{id:`account-theme-preference`,value:f,onChange:e=>{let t=e.target.value;r(t)&&p(t)},className:`min-h-[44px] w-full max-w-xs rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] px-3 py-2 text-[var(--color-text)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`,children:[(0,l.jsx)(`option`,{value:`system`,children:e(`account.themeOptionSystem`)}),a.map(t=>(0,l.jsx)(`option`,{value:t,children:e(u[t])},t))]})]}),(0,l.jsxs)(`div`,{className:`mb-4`,children:[(0,l.jsx)(`span`,{className:`block text-xs uppercase tracking-wider text-[var(--color-text-muted)] mb-1`,children:e(`account.name`)}),(0,l.jsx)(`span`,{className:`text-[var(--color-text-heading)]`,children:d(n)})]}),n.preferred_username&&n.preferred_username!==d(n)&&(0,l.jsxs)(`div`,{className:`mb-4`,children:[(0,l.jsx)(`span`,{className:`block text-xs uppercase tracking-wider text-[var(--color-text-muted)] mb-1`,children:e(`account.username`)}),(0,l.jsx)(`span`,{className:`text-[var(--color-text-heading)]`,children:n.preferred_username})]}),n.email&&(0,l.jsxs)(`div`,{className:`mb-4`,children:[(0,l.jsx)(`span`,{className:`block text-xs uppercase tracking-wider text-[var(--color-text-muted)] mb-1`,children:e(`account.email`)}),(0,l.jsxs)(`span`,{className:`text-[var(--color-text-heading)]`,children:[n.email,n.email_verified===!0?` (${e(`account.emailVerified`)})`:``]})]}),(0,l.jsxs)(`div`,{className:`mb-4`,children:[(0,l.jsx)(`span`,{className:`block text-xs uppercase tracking-wider text-[var(--color-text-muted)] mb-1`,children:e(`account.accountType`)}),(0,l.jsx)(`span`,{className:`text-[var(--color-text-heading)]`,children:n.account_label})]}),(0,l.jsxs)(`div`,{className:`mb-4`,children:[(0,l.jsx)(`span`,{className:`block text-xs uppercase tracking-wider text-[var(--color-text-muted)] mb-1`,children:e(`account.realm`)}),(0,l.jsx)(`span`,{className:`text-[var(--color-text-heading)]`,children:n.realm})]}),n.identity_provider&&(0,l.jsxs)(`div`,{className:`mb-4`,children:[(0,l.jsx)(`span`,{className:`block text-xs uppercase tracking-wider text-[var(--color-text-muted)] mb-1`,children:e(`account.identityProvider`)}),(0,l.jsx)(`span`,{className:`text-[var(--color-text-heading)]`,children:n.identity_provider})]}),n.groups.length>0&&(0,l.jsxs)(`div`,{className:`mb-4`,children:[(0,l.jsx)(`span`,{className:`block text-xs uppercase tracking-wider text-[var(--color-text-muted)] mb-1`,children:e(`account.groups`)}),(0,l.jsx)(`ul`,{className:`list-disc list-inside text-[var(--color-text-heading)] space-y-1`,children:n.groups.map(e=>(0,l.jsx)(`li`,{children:e},e))})]}),(0,l.jsx)(`div`,{className:`mt-6 flex gap-2 flex-wrap`,children:(0,l.jsx)(`a`,{href:`/auth/logout`,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center px-4 py-2 rounded-[var(--radius-md)] font-medium border border-[var(--color-border)] text-[var(--color-text)] bg-transparent no-underline hover:bg-[var(--color-surface-elevated)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`,children:e(`account.logOut`)})})]})]})}export{f as AccountPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./react-BvB9BS1T.js";var t=e(),n={shell:`bg-[var(--badge-shell-bg)] text-[var(--badge-shell-fg)]`,forward:`bg-[var(--badge-mcp-bg)] text-[var(--badge-mcp-fg)]`,user_input:`bg-[var(--badge-user-input-bg)] text-[var(--badge-user-input-fg)]`,comment:`bg-[var(--badge-comment-bg)] text-[var(--badge-comment-fg)]`},r={shell:`Shell command`,forward:`Forward link`,user_input:`User input`,comment:`Comment`};function i({type:e,payload:i}){let a=r[e]??e;return(0,t.jsxs)(`div`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] p-4`,children:[(0,t.jsx)(`div`,{className:`mb-2 flex items-center gap-2`,children:(0,t.jsx)(`span`,{className:`inline-block rounded px-2 py-0.5 text-xs uppercase tracking-wide ${n[e]??`bg-[var(--color-surface-elevated)] text-[var(--color-text-muted)]`}`,children:a})}),i?.cmd&&(0,t.jsxs)(`div`,{className:`mt-2`,children:[(0,t.jsx)(`div`,{className:`text-xs text-[var(--color-text-muted)]`,children:`Command`}),(0,t.jsx)(`code`,{className:`mt-0.5 block break-all rounded bg-[var(--color-surface-elevated)] px-3 py-2 font-mono text-sm text-[var(--color-text)]`,children:i.cmd})]}),i?.target&&(0,t.jsxs)(`div`,{className:`mt-2 text-sm text-[var(--color-text)]`,children:[`Target: `,i.target]}),i?.prompt&&(0,t.jsx)(`div`,{className:`mt-2 text-sm text-[var(--color-text)]`,children:i.prompt}),i?.min_length!=null&&(0,t.jsxs)(`div`,{className:`mt-2 text-sm text-[var(--color-text-muted)]`,children:[`Min length: `,i.min_length,` chars`]})]})}export{i as n,r as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t,m as n,y as r}from"./vendor-xESPQGR9.js";import{i,t as a}from"./react-BvB9BS1T.js";import{t as o}from"./SurfaceCard-BzJidvvn.js";import{a as s,n as c,r as l,s as u,t as d}from"./export-skill-zip-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t,m as n,y as r}from"./vendor-xESPQGR9.js";import{i,t as a}from"./react-BvB9BS1T.js";import{t as o}from"./SurfaceCard-BzJidvvn.js";import{a as s,n as c,r as l,s as u,t as d}from"./export-skill-zip-CHfMqCRE.js";import{n as f}from"./ChallengeCard-CdDjzVMc.js";import{n as p,t as m}from"./StepFlowGraph-BXsWPPO0.js";var h=e(i(),1),g=a();function _({value:e,label:t,className:n}){let{t:i}=r(),[a,o]=(0,h.useState)(!1),s=(0,h.useCallback)(async()=>{try{await navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),2e3)}catch{}},[e]);return(0,g.jsx)(`button`,{type:`button`,onClick:s,className:n,"aria-label":a?i(`run.copied`):t,title:t,children:i(a?`run.copied`:`run.copy`)})}function v(e){return e.body.replace(/\n```json\s*[\s\S]*?```\s*$/g,``).trim()}function y(){let{t:e}=r(),{uri:i}=n(),{data:a,isLoading:y,isError:b,error:x}=u(i?decodeURIComponent(i):void 0,!0),[S,C]=(0,h.useState)(!1),[w,T]=(0,h.useState)(null);if(y&&!a)return(0,g.jsx)(`p`,{className:`text-[var(--color-text-muted)]`,children:e(`protocol.loading`)});if(b||!a)return(0,g.jsxs)(`div`,{role:`alert`,className:`p-4 rounded-[var(--radius-md)] bg-[var(--color-error-bg)] text-[var(--color-error)]`,children:[x instanceof Error?x.message:e(`protocol.notFound`),(0,g.jsx)(t,{to:`/`,className:`block mt-2 text-[var(--color-primary)] underline hover:no-underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`,children:e(`notFound.goHome`)})]});let{title:E,steps:D,triggers:O,completion:k}=s(a.content),A=E.replace(/[^a-zA-Z0-9]+/g,`-`).replace(/^-|-$/g,``)||`protocol`,j=()=>{let e=new Blob([a.content],{type:`text/markdown;charset=utf-8`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`${A}.md`,n.click(),URL.revokeObjectURL(t)},M=async()=>{if(a?.uri){T(null),C(!0);try{let{blob:e,skill_bundle_manifest:t}=await d(a.uri),n=c(t,A);l(e,n)}catch(e){T(e instanceof Error?e.message:String(e))}finally{C(!1)}}},N=`min-h-[44px] min-w-[44px] inline-flex items-center justify-center px-4 py-2 rounded-[var(--radius-md)] font-medium border border-[var(--color-border)] text-[var(--color-text)] bg-[var(--color-surface)] no-underline hover:bg-[var(--color-surface-elevated)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`;return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`h1`,{className:`text-[var(--color-text-heading)] text-2xl font-semibold mb-1`,children:E}),(0,g.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:[(0,g.jsxs)(`p`,{className:`text-sm text-[var(--color-text-muted)] m-0`,children:[(0,g.jsxs)(`span`,{className:`sr-only`,children:[e(`protocol.uri`),`: `]}),(0,g.jsx)(`code`,{className:`break-all rounded bg-[var(--color-surface-elevated)] px-2 py-0.5 text-xs`,children:a.uri}),(0,g.jsxs)(`span`,{className:`ml-2`,children:[`· `,e(`protocol.readOnly`)]}),a.space_name!=null&&a.space_name.length>0?(0,g.jsxs)(`span`,{className:`ml-2 block w-full sm:inline sm:w-auto`,children:[`· `,e(`protocol.spaceLabel`),`: `,a.space_name]}):null]}),(0,g.jsx)(_,{value:a.uri,label:e(`protocol.copyUri`),className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center px-3 py-1.5 text-sm font-medium rounded-[var(--radius-md)] border border-[var(--color-border)] text-[var(--color-text)] bg-[var(--color-surface)] hover:bg-[var(--color-surface-elevated)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`})]}),(0,g.jsxs)(`div`,{className:`mb-6 flex flex-wrap gap-2`,children:[(0,g.jsx)(t,{to:`/protocols/${encodeURIComponent(a.uri)}/run`,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center px-4 py-2 rounded-[var(--radius-md)] font-medium bg-[var(--color-primary)] text-white no-underline hover:bg-[var(--color-primary-hover)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`,children:e(`protocol.runGuided`)}),(0,g.jsx)(t,{to:`/protocols/${encodeURIComponent(a.uri)}/edit`,className:N,children:e(`protocol.edit`)}),(0,g.jsx)(t,{to:`/protocols/new`,className:N,children:e(`protocol.duplicate`)})]}),(0,g.jsxs)(`div`,{className:`mb-6 grid gap-4 xl:grid-cols-[1.6fr_1fr]`,children:[(0,g.jsx)(o,{title:e(`protocol.howToUse`),subtitle:e(`protocol.howToUseInProduct`),children:(0,g.jsxs)(`p`,{className:`text-sm text-[var(--color-text-muted)] m-0`,children:[e(`protocol.howToUseCopy`),` `,(0,g.jsx)(`a`,{href:`https://github.com/SquadRules/mcp#readme`,target:`_blank`,rel:`noopener noreferrer`,className:`text-[var(--color-primary)] underline hover:no-underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`,children:e(`protocol.docsLink`)})]})}),(0,g.jsx)(o,{title:e(`protocol.exportCardTitle`),subtitle:e(`protocol.exportCardSubtitle`),children:(0,g.jsxs)(`div`,{className:`w-full max-w-[22rem] rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] p-3`,children:[(0,g.jsx)(`div`,{className:`mb-2 text-sm font-medium text-[var(--color-text-heading)]`,children:e(`protocol.download`)}),(0,g.jsxs)(`button`,{type:`button`,onClick:j,className:`flex min-h-[44px] w-full items-center justify-between rounded-[var(--radius-md)] px-3 text-left text-sm text-[var(--color-text)] hover:bg-[var(--color-surface-elevated)]`,children:[(0,g.jsx)(`span`,{children:e(`protocol.downloadAsMarkdown`)}),(0,g.jsx)(`span`,{className:`text-[var(--color-text-muted)]`,children:`.md`})]}),(0,g.jsxs)(`button`,{type:`button`,onClick:()=>void M(),disabled:S,className:`mt-1 flex min-h-[44px] w-full items-center justify-between rounded-[var(--radius-md)] px-3 text-left text-sm text-[var(--color-text)] hover:bg-[var(--color-surface-elevated)] disabled:opacity-60`,children:[(0,g.jsx)(`span`,{children:e(`protocol.downloadAsSkill`)}),(0,g.jsx)(`span`,{className:`text-[var(--color-text-muted)]`,children:`.zip`})]}),w?(0,g.jsx)(`p`,{className:`mt-2 text-xs text-[var(--color-error)] m-0`,role:`alert`,children:w}):null,(0,g.jsxs)(t,{to:`/protocols/${encodeURIComponent(a.uri)}/skill`,className:`mt-1 flex min-h-[44px] w-full items-center justify-between rounded-[var(--radius-md)] px-3 text-left text-sm text-[var(--color-text)] no-underline hover:bg-[var(--color-surface-elevated)]`,children:[(0,g.jsx)(`span`,{children:e(`protocol.editAsSkill`)}),(0,g.jsx)(`span`,{className:`text-[var(--color-text-muted)]`,children:`bundle`})]}),(0,g.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-[var(--color-text-muted)] m-0`,children:e(`protocol.exportFooter`)})]})})]}),(0,g.jsxs)(`section`,{className:`mb-6`,"aria-labelledby":`flow-heading`,children:[(0,g.jsx)(`h2`,{id:`flow-heading`,className:`mb-2 text-lg font-semibold text-[var(--color-text-heading)]`,children:e(`protocol.stepFlow`)}),(0,g.jsx)(m,{steps:D.map(e=>({label:e.label}))})]}),(0,g.jsxs)(`section`,{"aria-labelledby":`steps-heading`,className:`mb-6`,children:[(0,g.jsx)(`h2`,{id:`steps-heading`,className:`mb-2 text-lg font-semibold text-[var(--color-text-heading)]`,children:e(`protocol.steps`)}),(0,g.jsx)(`ul`,{className:`m-0 list-none divide-y divide-[var(--color-border)] rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] p-0`,children:D.map((e,t)=>{let n=v(e);return(0,g.jsxs)(`li`,{className:`p-4`,children:[(0,g.jsxs)(`strong`,{className:`block text-[var(--color-text-heading)]`,children:[t+1,`. `,e.label]}),(0,g.jsx)(`div`,{className:`mt-1 text-sm text-[var(--color-text-muted)] break-words`,children:e.summary}),(0,g.jsx)(`div`,{className:`mt-3`,children:(0,g.jsx)(f,{type:e.type,payload:e.challengePayload})}),n?(0,g.jsx)(`div`,{className:`mt-3 border-t border-[var(--color-border)] pt-3`,children:(0,g.jsx)(p,{content:n})}):null]},t)})})]}),(O||k)&&(0,g.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[O?(0,g.jsx)(o,{title:e(`protocol.triggers`),children:(0,g.jsx)(`div`,{className:`max-w-none text-sm text-[var(--color-text)]`,children:(0,g.jsx)(p,{content:O})})}):null,k?(0,g.jsx)(o,{title:e(`protocol.completion`),children:(0,g.jsx)(`div`,{className:`max-w-none text-sm text-[var(--color-text)]`,children:(0,g.jsx)(p,{content:k})})}):null]})]})}export{y as ProtocolDetailPage};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t,m as n,p as r,t as i,y as a}from"./vendor-xESPQGR9.js";import{i as o,t as s}from"./react-BvB9BS1T.js";import{t as c}from"./api-BgTb-tmJ.js";import{r as l,t as u}from"./SpaceSelect-D3al0TgQ.js";import{t as d}from"./SurfaceCard-BzJidvvn.js";import{a as f,i as p,n as m,o as h,r as g,s as _,t as v}from"./export-skill-zip-CHfMqCRE.js";import{t as y}from"./ChallengeCard-CdDjzVMc.js";import{t as b}from"./RichTextEditor-DWLV579w.js";var x=e(o(),1),S=i().min(1,`Protocol content is required`).refine(e=>e.includes(`# `),`Protocol must have an H1 title`).refine(e=>/(^|\n)##\s+Activation Patterns\b/i.test(e),`Include an "Activation Patterns" section (H2)`).refine(e=>/(^|\n)##\s+Reward Signal\b/i.test(e),`Include a "Reward Signal" section (H2)`),C={label:`Step`,bodyMarkdown:`What the user or agent does in this step.`,type:`comment`,comment:{min_length:10}},w=[`shell`,`forward`,`user_input`,`comment`],T=/^squadrules:\/\/adapter\/[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,E=s();function D({t:e,fileInputRef:n,onUpload:r,isNew:i,decodedUri:a}){return(0,E.jsx)(d,{className:`mb-8`,title:e(`protocolEdit.importCardTitle`),subtitle:e(`protocolEdit.uploadHint`),children:(0,E.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,E.jsx)(`input`,{ref:n,type:`file`,accept:`.md,text/markdown`,onChange:r,className:`sr-only`,id:`protocol-upload`,"aria-label":e(`protocolEdit.upload`)}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>n.current?.click(),className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] px-4 py-2 text-sm font-medium text-[var(--color-text)] hover:bg-[var(--color-surface-elevated)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`,children:e(`protocolEdit.upload`)}),!i&&a&&(0,E.jsx)(t,{to:`/protocols/${encodeURIComponent(a)}/skill`,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] px-4 py-2 text-sm font-medium text-[var(--color-text)] no-underline hover:bg-[var(--color-surface-elevated)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`,children:e(`protocol.editAsSkill`)})]})})}function O({t:e,preview:n,skillFolderSlug:r,isNew:i,decodedUri:a}){let[o,s]=(0,x.useState)(!1),[c,l]=(0,x.useState)(null);return(0,E.jsxs)(`div`,{className:`space-y-4`,"aria-label":e(`protocolEdit.previewLabel`),children:[(0,E.jsxs)(d,{title:e(`protocolEdit.previewRenderedTitle`),subtitle:e(`protocolEdit.previewRenderedSubtitle`),children:[(0,E.jsx)(`div`,{className:`text-lg font-semibold text-[var(--color-text-heading)]`,children:n.title}),(0,E.jsx)(`div`,{className:`mt-3 space-y-3`,children:n.steps.length===0?(0,E.jsx)(`div`,{className:`text-sm text-[var(--color-text-muted)]`,children:e(`protocolEdit.previewNoSteps`)}):n.steps.slice(0,20).map((t,n)=>(0,E.jsxs)(`div`,{className:`rounded-[var(--radius-sm)] border border-[var(--color-border)] bg-[var(--color-surface)] p-3`,children:[(0,E.jsx)(`div`,{className:`font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.previewStepLine`,{n:n+1,label:t.label})}),(0,E.jsx)(`div`,{className:`mt-1 text-sm text-[var(--color-text-muted)]`,children:y[t.type]??t.type})]},`${t.label}:${n}`))}),(0,E.jsxs)(`div`,{className:`mt-4 border-t border-[var(--color-border)] pt-4 text-sm text-[var(--color-text-muted)]`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsxs)(`strong`,{className:`text-[var(--color-text-heading)]`,children:[e(`protocol.triggers`),`:`]}),` `,n.triggers?e(`protocolEdit.present`):e(`protocolEdit.missing`)]}),(0,E.jsxs)(`div`,{className:`mt-1`,children:[(0,E.jsxs)(`strong`,{className:`text-[var(--color-text-heading)]`,children:[e(`protocol.completion`),`:`]}),` `,n.completion?e(`protocolEdit.present`):e(`protocolEdit.missing`)]})]})]}),!i&&a?(0,E.jsxs)(d,{title:e(`protocolEdit.skillShortcutTitle`),subtitle:e(`protocolEdit.skillShortcutSubtitle`),children:[(0,E.jsxs)(`div`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] p-3`,children:[(0,E.jsxs)(`div`,{className:`font-medium text-[var(--color-text-heading)]`,children:[r,`-skill/`]}),(0,E.jsxs)(`div`,{className:`mt-2 font-mono text-sm text-[var(--color-text-muted)]`,children:[`Skill.md`,(0,E.jsx)(`br`,{}),`references/`,(0,E.jsx)(`br`,{}),`\xA0\xA0SQUADRULES.md`]})]}),(0,E.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,E.jsx)(t,{to:`/protocols/${encodeURIComponent(a)}/skill`,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] px-4 py-2 text-sm font-medium text-[var(--color-text)] no-underline hover:bg-[var(--color-surface-elevated)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`,children:e(`protocol.editAsSkill`)}),(0,E.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>{(async()=>{if(a){l(null),s(!0);try{let{blob:e,skill_bundle_manifest:t}=await v(a),n=m(t,r);g(e,n)}catch(e){l(e instanceof Error?e.message:String(e))}finally{s(!1)}}})()},className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center rounded-[var(--radius-md)] bg-[var(--color-primary)] px-4 py-2 text-sm font-medium text-white hover:bg-[var(--color-primary-hover)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2 disabled:opacity-60`,children:e(`protocol.downloadAsSkill`)}),c?(0,E.jsx)(`p`,{className:`mt-2 m-0 text-xs text-[var(--color-error)]`,role:`alert`,children:c}):null]})]}):null]})}function k({t:e,isNew:t,spaces:n,spacesLoading:r,targetSpace:i,setTargetSpace:a,forkSourceUri:o,setForkSourceUri:s,moveSpace:c,setMoveSpace:l}){return(0,E.jsx)(`section`,{className:`mb-8 space-y-5 rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] p-5`,children:t?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{htmlFor:`protocol-target-space`,className:`mb-2 block font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.targetSpaceLabel`)}),(0,E.jsx)(u,{id:`protocol-target-space`,spaces:n,value:i,onChange:a,disabled:r}),(0,E.jsx)(`p`,{className:`mt-2 text-sm text-[var(--color-text-muted)]`,children:e(`protocolEdit.targetSpaceHint`)})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{htmlFor:`protocol-fork-source`,className:`mb-2 block font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.forkSourceLabel`)}),(0,E.jsx)(`input`,{id:`protocol-fork-source`,type:`text`,value:o,onChange:e=>s(e.target.value),placeholder:e(`protocolEdit.forkSourcePlaceholder`),autoComplete:`off`,className:`min-h-[44px] w-full max-w-2xl rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] px-4 py-3 text-sm text-[var(--color-text)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`}),(0,E.jsx)(`p`,{className:`mt-2 text-sm text-[var(--color-text-muted)]`,children:e(`protocolEdit.forkSourceHint`)})]})]}):(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{htmlFor:`protocol-move-space`,className:`mb-2 block font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.moveSpaceLabel`)}),(0,E.jsx)(u,{id:`protocol-move-space`,spaces:n,value:c,onChange:l,disabled:r}),(0,E.jsx)(`p`,{className:`mt-2 text-sm text-[var(--color-text-muted)]`,children:e(`protocolEdit.moveSpaceHint`)})]})})}var A=[`bash`,`sh`,`python3`,`python`,`node`],j=`min-h-[44px] w-full rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] px-4 py-3 text-sm text-[var(--color-text)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`,M=`min-h-[44px] w-full rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] px-4 py-3 text-sm text-[var(--color-text)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`;function N({t:e,step:t,index:n,stepsLength:r,uploadKey:i,challengeTypeLabel:a,setStep:o,removeStep:s}){return(0,E.jsxs)(`div`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] p-5 space-y-5`,children:[(0,E.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center justify-between gap-2`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{className:`text-sm font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.stepHeading`,{n:n+1})}),(0,E.jsx)(`div`,{className:`text-sm text-[var(--color-text-muted)]`,children:e(`protocolEdit.stepEditorHint`)})]}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>s(n),disabled:r<=1,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] px-4 py-2 text-sm font-medium text-[var(--color-text)] hover:bg-[var(--color-surface-elevated)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2 disabled:opacity-50`,children:e(`protocolEdit.removeStep`)})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{className:`mb-2 block font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.stepLabel`)}),(0,E.jsx)(`input`,{type:`text`,value:t.label,onChange:e=>o(n,{label:e.target.value}),className:j})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{className:`mb-2 font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.challengeType`)}),(0,E.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:w.map(e=>(0,E.jsx)(`button`,{type:`button`,"aria-pressed":t.type===e,onClick:()=>o(n,{type:e,shell:e===`shell`?{cmd:t.shell?.cmd??``,timeout_seconds:t.shell?.timeout_seconds??30,interpreter:t.shell?.interpreter,workdir:t.shell?.workdir,flags:t.shell?.flags??[],args:t.shell?.args??[]}:void 0,forward:e===`forward`?{target:t.forward?.target??``}:void 0,user_input:e===`user_input`?{prompt:t.user_input?.prompt??``}:void 0,comment:e===`comment`?{min_length:t.comment?.min_length??10}:void 0}),className:`min-h-[44px] rounded-[var(--radius-md)] px-4 text-sm font-medium ${t.type===e?`bg-[var(--color-primary)] text-white`:`border border-[var(--color-border)] bg-[var(--color-surface)] text-[var(--color-text)]`}`,children:a[e]},e))})]}),(0,E.jsx)(`div`,{children:(0,E.jsx)(b,{label:e(`protocolEdit.stepContent`),value:t.bodyMarkdown,onChange:e=>o(n,{bodyMarkdown:e}),contentKey:i})}),(0,E.jsxs)(`div`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] p-4`,children:[(0,E.jsx)(`div`,{className:`mb-3 text-sm font-medium text-[var(--color-text-heading)]`,children:`Challenge fields`}),(0,E.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[t.type===`shell`&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.shellCmd`)}),(0,E.jsx)(`input`,{type:`text`,value:t.shell?.cmd??``,onChange:e=>o(n,{shell:{cmd:e.target.value,timeout_seconds:t.shell?.timeout_seconds??30,interpreter:t.shell?.interpreter,workdir:t.shell?.workdir,flags:t.shell?.flags??[],args:t.shell?.args??[]}}),className:M})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.shellTimeout`)}),(0,E.jsx)(`input`,{type:`number`,min:1,value:t.shell?.timeout_seconds??30,onChange:e=>o(n,{shell:{cmd:t.shell?.cmd??``,timeout_seconds:Math.max(1,Number(e.target.value)||30),interpreter:t.shell?.interpreter,workdir:t.shell?.workdir,flags:t.shell?.flags??[],args:t.shell?.args??[]}}),className:M})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.shellInterpreter`)}),(0,E.jsxs)(`select`,{required:!0,value:t.shell?.interpreter??``,onChange:e=>o(n,{shell:{cmd:t.shell?.cmd??``,timeout_seconds:t.shell?.timeout_seconds??30,interpreter:e.target.value||void 0,workdir:t.shell?.workdir,flags:t.shell?.flags??[],args:t.shell?.args??[]}}),className:M,children:[(0,E.jsx)(`option`,{value:``,children:e(`protocolEdit.shellInterpreterPlaceholder`)}),A.map(e=>(0,E.jsx)(`option`,{value:e,children:e},e))]}),(0,E.jsx)(`p`,{className:`mt-2 text-xs text-[var(--color-text-muted)]`,children:e(`protocolEdit.shellInterpreterHint`)})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.shellWorkdir`)}),(0,E.jsx)(`input`,{type:`text`,value:t.shell?.workdir??``,onChange:e=>o(n,{shell:{cmd:t.shell?.cmd??``,timeout_seconds:t.shell?.timeout_seconds??30,interpreter:t.shell?.interpreter,workdir:e.target.value||void 0,flags:t.shell?.flags??[],args:t.shell?.args??[]}}),className:M})]}),(0,E.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,E.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.shellFlags`)}),(0,E.jsx)(`textarea`,{rows:3,value:(t.shell?.flags??[]).join(`
|
|
2
|
+
`),onChange:e=>o(n,{shell:{cmd:t.shell?.cmd??``,timeout_seconds:t.shell?.timeout_seconds??30,interpreter:t.shell?.interpreter,workdir:t.shell?.workdir,flags:e.target.value.split(`
|
|
3
|
+
`).map(e=>e.trim()).filter(Boolean),args:t.shell?.args??[]}}),className:`w-full rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] px-4 py-3 text-sm text-[var(--color-text)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`})]}),(0,E.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,E.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.shellArgs`)}),(0,E.jsx)(`textarea`,{rows:3,value:(t.shell?.args??[]).join(`
|
|
4
|
+
`),onChange:e=>o(n,{shell:{cmd:t.shell?.cmd??``,timeout_seconds:t.shell?.timeout_seconds??30,interpreter:t.shell?.interpreter,workdir:t.shell?.workdir,flags:t.shell?.flags??[],args:e.target.value.split(`
|
|
5
|
+
`).map(e=>e.trim()).filter(Boolean)}}),className:`w-full rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] px-4 py-3 text-sm text-[var(--color-text)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`})]})]}),t.type===`forward`&&(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.forwardTarget`)}),(0,E.jsx)(`input`,{type:`text`,value:t.forward?.target??``,onChange:e=>o(n,{forward:{target:e.target.value}}),className:M})]}),t.type===`user_input`&&(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.userInputPrompt`)}),(0,E.jsx)(`input`,{type:`text`,value:t.user_input?.prompt??``,onChange:e=>o(n,{user_input:{prompt:e.target.value}}),className:M})]}),t.type===`comment`&&(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.commentMinLength`)}),(0,E.jsx)(`input`,{type:`number`,min:1,value:t.comment?.min_length??10,onChange:e=>o(n,{comment:{min_length:Math.max(1,parseInt(e.target.value,10)||10)}}),className:M})]})]})]})]})}function P(){let{t:e}=a(),{uri:i}=n(),o=r(),s=i?decodeURIComponent(i):void 0,u=!s,{data:d,isLoading:m}=_(s,!u),[g,v]=(0,x.useState)({protocolLabel:``,triggersMarkdown:``,steps:[{...C}],completionMarkdown:``}),[y,w]=(0,x.useState)(()=>String(Date.now())),[A,j]=(0,x.useState)(!1),[M,P]=(0,x.useState)(null),[F,I]=(0,x.useState)(null),L=(0,x.useRef)(null),R=(0,x.useRef)(``),[z,B]=(0,x.useState)(``),[V,H]=(0,x.useState)(``),[U,W]=(0,x.useState)(``),{data:G,isLoading:K}=l(!0,{});(0,x.useEffect)(()=>{u&&(B(``),W(``))},[u]),(0,x.useEffect)(()=>{if(!u)return;let e=G?.spaces?.find(e=>e.type===`personal`);B(t=>t===``&&e?e.space_id:t)},[u,G?.spaces]),(0,x.useEffect)(()=>{if(u||!d)return;let e=typeof d.space_id==`string`?d.space_id.trim():``;R.current=e,H(e)},[u,d]),(0,x.useEffect)(()=>{if(d?.content)try{v(h(d.content)),w(String(Date.now()))}catch{v({protocolLabel:d.label||`Protocol`,triggersMarkdown:``,steps:[{...C}],completionMarkdown:``})}},[d]);let q=e=>{let t=e.target.files?.[0];if(!t)return;let n=new FileReader;n.onload=()=>{let e=typeof n.result==`string`?n.result:``;try{v(h(e)),w(String(Date.now())),I(null),P(null)}catch{P(`Could not parse the uploaded file. Use valid protocol markdown.`)}},n.readAsText(t,`UTF-8`),e.target.value=``},J=(e,t)=>{v(n=>({...n,[e]:t}))},Y=(e,t)=>{v(n=>({...n,steps:n.steps.map((n,r)=>r===e?typeof t==`function`?t(n):{...n,...t}:n)}))},X=()=>{v(e=>({...e,steps:[...e.steps,{...C,label:`Step ${e.steps.length+1}`}]}))},Z=e=>{v(t=>({...t,steps:t.steps.filter((t,n)=>n!==e)}))},Q=async t=>{t.preventDefault(),P(null),I(null);let n=p(g),r=S.safeParse(n);if(!r.success){I(r.error.issues[0]?.message??`Invalid`);return}let i=U.trim();if(i&&!T.test(i))I(e(`protocolEdit.forkUriInvalid`));else{j(!0);try{if(u){let e=z.trim()||`personal`,t=await c(`/api/train`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({content:n,llm_model_id:`squadrules-ui`,force_update:!1,space:e,...i?{source_adapter_uri:i}:{}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.message??t.statusText)}let r=await t.json(),a=r.items?.[0]?.adapter_uri,s=r.items?.[0]?.uri;o(a?`/protocols/${encodeURIComponent(a)}`:s?`/protocols/${encodeURIComponent(s)}`:`/`)}else{let e=R.current.trim(),t=V.trim(),r={uris:[s],content:[n]};t&&t!==e&&(r.space=t);let i=await c(`/api/tune`,{method:`POST`,body:JSON.stringify(r)});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e.message??i.statusText)}o(`/protocols/${encodeURIComponent(s)}`)}}catch(e){P(e instanceof Error?e.message:String(e))}finally{j(!1)}}},$=(()=>{try{return f(p(g))}catch{return{title:g.protocolLabel||`Protocol`,steps:[],triggers:``,completion:``}}})();if(!u&&m&&!d)return(0,E.jsx)(`p`,{className:`text-[var(--color-text-muted)]`,children:e(`protocol.loading`)});let ee={shell:e(`protocolEdit.challengeShell`),forward:e(`protocolEdit.challengeForward`),user_input:e(`protocolEdit.challengeUserInput`),comment:e(`protocolEdit.challengeComment`)},te=(g.protocolLabel.trim()||$.title||`skill`).replace(/[^a-zA-Z0-9]+/g,`-`).replace(/^-|-$/g,``).toLowerCase()||`skill`;return(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`h1`,{className:`mb-1 text-2xl font-semibold text-[var(--color-text-heading)]`,children:e(u?`protocolEdit.newTitle`:`protocolEdit.editTitle`)}),(0,E.jsx)(`p`,{className:`mb-6 text-sm text-[var(--color-text-muted)]`,children:e(`protocolEdit.hint`)}),(0,E.jsx)(k,{t:e,isNew:u,spaces:G?.spaces,spacesLoading:K,targetSpace:z,setTargetSpace:B,forkSourceUri:U,setForkSourceUri:W,moveSpace:V,setMoveSpace:H}),(0,E.jsx)(D,{t:e,fileInputRef:L,onUpload:q,isNew:u,decodedUri:s}),(0,E.jsx)(`form`,{onSubmit:Q,"aria-label":e(`protocolEdit.formLabel`),children:(0,E.jsxs)(`div`,{className:`mb-6 grid gap-6 xl:grid-cols-[1.45fr_1fr]`,children:[(0,E.jsxs)(`div`,{className:`space-y-6`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{htmlFor:`protocol-label`,className:`mb-2 block font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.protocolLabel`)}),(0,E.jsx)(`input`,{id:`protocol-label`,type:`text`,value:g.protocolLabel,onChange:e=>J(`protocolLabel`,e.target.value),className:`min-h-[44px] w-full rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] px-4 py-3 text-sm text-[var(--color-text)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`})]}),(0,E.jsx)(b,{label:e(`protocolEdit.triggersLabel`),hint:e(`protocolEdit.triggersEditorHint`),value:g.triggersMarkdown,onChange:e=>J(`triggersMarkdown`,e),contentKey:y}),g.steps.map((t,n)=>(0,E.jsx)(N,{t:e,step:t,index:n,stepsLength:g.steps.length,uploadKey:y,challengeTypeLabel:ee,setStep:Y,removeStep:Z},n)),(0,E.jsx)(`button`,{type:`button`,onClick:X,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] px-4 py-2 text-sm font-medium text-[var(--color-text)] hover:bg-[var(--color-surface-elevated)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`,children:e(`protocolEdit.addStep`)}),(0,E.jsx)(b,{label:e(`protocolEdit.completionLabel`),value:g.completionMarkdown,onChange:e=>J(`completionMarkdown`,e),contentKey:y}),F&&(0,E.jsx)(`p`,{className:`text-sm text-[var(--color-error)]`,role:`alert`,children:F}),M&&(0,E.jsx)(`div`,{className:`rounded-[var(--radius-md)] bg-[var(--color-error-bg)] p-4 text-[var(--color-error)]`,role:`alert`,children:M}),(0,E.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,E.jsx)(`button`,{type:`submit`,disabled:A,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center rounded-[var(--radius-md)] bg-[var(--color-primary)] px-4 py-2 font-medium text-white hover:bg-[var(--color-primary-hover)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2 disabled:opacity-60`,children:e(A?`protocolEdit.saving`:`protocolEdit.save`)}),(0,E.jsx)(t,{to:u?`/`:`/protocols/${encodeURIComponent(s)}`,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] px-4 py-2 font-medium text-[var(--color-text)] no-underline hover:bg-[var(--color-surface-elevated)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`,children:e(`protocolEdit.cancel`)})]})]}),(0,E.jsx)(O,{t:e,preview:$,skillFolderSlug:te,isNew:u,decodedUri:s})]})})]})}export{P as ProtocolEditPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t,h as n,m as r,s as i,y as a}from"./vendor-xESPQGR9.js";import{i as o,t as s}from"./react-BvB9BS1T.js";import{t as c}from"./api-BgTb-tmJ.js";import{t as l}from"./SurfaceCard-BzJidvvn.js";import{t as u}from"./ErrorAlert-BoPXaBKG.js";import{n as d}from"./ChallengeCard-CdDjzVMc.js";import{n as f,t as p}from"./StepFlowGraph-BXsWPPO0.js";import{n as m,t as h}from"./useRunSession-CB5wPJ8O.js";var g=e(o(),1),_=s();function v({contract:e,disabled:t,onSubmit:n}){let{t:r}=a(),i=e.type,[o,s]=(0,g.useState)(0),[c,l]=(0,g.useState)(``),[u,d]=(0,g.useState)(``),f=e.forward?.target??``,[p,m]=(0,g.useState)(!0),h=e.user_input?.prompt??``,[v,y]=(0,g.useState)(``),b=e.comment?.min_length??10,[x,S]=(0,g.useState)(``),[C,w]=(0,g.useState)(null);(0,g.useEffect)(()=>{w(null),s(0),l(``),d(``),m(!0),y(``),S(``)},[i,f,h,b]);let T=(0,g.useMemo)(()=>i===`shell`?Number.isFinite(o):i===`forward`?f.trim().length>0:i===`user_input`?v.trim().length>0:i===`comment`&&x.trim().length>=b,[i,o,f,v,x,b]);return(0,_.jsxs)(`form`,{onSubmit:e=>{if(e.preventDefault(),w(null),T)try{if(i===`shell`){n({type:i,shell:{exit_code:o,...c.trim()?{stdout:c}:{},...u.trim()?{stderr:u}:{}}});return}if(i===`forward`){n({type:i,forward:{target:f,success:p}});return}if(i===`user_input`){n({type:i,user_input:{confirmation:v.trim(),timestamp:new Date().toISOString()}});return}if(i===`comment`){n({type:i,comment:{text:x.trim()}});return}}catch(e){w(e instanceof Error?e.message:String(e))}},"aria-label":r(`run.solutionFormLabel`),children:[C&&(0,_.jsx)(`div`,{className:`mb-4 p-4 rounded-[var(--radius-md)] bg-[var(--color-error-bg)] text-[var(--color-error)]`,role:`alert`,children:C}),i===`shell`&&(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`label`,{htmlFor:`run-shell-exit-code`,className:`block font-medium text-[var(--color-text-heading)] mb-2`,children:r(`run.shell.exitCode`)}),(0,_.jsx)(`input`,{id:`run-shell-exit-code`,type:`number`,inputMode:`numeric`,value:o,onChange:e=>s(Number(e.target.value)),className:`w-full min-h-[44px] px-4 py-2 border border-[var(--color-border)] rounded-[var(--radius-md)] text-[var(--color-text)] bg-[var(--color-surface)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`,disabled:t,required:!0})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`label`,{htmlFor:`run-shell-stdout`,className:`block font-medium text-[var(--color-text-heading)] mb-2`,children:r(`run.shell.stdout`)}),(0,_.jsx)(`textarea`,{id:`run-shell-stdout`,value:c,onChange:e=>l(e.target.value),className:`w-full min-h-[8rem] px-4 py-3 border border-[var(--color-border)] rounded-[var(--radius-md)] text-[var(--color-text)] bg-[var(--color-surface)] font-mono text-sm resize-y`,disabled:t})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`label`,{htmlFor:`run-shell-stderr`,className:`block font-medium text-[var(--color-text-heading)] mb-2`,children:r(`run.shell.stderr`)}),(0,_.jsx)(`textarea`,{id:`run-shell-stderr`,value:u,onChange:e=>d(e.target.value),className:`w-full min-h-[6rem] px-4 py-3 border border-[var(--color-border)] rounded-[var(--radius-md)] text-[var(--color-text)] bg-[var(--color-surface)] font-mono text-sm resize-y`,disabled:t})]})]}),i===`forward`&&(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(`div`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] p-4`,children:[(0,_.jsx)(`div`,{className:`text-sm text-[var(--color-text-muted)]`,children:r(`run.forward.target`)}),(0,_.jsx)(`div`,{className:`font-medium text-[var(--color-text-heading)] break-all`,children:f||r(`run.forward.targetMissing`)})]}),(0,_.jsxs)(`label`,{className:`inline-flex items-center gap-2 min-h-[44px]`,children:[(0,_.jsx)(`input`,{type:`checkbox`,checked:p,onChange:e=>m(e.target.checked),disabled:t,className:`h-4 w-4`}),(0,_.jsx)(`span`,{className:`text-sm text-[var(--color-text)]`,children:r(`run.forward.success`)})]})]}),i===`user_input`&&(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(`div`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] p-4`,children:[(0,_.jsx)(`div`,{className:`text-sm text-[var(--color-text-muted)]`,children:r(`run.userInput.prompt`)}),(0,_.jsx)(`div`,{className:`font-medium text-[var(--color-text-heading)]`,children:h||r(`run.userInput.promptMissing`)})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`label`,{htmlFor:`run-user-confirmation`,className:`block font-medium text-[var(--color-text-heading)] mb-2`,children:r(`run.userInput.confirmation`)}),(0,_.jsx)(`textarea`,{id:`run-user-confirmation`,value:v,onChange:e=>y(e.target.value),className:`w-full min-h-[6rem] px-4 py-3 border border-[var(--color-border)] rounded-[var(--radius-md)] text-[var(--color-text)] bg-[var(--color-surface)] resize-y`,disabled:t,required:!0})]})]}),i===`comment`&&(0,_.jsxs)(`div`,{className:`space-y-2`,children:[(0,_.jsxs)(`div`,{className:`text-sm text-[var(--color-text-muted)]`,children:[r(`run.comment.minLength`,{count:b}),` · `,r(`run.comment.count`,{count:x.length})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`label`,{htmlFor:`run-comment-text`,className:`block font-medium text-[var(--color-text-heading)] mb-2`,children:r(`run.comment.text`)}),(0,_.jsx)(`textarea`,{id:`run-comment-text`,value:x,onChange:e=>S(e.target.value),className:`w-full min-h-[10rem] px-4 py-3 border border-[var(--color-border)] rounded-[var(--radius-md)] text-[var(--color-text)] bg-[var(--color-surface)] resize-y`,disabled:t,required:!0,"aria-invalid":x.trim().length>0&&x.trim().length<b})]})]}),(0,_.jsx)(`button`,{type:`submit`,disabled:t||!T,className:`mt-4 min-h-[44px] min-w-[44px] px-4 py-2 rounded-[var(--radius-md)] font-medium bg-[var(--color-primary)] text-white border-0 cursor-pointer disabled:opacity-60 disabled:cursor-not-allowed hover:bg-[var(--color-primary-hover)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`,children:r(`run.submitStep`)})]})}function y(e){let t=e.type;if(t===`shell`){let t=e.shell?.cmd;return{type:`shell`,...t?{payload:{cmd:t}}:{}}}if(t===`forward`){let t=e.forward?.target;return{type:`forward`,...t?{payload:{target:t}}:{}}}if(t===`user_input`){let t=e.user_input?.prompt;return{type:`user_input`,...t?{payload:{prompt:t}}:{}}}if(t===`comment`){let t=e.comment?.min_length;return{type:`comment`,...t==null?{}:{payload:{min_length:t}}}}return{type:t}}function b(e,t){let n=e.history.length,r=e.status===`running`,i=!!e.current_layer,a=e.status===`ready_to_reward`||e.status===`completed`||e.status===`error`,o=a?Math.max(n,1):Math.max(n+(r&&i?1:0),+!!r)||1;return{flowSteps:Array.from({length:o},(e,n)=>({label:t(n+1)})),currentFlowIndex:r&&i?n:void 0,displayCurrent:r&&i?n+1:a?o:Math.max(n,1),displayTotal:o}}function x({run:e,rewardOutcome:t,setRewardOutcome:n,rewardFeedback:r,setRewardFeedback:i,copyStatus:o,onCopy:s,onSubmitStep:c,onReward:l,isForwardStepPending:u,isForwardStartPending:m,isRewardPending:h}){let{t:g}=a(),{flowSteps:x,currentFlowIndex:S,displayCurrent:C,displayTotal:w}=b(e,e=>g(`run.flowStepN`,{n:e})),T=y(e.contract);return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`section`,{className:`mb-6`,"aria-labelledby":`run-flow-heading`,children:[(0,_.jsx)(`h2`,{id:`run-flow-heading`,className:`mb-2 text-lg font-semibold text-[var(--color-text-heading)]`,children:g(`run.progressHeading`)}),(0,_.jsx)(p,{steps:x,currentIndex:S})]}),(0,_.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2 text-sm text-[var(--color-text-muted)]`,role:`status`,children:[(0,_.jsx)(`span`,{className:`font-medium text-[var(--color-text-heading)]`,children:g(`run.stepProgress`,{current:C,total:w})}),(0,_.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,_.jsx)(`span`,{children:g(`run.sessionBadge`)})]}),e.last_message&&(0,_.jsxs)(`div`,{className:`mb-4 rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] p-4`,role:`status`,"aria-live":`polite`,children:[(0,_.jsx)(`div`,{className:`text-sm text-[var(--color-text-muted)]`,children:g(`run.serverMessage`)}),(0,_.jsx)(`div`,{className:`text-[var(--color-text)]`,children:e.last_message})]}),(0,_.jsxs)(`section`,{"aria-labelledby":`run-current-step`,className:`mb-6`,children:[(0,_.jsx)(`h2`,{id:`run-current-step`,className:`mb-2 text-lg font-semibold text-[var(--color-text-heading)]`,children:g(`run.currentStepHeading`)}),(0,_.jsx)(`div`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] p-4`,children:e.current_layer?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`mb-2 text-sm text-[var(--color-text-muted)]`,children:[g(`run.layerUri`),`: `,(0,_.jsx)(`span`,{className:`font-mono break-all`,children:e.current_layer.uri})]}),e.current_layer.content?(0,_.jsx)(`div`,{className:`prose prose-sm max-w-none text-[var(--color-text)]`,children:(0,_.jsx)(f,{content:e.current_layer.content})}):(0,_.jsx)(`p`,{className:`m-0 text-sm text-[var(--color-text-muted)]`,children:g(`run.noLayerContent`)})]}):(0,_.jsx)(`p`,{className:`m-0 text-sm text-[var(--color-text-muted)]`,children:g(`run.noLayerContent`)})})]}),(0,_.jsxs)(`section`,{"aria-labelledby":`run-challenge`,className:`mb-6`,children:[(0,_.jsx)(`h2`,{id:`run-challenge`,className:`mb-2 text-lg font-semibold text-[var(--color-text-heading)]`,children:g(`run.challengeHeading`)}),(0,_.jsx)(d,{type:T.type,payload:T.payload}),e.contract.type===`shell`&&e.contract.shell?.cmd&&(0,_.jsxs)(`div`,{className:`mt-2`,children:[(0,_.jsx)(`button`,{type:`button`,onClick:()=>s(e.contract.shell.cmd),className:`min-h-[44px] min-w-[44px] rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] px-4 py-2 text-sm font-medium text-[var(--color-text)] hover:bg-[var(--color-surface-elevated)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`,children:g(`run.copyShellCommand`)}),o?(0,_.jsx)(`div`,{className:`mt-2 text-xs text-[var(--color-text-muted)]`,children:o}):null]}),(0,_.jsxs)(`details`,{className:`mt-4 text-sm`,children:[(0,_.jsx)(`summary`,{className:`cursor-pointer text-[var(--color-primary)]`,children:g(`run.advanced`)}),(0,_.jsxs)(`div`,{className:`mt-2 space-y-2 text-[var(--color-text-muted)]`,children:[(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`span`,{className:`text-[var(--color-text-muted)]`,children:g(`run.contractType`)}),`:`,` `,(0,_.jsx)(`span`,{className:`font-medium text-[var(--color-text-heading)]`,children:e.contract.type})]}),e.contract.description&&(0,_.jsx)(`p`,{className:`m-0 text-sm`,children:e.contract.description}),e.contract.nonce&&(0,_.jsxs)(`div`,{children:[g(`run.nonce`),`: `,(0,_.jsx)(`span`,{className:`font-mono break-all`,children:e.contract.nonce})]}),e.contract.proof_hash&&(0,_.jsxs)(`div`,{children:[g(`run.proofHash`),`: `,(0,_.jsx)(`span`,{className:`font-mono break-all`,children:e.contract.proof_hash})]}),e.previous_proof_hash&&(0,_.jsxs)(`div`,{children:[g(`run.previousProofHash`),`: `,(0,_.jsx)(`span`,{className:`font-mono break-all`,children:e.previous_proof_hash})]})]})]})]}),e.status!==`completed`&&e.status!==`ready_to_reward`&&(0,_.jsxs)(`section`,{"aria-labelledby":`run-solution`,className:`mb-6`,children:[(0,_.jsx)(`h2`,{id:`run-solution`,className:`mb-2 text-lg font-semibold text-[var(--color-text-heading)]`,children:g(`run.solution`)}),(0,_.jsx)(`div`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] p-4`,children:(0,_.jsx)(v,{contract:e.contract,disabled:u||m,onSubmit:c})})]}),e.status===`ready_to_reward`&&(0,_.jsxs)(`section`,{"aria-labelledby":`run-reward`,className:`mb-6`,children:[(0,_.jsx)(`h2`,{id:`run-reward`,className:`mb-2 text-lg font-semibold text-[var(--color-text-heading)]`,children:g(`run.reward.title`)}),(0,_.jsxs)(`div`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] p-4`,children:[(0,_.jsx)(`div`,{className:`mb-4 text-sm text-[var(--color-text-muted)]`,children:g(`run.reward.subtitle`)}),(0,_.jsxs)(`div`,{className:`mb-4 flex flex-wrap gap-4`,role:`radiogroup`,"aria-label":g(`run.reward.outcomeLabel`),children:[(0,_.jsxs)(`label`,{className:`inline-flex min-h-[44px] items-center gap-2`,children:[(0,_.jsx)(`input`,{type:`radio`,name:`reward-outcome`,value:`success`,checked:t===`success`,onChange:()=>n(`success`)}),(0,_.jsx)(`span`,{className:`text-sm text-[var(--color-text)]`,children:g(`run.reward.success`)})]}),(0,_.jsxs)(`label`,{className:`inline-flex min-h-[44px] items-center gap-2`,children:[(0,_.jsx)(`input`,{type:`radio`,name:`reward-outcome`,value:`failure`,checked:t===`failure`,onChange:()=>n(`failure`)}),(0,_.jsx)(`span`,{className:`text-sm text-[var(--color-text)]`,children:g(`run.reward.failure`)})]})]}),(0,_.jsxs)(`div`,{className:`mb-4`,children:[(0,_.jsx)(`label`,{htmlFor:`run-reward-feedback`,className:`mb-2 block font-medium text-[var(--color-text-heading)]`,children:g(`run.reward.feedback`)}),(0,_.jsx)(`textarea`,{id:`run-reward-feedback`,value:r,onChange:e=>i(e.target.value),className:`min-h-[8rem] w-full resize-y rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] px-4 py-3 text-[var(--color-text)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`})]}),(0,_.jsx)(`button`,{type:`button`,onClick:l,disabled:h,className:`min-h-[44px] min-w-[44px] cursor-pointer rounded-[var(--radius-md)] border-0 bg-[var(--color-primary)] px-4 py-2 font-medium text-white hover:bg-[var(--color-primary-hover)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2 disabled:cursor-not-allowed disabled:opacity-60`,children:g(h?`run.reward.submitting`:`run.reward.submit`)})]})]}),e.history.length>0&&(0,_.jsxs)(`section`,{"aria-labelledby":`run-history`,className:`mb-6`,children:[(0,_.jsx)(`h2`,{id:`run-history`,className:`mb-2 text-lg font-semibold text-[var(--color-text-heading)]`,children:g(`run.history`)}),(0,_.jsx)(`ul`,{className:`m-0 list-none space-y-2 p-0`,"aria-label":g(`run.historyLabel`),children:e.history.slice().reverse().map((e,t)=>(0,_.jsxs)(`li`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] p-4`,children:[(0,_.jsxs)(`div`,{className:`text-sm text-[var(--color-text-muted)]`,children:[new Date(e.submitted_at).toLocaleString(),` · `,e.contract.type,` ·`,` `,(0,_.jsx)(`span`,{className:`font-mono break-all`,children:e.layer.uri})]}),e.server_message&&(0,_.jsx)(`div`,{className:`mt-1 text-sm text-[var(--color-text)]`,children:e.server_message})]},`${e.layer.uri}:${t}`))})]}),e.status===`completed`&&(0,_.jsxs)(`div`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--status-success-bg)] p-4 text-[var(--status-success-fg)]`,children:[(0,_.jsx)(`strong`,{className:`block`,children:g(`run.completed`)}),e.last_message&&(0,_.jsx)(`div`,{className:`mt-1 text-sm`,children:e.last_message})]})]})}async function S(e){let t=await c(`/api/forward`,{method:`POST`,body:JSON.stringify({uri:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.message??t.statusText)}return await t.json()}function C(){return n({mutationFn:e=>S(e)})}async function w(e){let t=await c(`/api/forward`,{method:`POST`,body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.message??t.statusText)}return await t.json()}function T(){return n({mutationFn:e=>w(e)})}async function E(e){let t=await c(`/api/reward`,{method:`POST`,body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.message??t.statusText)}return await t.json()}function D(){return n({mutationFn:e=>E(e)})}function O(e){if(e)return e.match(/squadrules:\/\/layer\/[0-9a-fA-F-]{36}(?:\?execution_id=[0-9a-fA-F-]{36})?/)?.[0]}function k(){return new Date().toISOString()}function A(){let{t:e}=a(),{uri:n}=r(),[o]=i(),s=n?decodeURIComponent(n):void 0,c=o.get(`session`),{session:d}=h(c),{upsert:f}=m(),p=C(),v=T(),y=D(),[b,S]=(0,g.useState)(null),[w,E]=(0,g.useState)(`success`),[A,j]=(0,g.useState)(``),[M,N]=(0,g.useState)(null);(0,g.useEffect)(()=>{d&&!b&&(S(d),E(`success`),j(``))},[d,b]);let P=e=>{S(e),f(e)},F=async()=>{if(s)try{let e=await p.mutateAsync(s),t=k(),n=`${s}:${t}`,r=e.next_action?.includes(`reward`)?`ready_to_reward`:`running`,i=O(e.next_action);P({id:n,adapter_uri:s,started_at:t,updated_at:t,status:r,current_layer:e.current_layer??null,contract:e.contract,next_action:e.next_action,last_message:e.message,previous_proof_hash:e.proof_hash,reward_uri:r===`ready_to_reward`?i:void 0,history:[]})}catch{S(null)}};return s?(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`h1`,{className:`text-[var(--color-text-heading)] text-2xl font-semibold mb-1`,children:e(`run.title`)}),(0,_.jsx)(`p`,{className:`mb-4 text-sm text-[var(--color-text-muted)]`,children:e(`run.guidedIntro`)}),(0,_.jsxs)(`p`,{className:`mb-4 text-sm text-[var(--color-text-muted)]`,children:[e(`run.adapterUri`),`: `,(0,_.jsx)(`span`,{className:`font-mono break-all`,children:s})]}),(0,_.jsxs)(`div`,{className:`flex flex-wrap gap-2 mb-6`,children:[(0,_.jsx)(t,{to:`/protocols/${encodeURIComponent(s)}`,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center px-4 py-2 rounded-[var(--radius-md)] font-medium border border-[var(--color-border)] text-[var(--color-text)] no-underline hover:bg-[var(--color-surface-elevated)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`,children:e(`run.backToProtocol`)}),!b&&(0,_.jsx)(`button`,{type:`button`,onClick:F,disabled:p.isPending,className:`min-h-[44px] min-w-[44px] px-4 py-2 rounded-[var(--radius-md)] font-medium bg-[var(--color-primary)] text-white border-0 cursor-pointer disabled:opacity-60 disabled:cursor-not-allowed hover:bg-[var(--color-primary-hover)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`,children:p.isPending?e(`run.starting`):e(`run.start`)})]}),(0,_.jsx)(l,{className:`mb-6`,title:e(`run.safety.title`),children:(0,_.jsx)(`p`,{className:`m-0 text-sm text-[var(--color-text-muted)]`,children:e(`run.safety.copy`)})}),p.isError&&(0,_.jsx)(u,{message:p.error instanceof Error?p.error.message:String(p.error),onRetry:()=>F(),showGoBack:!0}),b?.status===`error`&&b.last_message&&(0,_.jsx)(`div`,{className:`mb-6`,children:(0,_.jsx)(u,{message:b.last_message,onRetry:()=>F(),showGoBack:!0})}),b&&b.status!==`error`&&(0,_.jsx)(x,{run:b,rewardOutcome:w,setRewardOutcome:E,rewardFeedback:A,setRewardFeedback:j,copyStatus:M,onCopy:async t=>{N(null);try{await navigator.clipboard.writeText(t),N(e(`run.copied`)),setTimeout(()=>N(null),1500)}catch(e){N(e instanceof Error?e.message:String(e))}},onSubmitStep:async e=>{if(!b?.current_layer)return;let t=b.contract.nonce,n=b.previous_proof_hash??b.contract.proof_hash,r={...e,...t?{nonce:t}:{},...n?{proof_hash:n}:{}};try{let e=await v.mutateAsync({uri:b.current_layer.uri,solution:r}),t=k(),n=e.next_action?.includes(`reward`)||(e.message?.toLowerCase().includes(`call reward`)??!1),i=O(e.next_action)??b.reward_uri;P({...b,updated_at:t,status:n?`ready_to_reward`:`running`,current_layer:e.current_layer??null,contract:e.contract,next_action:e.next_action,last_message:e.message,previous_proof_hash:e.proof_hash??b.previous_proof_hash,reward_uri:n?i:void 0,history:[...b.history,{layer:b.current_layer,contract:b.contract,solution:r,submitted_at:t,proof_hash:e.proof_hash,server_message:e.message}]})}catch(e){P({...b,updated_at:k(),status:`error`,last_message:e instanceof Error?e.message:String(e)})}},onReward:async()=>{if(!b)return;let t=b.reward_uri??b.current_layer?.uri;if(t)try{let n=await y.mutateAsync({uri:t,outcome:w,feedback:A.trim()||e(`run.reward.defaultFeedback`)});P({...b,updated_at:k(),status:`completed`,last_message:n.results[0]?.feedback??b.last_message})}catch(e){P({...b,updated_at:k(),status:`error`,last_message:e instanceof Error?e.message:String(e)})}},isForwardStepPending:v.isPending,isForwardStartPending:p.isPending,isRewardPending:y.isPending})]}):(0,_.jsx)(u,{message:e(`run.missingUri`),showGoBack:!0})}export{A as RunGuidedPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t,m as n,y as r}from"./vendor-xESPQGR9.js";import{i,t as a}from"./react-BvB9BS1T.js";import{t as o}from"./SurfaceCard-BzJidvvn.js";import{a as s,n as c,r as l,s as u,t as d}from"./export-skill-zip-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t,m as n,y as r}from"./vendor-xESPQGR9.js";import{i,t as a}from"./react-BvB9BS1T.js";import{t as o}from"./SurfaceCard-BzJidvvn.js";import{a as s,n as c,r as l,s as u,t as d}from"./export-skill-zip-CHfMqCRE.js";import{t as f}from"./RichTextEditor-DWLV579w.js";var p=e(i(),1),m=a();function h(e){return`min-h-[44px] rounded-full px-4 text-sm font-medium ${e?`bg-[var(--color-primary)] text-white`:`border border-[var(--color-border)] bg-[var(--color-surface)] text-[var(--color-text)]`}`}function g(){let{t:e}=r(),{uri:i}=n(),{data:a,isLoading:g,isError:_,error:v}=u(i?decodeURIComponent(i):void 0,!0),[y,b]=(0,p.useState)(``),[x,S]=(0,p.useState)(``),[C,w]=(0,p.useState)(``),[T,E]=(0,p.useState)(!0),[D,O]=(0,p.useState)(!1),[k,A]=(0,p.useState)(null);if(g&&!a)return(0,m.jsx)(`p`,{className:`text-[var(--color-text-muted)]`,children:e(`protocol.loading`)});if(_||!a)return(0,m.jsxs)(`div`,{role:`alert`,className:`rounded-[var(--radius-md)] bg-[var(--color-error-bg)] p-4 text-[var(--color-error)]`,children:[v instanceof Error?v.message:e(`protocol.notFound`),(0,m.jsx)(t,{to:`/`,className:`mt-2 block text-[var(--color-primary)] underline hover:no-underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`,children:e(`notFound.goHome`)})]});let{title:j}=s(a.content),M=(y.trim()||j).replace(/[^a-zA-Z0-9]+/g,`-`).replace(/^-|-$/g,``)||`skill`,N=`${M}-skill`,P=async()=>{A(null),O(!0);try{let{blob:e,skill_bundle_manifest:t}=await d(a.uri),n=c(t,M);l(e,n)}catch(e){A(e instanceof Error?e.message:String(e))}finally{O(!1)}};return(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`h1`,{className:`mb-1 text-2xl font-semibold text-[var(--color-text-heading)]`,children:e(`skill.title`)}),(0,m.jsx)(`p`,{className:`mb-6 text-sm text-[var(--color-text-muted)]`,children:e(`skill.subtitle`)}),(0,m.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[1.3fr_1fr]`,children:[(0,m.jsxs)(`div`,{className:`space-y-4`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`label`,{htmlFor:`skill-name`,className:`mb-2 block font-medium text-[var(--color-text-heading)]`,children:e(`skill.skillName`)}),(0,m.jsx)(`input`,{id:`skill-name`,type:`text`,value:y,onChange:e=>b(e.target.value),placeholder:j,className:`min-h-[44px] w-full rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] px-4 py-3 text-sm text-[var(--color-text)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`})]}),(0,m.jsx)(f,{label:e(`skill.description`),hint:e(`skill.descriptionHint`),value:x,onChange:S,contentKey:`skill-desc`}),(0,m.jsx)(f,{label:e(`skill.whenToUse`),value:C,onChange:w,contentKey:`skill-when`}),(0,m.jsx)(o,{title:e(`skill.bundleContentsTitle`),subtitle:e(`skill.bundleContentsSubtitle`),children:(0,m.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,m.jsx)(`button`,{type:`button`,"aria-pressed":T,onClick:()=>E(e=>!e),className:h(T),children:e(`skill.includeReferences`)}),(0,m.jsx)(`button`,{type:`button`,disabled:!0,className:`${h(!1)} cursor-not-allowed opacity-50`,title:e(`skill.comingSoon`),children:e(`skill.chipReadme`)}),(0,m.jsx)(`button`,{type:`button`,disabled:!0,className:`${h(!1)} cursor-not-allowed opacity-50`,title:e(`skill.comingSoon`),children:e(`skill.chipPrompts`)})]})}),(0,m.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,m.jsx)(`button`,{type:`button`,onClick:()=>void P(),disabled:D,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center rounded-[var(--radius-md)] bg-[var(--color-primary)] px-4 py-2 font-medium text-white hover:bg-[var(--color-primary-hover)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2 disabled:opacity-60`,children:e(`skill.downloadAsSkill`)}),k?(0,m.jsx)(`p`,{className:`m-0 text-sm text-[var(--color-error)]`,role:`alert`,children:k}):null,(0,m.jsx)(t,{to:`/protocols/${encodeURIComponent(a.uri)}`,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] px-4 py-2 font-medium text-[var(--color-text)] no-underline hover:bg-[var(--color-surface-elevated)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`,children:e(`skill.backToProtocol`)})]})]}),(0,m.jsxs)(`div`,{className:`space-y-4`,children:[(0,m.jsx)(o,{title:e(`skill.bundlePreviewTitle`),subtitle:e(`skill.bundlePreviewSubtitle`),children:(0,m.jsxs)(`div`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] p-4 font-mono text-sm text-[var(--color-text)]`,children:[N,`.zip`,(0,m.jsx)(`br`,{}),`└── `,N,`/`,(0,m.jsx)(`br`,{}),`\xA0\xA0\xA0\xA0├── Skill.md`,(0,m.jsx)(`br`,{}),T?(0,m.jsxs)(m.Fragment,{children:[`\xA0\xA0\xA0\xA0└── references/`,(0,m.jsx)(`br`,{}),`\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0└── SQUADRULES.md`]}):(0,m.jsx)(m.Fragment,{children:`\xA0\xA0\xA0\xA0└── (no references/)`})]})}),(0,m.jsx)(o,{title:e(`skill.whyExportTitle`),subtitle:e(`skill.whyExportSubtitle`),children:(0,m.jsx)(`p`,{className:`m-0 text-sm text-[var(--color-text-muted)]`,children:e(`skill.whyExportBody`)})})]})]})]})}export{g as SkillBundlePage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import{g as e}from"./vendor-xESPQGR9.js";import{t}from"./api-BgTb-tmJ.js";async function n(e){let n=await t(`/api/export`,{method:`POST`,body:JSON.stringify({uri:e,format:`markdown`})});if(!n.ok){let e=(await n.json().catch(()=>({}))).message??n.statusText,t=Error(e);throw t.statusCode=n.status,t}let r=await n.json();return{content:r.content,uri:r.uri,label:r.adapter_name??`Adapter`,adapter_name:r.adapter_name??null,...r.adapter_version?{protocol_version:r.adapter_version}:{},...r.space_id!==void 0&&{space_id:r.space_id},...r.space_name!==void 0&&{space_name:r.space_name},...r.space_type!==void 0&&{space_type:r.space_type}}}function r(t,r){return e({queryKey:[`protocol`,t],queryFn:()=>n(t),enabled:!!(t&&r)})}function i(e){let t=e.split(`
|
|
2
2
|
`),n=`Protocol`,r=[],i=``,a=``,o=t.find(e=>e.startsWith(`# `));o&&(n=o.replace(/^#\s+/,``).trim());let s=e.split(/\n##\s+/);for(let e=1;e<s.length;e++){let t=s[e],n=t.split(`
|
|
3
|
-
`)[0]??``,o=n.trim(),c=t.slice(n.length).replace(/^\n+/,``).trim();if(o.toLowerCase().includes(`activation pattern`)||o.toLowerCase().includes(`natural language trigger`))i=c.replace(/\n```json[\s\S]*?```/g,``).trim();else if(o.toLowerCase().includes(`reward signal`)||o.toLowerCase().includes(`completion rule`))a=c.replace(/\n```json[\s\S]*?```/g,``).trim();else{let e=c.match(/```json\s*([\s\S]*?)```/),t=`comment`,n=`Comment`,i;if(e)try{let r=JSON.parse(e[1].trim()),a=r?.contract??r?.challenge??r;if(a?.type&&(t=String(a.type)),t===`shell`){let e=a?.shell?.cmd??a?.cmd,t=a?.shell?.interpreter;n=e?t?`Shell (${t}): ${String(e).slice(0,60)}${String(e).length>60?`…`:``}`:`Shell: ${String(e).slice(0,80)}${String(e).length>80?`…`:``}`:`Shell`,e&&(i={cmd:String(e)})}else if(t===`
|
|
3
|
+
`)[0]??``,o=n.trim(),c=t.slice(n.length).replace(/^\n+/,``).trim();if(o.toLowerCase().includes(`activation pattern`)||o.toLowerCase().includes(`natural language trigger`))i=c.replace(/\n```json[\s\S]*?```/g,``).trim();else if(o.toLowerCase().includes(`reward signal`)||o.toLowerCase().includes(`completion rule`))a=c.replace(/\n```json[\s\S]*?```/g,``).trim();else{let e=c.match(/```json\s*([\s\S]*?)```/),t=`comment`,n=`Comment`,i;if(e)try{let r=JSON.parse(e[1].trim()),a=r?.contract??r?.challenge??r;if(a?.type&&(t=String(a.type)),t===`shell`){let e=a?.shell?.cmd??a?.cmd,t=a?.shell?.interpreter;n=e?t?`Shell (${t}): ${String(e).slice(0,60)}${String(e).length>60?`…`:``}`:`Shell: ${String(e).slice(0,80)}${String(e).length>80?`…`:``}`:`Shell`,e&&(i={cmd:String(e)})}else if(t===`forward`){let e=a?.forward?.target;n=e?`Forward: ${String(e)}`:`Forward`,e&&(i={target:String(e)})}else if(t===`user_input`){let e=a?.user_input?.prompt;n=e?`User input: ${String(e)}`:`User input`,e&&(i={prompt:String(e)})}else if(t===`comment`){let e=a?.comment?.min_length;n=e?`Comment: min ${Number(e)} chars`:`Comment`,e!=null&&!Number.isNaN(Number(e))&&(i={min_length:Number(e)})}else n=String(t)}catch{}n||=String(t),r.push({label:o,type:t,summary:n,body:c,challengePayload:i})}}return{title:n,steps:r,triggers:i,completion:a}}function a(e){let{title:t,steps:n,triggers:r,completion:a}=i(e);return{protocolLabel:t,triggersMarkdown:r,steps:n.map(e=>{let t=e.body.replace(/\n```json\s*[\s\S]*?```\s*$/g,``).trim(),n=`comment`,r={label:e.label,bodyMarkdown:t,type:n},i=e.body.match(/```json\s*([\s\S]*?)```/);if(i)try{let e=JSON.parse(i[1].trim()),t=e?.contract??e?.challenge??e;if(t?.type&&[`shell`,`forward`,`user_input`,`comment`].includes(String(t.type))&&(n=t.type,r.type=n),n===`shell`){let e=t?.shell;r.shell={cmd:String(e?.cmd??t?.cmd??``).trim(),timeout_seconds:Number(e?.timeout_seconds??30),interpreter:typeof e?.interpreter==`string`?e.interpreter:void 0,workdir:typeof e?.workdir==`string`?e.workdir:void 0,flags:Array.isArray(e?.flags)?e.flags.map(String):[],args:Array.isArray(e?.args)?e.args.map(String):[]}}else n===`forward`?r.forward={target:String(t?.forward?.target??``).trim()}:n===`user_input`?r.user_input={prompt:String(t?.user_input?.prompt??``).trim()}:n===`comment`&&(r.comment={min_length:Number(t?.comment?.min_length??10)})}catch{}return r}),completionMarkdown:a}}function o(e){let t=[];t.push(`# ${e.protocolLabel.trim()||`Protocol`}`),t.push(``),t.push(`## Activation Patterns`),t.push(``),t.push(e.triggersMarkdown.trim()||`Describe when this protocol should run.`),t.push(``);for(let n of e.steps){t.push(`## ${n.label.trim()||`Step`}`),t.push(``),t.push(n.bodyMarkdown.trim()||`Step content.`);let e={type:n.type};if(n.type===`shell`){let t={cmd:n.shell?.cmd??``,timeout_seconds:n.shell?.timeout_seconds??30},r=n.shell?.interpreter?.trim();r&&(t.interpreter=r);let i=n.shell?.workdir?.trim();i&&(t.workdir=i),n.shell?.flags?.length&&(t.flags=n.shell.flags),n.shell?.args?.length&&(t.args=n.shell.args),e.shell=t}else n.type===`forward`?e.forward={target:n.forward?.target??``}:n.type===`user_input`?e.user_input={prompt:n.user_input?.prompt??``}:n.type===`comment`&&(e.comment={min_length:n.comment?.min_length??10});t.push(``),t.push("```json"),t.push(JSON.stringify({contract:e},null,2)),t.push("```"),t.push(``)}return t.push(`## Reward Signal`),t.push(``),t.push(e.completionMarkdown.trim()||`Describe how this adapter should be rewarded when it completes.`),t.join(`
|
|
4
4
|
`)}async function s(e){let n=await t(`/api/export`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({uri:e,format:`skill_zip`})});if(!n.ok){let e=(await n.json().catch(()=>({}))).message??n.statusText;throw Error(e)}let r=await n.json();if(r.format===`skill_zip`&&r.download_ref?.url){let e=await fetch(r.download_ref.url,{credentials:`same-origin`});if(!e.ok)throw Error(`Download failed: ${e.statusText}`);return{blob:await e.blob(),skill_bundle_manifest:r.skill_bundle_manifest}}if(r.format!==`skill_zip`||r.content_encoding!==`base64`)throw Error(`Expected a skill_zip export with download_ref or base64-encoded content.`);return{blob:c(r.content,r.content_type||`application/zip`),skill_bundle_manifest:r.skill_bundle_manifest}}function c(e,t){let n=atob(e),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return new Blob([r],{type:t})}function l(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.click(),URL.revokeObjectURL(n)}function u(e,t){try{if(e){let t=JSON.parse(e).skills?.[0]?.slug;if(t&&t.length>0)return`${t}-squadrules-skill.zip`}}catch{}return`${t.replace(/[^a-zA-Z0-9]+/g,`-`).replace(/^-|-$/g,``)||`squadrules-skill`}-squadrules-skill.zip`}export{i as a,o as i,u as n,a as o,l as r,r as s,s as t};
|