@abelxiaoxing/cadence 2.0.38 → 2.0.40
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/docs/conversation-mode.md +30 -0
- package/docs/reuse-and-distribution.md +78 -0
- package/package.json +4 -2
- package/src/activity.ts +147 -0
- package/src/index.ts +2 -0
- package/src/native-build.ts +1 -1
- package/src/operator-cli.mjs +4 -1
- package/src/research-scan.mjs +111 -31
- package/src/research-tools.mjs +75 -16
- package/src/sdk-worker.mjs +4 -1
- package/src/service/activity-files.ts +190 -0
- package/src/service/coordination.ts +6 -3
- package/src/service-cli.mjs +26 -8
- package/src/service-host.mjs +5314 -4828
- package/src/worker-toolkit.mjs +7 -1
- package/src/workspace.ts +58 -1
- package/web/dist/assets/cadence.js +18 -18
- package/web/dist/manifest.json +5 -5
package/src/worker-toolkit.mjs
CHANGED
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
import { Type } from "typebox";
|
|
4
4
|
import { createChangeTools } from "./change-tools.mjs";
|
|
5
5
|
import { createCoordinatorTools } from "./coordinator-tools.mjs";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
createResearchTools,
|
|
8
|
+
RESEARCH_INSTRUCTIONS,
|
|
9
|
+
} from "./research-tools.mjs";
|
|
7
10
|
import { sanitizeText } from "./worker-redaction.mjs";
|
|
8
11
|
import { captureBash } from "./worker-tools.mjs";
|
|
9
12
|
|
|
@@ -101,6 +104,9 @@ export function createWorkerToolkit(options) {
|
|
|
101
104
|
closing;
|
|
102
105
|
return {
|
|
103
106
|
capabilities,
|
|
107
|
+
instructions: capabilities.includes("observation")
|
|
108
|
+
? RESEARCH_INSTRUCTIONS
|
|
109
|
+
: "",
|
|
104
110
|
// Explicit allowlists are required by the installed public Pi SDK. Omitting
|
|
105
111
|
// one would enable its defaults, not mean "only our custom capabilities".
|
|
106
112
|
sessionOptions: {
|
package/src/workspace.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { gitArguments, gitEnvironment } from "./git-environment.mjs";
|
|
|
3
3
|
export { gitArguments, gitEnvironment } from "./git-environment.mjs";
|
|
4
4
|
|
|
5
5
|
/** Workspace identity and bounded filesystem operations, independent of task records. */
|
|
6
|
-
import { spawnSync } from "node:child_process";
|
|
6
|
+
import { execFile, spawnSync } from "node:child_process";
|
|
7
7
|
import { createHash } from "node:crypto";
|
|
8
8
|
import {
|
|
9
9
|
closeSync,
|
|
@@ -176,6 +176,63 @@ export function resolveWorkspace(cwd: string): { root: string; cwd: string } {
|
|
|
176
176
|
windowsHide: true,
|
|
177
177
|
},
|
|
178
178
|
);
|
|
179
|
+
return workspaceResult(actual, result);
|
|
180
|
+
}
|
|
181
|
+
const WORKSPACE_OBSERVATION_MS = 500;
|
|
182
|
+
/** Discovery must not block the Pi/HTTP event loop on a stalled Git command.
|
|
183
|
+
* Same physical-checkout policy as resolveWorkspace, with a caller-owned wait. */
|
|
184
|
+
export function resolveWorkspaceAsync(
|
|
185
|
+
cwd: string,
|
|
186
|
+
signal?: AbortSignal,
|
|
187
|
+
): Promise<{ root: string; cwd: string }> {
|
|
188
|
+
const actual = realpathSync(cwd);
|
|
189
|
+
return new Promise((resolve, reject) => {
|
|
190
|
+
execFile(
|
|
191
|
+
"git",
|
|
192
|
+
gitArguments(["rev-parse", "--show-toplevel"]),
|
|
193
|
+
{
|
|
194
|
+
cwd: actual,
|
|
195
|
+
env: gitEnvironment(),
|
|
196
|
+
encoding: "utf8",
|
|
197
|
+
timeout: WORKSPACE_OBSERVATION_MS,
|
|
198
|
+
maxBuffer: 8192,
|
|
199
|
+
windowsHide: true,
|
|
200
|
+
signal,
|
|
201
|
+
killSignal: "SIGKILL",
|
|
202
|
+
},
|
|
203
|
+
(error, stdout, stderr) => {
|
|
204
|
+
try {
|
|
205
|
+
if (error?.killed || error?.signal || signal?.aborted)
|
|
206
|
+
throw new Error("Workspace lookup interrupted");
|
|
207
|
+
resolve(
|
|
208
|
+
workspaceResult(actual, {
|
|
209
|
+
stdout,
|
|
210
|
+
stderr,
|
|
211
|
+
status: error
|
|
212
|
+
? typeof error.code === "number"
|
|
213
|
+
? error.code
|
|
214
|
+
: null
|
|
215
|
+
: 0,
|
|
216
|
+
error:
|
|
217
|
+
error && typeof error.code !== "number" ? error : undefined,
|
|
218
|
+
}),
|
|
219
|
+
);
|
|
220
|
+
} catch (error) {
|
|
221
|
+
reject(error);
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
);
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
function workspaceResult(
|
|
228
|
+
actual: string,
|
|
229
|
+
result: {
|
|
230
|
+
stdout?: string;
|
|
231
|
+
stderr: string;
|
|
232
|
+
status: number | null;
|
|
233
|
+
error?: Error | null;
|
|
234
|
+
},
|
|
235
|
+
): { root: string; cwd: string } {
|
|
179
236
|
// Remove only Git's record terminator, not valid whitespace in a path.
|
|
180
237
|
const topLevel = result.stdout?.replace(
|
|
181
238
|
process.platform === "win32" ? /\r?\n$/ : /\n$/,
|