agent-afk 5.202.1 → 5.203.0

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.
Files changed (36) hide show
  1. package/dist/agent/session/agent-session.d.ts +1 -0
  2. package/dist/agent/session-ledger-project.d.ts +103 -0
  3. package/dist/agent/session-ledger-reader.d.ts +8 -0
  4. package/dist/agent/session-ledger.d.ts +4 -63
  5. package/dist/agent/subagent/fork-types.d.ts +2 -1
  6. package/dist/agent/subagent.d.ts +3 -0
  7. package/dist/agent/types/session-types.d.ts +20 -0
  8. package/dist/cli.mjs +685 -685
  9. package/dist/index.mjs +229 -229
  10. package/dist/telegram.mjs +301 -301
  11. package/dist/web-server/frontend/app-approvals.d.ts +7 -0
  12. package/dist/web-server/frontend/app-views.d.ts +3 -0
  13. package/dist/web-server/frontend/at-file-panel.d.ts +5 -0
  14. package/dist/web-server/frontend/bg-jobs-panel.d.ts +14 -0
  15. package/dist/web-server/frontend/diff-viewer.d.ts +17 -0
  16. package/dist/web-server/frontend/ledger-adapter.d.ts +7 -2
  17. package/dist/web-server/frontend/memory-panel.d.ts +6 -0
  18. package/dist/web-server/frontend/model-selector.d.ts +10 -0
  19. package/dist/web-server/frontend/render-approvals.d.ts +22 -0
  20. package/dist/web-server/frontend/render-incremental.d.ts +1 -0
  21. package/dist/web-server/frontend/render.d.ts +3 -22
  22. package/dist/web-server/frontend/schedules-view.d.ts +1 -0
  23. package/dist/web-server/frontend/session-status.d.ts +11 -0
  24. package/dist/web-server/frontend/subagent-tree.d.ts +27 -0
  25. package/dist/web-server/frontend/thinking-panel.d.ts +3 -0
  26. package/dist/web-server/frontend/tool-trace-panel.d.ts +2 -0
  27. package/dist/web-server/frontend/view-model.d.ts +19 -1
  28. package/dist/web-server/routes.bg-jobs.d.ts +3 -0
  29. package/dist/web-server/routes.memory.d.ts +3 -0
  30. package/dist/web-server/routes.models.d.ts +6 -0
  31. package/dist/web-ui-assets/app.js +45 -45
  32. package/dist/web-ui-assets/approvals.css +3 -1
  33. package/dist/web-ui-assets/index.html +19 -10
  34. package/dist/web-ui-assets/schedules.css +2 -3
  35. package/dist/web-ui-assets/styles.css +263 -1
  36. package/package.json +1 -1
@@ -0,0 +1,7 @@
1
+ import type { ApprovalAnswer } from './render.js';
2
+ export type ApiFunction = <T>(path: string, init?: RequestInit) => Promise<T>;
3
+ export interface ApprovalsManager {
4
+ pollPending: () => Promise<void>;
5
+ answerApproval: (id: string, answer: ApprovalAnswer) => void;
6
+ }
7
+ export declare function createApprovalsManager(api: ApiFunction, container: HTMLElement): ApprovalsManager;
@@ -0,0 +1,3 @@
1
+ export type ApiFunction = <T>(path: string, init?: RequestInit) => Promise<T>;
2
+ export type ViewName = 'sessions' | 'schedules' | 'bg-jobs' | 'memory';
3
+ export declare function switchView(view: ViewName, api: ApiFunction): void;
@@ -0,0 +1,5 @@
1
+ export interface AtFileOpts {
2
+ input: HTMLTextAreaElement;
3
+ container: HTMLElement;
4
+ }
5
+ export declare function wireAtFileAffordance(opts: AtFileOpts): () => void;
@@ -0,0 +1,14 @@
1
+ export interface BgJobMeta {
2
+ jobId: string;
3
+ subagentId: string;
4
+ label: string;
5
+ promptHash: string;
6
+ model: string;
7
+ startedAt: number;
8
+ endedAt?: number;
9
+ status: 'running' | 'completed' | 'failed' | 'cancelled';
10
+ parentSessionId?: string;
11
+ stopReason?: string;
12
+ schemaVersion: 1;
13
+ }
14
+ export declare function renderBgJobsPanel(container: HTMLElement, jobs: BgJobMeta[]): void;
@@ -0,0 +1,17 @@
1
+ export interface DiffLine {
2
+ type: 'add' | 'del' | 'ctx';
3
+ content: string;
4
+ oldNum?: number;
5
+ newNum?: number;
6
+ }
7
+ export interface DiffHunk {
8
+ header: string;
9
+ oldStart: number;
10
+ newStart: number;
11
+ lines: DiffLine[];
12
+ }
13
+ export declare function parseDiffHunks(diff: string): DiffHunk[];
14
+ export declare function renderDiffBlock(diff: string, opts?: {
15
+ fileName?: string;
16
+ collapsed?: boolean;
17
+ }): HTMLElement;
@@ -1,14 +1,19 @@
1
- import type { TranscriptItem } from './view-model.js';
1
+ import type { TranscriptItem, ToolCallItem, SubagentItem } from './view-model.js';
2
2
  export interface LedgerRecordLike {
3
3
  v?: number;
4
4
  ts?: number;
5
5
  kind?: string;
6
6
  [key: string]: unknown;
7
7
  }
