@sage-protocol/pi-adapter 0.4.3 → 0.5.2
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/README.md +66 -1
- package/SKILL.md +6 -4
- package/USAGE.md +26 -2
- package/dist/inbox-output.d.ts +30 -0
- package/dist/inbox-output.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6844 -51
- package/dist/intercom-storage.d.ts +20 -0
- package/dist/intercom-storage.d.ts.map +1 -0
- package/dist/intercom.d.ts +72 -0
- package/dist/intercom.d.ts.map +1 -0
- package/dist/sage-pi-adapter.d.ts +52 -2
- package/dist/sage-pi-adapter.d.ts.map +1 -1
- package/dist/wallet-status.d.ts +37 -0
- package/dist/wallet-status.d.ts.map +1 -0
- package/extensions/index.ts +308 -84
- package/package.json +10 -7
- package/dist/behavior/index.js +0 -9
- package/dist/behavior/index.js.map +0 -1
- package/dist/behavior/pi-executor.js +0 -188
- package/dist/behavior/pi-executor.js.map +0 -1
- package/dist/behavior/resolver.js +0 -171
- package/dist/behavior/resolver.js.map +0 -1
- package/dist/behavior/types.js +0 -16
- package/dist/behavior/types.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/sage-pi-adapter.js +0 -2862
- package/dist/sage-pi-adapter.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sage-protocol/pi-adapter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Sage Protocol MCP integration for pi coding agent",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -20,23 +20,24 @@
|
|
|
20
20
|
],
|
|
21
21
|
"pi": {
|
|
22
22
|
"extensions": [
|
|
23
|
-
"./extensions"
|
|
23
|
+
"./extensions/index.ts"
|
|
24
24
|
]
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
|
-
"build": "
|
|
27
|
+
"build": "npm run build:types && npm run build:bundle",
|
|
28
|
+
"build:types": "tsc -p tsconfig.build.json --emitDeclarationOnly",
|
|
29
|
+
"build:bundle": "esbuild src/index.ts --bundle --platform=node --format=esm --outfile=dist/index.js --legal-comments=none",
|
|
28
30
|
"dev": "tsc -p tsconfig.build.json --watch",
|
|
29
31
|
"clean": "rm -rf dist",
|
|
30
32
|
"typecheck": "tsc -p tsconfig.build.json --noEmit",
|
|
31
33
|
"test": "vitest --run",
|
|
34
|
+
"profile:outputs": "node scripts/profile-outputs.mjs",
|
|
35
|
+
"test:pi-sdk": "node scripts/test-pi-sdk.mjs",
|
|
32
36
|
"prepare": "npm run build",
|
|
33
37
|
"prepublishOnly": "npm run clean && npm run build"
|
|
34
38
|
},
|
|
35
|
-
"dependencies": {
|
|
36
|
-
"@sinclair/typebox": "^0.34.0"
|
|
37
|
-
},
|
|
38
39
|
"peerDependencies": {
|
|
39
|
-
"@earendil-works/pi-coding-agent": ">=0.64.0 <0.
|
|
40
|
+
"@earendil-works/pi-coding-agent": ">=0.64.0 <0.87.0",
|
|
40
41
|
"@earendil-works/pi-tui": "*"
|
|
41
42
|
},
|
|
42
43
|
"peerDependenciesMeta": {
|
|
@@ -45,7 +46,9 @@
|
|
|
45
46
|
}
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
49
|
+
"@sinclair/typebox": "^0.34.0",
|
|
48
50
|
"@types/node": "^24.0.0",
|
|
51
|
+
"esbuild": "^0.25.0",
|
|
49
52
|
"typescript": "^5.7.0",
|
|
50
53
|
"vitest": "^4.1.8"
|
|
51
54
|
},
|
package/dist/behavior/index.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file behavior/index.ts
|
|
3
|
-
*
|
|
4
|
-
* Responsibility: Public API surface for the behavior execution subsystem.
|
|
5
|
-
* Re-exports types and implementations — nothing else.
|
|
6
|
-
*/
|
|
7
|
-
export { resolveBehaviorPlan } from "./resolver.js";
|
|
8
|
-
export { PiBehaviorExecutor } from "./pi-executor.js";
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/behavior/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgBH,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAyB,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file behavior/pi-executor.ts
|
|
3
|
-
*
|
|
4
|
-
* Responsibility: Pi-specific implementation of the BehaviorExecutor interface.
|
|
5
|
-
* Executes behavior plan steps as pi subagent invocations.
|
|
6
|
-
*
|
|
7
|
-
* Invariants:
|
|
8
|
-
* - Each step runs in an isolated subagent context (explorer for read-only, worker for mutations).
|
|
9
|
-
* - Inter-step results are threaded via the subagent task message.
|
|
10
|
-
* - MCP servers from the plan's mcp_servers_union are provisioned before execution.
|
|
11
|
-
* - Cancellation via AbortSignal is respected between steps (not mid-step).
|
|
12
|
-
* - This file is the ONLY place that depends on pi's subagent API.
|
|
13
|
-
*/
|
|
14
|
-
import { resolveBehaviorPlan } from "./resolver.js";
|
|
15
|
-
/**
|
|
16
|
-
* Pi-specific BehaviorExecutor.
|
|
17
|
-
*
|
|
18
|
-
* Executes behavior plan steps sequentially, threading output from each step
|
|
19
|
-
* as context into the next. In pi, each step maps to a subagent task — but
|
|
20
|
-
* since the adapter runs as an extension (not the agent loop controller),
|
|
21
|
-
* we execute via tool result injection: the plan is rendered as a structured
|
|
22
|
-
* controller prompt that the agent follows step-by-step.
|
|
23
|
-
*
|
|
24
|
-
* Why not spawn_agent directly?
|
|
25
|
-
* The pi extension API doesn't expose spawn_agent — that's a tool available
|
|
26
|
-
* to the agent itself. The executor prepares the plan for the agent to execute,
|
|
27
|
-
* optionally with subagent delegation hints.
|
|
28
|
-
*
|
|
29
|
-
* Execution modes:
|
|
30
|
-
* 1. **Controller prompt** (default): Render the plan as a structured prompt
|
|
31
|
-
* the agent follows. Steps include skill content and dependency hints.
|
|
32
|
-
* The agent decides whether to use subagents based on step complexity.
|
|
33
|
-
*
|
|
34
|
-
* 2. **Explicit delegation** (future): For plans with `isolation: "subagent"`
|
|
35
|
-
* on steps, the executor would need the agent to call spawn_agent per step.
|
|
36
|
-
* This requires the agent loop, not the extension layer.
|
|
37
|
-
*/
|
|
38
|
-
export class PiBehaviorExecutor {
|
|
39
|
-
name = "pi-behavior-executor";
|
|
40
|
-
bridge;
|
|
41
|
-
sendMessage;
|
|
42
|
-
constructor(config) {
|
|
43
|
-
this.bridge = config.bridge;
|
|
44
|
-
this.sendMessage = config.sendMessage;
|
|
45
|
-
}
|
|
46
|
-
async resolve(key) {
|
|
47
|
-
return resolveBehaviorPlan(this.bridge, key);
|
|
48
|
-
}
|
|
49
|
-
canExecute(plan) {
|
|
50
|
-
// We can execute any linear plan. Reject empty plans.
|
|
51
|
-
return plan.steps.length > 0;
|
|
52
|
-
}
|
|
53
|
-
async execute(plan, context) {
|
|
54
|
-
const startTime = Date.now();
|
|
55
|
-
const results = [];
|
|
56
|
-
// Render the plan as a controller prompt for the agent.
|
|
57
|
-
// This is plan injection (Smithers-style), not step completion.
|
|
58
|
-
const controllerPrompt = this.renderControllerPrompt(plan, context);
|
|
59
|
-
// Report plan to the agent via hook message
|
|
60
|
-
if (this.sendMessage) {
|
|
61
|
-
this.sendMessage({
|
|
62
|
-
customType: "sage-behavior-plan",
|
|
63
|
-
content: controllerPrompt,
|
|
64
|
-
display: true,
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
// Steps remain awaiting_agent until the host has real step results.
|
|
68
|
-
// Never claim completed solely because the plan was rendered.
|
|
69
|
-
for (const step of plan.steps) {
|
|
70
|
-
const stepStart = Date.now();
|
|
71
|
-
context.onProgress?.(step.id, "awaiting_agent");
|
|
72
|
-
results.push({
|
|
73
|
-
stepId: step.id,
|
|
74
|
-
status: "awaiting_agent",
|
|
75
|
-
durationMs: Date.now() - stepStart,
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
return {
|
|
79
|
-
status: "awaiting_agent",
|
|
80
|
-
steps: results,
|
|
81
|
-
totalDurationMs: Date.now() - startTime,
|
|
82
|
-
output: controllerPrompt,
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Render a behavior plan as a structured controller prompt.
|
|
87
|
-
*
|
|
88
|
-
* The controller prompt is designed to be injected into the agent's context,
|
|
89
|
-
* giving it a step-by-step execution plan with:
|
|
90
|
-
* - Skill content for each step
|
|
91
|
-
* - Dependency hints (which steps feed into which)
|
|
92
|
-
* - MCP server requirements
|
|
93
|
-
* - Subagent delegation hints for complex steps
|
|
94
|
-
*/
|
|
95
|
-
renderControllerPrompt(plan, context) {
|
|
96
|
-
const lines = [];
|
|
97
|
-
// Smithers-inspired: plan is an authority envelope + step menu, not a runtime.
|
|
98
|
-
// Status stays awaiting_agent until steps are actually done.
|
|
99
|
-
lines.push("# Behavior Plan (controller inject — not a completed run)");
|
|
100
|
-
lines.push("");
|
|
101
|
-
lines.push("This is a **durable step plan** for you (the agent) to execute with tools.");
|
|
102
|
-
lines.push("The adapter has **not** completed these steps. Status: `awaiting_agent`.");
|
|
103
|
-
lines.push("");
|
|
104
|
-
lines.push(`**Task:** ${context.task}`);
|
|
105
|
-
lines.push(`**Steps:** ${plan.steps.length}`);
|
|
106
|
-
lines.push("");
|
|
107
|
-
lines.push("## Load rule (per step)");
|
|
108
|
-
lines.push("");
|
|
109
|
-
lines.push("1. Load the **full** skill procedure for the step (`/skill:<key>`, read SKILL.md, or skills.get).");
|
|
110
|
-
lines.push("2. Freestyle tools **under that skill's constraints** — ranking/plan text is not enough.");
|
|
111
|
-
lines.push("3. Only after step work is done, move to the next step in order.");
|
|
112
|
-
lines.push("4. Report outcomes with `sage suggest feedback outcome <skill-key> --status passed|failed` when a procedure guided work.");
|
|
113
|
-
lines.push("");
|
|
114
|
-
if (context.mcpServersRequired.length > 0) {
|
|
115
|
-
lines.push("## Required MCP Servers");
|
|
116
|
-
for (const server of context.mcpServersRequired) {
|
|
117
|
-
lines.push(`- \`${server}\``);
|
|
118
|
-
}
|
|
119
|
-
lines.push("");
|
|
120
|
-
}
|
|
121
|
-
lines.push("## Execution Steps");
|
|
122
|
-
lines.push("");
|
|
123
|
-
lines.push("Execute the following steps **in order**. Each step builds on the previous.");
|
|
124
|
-
lines.push("For complex steps, consider delegating to a subagent (explorer for analysis, worker for implementation).");
|
|
125
|
-
lines.push("");
|
|
126
|
-
for (let i = 0; i < plan.steps.length; i++) {
|
|
127
|
-
const step = plan.steps[i];
|
|
128
|
-
lines.push(`### Step ${i + 1}: ${step.title}`);
|
|
129
|
-
lines.push("");
|
|
130
|
-
lines.push(`**Skill:** \`${step.skill_key}\``);
|
|
131
|
-
lines.push(`**Status:** awaiting_agent`);
|
|
132
|
-
lines.push(`**Load:** \`/skill:${step.skill_key}\` or \`sage library inspect skill get ${step.skill_key}\` or skills.get before freestyle`);
|
|
133
|
-
if (step.uses.length > 0) {
|
|
134
|
-
lines.push(`**Depends on:** ${step.uses.join(", ")}`);
|
|
135
|
-
}
|
|
136
|
-
lines.push("");
|
|
137
|
-
if (step.instruction) {
|
|
138
|
-
lines.push(step.instruction);
|
|
139
|
-
lines.push("");
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
lines.push(`_No body in plan — load full skill \`${step.skill_key}\` before acting._`);
|
|
143
|
-
lines.push("");
|
|
144
|
-
}
|
|
145
|
-
// Subagent delegation hint for steps that benefit from isolation
|
|
146
|
-
if (this.shouldSuggestSubagent(step, plan.steps.length)) {
|
|
147
|
-
lines.push(`> 💡 **Subagent hint:** This step may benefit from running in an isolated subagent.`);
|
|
148
|
-
lines.push(`> Use \`explorer\` for analysis/read-only steps, \`worker\` for implementation steps.`);
|
|
149
|
-
lines.push("");
|
|
150
|
-
}
|
|
151
|
-
if (i < plan.steps.length - 1) {
|
|
152
|
-
lines.push("---");
|
|
153
|
-
lines.push("");
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
lines.push("");
|
|
157
|
-
lines.push("## Completion");
|
|
158
|
-
lines.push("");
|
|
159
|
-
lines.push("After completing all steps, synthesize the results into a coherent response.");
|
|
160
|
-
lines.push("Reference findings from each step and note any cross-step insights.");
|
|
161
|
-
lines.push("Do not treat plan injection alone as success; only completed step work counts.");
|
|
162
|
-
return lines.join("\n");
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Heuristic: suggest subagent delegation for steps that benefit from isolation.
|
|
166
|
-
*
|
|
167
|
-
* - Plans with 4+ steps: suggest subagents for analysis-heavy steps
|
|
168
|
-
* - Steps with large instruction bodies (>2000 chars): benefit from dedicated context
|
|
169
|
-
* - Steps that are read-only analysis: explorer subagent
|
|
170
|
-
*/
|
|
171
|
-
shouldSuggestSubagent(step, totalSteps) {
|
|
172
|
-
if (totalSteps < 3)
|
|
173
|
-
return false; // Small plans don't need subagent overhead
|
|
174
|
-
if (step.instruction.length > 2000)
|
|
175
|
-
return true; // Large skill content benefits from isolation
|
|
176
|
-
// Analysis/review skills benefit from subagent isolation
|
|
177
|
-
const analysisKeywords = [
|
|
178
|
-
"review",
|
|
179
|
-
"audit",
|
|
180
|
-
"analysis",
|
|
181
|
-
"assess",
|
|
182
|
-
"evaluate",
|
|
183
|
-
"critique",
|
|
184
|
-
];
|
|
185
|
-
return analysisKeywords.some((kw) => step.skill_key.includes(kw) || step.title.toLowerCase().includes(kw));
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
//# sourceMappingURL=pi-executor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pi-executor.js","sourceRoot":"","sources":["../../src/behavior/pi-executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,mBAAmB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AI,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAED;;;;;;OAMG;IACK,qBAAqB,CAAC,IAAc,EAAE,UAAkB;QAC/D,IAAI,UAAU,GAAG,CAAC;YAAE,OAAO,KAAK,CAAC,CAAC,2CAA2C;QAC7E,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,IAAI;YAAE,OAAO,IAAI,CAAC,CAAC,8CAA8C;QAC/F,yDAAyD;QACzD,MAAM,gBAAgB,GAAG;YACxB,QAAQ;YACR,OAAO;YACP,UAAU;YACV,QAAQ;YACR,UAAU;YACV,UAAU;SACV,CAAC;QACF,OAAO,gBAAgB,CAAC,IAAI,CAC3B,CAAC,EAAE,EAAE,EAAE,CACN,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CACrE,CAAC;IACH,CAAC;CACD"}
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file behavior/resolver.ts
|
|
3
|
-
*
|
|
4
|
-
* Responsibility: Resolve behavior keys into BehaviorPlans via Sage MCP.
|
|
5
|
-
*
|
|
6
|
-
* Invariants:
|
|
7
|
-
* - Resolution always goes through the MCP bridge (never direct file reads).
|
|
8
|
-
* - Returns a validated BehaviorPlan or throws with a clear error.
|
|
9
|
-
* - The resolver is stateless — no caching (Sage MCP handles that).
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* Resolve a behavior key into a BehaviorPlan via Sage MCP.
|
|
13
|
-
*
|
|
14
|
-
* Calls `get_prompt(key, expand: ["behaviorPlan", "behaviorSkillBodies"])`
|
|
15
|
-
* through the MCP bridge and extracts the plan from the response.
|
|
16
|
-
*/
|
|
17
|
-
export async function resolveBehaviorPlan(bridge, key) {
|
|
18
|
-
if (!bridge.isReady()) {
|
|
19
|
-
throw new Error(`Cannot resolve behavior '${key}': Sage MCP bridge is not connected`);
|
|
20
|
-
}
|
|
21
|
-
// Call Sage MCP to get the behavior with plan expansion.
|
|
22
|
-
// The expand modes progressively resolve: parse → resolve → plan → bodies.
|
|
23
|
-
const result = await bridge.callCodeModeExecute({
|
|
24
|
-
domain: "prompts",
|
|
25
|
-
action: "get",
|
|
26
|
-
params: {
|
|
27
|
-
key,
|
|
28
|
-
expand: ["behaviorPlan", "behaviorSkillBodies"],
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
|
-
return extractPlanFromResult(result, key);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Extract and validate a BehaviorPlan from an MCP result.
|
|
35
|
-
*
|
|
36
|
-
* The MCP response may contain the plan in several locations depending
|
|
37
|
-
* on the Sage MCP version:
|
|
38
|
-
* - result.content[].text (JSON string)
|
|
39
|
-
* - result.extra.behaviorPlan (object)
|
|
40
|
-
* - result.plan (object)
|
|
41
|
-
*/
|
|
42
|
-
function extractPlanFromResult(result, key) {
|
|
43
|
-
if (!result || typeof result !== "object") {
|
|
44
|
-
throw new Error(`Empty response when resolving behavior '${key}'`);
|
|
45
|
-
}
|
|
46
|
-
const obj = result;
|
|
47
|
-
// Try structured plan field first (multiple nesting levels)
|
|
48
|
-
const promptEnvelope = obj.prompt;
|
|
49
|
-
const planCandidate = obj.plan ??
|
|
50
|
-
obj.behaviorPlan ??
|
|
51
|
-
obj.extra?.behaviorPlan ??
|
|
52
|
-
promptEnvelope?.behaviorPlan;
|
|
53
|
-
if (planCandidate && typeof planCandidate === "object") {
|
|
54
|
-
return validatePlan(planCandidate, key);
|
|
55
|
-
}
|
|
56
|
-
// Try parsing from MCP content text blocks
|
|
57
|
-
if (Array.isArray(obj.content)) {
|
|
58
|
-
for (const block of obj.content) {
|
|
59
|
-
if (!block || typeof block !== "object")
|
|
60
|
-
continue;
|
|
61
|
-
const text = block.text;
|
|
62
|
-
if (typeof text !== "string")
|
|
63
|
-
continue;
|
|
64
|
-
// Try JSON parse — the plan may be embedded as JSON
|
|
65
|
-
try {
|
|
66
|
-
const parsed = JSON.parse(text);
|
|
67
|
-
if (parsed &&
|
|
68
|
-
typeof parsed === "object" &&
|
|
69
|
-
Array.isArray(parsed.steps)) {
|
|
70
|
-
return validatePlan(parsed, key);
|
|
71
|
-
}
|
|
72
|
-
// Check nested
|
|
73
|
-
if (parsed.plan &&
|
|
74
|
-
typeof parsed.plan === "object" &&
|
|
75
|
-
Array.isArray(parsed.plan.steps)) {
|
|
76
|
-
return validatePlan(parsed.plan, key);
|
|
77
|
-
}
|
|
78
|
-
if (parsed.behaviorPlan && typeof parsed.behaviorPlan === "object") {
|
|
79
|
-
return validatePlan(parsed.behaviorPlan, key);
|
|
80
|
-
}
|
|
81
|
-
// Check inside prompt envelope — get_prompt returns { prompt: { behaviorPlan: ... } }
|
|
82
|
-
if (parsed.prompt &&
|
|
83
|
-
typeof parsed.prompt === "object" &&
|
|
84
|
-
parsed.prompt.behaviorPlan &&
|
|
85
|
-
typeof parsed.prompt.behaviorPlan === "object") {
|
|
86
|
-
return validatePlan(parsed.prompt.behaviorPlan, key);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
catch {
|
|
90
|
-
// Not JSON — may be the rendered markdown controller prompt.
|
|
91
|
-
// Extract plan structure from markdown if possible.
|
|
92
|
-
const markdownPlan = parseMarkdownPlan(text, key);
|
|
93
|
-
if (markdownPlan)
|
|
94
|
-
return markdownPlan;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
throw new Error(`Could not extract behavior plan from response for '${key}'. ` +
|
|
99
|
-
`The behavior may not exist or may not have the 'behavior' field in its prompt extra.`);
|
|
100
|
-
}
|
|
101
|
-
/** Validate a raw object as a BehaviorPlan. */
|
|
102
|
-
function validatePlan(raw, key) {
|
|
103
|
-
const steps = raw.steps;
|
|
104
|
-
if (!Array.isArray(steps) || steps.length === 0) {
|
|
105
|
-
throw new Error(`Behavior '${key}' resolved but has no steps`);
|
|
106
|
-
}
|
|
107
|
-
const validSteps = steps.map((step, i) => {
|
|
108
|
-
if (!step || typeof step !== "object") {
|
|
109
|
-
throw new Error(`Step ${i} in behavior '${key}' is not an object`);
|
|
110
|
-
}
|
|
111
|
-
const s = step;
|
|
112
|
-
return {
|
|
113
|
-
id: typeof s.id === "string" ? s.id : `step-${i + 1}`,
|
|
114
|
-
title: typeof s.title === "string" ? s.title : `Step ${i + 1}`,
|
|
115
|
-
skill_key: typeof s.skill_key === "string" ? s.skill_key : "",
|
|
116
|
-
instruction: typeof s.instruction === "string" ? s.instruction : "",
|
|
117
|
-
uses: Array.isArray(s.uses) ? s.uses : [],
|
|
118
|
-
produces: Array.isArray(s.produces)
|
|
119
|
-
? s.produces
|
|
120
|
-
: [`output-${i + 1}`],
|
|
121
|
-
};
|
|
122
|
-
});
|
|
123
|
-
return {
|
|
124
|
-
version: typeof raw.version === "string" ? raw.version : "1",
|
|
125
|
-
inputs: Array.isArray(raw.inputs)
|
|
126
|
-
? raw.inputs.map((inp) => ({
|
|
127
|
-
name: String(inp.name ?? ""),
|
|
128
|
-
description: typeof inp.description === "string" ? inp.description : undefined,
|
|
129
|
-
required: Boolean(inp.required),
|
|
130
|
-
}))
|
|
131
|
-
: [{ name: "task", required: true, description: "The task to perform" }],
|
|
132
|
-
steps: validSteps,
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Best-effort extraction of plan steps from Sage's rendered markdown controller prompt.
|
|
137
|
-
*
|
|
138
|
-
* When the MCP response is the rendered markdown (not raw JSON), parse step
|
|
139
|
-
* headers like "### Step 1: Skill Name" to reconstruct the plan structure.
|
|
140
|
-
*/
|
|
141
|
-
function parseMarkdownPlan(markdown, _key) {
|
|
142
|
-
const stepPattern = /^###?\s+Step\s+(\d+):\s+(.+)$/gm;
|
|
143
|
-
const steps = [];
|
|
144
|
-
let match;
|
|
145
|
-
while ((match = stepPattern.exec(markdown)) !== null) {
|
|
146
|
-
const stepNum = parseInt(match[1], 10);
|
|
147
|
-
const title = match[2].trim();
|
|
148
|
-
// Extract skill key from the line after "**Skill**: `key`"
|
|
149
|
-
const afterHeader = markdown.slice(match.index + match[0].length, match.index + match[0].length + 500);
|
|
150
|
-
const skillMatch = afterHeader.match(/\*\*Skill\*\*:\s*`([^`]+)`/);
|
|
151
|
-
const instructionMatch = afterHeader.match(/\*\*Instruction\*\*:\s*(.+?)(?:\n\*\*|\n###|$)/s);
|
|
152
|
-
steps.push({
|
|
153
|
-
id: `step-${stepNum}`,
|
|
154
|
-
title,
|
|
155
|
-
skill_key: skillMatch?.[1] ?? title.toLowerCase().replace(/\s+/g, "-"),
|
|
156
|
-
instruction: instructionMatch?.[1]?.trim() ?? `Apply the ${title} skill`,
|
|
157
|
-
uses: stepNum > 1 ? [`step-${stepNum - 1}`] : [],
|
|
158
|
-
produces: [`output-${stepNum}`],
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
if (steps.length === 0)
|
|
162
|
-
return null;
|
|
163
|
-
return {
|
|
164
|
-
version: "1",
|
|
165
|
-
inputs: [
|
|
166
|
-
{ name: "task", required: true, description: "The task to perform" },
|
|
167
|
-
],
|
|
168
|
-
steps,
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
//# sourceMappingURL=resolver.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolver.js","sourceRoot":"","sources":["../../src/behavior/resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACxC,MAAqB,EACrB,GAAW;IAEX,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CACd,4BAA4B,GAAG,qCAAqC,CACpE,CAAC;IACH,CAAC;IAED,yDAAyD;IACzD,2EAA2E;IAC3E,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC;QAC/C,MAAM,EAAE,SAAS;QACjB,MAA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AAW,GAAG,QAAQ,CAAC,KAAK,CACjC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAC7B,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,GAAG,CACnC,CAAC;QACF,MAAM,UAAU,GAAG,WAAW,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;QACnE,MAAM,gBAAgB,GAAG,WAAW,CAAC,KAAK,CACzC,iDAAiD,CACjD,CAAC;QAEF,KAAK,CAAC,IAAI,CAAC;YACV,EAAE,EAAE,QAAQ,OAAO,EAAE;YACrB,KAAK;YACL,SAAS,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;YACtE,WAAW,EAAE,gBAAgB,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,aAAa,KAAK,QAAQ;YACxE,IAAI,EAAE,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,OAAO,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE;YAChD,QAAQ,EAAE,CAAC,UAAU,OAAO,EAAE,CAAC;SAC/B,CAAC,CAAC;IACJ,CAAC;IAED,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAEpC,OAAO;QACN,OAAO,EAAE,GAAG;QACZ,MAAM,EAAE;YACP,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,qBAAqB,EAAE;SACpE;QACD,KAAK;KACL,CAAC;AACH,CAAC"}
|
package/dist/behavior/types.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file behavior/types.ts
|
|
3
|
-
*
|
|
4
|
-
* Responsibility: Define the canonical types for Sage behavior plans and the
|
|
5
|
-
* BehaviorExecutor plugin interface that bridges Sage's behavior engine to
|
|
6
|
-
* any AI harness's subagent system.
|
|
7
|
-
*
|
|
8
|
-
* Invariants:
|
|
9
|
-
* - Types mirror the Sage core Rust structs (crates/core/src/library/behavior.rs).
|
|
10
|
-
* - The BehaviorExecutor interface is the ONLY contract between the adapter core
|
|
11
|
-
* and harness-specific executors — core never imports from executor implementations.
|
|
12
|
-
* - All step IDs are unique within a plan.
|
|
13
|
-
* - Steps form a linear dependency chain (step-N uses output of step-N-1).
|
|
14
|
-
*/
|
|
15
|
-
export {};
|
|
16
|
-
//# sourceMappingURL=types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/behavior/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,4CAA4C;AAC5C,cAAc,sBAAsB,CAAC;AAErC,yCAAyC;AACzC,cAAc,qBAAqB,CAAC"}
|