agent-procedures 0.3.1 → 0.3.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/dist/runtime.js +10 -6
- package/lib/engine.js +5 -4
- package/lib/harnesses/claude.js +5 -2
- package/lib/recall.js +3 -1
- package/package.json +1 -1
package/dist/runtime.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated by agent-procedures@0.3.
|
|
1
|
+
// Generated by agent-procedures@0.3.2. Do not edit.
|
|
2
2
|
// To upgrade: npx agent-procedures init
|
|
3
3
|
|
|
4
4
|
// lib/main.js
|
|
@@ -391,13 +391,15 @@ function recall(prompt, procs) {
|
|
|
391
391
|
let text = formatSteps(best.steps, best.requires_env);
|
|
392
392
|
const alt = procs.find((e) => e.parent_id === best.id && e.type === "alt" && e.enabled !== false);
|
|
393
393
|
if (alt) text += "\n\nAlternative path that worked:\n" + formatSteps(alt.steps, alt.requires_env);
|
|
394
|
+
const label = best.trigger || "procedure";
|
|
394
395
|
return {
|
|
395
396
|
node: best,
|
|
396
397
|
text: `Reflex memory found a procedure for this task:
|
|
397
398
|
|
|
398
399
|
${text}
|
|
399
400
|
|
|
400
|
-
Follow these steps instead of figuring it out from scratch
|
|
401
|
+
Follow these steps instead of figuring it out from scratch.`,
|
|
402
|
+
notice: `Reflex recalled: "${label}"`
|
|
401
403
|
};
|
|
402
404
|
}
|
|
403
405
|
|
|
@@ -420,9 +422,9 @@ function onPrompt(evt, reflexDir) {
|
|
|
420
422
|
...sanitized.unsafe ? { contains_unresolvable_secret: true } : {}
|
|
421
423
|
});
|
|
422
424
|
const hit = recall(sanitized.text, readAllProcedures(reflexDir));
|
|
423
|
-
if (!hit) return { context: null };
|
|
425
|
+
if (!hit) return { context: null, notice: null };
|
|
424
426
|
appendTrace(reflexDir, sessionId, promptId, { t: "Recall", hit: hit.node.id });
|
|
425
|
-
return { context: hit.text };
|
|
427
|
+
return { context: hit.text, notice: hit.notice };
|
|
426
428
|
}
|
|
427
429
|
function onTool(evt, reflexDir) {
|
|
428
430
|
const sanitized = evt.tool === "Bash" || evt.tool === "bash" ? sanitizeCommand(evt.target) : sanitizeText(evt.target);
|
|
@@ -882,9 +884,11 @@ var claude_default = {
|
|
|
882
884
|
render(evt, result2) {
|
|
883
885
|
if (evt.type !== "prompt") return "";
|
|
884
886
|
if (!result2.context) return "{}";
|
|
885
|
-
|
|
887
|
+
const out = {
|
|
886
888
|
hookSpecificOutput: { hookEventName: "UserPromptSubmit", additionalContext: result2.context }
|
|
887
|
-
}
|
|
889
|
+
};
|
|
890
|
+
if (result2.notice) out.systemMessage = result2.notice;
|
|
891
|
+
return JSON.stringify(out);
|
|
888
892
|
}
|
|
889
893
|
};
|
|
890
894
|
|
package/lib/engine.js
CHANGED
|
@@ -18,8 +18,9 @@ import { recall } from "./recall.js";
|
|
|
18
18
|
* { type: "tool", sessionId, promptId, tool, target, ok }
|
|
19
19
|
* { type: "stop", sessionId, promptId, interrupted, busy }
|
|
20
20
|
*
|
|
21
|
-
* Returns { context: string | null
|
|
22
|
-
* inject into the agent's next turn
|
|
21
|
+
* Returns { context: string | null, notice?: string | null }.
|
|
22
|
+
* `context` is text the harness should inject into the agent's next turn.
|
|
23
|
+
* `notice` is a short user-visible line; the harness maps it if the host supports it.
|
|
23
24
|
*/
|
|
24
25
|
export function handleEvent(evt, reflexDir, deps = {}) {
|
|
25
26
|
if (!evt || !evt.sessionId || !evt.promptId) return { context: null };
|
|
@@ -45,10 +46,10 @@ function onPrompt(evt, reflexDir) {
|
|
|
45
46
|
});
|
|
46
47
|
|
|
47
48
|
const hit = recall(sanitized.text, readAllProcedures(reflexDir));
|
|
48
|
-
if (!hit) return { context: null };
|
|
49
|
+
if (!hit) return { context: null, notice: null };
|
|
49
50
|
|
|
50
51
|
appendTrace(reflexDir, sessionId, promptId, { t: "Recall", hit: hit.node.id });
|
|
51
|
-
return { context: hit.text };
|
|
52
|
+
return { context: hit.text, notice: hit.notice };
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
// --- tool: trace ----------------------------------------------------------
|
package/lib/harnesses/claude.js
CHANGED
|
@@ -70,8 +70,11 @@ export default {
|
|
|
70
70
|
render(evt, result) {
|
|
71
71
|
if (evt.type !== "prompt") return "";
|
|
72
72
|
if (!result.context) return "{}";
|
|
73
|
-
|
|
73
|
+
const out = {
|
|
74
74
|
hookSpecificOutput: { hookEventName: "UserPromptSubmit", additionalContext: result.context },
|
|
75
|
-
}
|
|
75
|
+
};
|
|
76
|
+
// Top-level systemMessage is shown to the user; not model context.
|
|
77
|
+
if (result.notice) out.systemMessage = result.notice;
|
|
78
|
+
return JSON.stringify(out);
|
|
76
79
|
},
|
|
77
80
|
};
|
package/lib/recall.js
CHANGED
|
@@ -77,7 +77,7 @@ function formatSteps(steps, requiresEnv = []) {
|
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
79
|
* Best-scoring root procedure for this prompt, or null.
|
|
80
|
-
* Returns { node, text }
|
|
80
|
+
* Returns { node, text, notice } — text for the agent, notice for the harness UI.
|
|
81
81
|
*/
|
|
82
82
|
export function recall(prompt, procs) {
|
|
83
83
|
if (!prompt) return null;
|
|
@@ -101,8 +101,10 @@ export function recall(prompt, procs) {
|
|
|
101
101
|
const alt = procs.find((e) => e.parent_id === best.id && e.type === "alt" && e.enabled !== false);
|
|
102
102
|
if (alt) text += "\n\nAlternative path that worked:\n" + formatSteps(alt.steps, alt.requires_env);
|
|
103
103
|
|
|
104
|
+
const label = best.trigger || "procedure";
|
|
104
105
|
return {
|
|
105
106
|
node: best,
|
|
106
107
|
text: `Reflex memory found a procedure for this task:\n\n${text}\n\nFollow these steps instead of figuring it out from scratch.`,
|
|
108
|
+
notice: `Reflex recalled: "${label}"`,
|
|
107
109
|
};
|
|
108
110
|
}
|