@saadnvd1/agent-os 0.3.482 → 0.3.484
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/README.md +33 -7
- package/app/api/bus/stop/route.ts +26 -0
- package/app/api/fresh-start/route.ts +3 -1
- package/app/api/stall/route.ts +18 -0
- package/components/SessionList/RowParts.tsx +6 -0
- package/components/SessionList/SessionList.types.ts +1 -0
- package/components/Workspaces/FreshStartForm.tsx +21 -9
- package/components/Workspaces/StallForm.tsx +101 -0
- package/components/Workspaces/WorkspaceSettings.tsx +2 -0
- package/data/stall/index.ts +33 -0
- package/lib/chat/activity.ts +80 -6
- package/lib/chat/compact-context.ts +55 -0
- package/lib/chat/driver.ts +4 -0
- package/lib/chat/drivers/claude-approvals.ts +32 -0
- package/lib/chat/drivers/claude.ts +4 -0
- package/lib/chat/events.ts +1 -1
- package/lib/chat/refresh.ts +19 -6
- package/lib/chat/registry.ts +7 -0
- package/lib/chat/runner.ts +2 -0
- package/lib/chat/socket.ts +2 -2
- package/lib/chat/stale.ts +5 -4
- package/lib/chat/stall-limits.ts +5 -0
- package/lib/chat/stall.ts +50 -0
- package/lib/chat/stop.ts +67 -0
- package/lib/chat/worker/host.ts +30 -4
- package/lib/chat/worker/protocol.ts +2 -1
- package/lib/chat/working-state.ts +111 -0
- package/lib/db/migrations.ts +13 -0
- package/lib/orchestrator/act.ts +3 -9
- package/lib/orchestrator/conditions.ts +11 -0
- package/lib/orchestrator/facts.ts +5 -1
- package/lib/orchestrator/tools.ts +1 -1
- package/lib/sessions/stop.ts +28 -0
- package/lib/sidebar/shelves.ts +2 -0
- package/lib/stacks/restack.ts +7 -13
- package/lib/status/collect.ts +4 -1
- package/lib/usage/turns.ts +11 -4
- package/package.json +1 -1
package/lib/stacks/restack.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import { db, stackQueries as q, type Session, type StackItemRow } from "../db";
|
|
12
12
|
import { getDefaultBranch } from "../git";
|
|
13
13
|
import { sendMessage } from "../bus";
|
|
14
|
-
import {
|
|
14
|
+
import { stopChatTurn } from "../chat/stop";
|
|
15
15
|
import { findPRStrict, run } from "../tasks/gh";
|
|
16
16
|
import type { TaskPR } from "../tasks/state";
|
|
17
17
|
import { expandHome } from "../tasks/session";
|
|
@@ -64,7 +64,7 @@ export const stackNotice = (
|
|
|
64
64
|
origin: { kind: "system", label, body } as const,
|
|
65
65
|
});
|
|
66
66
|
|
|
67
|
-
const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));
|
|
67
|
+
const sleep = (ms: number) => new Promise<void>((r) => setTimeout(r, ms));
|
|
68
68
|
// The note on an item left alone because its agent was still working.
|
|
69
69
|
export const AGENT_BUSY = "Waiting for its agent to stop";
|
|
70
70
|
// How long a chat's turn may take to stop after it's interrupted.
|
|
@@ -79,17 +79,11 @@ export async function interruptAgent(
|
|
|
79
79
|
wait = sleep
|
|
80
80
|
): Promise<boolean> {
|
|
81
81
|
if (session.view === "chat") {
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
await interruptChat(session.id);
|
|
88
|
-
for (let waited = 0; waited < CHAT_STOP_WAIT_MS; waited += 500) {
|
|
89
|
-
await wait(500);
|
|
90
|
-
if (!busy(await now())) return true;
|
|
91
|
-
}
|
|
92
|
-
return false;
|
|
82
|
+
const out = await stopChatTurn(session.id, {
|
|
83
|
+
graceMs: CHAT_STOP_WAIT_MS,
|
|
84
|
+
sleep: wait,
|
|
85
|
+
});
|
|
86
|
+
return out.stopped;
|
|
93
87
|
}
|
|
94
88
|
const sent = await run(
|
|
95
89
|
"tmux",
|
package/lib/status/collect.ts
CHANGED
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
} from "../providers/registry";
|
|
22
22
|
import { getDb, type Session } from "../db";
|
|
23
23
|
import { chatState } from "../chat/runner";
|
|
24
|
-
import { chatActivityLine } from "../chat/activity";
|
|
24
|
+
import { chatActivityLine, chatStall } from "../chat/activity";
|
|
25
25
|
import {
|
|
26
26
|
chatNeed,
|
|
27
27
|
isUnread,
|
|
@@ -60,6 +60,8 @@ export interface SessionStatusResponse {
|
|
|
60
60
|
asks?: number;
|
|
61
61
|
need?: SessionNeed | null;
|
|
62
62
|
unread?: boolean;
|
|
63
|
+
// A chat turn silent past the stall threshold (lib/chat/stall).
|
|
64
|
+
stalled?: boolean;
|
|
63
65
|
// A program's own message (OSC 7501): untrusted, plain text only.
|
|
64
66
|
detail?: string | null;
|
|
65
67
|
progress?: number | null;
|
|
@@ -464,6 +466,7 @@ async function collect(): Promise<StatusSnapshot> {
|
|
|
464
466
|
agentType: session.agent_type,
|
|
465
467
|
need: chatNeed(session, state, asks),
|
|
466
468
|
unread: isUnread(session, state),
|
|
469
|
+
...(chatStall(session.id) && { stalled: true }),
|
|
467
470
|
...(session.role === "orchestrator" && { asks }),
|
|
468
471
|
};
|
|
469
472
|
}
|
package/lib/usage/turns.ts
CHANGED
|
@@ -91,10 +91,16 @@ export function recordTurn(
|
|
|
91
91
|
return totals;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
// When a compaction ran: "mid_turn" is the agent's own, at its auto-compact
|
|
95
|
+
// window, while it worked; the rest happen between turns.
|
|
96
|
+
export type CompactionPhase = "mid_turn" | "between_turns";
|
|
97
|
+
export const compactionPhase = (trigger: string): CompactionPhase =>
|
|
98
|
+
trigger === "auto" ? "mid_turn" : "between_turns";
|
|
99
|
+
|
|
94
100
|
// Records one compaction: who ran it ("auto" is the agent's own, at its
|
|
95
101
|
// auto-compact window; "threshold" and "stale" are AgentOS's before a
|
|
96
|
-
// message; "manual" is a /compact someone typed),
|
|
97
|
-
// and after when the agent said.
|
|
102
|
+
// message; "manual" is a /compact someone typed), which phase that was,
|
|
103
|
+
// and the context before and after when the agent said.
|
|
98
104
|
export function recordCompaction(
|
|
99
105
|
session: Pick<Session, "id" | "name" | "workspace_id">,
|
|
100
106
|
c: { trigger: string; before?: number; after?: number },
|
|
@@ -106,14 +112,15 @@ export function recordCompaction(
|
|
|
106
112
|
| { name: string; workspace_id: string | null }
|
|
107
113
|
| undefined;
|
|
108
114
|
db.prepare(
|
|
109
|
-
`INSERT INTO chat_compactions (session_id, session_name, workspace_id, at, trigger, before_tokens, after_tokens)
|
|
110
|
-
VALUES (?, ?, ?, ?, ?, ?, ?)`
|
|
115
|
+
`INSERT INTO chat_compactions (session_id, session_name, workspace_id, at, trigger, phase, before_tokens, after_tokens)
|
|
116
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`
|
|
111
117
|
).run(
|
|
112
118
|
session.id,
|
|
113
119
|
current?.name ?? session.name,
|
|
114
120
|
current?.workspace_id ?? session.workspace_id,
|
|
115
121
|
at,
|
|
116
122
|
c.trigger,
|
|
123
|
+
compactionPhase(c.trigger),
|
|
117
124
|
c.before ?? null,
|
|
118
125
|
c.after ?? null
|
|
119
126
|
);
|