@toddzheng024/dscode-bundle 0.7.23 → 0.7.24
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/THIRD_PARTY_NOTICES.md +3 -0
- package/cordis.patch.yml +2 -0
- package/package.json +4 -2
- package/plugins/dscode/index.mjs +1 -1
- package/plugins/openrouter/adapter.mjs +23 -2
- package/plugins/openrouter/wire.mjs +2 -1
- package/plugins/triggers/cli.mjs +439 -0
- package/plugins/triggers/config.mjs +245 -0
- package/plugins/triggers/host.mjs +138 -0
- package/plugins/triggers/index.mjs +57 -0
- package/plugins/triggers/launchd.mjs +101 -0
- package/plugins/triggers/log.mjs +104 -0
- package/plugins/triggers/options.mjs +109 -0
- package/plugins/triggers/overlay.mjs +7 -0
- package/plugins/triggers/poll.mjs +57 -0
- package/plugins/triggers/run.mjs +156 -0
- package/plugins/triggers/spool.mjs +128 -0
- package/presets/dscode/agent.cordis.yml +1 -1
- package/vendor/command-goal/LICENSE +21 -0
- package/vendor/command-goal/index.js +208 -0
- package/vendor/command-goal/types/index.d.ts +10 -0
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
// dscode-goal-cap-v1
|
|
2
|
+
import { GoalError } from "@deepseek-ai/dsh-goal";
|
|
3
|
+
import { createUserMessage } from "@deepseek-ai/dsh-llm";
|
|
4
|
+
//#region lib/types/index.js
|
|
5
|
+
/**
|
|
6
|
+
* Human-facing `/goal` command over the persisted same-session goal domain.
|
|
7
|
+
* @module @deepseek-ai/dsh-command-goal
|
|
8
|
+
*/
|
|
9
|
+
const name = "command-goal";
|
|
10
|
+
const inject = ["commands", "goals"];
|
|
11
|
+
const USAGE = "Usage: /goal [<objective>|clear|edit <objective>|pause|resume], /goal[<rounds>] set the round cap";
|
|
12
|
+
/** Fail loudly if a locally closed union gains an unhandled member. */
|
|
13
|
+
/* v8 ignore start -- closed-union backstop is unreachable without violating the TypeScript contract */
|
|
14
|
+
function assertNever(value, label) {
|
|
15
|
+
throw new TypeError(`unknown ${label}: ${String(value)}`);
|
|
16
|
+
}
|
|
17
|
+
/* v8 ignore stop */
|
|
18
|
+
/** Parse only the grammar owned by `/goal`; arbitrary other input is an objective. */
|
|
19
|
+
function parseGoalCommand(rawInput) {
|
|
20
|
+
const input = rawInput.trim();
|
|
21
|
+
const capMatch = /^\[(\d+)\]\s*(.*)$/su.exec(input);
|
|
22
|
+
if (capMatch !== null) {
|
|
23
|
+
const maxGoalRounds = Number(capMatch[1]);
|
|
24
|
+
const rest = capMatch[2].trim();
|
|
25
|
+
if (maxGoalRounds < 1 || ["clear", "pause", "resume", "edit"].includes(rest.toLowerCase())) return { kind: "invalid-cap" };
|
|
26
|
+
return rest === "" ? { kind: "cap", maxGoalRounds } : { kind: "create", objective: rest, maxGoalRounds };
|
|
27
|
+
}
|
|
28
|
+
if (input.length === 0) return { kind: "show" };
|
|
29
|
+
const control = input.toLowerCase();
|
|
30
|
+
if (control === "clear") return { kind: "clear" };
|
|
31
|
+
if (control === "pause") return { kind: "pause" };
|
|
32
|
+
if (control === "resume") return { kind: "resume" };
|
|
33
|
+
if (control === "edit") return { kind: "invalid-edit" };
|
|
34
|
+
if (/^edit(?=\s)/iu.test(input)) return {
|
|
35
|
+
kind: "edit",
|
|
36
|
+
objective: input.slice(4).trim()
|
|
37
|
+
};
|
|
38
|
+
return {
|
|
39
|
+
kind: "create",
|
|
40
|
+
objective: input
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/** Human label for one durable goal phase. */
|
|
44
|
+
function phaseLabel(phase) {
|
|
45
|
+
switch (phase) {
|
|
46
|
+
case "active": return "active";
|
|
47
|
+
case "paused": return "paused";
|
|
48
|
+
case "blocked": return "blocked";
|
|
49
|
+
case "complete": return "complete";
|
|
50
|
+
/* v8 ignore next 2 -- GoalPhase is closed and every member is handled above */
|
|
51
|
+
default: return assertNever(phase, "goal phase");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/** Commands that are meaningful from one exact live state. */
|
|
55
|
+
function commandHint(goal) {
|
|
56
|
+
if (goal.phase === "active") return goal.activation === "armed" ? "/goal edit <objective>, /goal pause, /goal clear" : "/goal edit <objective>, /goal resume, /goal clear";
|
|
57
|
+
switch (goal.phase) {
|
|
58
|
+
case "paused":
|
|
59
|
+
case "blocked": return "/goal edit <objective>, /goal resume, /goal clear";
|
|
60
|
+
case "complete": return "/goal <objective>, /goal clear";
|
|
61
|
+
/* v8 ignore next 2 -- the active branch and every non-active phase are handled above */
|
|
62
|
+
default: return assertNever(goal.phase, "goal phase");
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/** Render direct UI output without exposing compare-and-set internals. */
|
|
66
|
+
function renderGoal(title, goal) {
|
|
67
|
+
const reason = goal.phase === "blocked" ? goal.blockedReason : void 0;
|
|
68
|
+
/* v8 ignore next -- durable replay guarantees every blocked goal carries its validated reason */
|
|
69
|
+
if (goal.phase === "blocked" && reason === void 0) throw new TypeError("blocked goal is missing its reason");
|
|
70
|
+
const blocker = reason === void 0 ? [] : [`Blocker: ${reason.code}: ${reason.message}`];
|
|
71
|
+
return {
|
|
72
|
+
kind: "success",
|
|
73
|
+
text: [
|
|
74
|
+
title,
|
|
75
|
+
`Status: ${phaseLabel(goal.phase)}`,
|
|
76
|
+
...blocker,
|
|
77
|
+
`Objective: ${goal.objective}`,
|
|
78
|
+
`Rounds: ${goal.roundsStarted}/${goal.maxGoalRounds}`,
|
|
79
|
+
`Activation: ${goal.activation}`,
|
|
80
|
+
"",
|
|
81
|
+
`Commands: ${commandHint(goal)}`
|
|
82
|
+
].join("\n")
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/** Exact current compare-and-set ref. */
|
|
86
|
+
function goalRef(goal) {
|
|
87
|
+
return {
|
|
88
|
+
id: goal.id,
|
|
89
|
+
revision: goal.revision
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/** dscode: the create/edit request, carrying the `[N]` cap when the human set one. */
|
|
93
|
+
function goalRequest(command) {
|
|
94
|
+
return { objective: command.objective, ...command.maxGoalRounds === void 0 ? {} : { maxGoalRounds: command.maxGoalRounds } };
|
|
95
|
+
}
|
|
96
|
+
/** Direct error for an operation that requires a current goal. */
|
|
97
|
+
function missingGoal(action) {
|
|
98
|
+
return {
|
|
99
|
+
kind: "error",
|
|
100
|
+
text: `No goal is currently set; /goal ${action} requires one. ${USAGE}`
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Submit the invocation's admitted composer attachments as one model-visible user
|
|
105
|
+
* message ahead of the goal's next round. The attachments precede a fixed text
|
|
106
|
+
* block naming their role, so a later goal round reads them from ordinary
|
|
107
|
+
* session history without the goal domain storing attachment state.
|
|
108
|
+
*/
|
|
109
|
+
function submitObjectiveAttachments(invocation) {
|
|
110
|
+
if (invocation.attachments.length === 0) return;
|
|
111
|
+
invocation.agent.followup(createUserMessage({
|
|
112
|
+
content: [...invocation.attachments, {
|
|
113
|
+
type: "text",
|
|
114
|
+
text: "Reference attachments for the goal objective."
|
|
115
|
+
}],
|
|
116
|
+
source: { kind: "user" }
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
119
|
+
/** Execute one parsed human command through the domain that owns persistence. */
|
|
120
|
+
function executeGoalCommand(ctx, invocation) {
|
|
121
|
+
const command = parseGoalCommand(invocation.rawInput);
|
|
122
|
+
if (invocation.attachments.length > 0 && command.kind !== "create" && command.kind !== "edit") return {
|
|
123
|
+
kind: "error",
|
|
124
|
+
text: "Attachments only accompany a goal objective: /goal <objective> or /goal edit <objective>."
|
|
125
|
+
};
|
|
126
|
+
try {
|
|
127
|
+
const current = ctx.goals.get(invocation.agent);
|
|
128
|
+
switch (command.kind) {
|
|
129
|
+
case "show": return current === void 0 ? {
|
|
130
|
+
kind: "success",
|
|
131
|
+
text: `No goal is currently set.\n${USAGE}`
|
|
132
|
+
} : renderGoal("Goal", current);
|
|
133
|
+
case "invalid-edit": return {
|
|
134
|
+
kind: "error",
|
|
135
|
+
text: `Goal editing requires a replacement objective.\n${USAGE}`
|
|
136
|
+
};
|
|
137
|
+
case "create": {
|
|
138
|
+
if (current !== void 0 && current.phase !== "complete") return {
|
|
139
|
+
kind: "error",
|
|
140
|
+
text: `A goal is already ${phaseLabel(current.phase)}. Use /goal edit <objective> to change it or /goal clear before replacing it.`
|
|
141
|
+
};
|
|
142
|
+
const created = ctx.goals.create(invocation.agent, goalRequest(command));
|
|
143
|
+
submitObjectiveAttachments(invocation);
|
|
144
|
+
return renderGoal("Goal created", created);
|
|
145
|
+
}
|
|
146
|
+
case "edit": {
|
|
147
|
+
if (current === void 0) return missingGoal("edit");
|
|
148
|
+
if (current.phase === "complete") {
|
|
149
|
+
const replaced = ctx.goals.create(invocation.agent, goalRequest(command));
|
|
150
|
+
submitObjectiveAttachments(invocation);
|
|
151
|
+
return renderGoal("Goal created", replaced);
|
|
152
|
+
}
|
|
153
|
+
const edited = ctx.goals.edit(invocation.agent, goalRef(current), goalRequest(command));
|
|
154
|
+
submitObjectiveAttachments(invocation);
|
|
155
|
+
return renderGoal("Goal updated", edited);
|
|
156
|
+
}
|
|
157
|
+
case "pause":
|
|
158
|
+
if (current === void 0) return missingGoal("pause");
|
|
159
|
+
return renderGoal("Goal paused", ctx.goals.pause(invocation.agent, goalRef(current)));
|
|
160
|
+
case "resume":
|
|
161
|
+
if (current === void 0) return missingGoal("resume");
|
|
162
|
+
return renderGoal("Goal resumed", ctx.goals.resume(invocation.agent, goalRef(current)));
|
|
163
|
+
case "clear":
|
|
164
|
+
if (current === void 0) return {
|
|
165
|
+
kind: "success",
|
|
166
|
+
text: "No goal to clear."
|
|
167
|
+
};
|
|
168
|
+
ctx.goals.clear(invocation.agent, goalRef(current));
|
|
169
|
+
return {
|
|
170
|
+
kind: "success",
|
|
171
|
+
text: "Goal cleared."
|
|
172
|
+
};
|
|
173
|
+
case "cap": {
|
|
174
|
+
if (current === void 0) return {
|
|
175
|
+
kind: "error",
|
|
176
|
+
text: `No goal is currently set; /goal[<rounds>] changes the round cap of an existing goal. ${USAGE}`
|
|
177
|
+
};
|
|
178
|
+
return renderGoal("Goal updated", ctx.goals.edit(invocation.agent, goalRef(current), { maxGoalRounds: command.maxGoalRounds }));
|
|
179
|
+
}
|
|
180
|
+
case "invalid-cap": return {
|
|
181
|
+
kind: "error",
|
|
182
|
+
text: `The round cap must be a positive whole number and cannot accompany a control word.\n${USAGE}`
|
|
183
|
+
};
|
|
184
|
+
/* v8 ignore next 2 -- GoalCommand is closed and every member is handled above */
|
|
185
|
+
default: return assertNever(command, "goal command");
|
|
186
|
+
}
|
|
187
|
+
} catch (error) {
|
|
188
|
+
if (error instanceof GoalError) return {
|
|
189
|
+
kind: "error",
|
|
190
|
+
text: "The goal command is not valid for the current state. Run /goal to view available commands."
|
|
191
|
+
};
|
|
192
|
+
throw error;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/** Register the Codex-shaped `/goal` command for every composed command adapter. */
|
|
196
|
+
function apply(ctx) {
|
|
197
|
+
ctx.commands.register({
|
|
198
|
+
name: "goal",
|
|
199
|
+
description: "set or view the goal for a long-running task",
|
|
200
|
+
input: {
|
|
201
|
+
hint: "[<objective>|clear|edit <objective>|pause|resume], [<rounds>]",
|
|
202
|
+
attachments: true
|
|
203
|
+
},
|
|
204
|
+
handler: (invocation) => executeGoalCommand(ctx, invocation)
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
//#endregion
|
|
208
|
+
export { apply, inject, name };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Human-facing `/goal` command over the persisted same-session goal domain.
|
|
3
|
+
* @module @deepseek-ai/dsh-command-goal
|
|
4
|
+
*/
|
|
5
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
6
|
+
export declare const name = "command-goal";
|
|
7
|
+
export declare const inject: string[];
|
|
8
|
+
/** Register the Codex-shaped `/goal` command for every composed command adapter. */
|
|
9
|
+
export declare function apply(ctx: Context): void;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|