opencode-subagent-magazine 1.5.2 → 1.6.0-beta.1
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/LICENSE +21 -21
- package/README.md +192 -192
- package/dist/_version.d.ts +1 -1
- package/dist/_version.js +1 -1
- package/dist/core/color.d.ts +20 -0
- package/dist/core/color.js +68 -0
- package/dist/core/format.d.ts +5 -0
- package/dist/core/format.js +68 -0
- package/dist/core/index.d.ts +6 -0
- package/dist/core/index.js +6 -0
- package/dist/core/kv.d.ts +20 -0
- package/dist/core/kv.js +30 -0
- package/dist/core/state-machine.d.ts +17 -0
- package/dist/core/state-machine.js +27 -0
- package/dist/core/types.d.ts +51 -0
- package/dist/core/types.js +2 -0
- package/dist/core/usage.d.ts +15 -0
- package/dist/core/usage.js +1 -0
- package/dist/index.js +148 -1484
- package/dist/panel/SubAgentPanel.d.ts +13 -0
- package/dist/panel/SubAgentPanel.js +1237 -0
- package/dist/panel/panel-api.d.ts +67 -0
- package/dist/panel/panel-api.js +1 -0
- package/dist/panel/store.d.ts +5 -0
- package/dist/panel/store.js +5 -0
- package/dist/tui.js +388 -292
- package/dist/v2/commands.d.ts +7 -0
- package/dist/v2/commands.js +263 -0
- package/dist/v2/index.d.ts +8 -0
- package/dist/v2/index.js +62 -0
- package/dist/v2/theme.d.ts +3 -0
- package/dist/v2/theme.js +12 -0
- package/dist/v2/types.d.ts +231 -0
- package/dist/v2/types.js +6 -0
- package/dist/v2/v2-panel-api.d.ts +12 -0
- package/dist/v2/v2-panel-api.js +350 -0
- package/dist/v2.js +3008 -0
- package/install.mjs +103 -103
- package/package.json +64 -63
- package/src/_version.ts +1 -1
- package/src/clipboard.ts +134 -134
- package/src/core/color.ts +70 -0
- package/src/core/format.ts +61 -0
- package/src/core/index.ts +6 -0
- package/src/core/kv.ts +36 -0
- package/src/core/state-machine.ts +46 -0
- package/src/core/types.ts +58 -0
- package/src/core/usage.ts +16 -0
- package/src/i18n.ts +261 -261
- package/src/index.tsx +124 -1750
- package/src/panel/SubAgentPanel.tsx +1465 -0
- package/src/panel/panel-api.ts +72 -0
- package/src/panel/store.ts +8 -0
- package/src/server.ts +10 -10
- package/src/v2/commands.ts +251 -0
- package/src/v2/index.tsx +98 -0
- package/src/v2/theme.ts +14 -0
- package/src/v2/types.ts +165 -0
- package/src/v2/v2-panel-api.ts +306 -0
- package/tui/index.js +11 -0
package/dist/core/kv.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export const KV_PREFIX = "subagent_magazine";
|
|
2
|
+
export const SESSION_DATA_KEY = `${KV_PREFIX}.session_data`;
|
|
3
|
+
/** Setting keys shared by V1/V2 (values are raw strings in KV). */
|
|
4
|
+
export const SETTING_KEYS = {
|
|
5
|
+
lang: `${KV_PREFIX}.lang`,
|
|
6
|
+
maxEntries: `${KV_PREFIX}.max_entries`,
|
|
7
|
+
order: `${KV_PREFIX}.order`,
|
|
8
|
+
scrollMode: `${KV_PREFIX}.scroll_mode`,
|
|
9
|
+
open: `${KV_PREFIX}.open`,
|
|
10
|
+
ttlDays: `${KV_PREFIX}.ttl_days`,
|
|
11
|
+
};
|
|
12
|
+
export function loadSessionData(kv) {
|
|
13
|
+
try {
|
|
14
|
+
const raw = kv.get(SESSION_DATA_KEY, "{}");
|
|
15
|
+
return JSON.parse(String(raw));
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export function saveSessionData(kv, data) {
|
|
22
|
+
try {
|
|
23
|
+
kv.set(SESSION_DATA_KEY, JSON.stringify(data));
|
|
24
|
+
}
|
|
25
|
+
catch { }
|
|
26
|
+
}
|
|
27
|
+
export function readTTLDays(kv) {
|
|
28
|
+
const ttlDaysRaw = parseInt(String(kv.get(SETTING_KEYS.ttlDays, "3")), 10);
|
|
29
|
+
return Number.isNaN(ttlDaysRaw) ? 3 : ttlDaysRaw;
|
|
30
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { SubEntry, SubStatus } from "./types";
|
|
2
|
+
import type { TodoStats } from "./usage";
|
|
3
|
+
/** Final status decision when a child session settles (V1 `session.idle` semantics). */
|
|
4
|
+
export declare function settleOnIdle(entry: SubEntry): SubStatus;
|
|
5
|
+
/** Agent-name normalization used by the fallback matching chain. */
|
|
6
|
+
export declare function normalizeAgent(s: string): string;
|
|
7
|
+
/** Snapshot of usage values captured when a child session settles. */
|
|
8
|
+
export interface SettleSnapshot {
|
|
9
|
+
tokens?: number;
|
|
10
|
+
cost?: number;
|
|
11
|
+
model?: string;
|
|
12
|
+
todo?: TodoStats;
|
|
13
|
+
}
|
|
14
|
+
/** Apply a settled status + usage backfill onto an entry (no-op preserving already-settled). */
|
|
15
|
+
export declare function settleEntry(entry: SubEntry, targetStatus: SubStatus, nowTs: number, snap: SettleSnapshot, errorMsg?: string): SubEntry;
|
|
16
|
+
/** Time-based scan heuristic: how old must a running entry be before assuming completion. */
|
|
17
|
+
export declare const STALE_RUNNING_MS: number;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Final status decision when a child session settles (V1 `session.idle` semantics). */
|
|
2
|
+
export function settleOnIdle(entry) {
|
|
3
|
+
if (entry.status === "cancel_requested" && entry.abortAccepted)
|
|
4
|
+
return "cancelled";
|
|
5
|
+
return "done";
|
|
6
|
+
}
|
|
7
|
+
/** Agent-name normalization used by the fallback matching chain. */
|
|
8
|
+
export function normalizeAgent(s) {
|
|
9
|
+
return s.toLowerCase().replace(/[^a-z0-9-]/g, "");
|
|
10
|
+
}
|
|
11
|
+
/** Apply a settled status + usage backfill onto an entry (no-op preserving already-settled). */
|
|
12
|
+
export function settleEntry(entry, targetStatus, nowTs, snap, errorMsg) {
|
|
13
|
+
const alreadySettled = entry.status !== "running" && entry.status !== "cancel_requested";
|
|
14
|
+
const finalStatus = targetStatus === "error" ? "error" : settleOnIdle(entry);
|
|
15
|
+
return {
|
|
16
|
+
...entry,
|
|
17
|
+
...(alreadySettled ? {} : { status: finalStatus, endedAt: nowTs }),
|
|
18
|
+
tokens: entry.tokens ?? snap.tokens,
|
|
19
|
+
cost: entry.cost ?? snap.cost,
|
|
20
|
+
model: entry.model ?? snap.model,
|
|
21
|
+
todoTotal: entry.todoTotal ?? snap.todo?.total,
|
|
22
|
+
todoDone: entry.todoDone ?? snap.todo?.done,
|
|
23
|
+
error: errorMsg || entry.error,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/** Time-based scan heuristic: how old must a running entry be before assuming completion. */
|
|
27
|
+
export const STALE_RUNNING_MS = 30 * 60 * 1000;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { LangCode } from "../i18n";
|
|
2
|
+
export type SubStatus = "running" | "done" | "error" | "cancel_requested" | "cancelled";
|
|
3
|
+
export interface SubEntry {
|
|
4
|
+
id: string;
|
|
5
|
+
title: string;
|
|
6
|
+
agent: string;
|
|
7
|
+
prompt: string;
|
|
8
|
+
error?: string;
|
|
9
|
+
tokens?: number;
|
|
10
|
+
cost?: number;
|
|
11
|
+
status: SubStatus;
|
|
12
|
+
sessionId?: string;
|
|
13
|
+
startedAt: number;
|
|
14
|
+
endedAt?: number;
|
|
15
|
+
model?: string;
|
|
16
|
+
todoTotal?: number;
|
|
17
|
+
todoDone?: number;
|
|
18
|
+
cancelRequestedAt?: number;
|
|
19
|
+
abortAccepted?: boolean;
|
|
20
|
+
cancelReason?: "manual";
|
|
21
|
+
}
|
|
22
|
+
export type Lang = LangCode;
|
|
23
|
+
export type SortOrder = "desc" | "asc";
|
|
24
|
+
export type ScrollMode = "wheel" | "click";
|
|
25
|
+
/** OpenCode built-in tool names that spawn sub-agents or delegate tasks. */
|
|
26
|
+
export declare const SUBAGENT_TOOLS: Set<string>;
|
|
27
|
+
export interface ChildRecord {
|
|
28
|
+
scroll: number;
|
|
29
|
+
expanded: string;
|
|
30
|
+
entries: SubEntry[];
|
|
31
|
+
clearedIds?: string[];
|
|
32
|
+
}
|
|
33
|
+
export interface SessionRecord {
|
|
34
|
+
ts: number;
|
|
35
|
+
entries: SubEntry[];
|
|
36
|
+
scroll: number;
|
|
37
|
+
expanded: string;
|
|
38
|
+
children: Record<string, ChildRecord>;
|
|
39
|
+
clearedIds?: string[];
|
|
40
|
+
}
|
|
41
|
+
export interface SharedSignals {
|
|
42
|
+
lang: () => Lang;
|
|
43
|
+
setLang: (l: Lang) => void;
|
|
44
|
+
maxEntries: () => number;
|
|
45
|
+
setMaxEntries: (n: number) => void;
|
|
46
|
+
sortOrder: () => SortOrder;
|
|
47
|
+
setSortOrder: (o: SortOrder) => void;
|
|
48
|
+
scrollMode: () => ScrollMode;
|
|
49
|
+
setScrollMode: (m: ScrollMode) => void;
|
|
50
|
+
sessionId: string;
|
|
51
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface TodoStats {
|
|
2
|
+
total: number;
|
|
3
|
+
done: number;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Data-source abstraction for per-session usage reads.
|
|
7
|
+
* V1 and V2 provide their own implementations backed by their respective
|
|
8
|
+
* client APIs; the state machine consumes only this surface.
|
|
9
|
+
*/
|
|
10
|
+
export interface UsageReader {
|
|
11
|
+
readSessionTokens(sid: string): number | undefined;
|
|
12
|
+
readSessionCost(sid: string): number | undefined;
|
|
13
|
+
readSessionModel(sid: string): string | undefined;
|
|
14
|
+
readSessionTodo(sid: string): TodoStats | undefined;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|