8
- export declare function ledgerRecordToItem(record: LedgerRecordLike): TranscriptItem | undefined;
8
+ export declare function resetIdCounter(): void;
9
+ export declare function ledgerRecordToItem(record: LedgerRecordLike, toolIndex?: Map<string, ToolCallItem>, subagentIndex?: Map<string, SubagentItem>): TranscriptItem | undefined;
10
+ export declare function ledgerToItems(records: LedgerRecordLike[]): TranscriptItem[];
9
11
  export interface SessionTotals {
10
12
  costUsd: number;
11
13
  durationMs: number;
12
14
  turns: number;
15
+ inputTokens?: number;
16
+ outputTokens?: number;
17
+ cacheReadTokens?: number;
13
18
  }
14
19
  export declare function accumulateTotals(totals: SessionTotals, record: LedgerRecordLike): SessionTotals;
@@ -0,0 +1,6 @@
1
+ export interface MemoryPanelOpts {
2
+ api: (path: string, init?: RequestInit) => Promise<unknown>;
3
+ }
4
+ export declare function createMemoryPanel(opts: MemoryPanelOpts): HTMLElement & {
5
+ refresh(): void;
6
+ };
@@ -0,0 +1,10 @@
1
+ export interface ModelInfo {
2
+ id: string;
3
+ label: string;
4
+ }
5
+ export interface ModelSelectorOpts {
6
+ onSelect: (modelId: string) => void;
7
+ current?: string;
8
+ }
9
+ export declare function createModelSelector(opts: ModelSelectorOpts, models?: readonly ModelInfo[]): HTMLElement;
10
+ export declare function renderModelBadge(model: string): HTMLElement;
@@ -0,0 +1,22 @@
1
+ export interface PendingApproval {
2
+ id: string;
3
+ sessionId?: string;
4
+ createdAt?: string;
5
+ request: {
6
+ message?: string;
7
+ title?: string;
8
+ description?: string;
9
+ serverName?: string;
10
+ origin?: string;
11
+ type?: 'text' | 'confirm' | 'choice' | 'multi_choice' | 'number';
12
+ choices?: string[];
13
+ questionDefault?: string | boolean | number;
14
+ };
15
+ }
16
+ export type ApprovalAnswer = {
17
+ action: 'accept';
18
+ content?: Record<string, unknown>;
19
+ } | {
20
+ action: 'decline';
21
+ };
22
+ export declare function renderApprovals(container: HTMLElement, pending: PendingApproval[], onAnswer: (id: string, answer: ApprovalAnswer) => void): void;
@@ -1,2 +1,3 @@
1
1
  import type { TranscriptItem } from './view-model.js';
2
+ export declare function resetNodeCache(): void;
2
3
  export declare function applyIncrementalUpdate(container: HTMLElement, items: TranscriptItem[], renderItem: (item: TranscriptItem) => HTMLElement): void;
@@ -1,4 +1,6 @@
1
1
  import type { TranscriptItem } from './view-model.js';
