dsh-checklists 0.5.0 → 0.5.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/lib/index.js +26 -11
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -54,10 +54,12 @@ export function apply(ctx, config = {}) {
|
|
|
54
54
|
const activity = new Map();
|
|
55
55
|
const gateLog = [];
|
|
56
56
|
const events = ctx;
|
|
57
|
-
ctx.effect(() => events.on('tools/result', (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const
|
|
57
|
+
ctx.effect(() => events.on('tools/result', (exec) => {
|
|
58
|
+
// `tools/result` is emitted as (execution, result); the execution carries
|
|
59
|
+
// the tool name and the calling agent.
|
|
60
|
+
const call = exec;
|
|
61
|
+
const toolName = call?.name;
|
|
62
|
+
const agentId = call?.agent?.id;
|
|
61
63
|
if (typeof toolName !== 'string' || typeof agentId !== 'string')
|
|
62
64
|
return;
|
|
63
65
|
const current = activity.get(agentId) ?? { mutated: false, checklistWrite: false };
|
|
@@ -67,11 +69,7 @@ export function apply(ctx, config = {}) {
|
|
|
67
69
|
current.checklistWrite = true;
|
|
68
70
|
activity.set(agentId, current);
|
|
69
71
|
}));
|
|
70
|
-
|
|
71
|
-
const event = payload;
|
|
72
|
-
const agentId = event.agent?.id;
|
|
73
|
-
if (typeof agentId !== 'string')
|
|
74
|
-
return;
|
|
72
|
+
const evaluate = (agentId, source) => {
|
|
75
73
|
const current = activity.get(agentId) ?? { mutated: false, checklistWrite: false };
|
|
76
74
|
activity.set(agentId, { mutated: false, checklistWrite: false });
|
|
77
75
|
const doc = store.peek(agentId);
|
|
@@ -80,17 +78,34 @@ export function apply(ctx, config = {}) {
|
|
|
80
78
|
for (const list of doc.lists)
|
|
81
79
|
doing += countState(list.items, 'doing');
|
|
82
80
|
const decision = decideNudge(current, doing);
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
// Log every decision while the gate is in observe mode: an empty log must
|
|
82
|
+
// mean "the event never fired", never "the answer was no".
|
|
85
83
|
gateLog.push({
|
|
86
84
|
at: new Date().toISOString(),
|
|
87
85
|
sessionId: agentId,
|
|
86
|
+
source,
|
|
88
87
|
nudge: decision.nudge,
|
|
89
88
|
reason: decision.reason,
|
|
90
89
|
doing,
|
|
91
90
|
});
|
|
92
91
|
if (gateLog.length > 20)
|
|
93
92
|
gateLog.shift();
|
|
93
|
+
};
|
|
94
|
+
ctx.effect(() => events.on('agent/turn-stopping', (payload) => {
|
|
95
|
+
const event = payload;
|
|
96
|
+
if (typeof event.agent?.id === 'string')
|
|
97
|
+
evaluate(event.agent.id, 'turn-stopping');
|
|
98
|
+
}));
|
|
99
|
+
// Second observation point. `agent/status` → idle also marks a turn end, so
|
|
100
|
+
// keeping both in the log tells us which one the runtime actually delivers —
|
|
101
|
+
// and leaves the gate working if `turn-stopping` turns out not to reach a
|
|
102
|
+
// root listener.
|
|
103
|
+
ctx.effect(() => events.on('agent/status', (payload) => {
|
|
104
|
+
const event = payload;
|
|
105
|
+
if (event.status !== 'idle')
|
|
106
|
+
return;
|
|
107
|
+
if (typeof event.agent?.id === 'string')
|
|
108
|
+
evaluate(event.agent.id, 'status');
|
|
94
109
|
}));
|
|
95
110
|
let loggedScope = false;
|
|
96
111
|
ctx.inject(['systemPrompt'], (promptCtx) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-checklists",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Session-scoped checklists for DeepSeek Harness: the agent tracks work as a tree, the model always sees a compact digest, and a read-only sidebar tab mirrors it.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|