@todos-dev/cli 0.1.8 → 0.1.9
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/index.js +41 -2
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -15756,6 +15756,7 @@ function attachStreamingSession(session, label, postToken, onStop) {
|
|
|
15756
15756
|
}
|
|
15757
15757
|
|
|
15758
15758
|
// src/machine.ts
|
|
15759
|
+
var NO_MODEL_ERROR = "No authenticated model available on this machine. Run `tds provider add` (or `tds provider login <name>`) on the machine.";
|
|
15759
15760
|
function makeDone(step, serverUrl, token) {
|
|
15760
15761
|
const { stepId, conversationId, mode } = step;
|
|
15761
15762
|
return (payload) => postCritical(serverUrl, `/api/machine/done/${stepId}`, { conversationId, mode, ...payload }, token).catch((err) => console.error(`[step] ${stepId} done report failed:`, err.message));
|
|
@@ -15827,6 +15828,7 @@ async function downloadStepImages(step) {
|
|
|
15827
15828
|
async function executeStep(step, serverUrl, token, tunnel) {
|
|
15828
15829
|
const { stepId, conversationId } = step;
|
|
15829
15830
|
if (step.mode === "restore") return executeRestore(step, serverUrl, token);
|
|
15831
|
+
if (step.mode === "compact") return executeCompact(step, serverUrl, token);
|
|
15830
15832
|
console.log(`[step] ${stepId} start (conv ${conversationId})`);
|
|
15831
15833
|
let interrupted = false;
|
|
15832
15834
|
let abortRef = null;
|
|
@@ -15845,7 +15847,7 @@ async function executeStep(step, serverUrl, token, tunnel) {
|
|
|
15845
15847
|
ensureSkillGc(agentDir);
|
|
15846
15848
|
const model = resolveModel(modelRegistry, step.agent);
|
|
15847
15849
|
if (!model) {
|
|
15848
|
-
await done({ error:
|
|
15850
|
+
await done({ error: NO_MODEL_ERROR });
|
|
15849
15851
|
return;
|
|
15850
15852
|
}
|
|
15851
15853
|
console.log(`[step] ${stepId} using model ${model.provider}/${model.id}`);
|
|
@@ -15915,7 +15917,7 @@ async function executeStep(step, serverUrl, token, tunnel) {
|
|
|
15915
15917
|
if (diff) await uploadDiff(step.diffUploadUrl, diff, stepId);
|
|
15916
15918
|
}
|
|
15917
15919
|
};
|
|
15918
|
-
const donePayload = () => ({ text: stream.getFullText(), modelId: step.agent.modelId || model.id, commitSha, sessionLeafEntryId, diffHash });
|
|
15920
|
+
const donePayload = () => ({ text: stream.getFullText(), modelId: step.agent.modelId || model.id, commitSha, sessionLeafEntryId, diffHash, contextUsage: session.getContextUsage() });
|
|
15919
15921
|
const images = await downloadStepImages(step);
|
|
15920
15922
|
try {
|
|
15921
15923
|
await session.prompt(step.prompt, images.length ? { images } : void 0);
|
|
@@ -15975,6 +15977,43 @@ async function executeRestore(step, serverUrl, token) {
|
|
|
15975
15977
|
await done({ diffHash });
|
|
15976
15978
|
console.log(`[restore] ${stepId} done`);
|
|
15977
15979
|
}
|
|
15980
|
+
async function executeCompact(step, serverUrl, token) {
|
|
15981
|
+
const { stepId, conversationId } = step;
|
|
15982
|
+
console.log(`[compact] ${stepId} start (conv ${conversationId})`);
|
|
15983
|
+
const done = makeDone(step, serverUrl, token);
|
|
15984
|
+
try {
|
|
15985
|
+
const { sdk, authStorage, modelRegistry, agentDir } = await getPiRuntime();
|
|
15986
|
+
const model = resolveModel(modelRegistry, step.agent);
|
|
15987
|
+
if (!model) {
|
|
15988
|
+
await done({ error: NO_MODEL_ERROR });
|
|
15989
|
+
return;
|
|
15990
|
+
}
|
|
15991
|
+
const m = await materializeSession({ sdk, sessionKey: conversationId, cwd: agentDir, restoreUrl: step.sessionRestoreUrl });
|
|
15992
|
+
if (!m.isContinue) {
|
|
15993
|
+
await done({ contextUsage: void 0 });
|
|
15994
|
+
return;
|
|
15995
|
+
}
|
|
15996
|
+
const session = await createSession(sdk, {
|
|
15997
|
+
authStorage,
|
|
15998
|
+
modelRegistry,
|
|
15999
|
+
model,
|
|
16000
|
+
cwd: agentDir,
|
|
16001
|
+
agentDir,
|
|
16002
|
+
tools: [],
|
|
16003
|
+
sessionManager: m.sessionManager,
|
|
16004
|
+
thinkingLevel: step.agent.thinkingLevel ?? "",
|
|
16005
|
+
webSearch: false
|
|
16006
|
+
});
|
|
16007
|
+
const result = await session.compact();
|
|
16008
|
+
await backupSession(conversationId, session.sessionFile, step.sessionBackupUrl);
|
|
16009
|
+
await done({ contextUsage: session.getContextUsage(), tokensBefore: result?.tokensBefore });
|
|
16010
|
+
console.log(`[compact] ${stepId} done (before ~${result?.tokensBefore} tokens)`);
|
|
16011
|
+
} catch (err) {
|
|
16012
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
16013
|
+
console.error(`[compact] ${stepId} failed:`, msg);
|
|
16014
|
+
await done({ error: msg });
|
|
16015
|
+
}
|
|
16016
|
+
}
|
|
15978
16017
|
|
|
15979
16018
|
// src/lib/daemon.ts
|
|
15980
16019
|
var import_child_process2 = require("child_process");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@todos-dev/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"bin": {
|
|
5
5
|
"tds": "dist/index.js"
|
|
6
6
|
},
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
"@tds/types": "0.1.0"
|
|
31
31
|
},
|
|
32
32
|
"optionalDependencies": {
|
|
33
|
-
"@todos-dev/cli-darwin-arm64": "0.1.
|
|
34
|
-
"@todos-dev/cli-darwin-x64": "0.1.
|
|
35
|
-
"@todos-dev/cli-linux-x64": "0.1.
|
|
36
|
-
"@todos-dev/cli-linux-arm64": "0.1.
|
|
37
|
-
"@todos-dev/cli-win32-x64": "0.1.
|
|
38
|
-
"@todos-dev/cli-win32-arm64": "0.1.
|
|
33
|
+
"@todos-dev/cli-darwin-arm64": "0.1.9",
|
|
34
|
+
"@todos-dev/cli-darwin-x64": "0.1.9",
|
|
35
|
+
"@todos-dev/cli-linux-x64": "0.1.9",
|
|
36
|
+
"@todos-dev/cli-linux-arm64": "0.1.9",
|
|
37
|
+
"@todos-dev/cli-win32-x64": "0.1.9",
|
|
38
|
+
"@todos-dev/cli-win32-arm64": "0.1.9"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"dev": "tsx watch src/index.ts",
|