@standardagents/code 0.11.1 → 0.11.3
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 +24 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3293,8 +3293,16 @@ var BUSY_TAIL_STALE_MS = 30 * 6e4;
|
|
|
3293
3293
|
function toMs(raw) {
|
|
3294
3294
|
return raw > 1e14 ? raw / 1e3 : raw < 1e12 ? raw * 1e3 : raw;
|
|
3295
3295
|
}
|
|
3296
|
+
var EXECUTION_STOPPED_MARKER = "Execution stopped by user";
|
|
3296
3297
|
function deriveSessionActivity(messages, nowMs = Date.now()) {
|
|
3297
|
-
const
|
|
3298
|
+
const all = messages.filter((message) => message.silent !== true && message.metadata?.silent !== true).sort((a, b) => createdAt(a) - createdAt(b));
|
|
3299
|
+
let stopMs = 0;
|
|
3300
|
+
for (const message of all) {
|
|
3301
|
+
if (message.role === "system" && messageText(message.content).startsWith(EXECUTION_STOPPED_MARKER)) {
|
|
3302
|
+
stopMs = Math.max(stopMs, toMs(createdAt(message)));
|
|
3303
|
+
}
|
|
3304
|
+
}
|
|
3305
|
+
const visible = stopMs > 0 ? all.filter((message) => toMs(createdAt(message)) > stopMs) : all;
|
|
3298
3306
|
if (visible.some((message) => message.status === "pending")) {
|
|
3299
3307
|
const lastPending = [...visible].reverse().find((m) => m.status === "pending");
|
|
3300
3308
|
const pendingMs = lastPending ? toMs(createdAt(lastPending)) : 0;
|
|
@@ -7015,7 +7023,7 @@ async function pickDirectory(tui, backend, opts = {}) {
|
|
|
7015
7023
|
return null;
|
|
7016
7024
|
}
|
|
7017
7025
|
spin?.stop();
|
|
7018
|
-
const title = () => `${c2.bold}
|
|
7026
|
+
const title = () => `${c2.bold}Browse ${backend.label}${c2.reset} ${c2.teal}${tail(listing.path, 48)}${c2.reset}` + (showHidden ? ` ${c2.dim}\xB7 hidden shown${c2.reset}` : "");
|
|
7019
7027
|
const footer = (error) => error ? `${c2.yellow}${error}${c2.reset} ${c2.dim}${KEY_HINTS}${c2.reset}` : `${c2.dim}${KEY_HINTS}${c2.reset}`;
|
|
7020
7028
|
const buildItems = () => {
|
|
7021
7029
|
const pageSize = Math.max(5, Math.min(14, (process.stdout.rows || 24) - 9));
|
|
@@ -8617,7 +8625,7 @@ ${c4.dim}Press Control-C again to exit${c4.reset}
|
|
|
8617
8625
|
if (result.hint) stdout.write(` ${c4.dim}${result.hint}${c4.reset}
|
|
8618
8626
|
`);
|
|
8619
8627
|
};
|
|
8620
|
-
stdout.write(`${c4.bold}
|
|
8628
|
+
stdout.write(`${c4.bold}Sign in to ${gradientText("Standard Code")}${c4.reset}
|
|
8621
8629
|
`);
|
|
8622
8630
|
if (`https://${host}` !== PRODUCTION_ENDPOINT) {
|
|
8623
8631
|
stdout.write(`${c4.dim}Connecting to${c4.reset} ${c4.teal}${host}${c4.reset}
|
|
@@ -8729,7 +8737,7 @@ ${c4.dim}Press Control-C again to exit${c4.reset}
|
|
|
8729
8737
|
flow: for (; ; ) {
|
|
8730
8738
|
if (step === "machine") {
|
|
8731
8739
|
const picked = await tui.select(
|
|
8732
|
-
`${c4.bold}
|
|
8740
|
+
`${c4.bold}Where should this session run?${c4.reset} ${c4.dim}\u2191\u2193 \xB7 enter \xB7 esc${c4.reset}`,
|
|
8733
8741
|
[
|
|
8734
8742
|
{
|
|
8735
8743
|
label: `This machine \u2014 ${self ? machineDisplayName(self) : machine}`,
|
|
@@ -8813,7 +8821,7 @@ ${c4.dim}Press Control-C again to exit${c4.reset}
|
|
|
8813
8821
|
items.push({ label: "\uFF0B Start a new session", value: null });
|
|
8814
8822
|
const whereLabel = session.mode === "remote" && session.runner ? `${session.runner.name}:${shortenPath(session.remotePath ?? "")}` : shortDir;
|
|
8815
8823
|
const picked = await tui.select(
|
|
8816
|
-
`${c4.bold}
|
|
8824
|
+
`${c4.bold}Resume a session${c4.reset} ${c4.gray}${whereLabel}${c4.reset} ${c4.dim}\u2191\u2193 \xB7 enter \xB7 esc${c4.reset}`,
|
|
8817
8825
|
items
|
|
8818
8826
|
);
|
|
8819
8827
|
if (picked === void 0) {
|
|
@@ -8839,7 +8847,7 @@ ${c4.dim}Press Control-C again to exit${c4.reset}
|
|
|
8839
8847
|
} else {
|
|
8840
8848
|
if (!agentOverride) {
|
|
8841
8849
|
const picked = await tui.select(
|
|
8842
|
-
`${c4.bold}
|
|
8850
|
+
`${c4.bold}Which agent?${c4.reset} ${c4.dim}\u2191\u2193 \xB7 enter \xB7 esc${c4.reset}`,
|
|
8843
8851
|
AGENT_CHOICES.map((choice) => ({
|
|
8844
8852
|
label: choice.title,
|
|
8845
8853
|
hint: choice.description,
|
|
@@ -8889,7 +8897,7 @@ async function ensureSamaAuth(tui, api) {
|
|
|
8889
8897
|
checking.stop();
|
|
8890
8898
|
if (already) return true;
|
|
8891
8899
|
const picked = await tui.select(
|
|
8892
|
-
`${c4.bold}
|
|
8900
|
+
`${c4.bold}Authenticate with ChatGPT${c4.reset} ${c4.dim}Sama One runs on OpenAI using your own ChatGPT Pro account${c4.reset}`,
|
|
8893
8901
|
[
|
|
8894
8902
|
{
|
|
8895
8903
|
label: "Continue with ChatGPT",
|
|
@@ -8924,7 +8932,7 @@ async function ensureSamaAuth(tui, api) {
|
|
|
8924
8932
|
}
|
|
8925
8933
|
async function runAgentSwitchMenu(tui, api, threadId) {
|
|
8926
8934
|
const picked = await tui.select(
|
|
8927
|
-
`${c4.bold}
|
|
8935
|
+
`${c4.bold}Switch agent${c4.reset} ${c4.dim}takes effect on the next message${c4.reset}`,
|
|
8928
8936
|
AGENT_CHOICES.map((choice) => ({
|
|
8929
8937
|
label: choice.title,
|
|
8930
8938
|
hint: choice.description,
|
|
@@ -8969,7 +8977,7 @@ async function pickLocalProject(tui, api, self, cwd, machineName) {
|
|
|
8969
8977
|
{ label: "\uFF0B New project", hint: "browse or create a directory", value: NEW }
|
|
8970
8978
|
];
|
|
8971
8979
|
const picked = await tui.select(
|
|
8972
|
-
`${c4.bold}
|
|
8980
|
+
`${c4.bold}Project on ${label}${c4.reset} ${c4.dim}\u2191\u2193 \xB7 enter \xB7 esc${c4.reset}`,
|
|
8973
8981
|
items,
|
|
8974
8982
|
{ spaced: true }
|
|
8975
8983
|
);
|
|
@@ -8993,7 +9001,7 @@ async function pickRemoteProject(tui, api, runner) {
|
|
|
8993
9001
|
);
|
|
8994
9002
|
items.push({ label: "\uFF0B New project", hint: "browse or create a directory", value: ENTER_PATH });
|
|
8995
9003
|
const picked = await tui.select(
|
|
8996
|
-
`${c4.bold}
|
|
9004
|
+
`${c4.bold}Project on ${runner.name}${c4.reset} ${c4.dim}\u2191\u2193 \xB7 enter \xB7 esc${c4.reset}`,
|
|
8997
9005
|
items,
|
|
8998
9006
|
{ spaced: true }
|
|
8999
9007
|
);
|
|
@@ -9072,6 +9080,7 @@ async function runInteractive(tui, api, threadId, projectDir, machine, resumed,
|
|
|
9072
9080
|
const runnerName = session.runner?.name ?? "the remote machine";
|
|
9073
9081
|
let currentOwner = null;
|
|
9074
9082
|
let ownershipKnown = false;
|
|
9083
|
+
let ownershipWasOurs = false;
|
|
9075
9084
|
const describeExecOwner = (o) => o?.client_kind === "daemon" ? "the daemon on this machine" : o?.client_name || "another client";
|
|
9076
9085
|
const registry = new ProcessRegistry(api, threadId, machine);
|
|
9077
9086
|
const refreshBgCount = () => {
|
|
@@ -9160,13 +9169,15 @@ async function runInteractive(tui, api, threadId, projectDir, machine, resumed,
|
|
|
9160
9169
|
},
|
|
9161
9170
|
onOwnership: (isOwner, owner2) => {
|
|
9162
9171
|
const wasKnown = ownershipKnown;
|
|
9172
|
+
const moved = !wasKnown || ownershipWasOurs !== isOwner || (currentOwner?.client_id ?? null) !== (owner2?.client_id ?? null);
|
|
9163
9173
|
ownershipKnown = true;
|
|
9174
|
+
ownershipWasOurs = isOwner;
|
|
9164
9175
|
currentOwner = owner2;
|
|
9165
9176
|
if (isOwner) {
|
|
9166
9177
|
bridge?.setClaim("takeover");
|
|
9167
9178
|
exec?.writeSessionInfo();
|
|
9168
|
-
if (wasKnown) tui.print(`${c4.dim}Tool execution moved to this terminal.${c4.reset}`);
|
|
9169
|
-
} else if (wasKnown) {
|
|
9179
|
+
if (wasKnown && moved) tui.print(`${c4.dim}Tool execution moved to this terminal.${c4.reset}`);
|
|
9180
|
+
} else if (wasKnown && moved) {
|
|
9170
9181
|
tui.print(`${c4.dim}Tool execution moved to ${describeExecOwner(owner2)}.${c4.reset}`);
|
|
9171
9182
|
}
|
|
9172
9183
|
},
|
|
@@ -9569,7 +9580,7 @@ why: ${req.requestPermission}` : ""}`,
|
|
|
9569
9580
|
const cost = fmtCost(q);
|
|
9570
9581
|
const lines = [
|
|
9571
9582
|
"",
|
|
9572
|
-
`${c4.bold}
|
|
9583
|
+
`${c4.bold}\u2726 Add a parallel session${c4.reset}`,
|
|
9573
9584
|
"",
|
|
9574
9585
|
`${dots.join(" ")} ${c4.dim}${q.current} of ${q.current} session${q.current === 1 ? "" : "s"} in use${c4.reset}`
|
|
9575
9586
|
];
|