2
+ export type { PendingApproval, ApprovalAnswer } from './render-approvals.js';
3
+ export { renderApprovals } from './render-approvals.js';
2
4
  export interface SessionSummary {
3
5
  id: string;
4
6
  mode: 'live' | 'readonly';
@@ -7,29 +9,8 @@ export interface SessionSummary {
7
9
  updatedAt?: string;
8
10
  title?: string;
9
11
  alive?: boolean;
12
+ model?: string;
10
13
  }
11
14
  export declare function renderSidebar(container: HTMLElement, sessions: SessionSummary[], activeId: string | undefined, onSelect: (id: string) => void): void;
12
15
  export declare function renderTranscript(container: HTMLElement, items: TranscriptItem[]): void;
13
16
  export declare function relativeTime(iso: string): string;
14
- export interface PendingApproval {
15
- id: string;
16
- sessionId?: string;
17
- createdAt?: string;
18
- request: {
19
- message?: string;
20
- title?: string;
21
- description?: string;
22
- serverName?: string;
23
- origin?: string;
24
- type?: 'text' | 'confirm' | 'choice' | 'multi_choice' | 'number';
25
- choices?: string[];
26
- questionDefault?: string | boolean | number;
27
- };
28
- }
29
- export type ApprovalAnswer = {
30
- action: 'accept';
31
- content?: Record<string, unknown>;
32
- } | {
33
- action: 'decline';
34
- };
35
- export declare function renderApprovals(container: HTMLElement, pending: PendingApproval[], onAnswer: (id: string, answer: ApprovalAnswer) => void): void;
@@ -26,6 +26,7 @@ export declare class SchedulesView {
26
26
  load(): Promise<void>;
27
27
  private render;
28
28
  private renderCard;
29
+ private inflight;
29
30
  private toggleSchedule;
30
31
  private deleteSchedule;
31
32
  }
@@ -0,0 +1,11 @@
1
+ import type { SessionSummary } from './render.js';
2
+ export type SessionStatusGroup = 'needs-input' | 'active' | 'completed';
3
+ export interface SessionGroups {
4
+ needsInput: SessionSummary[];
5
+ active: SessionSummary[];
6
+ completed: SessionSummary[];
7
+ }
8
+ export declare function classifySession(session: SessionSummary, pendingSessionIds?: ReadonlySet<string>): SessionStatusGroup;
9
+ export declare function groupSessionsByStatus(sessions: SessionSummary[], pendingSessionIds?: ReadonlySet<string>): SessionGroups;
10
+ export declare function renderStatusBadge(status: SessionStatusGroup): HTMLSpanElement;
11
+ export declare function renderGroupedSessionList(groups: SessionGroups, container: HTMLElement, activeId: string | undefined, onSelect: (id: string) => void): void;
@@ -0,0 +1,27 @@
1
+ export interface SubagentNode {
2
+ id: string;
3
+ parentId?: string;
4
+ model?: string;
5
+ agentType?: string;
6
+ status: string;
7
+ durationMs?: number;
8
+ totalCostUsd?: number;
9
+ promptHead?: string;
10
+ children: SubagentNode[];
11
+ }
12
+ export interface SubagentLifecycleEvent {
13
+ subagentId: string;
14
+ status: string;
15
+ parentId?: string;
16
+ model?: string;
17
+ agentType?: string;
18
+ durationMs?: number;
19
+ totalCostUsd?: number;
20
+ promptHead?: string;
21
+ }
22
+ export declare class SubagentTreeState {
23
+ #private;
24
+ addEvent(event: SubagentLifecycleEvent): void;
25
+ getRoots(): SubagentNode[];
26
+ }
27
+ export declare function renderSubagentTree(state: SubagentTreeState, container: HTMLElement): void;
@@ -0,0 +1,3 @@
1
+ import type { ThinkingItem } from './view-model.js';
2
+ export declare function renderThinkingBlock(item: ThinkingItem, container: HTMLElement): void;
3
+ export declare function createThinkingBlockNode(item: ThinkingItem): HTMLElement;
@@ -0,0 +1,2 @@
1
+ import type { ToolCallItem } from './view-model.js';
2
+ export declare function renderToolCallCard(item: ToolCallItem, container: HTMLElement): void;
@@ -26,6 +26,7 @@ export interface ToolCallItem {
26
26
  output?: string;
27
27
  outputUnavailable?: boolean;
28
28
  diff?: ToolDiffChunk['diff'];
29
+ durationMs?: number;
29
30
  }
30
31
  export interface ErrorItem {
31
32
  kind: 'error';
@@ -37,7 +38,24 @@ export interface NoticeItem {
37
38
  id: string;
38
39
  text: string;
39
40
  }
40
- export type TranscriptItem = UserMessageItem | AssistantTextItem | ThinkingItem | ToolCallItem | ErrorItem | NoticeItem;
41
+ export interface SubagentItem {
42
+ kind: 'subagent';
43
+ id: string;
44
+ subagentId: string;
45
+ status: string;
46
+ label: string;
47
+ model?: string;
48
+ durationMs?: number;
49
+ promptHead?: string;
50
+ }
51
+ export interface BgJobItem {
52
+ kind: 'bg_job';
53
+ id: string;
54
+ jobId: string;
55
+ status: string;
56
+ label: string;
57
+ }
58
+ export type TranscriptItem = UserMessageItem | AssistantTextItem | ThinkingItem | ToolCallItem | ErrorItem | NoticeItem | SubagentItem | BgJobItem;
41
59
  export interface ApplyOptions {
42
60
  replay?: boolean;
43
61
  }
@@ -0,0 +1,3 @@
1
+ import type { ServerResponse } from 'node:http';
2
+ export declare function handleListBgJobs(res: ServerResponse): Promise<void>;
3
+ export declare function handleGetBgJob(res: ServerResponse, jobId: string): Promise<void>;
@@ -0,0 +1,3 @@
1
+ import type { ServerResponse } from 'node:http';
2
+ export declare function handleSearchMemory(res: ServerResponse, query: URLSearchParams): Promise<void>;
3
+ export declare function handleGetHotMemory(res: ServerResponse): Promise<void>;
@@ -0,0 +1,6 @@
1
+ import type { ServerResponse } from 'node:http';
2
+ export interface ModelInfo {
3
+ id: string;
4
+ label: string;
5
+ }
6
+ export declare function handleListModels(res: ServerResponse): void;