@agimon-ai/doompi-task 0.0.1-alpha.13 → 0.0.1-alpha.14
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/commands/task/promptGuidelines.cjs +1 -1
- package/dist/commands/task/promptGuidelines.cjs.map +1 -1
- package/dist/commands/task/promptGuidelines.mjs +1 -1
- package/dist/commands/task/promptGuidelines.mjs.map +1 -1
- package/dist/commands/task/responseEnvelope.cjs +6 -5
- package/dist/commands/task/responseEnvelope.cjs.map +1 -1
- package/dist/commands/task/responseEnvelope.d.cts +14 -2
- package/dist/commands/task/responseEnvelope.d.cts.map +1 -1
- package/dist/commands/task/responseEnvelope.d.mts +14 -2
- package/dist/commands/task/responseEnvelope.d.mts.map +1 -1
- package/dist/commands/task/responseEnvelope.mjs +6 -5
- package/dist/commands/task/responseEnvelope.mjs.map +1 -1
- package/dist/commands/task/taskTool.cjs +2 -2
- package/dist/commands/task/taskTool.cjs.map +1 -1
- package/dist/commands/task/taskTool.d.cts.map +1 -1
- package/dist/commands/task/taskTool.d.mts.map +1 -1
- package/dist/commands/task/taskTool.mjs +2 -2
- package/dist/commands/task/taskTool.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +1 -1
- package/dist/schemas/task.cjs +1 -1
- package/dist/schemas/task.cjs.map +1 -1
- package/dist/schemas/task.d.cts +28 -11
- package/dist/schemas/task.d.cts.map +1 -1
- package/dist/schemas/task.d.mts +28 -11
- package/dist/schemas/task.d.mts.map +1 -1
- package/dist/schemas/task.mjs +1 -1
- package/dist/schemas/task.mjs.map +1 -1
- package/dist/services/store/types.cjs.map +1 -1
- package/dist/services/store/types.d.cts +22 -10
- package/dist/services/store/types.d.cts.map +1 -1
- package/dist/services/store/types.d.mts +22 -10
- package/dist/services/store/types.d.mts.map +1 -1
- package/dist/services/store/types.mjs.map +1 -1
- package/dist/store/types.d.cts +2 -2
- package/dist/store/types.d.mts +2 -2
- package/dist/tool/responseEnvelope.cjs +1 -1
- package/dist/tool/responseEnvelope.d.cts +2 -2
- package/dist/tool/responseEnvelope.d.mts +2 -2
- package/dist/tool/responseEnvelope.mjs +1 -1
- package/dist/tool/schema.cjs +1 -1
- package/dist/tool/schema.d.cts +2 -2
- package/dist/tool/schema.d.mts +2 -2
- package/dist/tool/schema.mjs +1 -1
- package/dist/tui/format.cjs +3 -3
- package/dist/tui/format.cjs.map +1 -1
- package/dist/tui/format.d.cts.map +1 -1
- package/dist/tui/format.d.mts.map +1 -1
- package/dist/tui/format.mjs +3 -3
- package/dist/tui/format.mjs.map +1 -1
- package/package.json +4 -4
|
@@ -123,6 +123,23 @@ interface UpsertSummary {
|
|
|
123
123
|
applied: number[];
|
|
124
124
|
failed: number;
|
|
125
125
|
}
|
|
126
|
+
/** One task-to-agent handoff inside a native assignment batch. */
|
|
127
|
+
interface TaskAssignment {
|
|
128
|
+
id: number;
|
|
129
|
+
agent: string;
|
|
130
|
+
inlineAgent?: InlineAgent;
|
|
131
|
+
instructions?: string;
|
|
132
|
+
relevantFiles?: string[];
|
|
133
|
+
priorFindings?: string;
|
|
134
|
+
model?: string;
|
|
135
|
+
context?: 'fresh' | 'fork';
|
|
136
|
+
}
|
|
137
|
+
/** Which assignment entries started, so renderResult can show one consolidated batch. */
|
|
138
|
+
interface AssignmentSummary {
|
|
139
|
+
/** Ids of successful entries, in request order. A failed entry contributes nothing. */
|
|
140
|
+
assigned: number[];
|
|
141
|
+
failed: number;
|
|
142
|
+
}
|
|
126
143
|
/**
|
|
127
144
|
* Open-shape input bag the reducer accepts. The index signature lets the
|
|
128
145
|
* runtime pass a TypeBox `Static<typeof TaskParamsSchema>` through without
|
|
@@ -134,19 +151,13 @@ interface UpsertSummary {
|
|
|
134
151
|
interface TaskMutationParams {
|
|
135
152
|
[key: string]: unknown;
|
|
136
153
|
tasks?: TaskItemMutation[];
|
|
154
|
+
/** `assign` only: independent task-to-agent handoffs dispatched by one tool call. */
|
|
155
|
+
assignments?: TaskAssignment[];
|
|
137
156
|
/** `list` filter only. To set a status, upsert the task by id. */
|
|
138
157
|
status?: TaskStatus;
|
|
139
|
-
/** `get`, `delete`,
|
|
158
|
+
/** `get`, `delete`, and `cancel` only. Assign ids live in `assignments[]`. */
|
|
140
159
|
id?: number;
|
|
141
160
|
includeDeleted?: boolean;
|
|
142
|
-
agent?: string;
|
|
143
|
-
inlineAgent?: InlineAgent;
|
|
144
|
-
instructions?: string;
|
|
145
|
-
/** `assign` only: the context pack the parent hands to the child. */
|
|
146
|
-
relevantFiles?: string[];
|
|
147
|
-
priorFindings?: string;
|
|
148
|
-
model?: string;
|
|
149
|
-
context?: 'fresh' | 'fork';
|
|
150
161
|
}
|
|
151
162
|
/** Snapshot returned under a tool result's `details` for renderResult. */
|
|
152
163
|
interface TaskDetails {
|
|
@@ -157,9 +168,10 @@ interface TaskDetails {
|
|
|
157
168
|
rev: number;
|
|
158
169
|
error?: string;
|
|
159
170
|
upsert?: UpsertSummary;
|
|
171
|
+
assignment?: AssignmentSummary;
|
|
160
172
|
}
|
|
161
173
|
/** A delegation is "live" while the owning run may still produce a response. */
|
|
162
174
|
declare function isDelegationActive(task: Task): boolean;
|
|
163
175
|
//#endregion
|
|
164
|
-
export { DELETED_STATUS, DelegationResult, DelegationState, DepToken, STORE_SCHEMA_VERSION, Task, TaskAction, TaskDelegation, TaskDetails, TaskDocument, TaskItemMutation, TaskMutationParams, TaskStatus, UpsertItemOutcome, UpsertSummary, emptyDocument, isDelegationActive };
|
|
176
|
+
export { AssignmentSummary, DELETED_STATUS, DelegationResult, DelegationState, DepToken, STORE_SCHEMA_VERSION, Task, TaskAction, TaskAssignment, TaskDelegation, TaskDetails, TaskDocument, TaskItemMutation, TaskMutationParams, TaskStatus, UpsertItemOutcome, UpsertSummary, emptyDocument, isDelegationActive };
|
|
165
177
|
//# sourceMappingURL=types.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","names":[],"sources":["../../../src/services/store/types.ts"],"mappings":";;KAUY;cAEC,gBAAgB;KAEjB;KAEA;;UAGK;EACf;EACA;EACA;EACA;EACA;EACA;EACA;;;;;;;;;UAUe;EACf;EACA;EACA,OAAO;EACP;EACA;EACA;EACA;EACA;EACA;EACA,SAAS;;UAGM;EACf;EACA;EACA;EACA;EACA,QAAQ;EACR;EACA;EACA,WAAW;EACX;EACA;EACA,aAAa;;cAGF;;UAGI;EACf;EACA;EACA;EACA,OAAO;;iBAGO,iBAAiB;;;;;;;;KAWrB;;;;;;;;;UAUK;EACf;EACA;EACA;EACA;EACA;EACA,SAAS;EACT,YAAY;EACZ,eAAe;EACf,kBAAkB;EAClB;EACA,WAAW;;;;;;;;;KAUD;EAEN;EACA;EACA;EACA;EACA,QAAQ;EACR;EACA;;EAEA;EAAe;EAAiB;EAAY,YAAY;EAAY,UAAU;;EAC9E;EAAe;EAAmB;EAAY,QAAQ;;EACtD;EAAe;EAAgB;EAAiB;EAAa;;;UAGlD;;EAEf;EACA;;;;;;;;;;UAWe;GACd;EACD,QAAQ;;EAER,SAAS;;EAET;EACA
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../../../src/services/store/types.ts"],"mappings":";;KAUY;cAEC,gBAAgB;KAEjB;KAEA;;UAGK;EACf;EACA;EACA;EACA;EACA;EACA;EACA;;;;;;;;;UAUe;EACf;EACA;EACA,OAAO;EACP;EACA;EACA;EACA;EACA;EACA;EACA,SAAS;;UAGM;EACf;EACA;EACA;EACA;EACA,QAAQ;EACR;EACA;EACA,WAAW;EACX;EACA;EACA,aAAa;;cAGF;;UAGI;EACf;EACA;EACA;EACA,OAAO;;iBAGO,iBAAiB;;;;;;;;KAWrB;;;;;;;;;UAUK;EACf;EACA;EACA;EACA;EACA;EACA,SAAS;EACT,YAAY;EACZ,eAAe;EACf,kBAAkB;EAClB;EACA,WAAW;;;;;;;;;KAUD;EAEN;EACA;EACA;EACA;EACA,QAAQ;EACR;EACA;;EAEA;EAAe;EAAiB;EAAY,YAAY;EAAY,UAAU;;EAC9E;EAAe;EAAmB;EAAY,QAAQ;;EACtD;EAAe;EAAgB;EAAiB;EAAa;;;UAGlD;;EAEf;EACA;;;UAIe;EACf;EACA;EACA,cAAc;EACd;EACA;EACA;EACA;EACA;;;UAIe;;EAEf;EACA;;;;;;;;;;UAWe;GACd;EACD,QAAQ;;EAER,cAAc;;EAEd,SAAS;;EAET;EACA;;;UAIe;EACf,QAAQ;EACR,QAAQ;EACR,OAAO;EACP;EACA;EACA;EACA,SAAS;EACT,aAAa;;;iBAIC,mBAAmB,MAAM"}
|
|
@@ -123,6 +123,23 @@ interface UpsertSummary {
|
|
|
123
123
|
applied: number[];
|
|
124
124
|
failed: number;
|
|
125
125
|
}
|
|
126
|
+
/** One task-to-agent handoff inside a native assignment batch. */
|
|
127
|
+
interface TaskAssignment {
|
|
128
|
+
id: number;
|
|
129
|
+
agent: string;
|
|
130
|
+
inlineAgent?: InlineAgent;
|
|
131
|
+
instructions?: string;
|
|
132
|
+
relevantFiles?: string[];
|
|
133
|
+
priorFindings?: string;
|
|
134
|
+
model?: string;
|
|
135
|
+
context?: 'fresh' | 'fork';
|
|
136
|
+
}
|
|
137
|
+
/** Which assignment entries started, so renderResult can show one consolidated batch. */
|
|
138
|
+
interface AssignmentSummary {
|
|
139
|
+
/** Ids of successful entries, in request order. A failed entry contributes nothing. */
|
|
140
|
+
assigned: number[];
|
|
141
|
+
failed: number;
|
|
142
|
+
}
|
|
126
143
|
/**
|
|
127
144
|
* Open-shape input bag the reducer accepts. The index signature lets the
|
|
128
145
|
* runtime pass a TypeBox `Static<typeof TaskParamsSchema>` through without
|
|
@@ -134,19 +151,13 @@ interface UpsertSummary {
|
|
|
134
151
|
interface TaskMutationParams {
|
|
135
152
|
[key: string]: unknown;
|
|
136
153
|
tasks?: TaskItemMutation[];
|
|
154
|
+
/** `assign` only: independent task-to-agent handoffs dispatched by one tool call. */
|
|
155
|
+
assignments?: TaskAssignment[];
|
|
137
156
|
/** `list` filter only. To set a status, upsert the task by id. */
|
|
138
157
|
status?: TaskStatus;
|
|
139
|
-
/** `get`, `delete`,
|
|
158
|
+
/** `get`, `delete`, and `cancel` only. Assign ids live in `assignments[]`. */
|
|
140
159
|
id?: number;
|
|
141
160
|
includeDeleted?: boolean;
|
|
142
|
-
agent?: string;
|
|
143
|
-
inlineAgent?: InlineAgent;
|
|
144
|
-
instructions?: string;
|
|
145
|
-
/** `assign` only: the context pack the parent hands to the child. */
|
|
146
|
-
relevantFiles?: string[];
|
|
147
|
-
priorFindings?: string;
|
|
148
|
-
model?: string;
|
|
149
|
-
context?: 'fresh' | 'fork';
|
|
150
161
|
}
|
|
151
162
|
/** Snapshot returned under a tool result's `details` for renderResult. */
|
|
152
163
|
interface TaskDetails {
|
|
@@ -157,9 +168,10 @@ interface TaskDetails {
|
|
|
157
168
|
rev: number;
|
|
158
169
|
error?: string;
|
|
159
170
|
upsert?: UpsertSummary;
|
|
171
|
+
assignment?: AssignmentSummary;
|
|
160
172
|
}
|
|
161
173
|
/** A delegation is "live" while the owning run may still produce a response. */
|
|
162
174
|
declare function isDelegationActive(task: Task): boolean;
|
|
163
175
|
//#endregion
|
|
164
|
-
export { DELETED_STATUS, DelegationResult, DelegationState, DepToken, STORE_SCHEMA_VERSION, Task, TaskAction, TaskDelegation, TaskDetails, TaskDocument, TaskItemMutation, TaskMutationParams, TaskStatus, UpsertItemOutcome, UpsertSummary, emptyDocument, isDelegationActive };
|
|
176
|
+
export { AssignmentSummary, DELETED_STATUS, DelegationResult, DelegationState, DepToken, STORE_SCHEMA_VERSION, Task, TaskAction, TaskAssignment, TaskDelegation, TaskDetails, TaskDocument, TaskItemMutation, TaskMutationParams, TaskStatus, UpsertItemOutcome, UpsertSummary, emptyDocument, isDelegationActive };
|
|
165
177
|
//# sourceMappingURL=types.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","names":[],"sources":["../../../src/services/store/types.ts"],"mappings":";;KAUY;cAEC,gBAAgB;KAEjB;KAEA;;UAGK;EACf;EACA;EACA;EACA;EACA;EACA;EACA;;;;;;;;;UAUe;EACf;EACA;EACA,OAAO;EACP;EACA;EACA;EACA;EACA;EACA;EACA,SAAS;;UAGM;EACf;EACA;EACA;EACA;EACA,QAAQ;EACR;EACA;EACA,WAAW;EACX;EACA;EACA,aAAa;;cAGF;;UAGI;EACf;EACA;EACA;EACA,OAAO;;iBAGO,iBAAiB;;;;;;;;KAWrB;;;;;;;;;UAUK;EACf;EACA;EACA;EACA;EACA;EACA,SAAS;EACT,YAAY;EACZ,eAAe;EACf,kBAAkB;EAClB;EACA,WAAW;;;;;;;;;KAUD;EAEN;EACA;EACA;EACA;EACA,QAAQ;EACR;EACA;;EAEA;EAAe;EAAiB;EAAY,YAAY;EAAY,UAAU;;EAC9E;EAAe;EAAmB;EAAY,QAAQ;;EACtD;EAAe;EAAgB;EAAiB;EAAa;;;UAGlD;;EAEf;EACA;;;;;;;;;;UAWe;GACd;EACD,QAAQ;;EAER,SAAS;;EAET;EACA
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../../../src/services/store/types.ts"],"mappings":";;KAUY;cAEC,gBAAgB;KAEjB;KAEA;;UAGK;EACf;EACA;EACA;EACA;EACA;EACA;EACA;;;;;;;;;UAUe;EACf;EACA;EACA,OAAO;EACP;EACA;EACA;EACA;EACA;EACA;EACA,SAAS;;UAGM;EACf;EACA;EACA;EACA;EACA,QAAQ;EACR;EACA;EACA,WAAW;EACX;EACA;EACA,aAAa;;cAGF;;UAGI;EACf;EACA;EACA;EACA,OAAO;;iBAGO,iBAAiB;;;;;;;;KAWrB;;;;;;;;;UAUK;EACf;EACA;EACA;EACA;EACA;EACA,SAAS;EACT,YAAY;EACZ,eAAe;EACf,kBAAkB;EAClB;EACA,WAAW;;;;;;;;;KAUD;EAEN;EACA;EACA;EACA;EACA,QAAQ;EACR;EACA;;EAEA;EAAe;EAAiB;EAAY,YAAY;EAAY,UAAU;;EAC9E;EAAe;EAAmB;EAAY,QAAQ;;EACtD;EAAe;EAAgB;EAAiB;EAAa;;;UAGlD;;EAEf;EACA;;;UAIe;EACf;EACA;EACA,cAAc;EACd;EACA;EACA;EACA;EACA;;;UAIe;;EAEf;EACA;;;;;;;;;;UAWe;GACd;EACD,QAAQ;;EAER,cAAc;;EAEd,SAAS;;EAET;EACA;;;UAIe;EACf,QAAQ;EACR,QAAQ;EACR,OAAO;EACP;EACA;EACA;EACA,SAAS;EACT,aAAa;;;iBAIC,mBAAmB,MAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","names":[],"sources":["../../../src/services/store/types.ts"],"sourcesContent":["/**\n * Domain types for the file-backed task store.\n *\n * The on-disk document is the durable source of truth (unlike rpiv-todo, which\n * replayed state from the transcript). Every field here round-trips through\n * JSON, so nothing may hold non-serializable values.\n */\n\nimport type { InlineAgent } from '@agimon-ai/doompi-extension-contracts/subagent-tool';\n\nexport type TaskStatus = 'pending' | 'in_progress' | 'completed' | 'failed' | 'deleted';\n\nexport const DELETED_STATUS: TaskStatus = 'deleted';\n\nexport type TaskAction = 'upsert' | 'list' | 'get' | 'delete' | 'clear' | 'assign' | 'cancel';\n\nexport type DelegationState = 'requested' | 'running' | 'completed' | 'failed' | 'cancelled';\n\n/** Terminal result of a delegated subagent run, copied off the delegation response. */\nexport interface DelegationResult {\n status: string;\n output?: string;\n outputPath?: string;\n sessionFile?: string;\n error?: string;\n durationMs?: number;\n toolCount?: number;\n}\n\n/**\n * Delegation bookkeeping attached to a task that was handed to a subagent.\n *\n * `pid` is the harness process that owns the run: it is the only way to tell an\n * genuinely-running delegation from one orphaned by a harness crash, since the\n * child dies with its parent but the file survives.\n */\nexport interface TaskDelegation {\n requestId: string;\n agent: string;\n state: DelegationState;\n sessionId?: string;\n pid?: number;\n runId?: string;\n model?: string;\n startedAt?: string;\n endedAt?: string;\n result?: DelegationResult;\n}\n\nexport interface Task {\n id: number;\n subject: string;\n description?: string;\n activeForm?: string;\n status: TaskStatus;\n blockedBy?: number[];\n owner?: string;\n metadata?: Record<string, unknown>;\n createdAt?: string;\n updatedAt?: string;\n delegation?: TaskDelegation;\n}\n\nexport const STORE_SCHEMA_VERSION = 1;\n\n/** The complete on-disk document. `rev` increments on every committed write. */\nexport interface TaskDocument {\n version: number;\n rev: number;\n nextId: number;\n tasks: Task[];\n}\n\nexport function emptyDocument(): TaskDocument {\n return { version: STORE_SCHEMA_VERSION, rev: 0, nextId: 1, tasks: [] };\n}\n\n/**\n * A dependency target inside an upsert item: an existing task id, or the `ref`\n * of a task created earlier in the same call.\n *\n * Refs must start with a letter (see `REF_PATTERN`), so a ref is structurally\n * unconfusable with a stringified id and the discrimination is just `typeof`.\n */\nexport type DepToken = number | string;\n\n/**\n * One entry of an `upsert` call. No `id` creates a task; an `id` updates one.\n *\n * `blockedBy` (absolute set) is create-only and `addBlockedBy`/`removeBlockedBy`\n * (additive merge) are update-only, matching the split the two former actions\n * had. A field used against the wrong kind fails that item rather than being\n * silently ignored.\n */\nexport interface TaskItemMutation {\n id?: number;\n ref?: string;\n subject?: string;\n description?: string;\n activeForm?: string;\n status?: TaskStatus;\n blockedBy?: DepToken[];\n addBlockedBy?: DepToken[];\n removeBlockedBy?: DepToken[];\n owner?: string;\n metadata?: Record<string, unknown>;\n}\n\n/**\n * What one upsert item did. `index` is its position in the request array, so a\n * model reading a partial result can tell which entries still need resending.\n *\n * `message` is unprefixed: the `item[N] failed:` framing belongs to the\n * formatter, because the Task Space overlay shows this text on its own.\n */\nexport type UpsertItemOutcome =\n | {\n index: number;\n kind: 'created';\n id: number;\n subject: string;\n status: TaskStatus;\n ref?: string;\n blockedBy?: number[];\n }\n | { index: number; kind: 'updated'; id: number; fromStatus: TaskStatus; toStatus: TaskStatus }\n | { index: number; kind: 'unchanged'; id: number; status: TaskStatus }\n | { index: number; kind: 'failed'; message: string; id?: number; ref?: string };\n\n/** Which tasks an upsert touched, so renderResult names them instead of guessing. */\nexport interface UpsertSummary {\n /** Ids of applied entries, in request order. A failed entry contributes nothing. */\n applied: number[];\n failed: number;\n}\n\n/**\n * Open-shape input bag the reducer accepts. The index signature lets the\n * runtime pass a TypeBox `Static<typeof TaskParamsSchema>` through without\n * casting each field.\n *\n * Per-task fields live on `tasks[]`, not here: a top-level `subject` or\n * `status` would be ambiguous once one call can carry many tasks.\n */\nexport interface TaskMutationParams {\n [key: string]: unknown;\n tasks?: TaskItemMutation[];\n /** `list` filter only. To set a status, upsert the task by id. */\n status?: TaskStatus;\n /** `get`, `delete`,
|
|
1
|
+
{"version":3,"file":"types.mjs","names":[],"sources":["../../../src/services/store/types.ts"],"sourcesContent":["/**\n * Domain types for the file-backed task store.\n *\n * The on-disk document is the durable source of truth (unlike rpiv-todo, which\n * replayed state from the transcript). Every field here round-trips through\n * JSON, so nothing may hold non-serializable values.\n */\n\nimport type { InlineAgent } from '@agimon-ai/doompi-extension-contracts/subagent-tool';\n\nexport type TaskStatus = 'pending' | 'in_progress' | 'completed' | 'failed' | 'deleted';\n\nexport const DELETED_STATUS: TaskStatus = 'deleted';\n\nexport type TaskAction = 'upsert' | 'list' | 'get' | 'delete' | 'clear' | 'assign' | 'cancel';\n\nexport type DelegationState = 'requested' | 'running' | 'completed' | 'failed' | 'cancelled';\n\n/** Terminal result of a delegated subagent run, copied off the delegation response. */\nexport interface DelegationResult {\n status: string;\n output?: string;\n outputPath?: string;\n sessionFile?: string;\n error?: string;\n durationMs?: number;\n toolCount?: number;\n}\n\n/**\n * Delegation bookkeeping attached to a task that was handed to a subagent.\n *\n * `pid` is the harness process that owns the run: it is the only way to tell an\n * genuinely-running delegation from one orphaned by a harness crash, since the\n * child dies with its parent but the file survives.\n */\nexport interface TaskDelegation {\n requestId: string;\n agent: string;\n state: DelegationState;\n sessionId?: string;\n pid?: number;\n runId?: string;\n model?: string;\n startedAt?: string;\n endedAt?: string;\n result?: DelegationResult;\n}\n\nexport interface Task {\n id: number;\n subject: string;\n description?: string;\n activeForm?: string;\n status: TaskStatus;\n blockedBy?: number[];\n owner?: string;\n metadata?: Record<string, unknown>;\n createdAt?: string;\n updatedAt?: string;\n delegation?: TaskDelegation;\n}\n\nexport const STORE_SCHEMA_VERSION = 1;\n\n/** The complete on-disk document. `rev` increments on every committed write. */\nexport interface TaskDocument {\n version: number;\n rev: number;\n nextId: number;\n tasks: Task[];\n}\n\nexport function emptyDocument(): TaskDocument {\n return { version: STORE_SCHEMA_VERSION, rev: 0, nextId: 1, tasks: [] };\n}\n\n/**\n * A dependency target inside an upsert item: an existing task id, or the `ref`\n * of a task created earlier in the same call.\n *\n * Refs must start with a letter (see `REF_PATTERN`), so a ref is structurally\n * unconfusable with a stringified id and the discrimination is just `typeof`.\n */\nexport type DepToken = number | string;\n\n/**\n * One entry of an `upsert` call. No `id` creates a task; an `id` updates one.\n *\n * `blockedBy` (absolute set) is create-only and `addBlockedBy`/`removeBlockedBy`\n * (additive merge) are update-only, matching the split the two former actions\n * had. A field used against the wrong kind fails that item rather than being\n * silently ignored.\n */\nexport interface TaskItemMutation {\n id?: number;\n ref?: string;\n subject?: string;\n description?: string;\n activeForm?: string;\n status?: TaskStatus;\n blockedBy?: DepToken[];\n addBlockedBy?: DepToken[];\n removeBlockedBy?: DepToken[];\n owner?: string;\n metadata?: Record<string, unknown>;\n}\n\n/**\n * What one upsert item did. `index` is its position in the request array, so a\n * model reading a partial result can tell which entries still need resending.\n *\n * `message` is unprefixed: the `item[N] failed:` framing belongs to the\n * formatter, because the Task Space overlay shows this text on its own.\n */\nexport type UpsertItemOutcome =\n | {\n index: number;\n kind: 'created';\n id: number;\n subject: string;\n status: TaskStatus;\n ref?: string;\n blockedBy?: number[];\n }\n | { index: number; kind: 'updated'; id: number; fromStatus: TaskStatus; toStatus: TaskStatus }\n | { index: number; kind: 'unchanged'; id: number; status: TaskStatus }\n | { index: number; kind: 'failed'; message: string; id?: number; ref?: string };\n\n/** Which tasks an upsert touched, so renderResult names them instead of guessing. */\nexport interface UpsertSummary {\n /** Ids of applied entries, in request order. A failed entry contributes nothing. */\n applied: number[];\n failed: number;\n}\n\n/** One task-to-agent handoff inside a native assignment batch. */\nexport interface TaskAssignment {\n id: number;\n agent: string;\n inlineAgent?: InlineAgent;\n instructions?: string;\n relevantFiles?: string[];\n priorFindings?: string;\n model?: string;\n context?: 'fresh' | 'fork';\n}\n\n/** Which assignment entries started, so renderResult can show one consolidated batch. */\nexport interface AssignmentSummary {\n /** Ids of successful entries, in request order. A failed entry contributes nothing. */\n assigned: number[];\n failed: number;\n}\n\n/**\n * Open-shape input bag the reducer accepts. The index signature lets the\n * runtime pass a TypeBox `Static<typeof TaskParamsSchema>` through without\n * casting each field.\n *\n * Per-task fields live on `tasks[]`, not here: a top-level `subject` or\n * `status` would be ambiguous once one call can carry many tasks.\n */\nexport interface TaskMutationParams {\n [key: string]: unknown;\n tasks?: TaskItemMutation[];\n /** `assign` only: independent task-to-agent handoffs dispatched by one tool call. */\n assignments?: TaskAssignment[];\n /** `list` filter only. To set a status, upsert the task by id. */\n status?: TaskStatus;\n /** `get`, `delete`, and `cancel` only. Assign ids live in `assignments[]`. */\n id?: number;\n includeDeleted?: boolean;\n}\n\n/** Snapshot returned under a tool result's `details` for renderResult. */\nexport interface TaskDetails {\n action: TaskAction;\n params: Record<string, unknown>;\n tasks: Task[];\n nextId: number;\n rev: number;\n error?: string;\n upsert?: UpsertSummary;\n assignment?: AssignmentSummary;\n}\n\n/** A delegation is \"live\" while the owning run may still produce a response. */\nexport function isDelegationActive(task: Task): boolean {\n const state = task.delegation?.state;\n return state === 'requested' || state === 'running';\n}\n"],"mappings":"AAYA,MAAa,EAA6B,UAmD7B,EAAuB,EAUpC,SAAgB,GAA8B,CAC5C,MAAO,CAAE,QAAA,EAA+B,IAAK,EAAG,OAAQ,EAAG,MAAO,CAAC,CAAE,CACvE,CAiHA,SAAgB,EAAmB,EAAqB,CACtD,IAAM,EAAQ,EAAK,YAAY,MAC/B,OAAO,IAAU,aAAe,IAAU,SAC5C"}
|
package/dist/store/types.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DELETED_STATUS, DelegationResult, DelegationState, DepToken, STORE_SCHEMA_VERSION, Task, TaskAction, TaskDelegation, TaskDetails, TaskDocument, TaskItemMutation, TaskMutationParams, TaskStatus, UpsertItemOutcome, UpsertSummary, emptyDocument, isDelegationActive } from "../services/store/types.cjs";
|
|
2
|
-
export { DELETED_STATUS, DelegationResult, DelegationState, DepToken, STORE_SCHEMA_VERSION, Task, TaskAction, TaskDelegation, TaskDetails, TaskDocument, TaskItemMutation, TaskMutationParams, TaskStatus, UpsertItemOutcome, UpsertSummary, emptyDocument, isDelegationActive };
|
|
1
|
+
import { AssignmentSummary, DELETED_STATUS, DelegationResult, DelegationState, DepToken, STORE_SCHEMA_VERSION, Task, TaskAction, TaskAssignment, TaskDelegation, TaskDetails, TaskDocument, TaskItemMutation, TaskMutationParams, TaskStatus, UpsertItemOutcome, UpsertSummary, emptyDocument, isDelegationActive } from "../services/store/types.cjs";
|
|
2
|
+
export { AssignmentSummary, DELETED_STATUS, DelegationResult, DelegationState, DepToken, STORE_SCHEMA_VERSION, Task, TaskAction, TaskAssignment, TaskDelegation, TaskDetails, TaskDocument, TaskItemMutation, TaskMutationParams, TaskStatus, UpsertItemOutcome, UpsertSummary, emptyDocument, isDelegationActive };
|
package/dist/store/types.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DELETED_STATUS, DelegationResult, DelegationState, DepToken, STORE_SCHEMA_VERSION, Task, TaskAction, TaskDelegation, TaskDetails, TaskDocument, TaskItemMutation, TaskMutationParams, TaskStatus, UpsertItemOutcome, UpsertSummary, emptyDocument, isDelegationActive } from "../services/store/types.mjs";
|
|
2
|
-
export { DELETED_STATUS, DelegationResult, DelegationState, DepToken, STORE_SCHEMA_VERSION, Task, TaskAction, TaskDelegation, TaskDetails, TaskDocument, TaskItemMutation, TaskMutationParams, TaskStatus, UpsertItemOutcome, UpsertSummary, emptyDocument, isDelegationActive };
|
|
1
|
+
import { AssignmentSummary, DELETED_STATUS, DelegationResult, DelegationState, DepToken, STORE_SCHEMA_VERSION, Task, TaskAction, TaskAssignment, TaskDelegation, TaskDetails, TaskDocument, TaskItemMutation, TaskMutationParams, TaskStatus, UpsertItemOutcome, UpsertSummary, emptyDocument, isDelegationActive } from "../services/store/types.mjs";
|
|
2
|
+
export { AssignmentSummary, DELETED_STATUS, DelegationResult, DelegationState, DepToken, STORE_SCHEMA_VERSION, Task, TaskAction, TaskAssignment, TaskDelegation, TaskDetails, TaskDocument, TaskItemMutation, TaskMutationParams, TaskStatus, UpsertItemOutcome, UpsertSummary, emptyDocument, isDelegationActive };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../commands/task/responseEnvelope.cjs");exports.MSG_ALL_COMPLETE_CLEAR=e.MSG_ALL_COMPLETE_CLEAR,exports.MSG_UPSERT_NONE_APPLIED=e.MSG_UPSERT_NONE_APPLIED,exports.MSG_UPSERT_PARTIAL=e.MSG_UPSERT_PARTIAL,exports.buildTextResult=e.buildTextResult,exports.buildToolResult=e.buildToolResult,exports.formatContent=e.formatContent,exports.formatUpsertFailureText=e.formatUpsertFailureText;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../commands/task/responseEnvelope.cjs");exports.MSG_ALL_COMPLETE_CLEAR=e.MSG_ALL_COMPLETE_CLEAR,exports.MSG_ASSIGN_PARTIAL=e.MSG_ASSIGN_PARTIAL,exports.MSG_UPSERT_NONE_APPLIED=e.MSG_UPSERT_NONE_APPLIED,exports.MSG_UPSERT_PARTIAL=e.MSG_UPSERT_PARTIAL,exports.buildAssignmentResult=e.buildAssignmentResult,exports.buildTextResult=e.buildTextResult,exports.buildToolResult=e.buildToolResult,exports.formatAssignmentResults=e.formatAssignmentResults,exports.formatContent=e.formatContent,exports.formatUpsertFailureText=e.formatUpsertFailureText;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { MSG_ALL_COMPLETE_CLEAR, MSG_UPSERT_NONE_APPLIED, MSG_UPSERT_PARTIAL, ToolResult, buildTextResult, buildToolResult, formatContent, formatUpsertFailureText } from "../commands/task/responseEnvelope.cjs";
|
|
2
|
-
export { MSG_ALL_COMPLETE_CLEAR, MSG_UPSERT_NONE_APPLIED, MSG_UPSERT_PARTIAL, ToolResult, buildTextResult, buildToolResult, formatContent, formatUpsertFailureText };
|
|
1
|
+
import { AssignmentItemResult, MSG_ALL_COMPLETE_CLEAR, MSG_ASSIGN_PARTIAL, MSG_UPSERT_NONE_APPLIED, MSG_UPSERT_PARTIAL, ToolResult, buildAssignmentResult, buildTextResult, buildToolResult, formatAssignmentResults, formatContent, formatUpsertFailureText } from "../commands/task/responseEnvelope.cjs";
|
|
2
|
+
export { AssignmentItemResult, MSG_ALL_COMPLETE_CLEAR, MSG_ASSIGN_PARTIAL, MSG_UPSERT_NONE_APPLIED, MSG_UPSERT_PARTIAL, ToolResult, buildAssignmentResult, buildTextResult, buildToolResult, formatAssignmentResults, formatContent, formatUpsertFailureText };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { MSG_ALL_COMPLETE_CLEAR, MSG_UPSERT_NONE_APPLIED, MSG_UPSERT_PARTIAL, ToolResult, buildTextResult, buildToolResult, formatContent, formatUpsertFailureText } from "../commands/task/responseEnvelope.mjs";
|
|
2
|
-
export { MSG_ALL_COMPLETE_CLEAR, MSG_UPSERT_NONE_APPLIED, MSG_UPSERT_PARTIAL, ToolResult, buildTextResult, buildToolResult, formatContent, formatUpsertFailureText };
|
|
1
|
+
import { AssignmentItemResult, MSG_ALL_COMPLETE_CLEAR, MSG_ASSIGN_PARTIAL, MSG_UPSERT_NONE_APPLIED, MSG_UPSERT_PARTIAL, ToolResult, buildAssignmentResult, buildTextResult, buildToolResult, formatAssignmentResults, formatContent, formatUpsertFailureText } from "../commands/task/responseEnvelope.mjs";
|
|
2
|
+
export { AssignmentItemResult, MSG_ALL_COMPLETE_CLEAR, MSG_ASSIGN_PARTIAL, MSG_UPSERT_NONE_APPLIED, MSG_UPSERT_PARTIAL, ToolResult, buildAssignmentResult, buildTextResult, buildToolResult, formatAssignmentResults, formatContent, formatUpsertFailureText };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MSG_ALL_COMPLETE_CLEAR as e,
|
|
1
|
+
import{MSG_ALL_COMPLETE_CLEAR as e,MSG_ASSIGN_PARTIAL as t,MSG_UPSERT_NONE_APPLIED as n,MSG_UPSERT_PARTIAL as r,buildAssignmentResult as i,buildTextResult as a,buildToolResult as o,formatAssignmentResults as s,formatContent as c,formatUpsertFailureText as l}from"../commands/task/responseEnvelope.mjs";export{e as MSG_ALL_COMPLETE_CLEAR,t as MSG_ASSIGN_PARTIAL,n as MSG_UPSERT_NONE_APPLIED,r as MSG_UPSERT_PARTIAL,i as buildAssignmentResult,a as buildTextResult,o as buildToolResult,s as formatAssignmentResults,c as formatContent,l as formatUpsertFailureText};
|
package/dist/tool/schema.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../schemas/task.cjs");exports.COMMAND_NAME=e.COMMAND_NAME,exports.ERR_REQUIRES_INTERACTIVE=e.ERR_REQUIRES_INTERACTIVE,exports.MSG_NO_TASKS=e.MSG_NO_TASKS,exports.MSG_UPSERT_FIELD_MISPLACED=e.MSG_UPSERT_FIELD_MISPLACED,exports.TASK_ACTIONS=e.TASK_ACTIONS,exports.TASK_ACTION_FIELDS=e.TASK_ACTION_FIELDS,exports.TASK_CONTEXTS=e.TASK_CONTEXTS,exports.TASK_STATUSES=e.TASK_STATUSES,exports.TOOL_LABEL=e.TOOL_LABEL,exports.TOOL_NAME=e.TOOL_NAME,exports.TaskItemSchema=e.TaskItemSchema,exports.TaskParamsSchema=e.TaskParamsSchema,exports.taskActionAcceptsField=e.taskActionAcceptsField;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../schemas/task.cjs");exports.COMMAND_NAME=e.COMMAND_NAME,exports.ERR_REQUIRES_INTERACTIVE=e.ERR_REQUIRES_INTERACTIVE,exports.MSG_NO_TASKS=e.MSG_NO_TASKS,exports.MSG_UPSERT_FIELD_MISPLACED=e.MSG_UPSERT_FIELD_MISPLACED,exports.TASK_ACTIONS=e.TASK_ACTIONS,exports.TASK_ACTION_FIELDS=e.TASK_ACTION_FIELDS,exports.TASK_CONTEXTS=e.TASK_CONTEXTS,exports.TASK_STATUSES=e.TASK_STATUSES,exports.TOOL_LABEL=e.TOOL_LABEL,exports.TOOL_NAME=e.TOOL_NAME,exports.TaskAssignmentSchema=e.TaskAssignmentSchema,exports.TaskItemSchema=e.TaskItemSchema,exports.TaskParamsSchema=e.TaskParamsSchema,exports.taskActionAcceptsField=e.taskActionAcceptsField;
|
package/dist/tool/schema.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { COMMAND_NAME, ERR_REQUIRES_INTERACTIVE, MSG_NO_TASKS, MSG_UPSERT_FIELD_MISPLACED, TASK_ACTIONS, TASK_ACTION_FIELDS, TASK_CONTEXTS, TASK_STATUSES, TOOL_LABEL, TOOL_NAME, TaskItemParams, TaskItemSchema, TaskParams, TaskParamsSchema, taskActionAcceptsField } from "../schemas/task.cjs";
|
|
2
|
-
export { COMMAND_NAME, ERR_REQUIRES_INTERACTIVE, MSG_NO_TASKS, MSG_UPSERT_FIELD_MISPLACED, TASK_ACTIONS, TASK_ACTION_FIELDS, TASK_CONTEXTS, TASK_STATUSES, TOOL_LABEL, TOOL_NAME, TaskItemParams, TaskItemSchema, TaskParams, TaskParamsSchema, taskActionAcceptsField };
|
|
1
|
+
import { COMMAND_NAME, ERR_REQUIRES_INTERACTIVE, MSG_NO_TASKS, MSG_UPSERT_FIELD_MISPLACED, TASK_ACTIONS, TASK_ACTION_FIELDS, TASK_CONTEXTS, TASK_STATUSES, TOOL_LABEL, TOOL_NAME, TaskAssignmentParams, TaskAssignmentSchema, TaskItemParams, TaskItemSchema, TaskParams, TaskParamsSchema, taskActionAcceptsField } from "../schemas/task.cjs";
|
|
2
|
+
export { COMMAND_NAME, ERR_REQUIRES_INTERACTIVE, MSG_NO_TASKS, MSG_UPSERT_FIELD_MISPLACED, TASK_ACTIONS, TASK_ACTION_FIELDS, TASK_CONTEXTS, TASK_STATUSES, TOOL_LABEL, TOOL_NAME, TaskAssignmentParams, TaskAssignmentSchema, TaskItemParams, TaskItemSchema, TaskParams, TaskParamsSchema, taskActionAcceptsField };
|
package/dist/tool/schema.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { COMMAND_NAME, ERR_REQUIRES_INTERACTIVE, MSG_NO_TASKS, MSG_UPSERT_FIELD_MISPLACED, TASK_ACTIONS, TASK_ACTION_FIELDS, TASK_CONTEXTS, TASK_STATUSES, TOOL_LABEL, TOOL_NAME, TaskItemParams, TaskItemSchema, TaskParams, TaskParamsSchema, taskActionAcceptsField } from "../schemas/task.mjs";
|
|
2
|
-
export { COMMAND_NAME, ERR_REQUIRES_INTERACTIVE, MSG_NO_TASKS, MSG_UPSERT_FIELD_MISPLACED, TASK_ACTIONS, TASK_ACTION_FIELDS, TASK_CONTEXTS, TASK_STATUSES, TOOL_LABEL, TOOL_NAME, TaskItemParams, TaskItemSchema, TaskParams, TaskParamsSchema, taskActionAcceptsField };
|
|
1
|
+
import { COMMAND_NAME, ERR_REQUIRES_INTERACTIVE, MSG_NO_TASKS, MSG_UPSERT_FIELD_MISPLACED, TASK_ACTIONS, TASK_ACTION_FIELDS, TASK_CONTEXTS, TASK_STATUSES, TOOL_LABEL, TOOL_NAME, TaskAssignmentParams, TaskAssignmentSchema, TaskItemParams, TaskItemSchema, TaskParams, TaskParamsSchema, taskActionAcceptsField } from "../schemas/task.mjs";
|
|
2
|
+
export { COMMAND_NAME, ERR_REQUIRES_INTERACTIVE, MSG_NO_TASKS, MSG_UPSERT_FIELD_MISPLACED, TASK_ACTIONS, TASK_ACTION_FIELDS, TASK_CONTEXTS, TASK_STATUSES, TOOL_LABEL, TOOL_NAME, TaskAssignmentParams, TaskAssignmentSchema, TaskItemParams, TaskItemSchema, TaskParams, TaskParamsSchema, taskActionAcceptsField };
|
package/dist/tool/schema.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{COMMAND_NAME as e,ERR_REQUIRES_INTERACTIVE as t,MSG_NO_TASKS as n,MSG_UPSERT_FIELD_MISPLACED as r,TASK_ACTIONS as i,TASK_ACTION_FIELDS as a,TASK_CONTEXTS as o,TASK_STATUSES as s,TOOL_LABEL as c,TOOL_NAME as l,
|
|
1
|
+
import{COMMAND_NAME as e,ERR_REQUIRES_INTERACTIVE as t,MSG_NO_TASKS as n,MSG_UPSERT_FIELD_MISPLACED as r,TASK_ACTIONS as i,TASK_ACTION_FIELDS as a,TASK_CONTEXTS as o,TASK_STATUSES as s,TOOL_LABEL as c,TOOL_NAME as l,TaskAssignmentSchema as u,TaskItemSchema as d,TaskParamsSchema as f,taskActionAcceptsField as p}from"../schemas/task.mjs";export{e as COMMAND_NAME,t as ERR_REQUIRES_INTERACTIVE,n as MSG_NO_TASKS,r as MSG_UPSERT_FIELD_MISPLACED,i as TASK_ACTIONS,a as TASK_ACTION_FIELDS,o as TASK_CONTEXTS,s as TASK_STATUSES,c as TOOL_LABEL,l as TOOL_NAME,u as TaskAssignmentSchema,d as TaskItemSchema,f as TaskParamsSchema,p as taskActionAcceptsField};
|
package/dist/tui/format.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../services/delegation/manager.cjs");let t=require("@earendil-works/pi-tui"),n=require("@agimon-ai/doompi-ui/theme"),r=require("@agimon-ai/doompi-ui/toolChrome");const i={pending:`○`,in_progress:`◐`,completed:`●`,failed:`✗`,deleted:`⊘`},a={pending:`dim`,in_progress:`warning`,completed:`success`,failed:`error`,deleted:`muted`},o={pending:`pending`,in_progress:`in progress`,completed:`completed`,failed:`failed`,deleted:`deleted`},s={...i,completed:`✓`,deleted:i.failed},c={...a,deleted:`error`},l=1e3,u=/^working:\s*/i;function d(e){return e?.replace(u,``).trim()||void 0}const f={upsert:`✎`,delete:`×`,get:`›`,list:`☰`,clear:`∅`,assign:`⇒`,cancel:`⊗`};function p(e){return e.length===0?f.upsert:e.every(e=>e.id===void 0)?`+`:e.every(e=>e.id!==void 0)?`→`:f.upsert}function m(e,t){return t.fg(c[e],s[e])}function h(e){let t=Math.max(0,Math.floor(e/1e3)),n=t%60,r=Math.floor(t/60);if(r<60)return r===0?`${n}s`:`${r}m${String(n).padStart(2,`0`)}s`;let i=r%60;return`${Math.floor(r/60)}h${String(i).padStart(2,`0`)}m${String(n).padStart(2,`0`)}s`}function g(e){let t=Math.max(0,Math.round(e));return t<l?String(t):t<1e4?`${(t/l).toFixed(1)}k`:`${Math.round(t/l)}k`}function _(t,r,i,a,o=Date.now(),s){let c=t.status===`in_progress`?`accent`:t.status===`completed`||t.status===`deleted`?`muted`:`text`,l=r.fg(c,t.subject);(t.status===`completed`||t.status===`deleted`)&&(l=r.strikethrough(l));let u=m(t.status,r);i&&(u+=` ${r.fg(`dim`,`#${t.id}`)}`),u+=` ${l}`;let f=t.delegation?.agent;if(f&&t.delegation?.state===`running`){let i=[];a&&(i.push(r.fg(`muted`,`[${h(e.DelegationManager.elapsedMs(a,o))}]`)),a.tokens!==void 0&&i.push(r.fg(`muted`,`[${g(a.tokens)}]`)));let c=t.delegation.runId??t.delegation.requestId;i.push(r.fg(s??(0,n.agentIdentityColor)(c),`[${f}]`)),u+=` ${i.join(``)}`;let l=d(a?.currentTool);l&&(u+=` ${r.fg(`muted`,`· ${l}`)}`)}else f&&(u+=` ${r.fg(`muted`,`[${f}]`)}`);return t.status===`in_progress`&&t.activeForm&&(u+=` ${r.fg(`muted`,`(${t.activeForm})`)}`),t.blockedBy?.length&&(u+=` ${r.fg(`muted`,`⛓ ${t.blockedBy.map(e=>`#${e}`).join(`,`)}`)}`),u}function v(e,t){let n=e.status===`in_progress`&&e.activeForm?` (${e.activeForm})`:``,r=e.delegation?.agent?` [${e.delegation.agent}]`:``,i=e.blockedBy?.length?` ⛓ ${e.blockedBy.map(e=>`#${e}`).join(`,`)}`:``;return` ${t} #${e.id} ${e.subject}${n}${r}${i}`}function y(e,t,n){let i=e.action===`upsert`?e.tasks??[]:[],a=e.action===`upsert`?p(i):f[e.action]??e.action,s=(0,r.renderToolHeading)(`task`,`${a} ${e.action}`,t);if(e.action===`upsert`){if(i.length===1){let e=i[0];if(e.id===void 0)e.subject&&(s+=` ${t.fg(`dim`,e.subject)}`);else{let r=n.find(t=>t.id===e.id)?.subject??e.subject??`#${e.id}`;s+=` ${t.fg(`accent`,r)}`}}else i.length>1&&(s+=` ${t.fg(`dim`,`${i.length} tasks`)}`)}else if(e.action===`assign
|
|
2
|
-
`).filter(e=>e.trim().length>0)}function w(e){let t=e.params,n=e.tasks;return t.includeDeleted!==!0&&(n=n.filter(e=>e.status!==`deleted`)),t.status&&(n=n.filter(e=>e.status===t.status)),n}function T(e){let t=e.params;if(t.id!==void 0)return e.tasks.find(e=>e.id===t.id)}function E(e){return(e.upsert?.applied??[]).flatMap(t=>e.tasks.find(e=>e.id===t)??[])}function D(e,n,r){let i=e.details;if(n.isPartial){let n=C(S(e)).at(-1)??`working`;return new t.Text(r.fg(`warning`,`◐`)+r.fg(`dim`,` ${n}`),0,0)}if(e.isError===!0||i?.error!==void 0){let a=C(i?.error??S(e));if(a.length<=1)return new t.Text(r.fg(`error`,`✗`)+r.fg(`dim`,a[0]?` ${a[0]}`:``),0,0);let o=n.expanded?a:a.slice(0,8);return new t.Text([...o.map(e=>r.fg(`toolOutput`,e)),r.fg(`error`,`✗`)].join(`
|
|
3
|
-
`),0,0)}if(!i)return new t.Text(r.fg(`success`,`✓`),0,0);let s=e=>({left:_(e,r,!0),right:r.fg(a[e.status],o[e.status])});if(i.action===`list`){let e=w(i),t=n.expanded?e:e.slice(0,8),a=t.map(s),o=e.length===0?`no tasks`:`${e.length} task${e.length===1?``:`s`}`;return e.length>t.length&&(o+=` · ctrl+o`),a.push({left:r.fg(`success`,`✓`)+r.fg(`dim`,` ${o}`)}),new b(a)}if(i.action===`clear`)return new t.Text(r.fg(`success`,`✓`)+r.fg(`dim`,` cleared`),0,0);if(i.action===`upsert`){let e=E(i),t=i.upsert?.failed??0;if(e.length===1&&t===0)return new b([s(e[0])]);let a=n.expanded?e:e.slice(0,8),o=a.map(s),c=`${e.length} applied`;t>0&&(c+=` · ${t} failed`),e.length>a.length&&(c+=` · ctrl+o`);let l=t>0?r.fg(`warning`,`!`):r.fg(`success`,`✓`);return o.push({left:l+r.fg(`dim`,` ${c}`)}),new b(o)}let c=T(i);return c?new b([s(c)]):new t.Text(r.fg(`success`,`✓`),0,0)}function
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../services/delegation/manager.cjs");let t=require("@earendil-works/pi-tui"),n=require("@agimon-ai/doompi-ui/theme"),r=require("@agimon-ai/doompi-ui/toolChrome");const i={pending:`○`,in_progress:`◐`,completed:`●`,failed:`✗`,deleted:`⊘`},a={pending:`dim`,in_progress:`warning`,completed:`success`,failed:`error`,deleted:`muted`},o={pending:`pending`,in_progress:`in progress`,completed:`completed`,failed:`failed`,deleted:`deleted`},s={...i,completed:`✓`,deleted:i.failed},c={...a,deleted:`error`},l=1e3,u=/^working:\s*/i;function d(e){return e?.replace(u,``).trim()||void 0}const f={upsert:`✎`,delete:`×`,get:`›`,list:`☰`,clear:`∅`,assign:`⇒`,cancel:`⊗`};function p(e){return e.length===0?f.upsert:e.every(e=>e.id===void 0)?`+`:e.every(e=>e.id!==void 0)?`→`:f.upsert}function m(e,t){return t.fg(c[e],s[e])}function h(e){let t=Math.max(0,Math.floor(e/1e3)),n=t%60,r=Math.floor(t/60);if(r<60)return r===0?`${n}s`:`${r}m${String(n).padStart(2,`0`)}s`;let i=r%60;return`${Math.floor(r/60)}h${String(i).padStart(2,`0`)}m${String(n).padStart(2,`0`)}s`}function g(e){let t=Math.max(0,Math.round(e));return t<l?String(t):t<1e4?`${(t/l).toFixed(1)}k`:`${Math.round(t/l)}k`}function _(t,r,i,a,o=Date.now(),s){let c=t.status===`in_progress`?`accent`:t.status===`completed`||t.status===`deleted`?`muted`:`text`,l=r.fg(c,t.subject);(t.status===`completed`||t.status===`deleted`)&&(l=r.strikethrough(l));let u=m(t.status,r);i&&(u+=` ${r.fg(`dim`,`#${t.id}`)}`),u+=` ${l}`;let f=t.delegation?.agent;if(f&&t.delegation?.state===`running`){let i=[];a&&(i.push(r.fg(`muted`,`[${h(e.DelegationManager.elapsedMs(a,o))}]`)),a.tokens!==void 0&&i.push(r.fg(`muted`,`[${g(a.tokens)}]`)));let c=t.delegation.runId??t.delegation.requestId;i.push(r.fg(s??(0,n.agentIdentityColor)(c),`[${f}]`)),u+=` ${i.join(``)}`;let l=d(a?.currentTool);l&&(u+=` ${r.fg(`muted`,`· ${l}`)}`)}else f&&(u+=` ${r.fg(`muted`,`[${f}]`)}`);return t.status===`in_progress`&&t.activeForm&&(u+=` ${r.fg(`muted`,`(${t.activeForm})`)}`),t.blockedBy?.length&&(u+=` ${r.fg(`muted`,`⛓ ${t.blockedBy.map(e=>`#${e}`).join(`,`)}`)}`),u}function v(e,t){let n=e.status===`in_progress`&&e.activeForm?` (${e.activeForm})`:``,r=e.delegation?.agent?` [${e.delegation.agent}]`:``,i=e.blockedBy?.length?` ⛓ ${e.blockedBy.map(e=>`#${e}`).join(`,`)}`:``;return` ${t} #${e.id} ${e.subject}${n}${r}${i}`}function y(e,t,n){let i=e.action===`upsert`?e.tasks??[]:[],a=e.action===`upsert`?p(i):f[e.action]??e.action,s=(0,r.renderToolHeading)(`task`,`${a} ${e.action}`,t);if(e.action===`upsert`){if(i.length===1){let e=i[0];if(e.id===void 0)e.subject&&(s+=` ${t.fg(`dim`,e.subject)}`);else{let r=n.find(t=>t.id===e.id)?.subject??e.subject??`#${e.id}`;s+=` ${t.fg(`accent`,r)}`}}else i.length>1&&(s+=` ${t.fg(`dim`,`${i.length} tasks`)}`)}else if(e.action===`assign`){let r=e.assignments??[];if(r.length===1){let e=r[0],i=n.find(t=>t.id===e.id)?.subject??`#${e.id}`;s+=` ${t.fg(`accent`,i)}`,e.agent&&(s+=` ${t.fg(`muted`,`→ ${e.agent}`)}`)}else r.length>1&&(s+=` ${t.fg(`dim`,`${r.length} tasks`)}`)}else if((e.action===`get`||e.action===`delete`||e.action===`cancel`)&&e.id!==void 0){let r=n.find(t=>t.id===e.id)?.subject??`#${e.id}`;s+=` ${t.fg(`accent`,r)}`}else e.action===`list`&&e.status&&(s+=` ${t.fg(`muted`,o[e.status])}`);return new r.DoomToolCall(s)}var b=class{rows;constructor(e){this.rows=e}invalidate(){}render(e){return this.rows.map(({left:n,right:r})=>{if(r===void 0||r.length===0)return(0,t.truncateToWidth)(n,e);let i=(0,t.visibleWidth)(r),a=e-i-2;if(a<=0)return(0,t.truncateToWidth)(n,e);let o=(0,t.truncateToWidth)(n,a),s=Math.max(2,e-(0,t.visibleWidth)(o)-i);return o+` `.repeat(s)+r})}},x=class{content;theme;constructor(e,t){this.content=e,this.theme=t}render(e){if(e<=0)return[];if(e<3)return this.content.render(e);let t=e-2,n=this.theme.fg(`borderMuted`,`─`.repeat(t)),r=this.content.render(t).map(e=>` ${e}`);return[` ${n}`,...r,``]}invalidate(){this.content.invalidate()}};function S(e){return(e.content??[]).map(e=>e.text??``).join(``)}function C(e){return e.split(`
|
|
2
|
+
`).filter(e=>e.trim().length>0)}function w(e){let t=e.params,n=e.tasks;return t.includeDeleted!==!0&&(n=n.filter(e=>e.status!==`deleted`)),t.status&&(n=n.filter(e=>e.status===t.status)),n}function T(e){let t=e.params;if(t.id!==void 0)return e.tasks.find(e=>e.id===t.id)}function E(e){return(e.upsert?.applied??[]).flatMap(t=>e.tasks.find(e=>e.id===t)??[])}function D(e){return(e.assignment?.assigned??[]).flatMap(t=>e.tasks.find(e=>e.id===t)??[])}function O(e,n,r){let i=e.details;if(n.isPartial){let n=C(S(e)).at(-1)??`working`;return new t.Text(r.fg(`warning`,`◐`)+r.fg(`dim`,` ${n}`),0,0)}if(e.isError===!0||i?.error!==void 0){let a=C(i?.error??S(e));if(a.length<=1)return new t.Text(r.fg(`error`,`✗`)+r.fg(`dim`,a[0]?` ${a[0]}`:``),0,0);let o=n.expanded?a:a.slice(0,8);return new t.Text([...o.map(e=>r.fg(`toolOutput`,e)),r.fg(`error`,`✗`)].join(`
|
|
3
|
+
`),0,0)}if(!i)return new t.Text(r.fg(`success`,`✓`),0,0);let s=e=>({left:_(e,r,!0),right:r.fg(a[e.status],o[e.status])});if(i.action===`list`){let e=w(i),t=n.expanded?e:e.slice(0,8),a=t.map(s),o=e.length===0?`no tasks`:`${e.length} task${e.length===1?``:`s`}`;return e.length>t.length&&(o+=` · ctrl+o`),a.push({left:r.fg(`success`,`✓`)+r.fg(`dim`,` ${o}`)}),new b(a)}if(i.action===`clear`)return new t.Text(r.fg(`success`,`✓`)+r.fg(`dim`,` cleared`),0,0);if(i.action===`assign`&&i.assignment){let e=D(i),t=i.assignment.failed;if(e.length===1&&t===0)return new b([s(e[0])]);let a=n.expanded?e:e.slice(0,8),o=a.map(s),c=`${e.length} assigned`;t>0&&(c+=` · ${t} failed`),e.length>a.length&&(c+=` · ctrl+o`);let l=t>0?r.fg(`warning`,`!`):r.fg(`success`,`✓`);return o.push({left:l+r.fg(`dim`,` ${c}`)}),new b(o)}if(i.action===`upsert`){let e=E(i),t=i.upsert?.failed??0;if(e.length===1&&t===0)return new b([s(e[0])]);let a=n.expanded?e:e.slice(0,8),o=a.map(s),c=`${e.length} applied`;t>0&&(c+=` · ${t} failed`),e.length>a.length&&(c+=` · ctrl+o`);let l=t>0?r.fg(`warning`,`!`):r.fg(`success`,`✓`);return o.push({left:l+r.fg(`dim`,` ${c}`)}),new b(o)}let c=T(i);return c?new b([s(c)]):new t.Text(r.fg(`success`,`✓`),0,0)}function k(e,t,n){return new x(O(e,t,n),n)}exports.ACTION_GLYPH=f,exports.JustifiedRows=b,exports.STATUS_COLOR=a,exports.STATUS_GLYPH=i,exports.STATUS_LABEL=o,exports.formatCommandTaskLine=v,exports.formatElapsedMs=h,exports.formatOverlayTaskLine=_,exports.formatTokenCount=g,exports.overlayStatusGlyph=m,exports.renderTaskCall=y,exports.renderTaskResult=k;
|
|
4
4
|
//# sourceMappingURL=format.cjs.map
|
package/dist/tui/format.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.cjs","names":["DelegationManager","agentIdentityColor","renderToolHeading","DoomToolCall","truncateToWidth","visibleWidth","Text"],"sources":["../../src/tui/format.ts"],"sourcesContent":["import { agentIdentityColor } from '@agimon-ai/doompi-ui/theme';\nimport { DoomToolCall, renderToolHeading } from '@agimon-ai/doompi-ui/toolChrome';\nimport type { Theme } from '@earendil-works/pi-coding-agent';\nimport { type Component, Text, truncateToWidth, visibleWidth } from '@earendil-works/pi-tui';\nimport { DelegationManager, type DelegationProgress } from '../services/delegation/manager.ts';\nimport type {\n Task,\n TaskAction,\n TaskDetails,\n TaskItemMutation,\n TaskMutationParams,\n TaskStatus,\n} from '../services/store/types.ts';\n\nexport const STATUS_GLYPH: Record<TaskStatus, string> = {\n pending: '○',\n in_progress: '◐',\n completed: '●',\n failed: '✗',\n deleted: '⊘',\n};\n\ntype TaskStatusColor = 'dim' | 'warning' | 'success' | 'error' | 'muted';\n\nexport const STATUS_COLOR: Record<TaskStatus, TaskStatusColor> = {\n pending: 'dim',\n in_progress: 'warning',\n completed: 'success',\n failed: 'error',\n deleted: 'muted',\n};\n\nexport const STATUS_LABEL: Record<TaskStatus, string> = {\n pending: 'pending',\n in_progress: 'in progress',\n completed: 'completed',\n failed: 'failed',\n deleted: 'deleted',\n};\n\nconst OVERLAY_STATUS_GLYPH: Record<TaskStatus, string> = {\n ...STATUS_GLYPH,\n completed: '✓',\n deleted: STATUS_GLYPH.failed,\n};\n\nconst OVERLAY_STATUS_COLOR: Record<TaskStatus, TaskStatusColor> = {\n ...STATUS_COLOR,\n deleted: 'error',\n};\nconst MILLISECONDS_PER_SECOND = 1000;\nconst SECONDS_PER_MINUTE = 60;\nconst MINUTES_PER_HOUR = 60;\nconst TOKENS_PER_KILO = 1000;\nconst TOKEN_DECIMAL_LIMIT = 10_000;\nconst REDUNDANT_WORKING_PREFIX = /^working:\\s*/i;\n\n/** Thinking text already communicates activity; keep only its useful content. */\nfunction progressText(currentTool: string | undefined): string | undefined {\n const text = currentTool?.replace(REDUNDANT_WORKING_PREFIX, '').trim();\n return text || undefined;\n}\n\nexport const ACTION_GLYPH: Record<TaskAction, string> = {\n upsert: '✎',\n delete: '×',\n get: '›',\n list: '☰',\n clear: '∅',\n assign: '⇒',\n cancel: '⊗',\n};\n\n/**\n * `upsert` is two operations behind one name, so a homogeneous batch narrows to\n * the glyph the operator already reads: `+` means new work appeared, `→` means\n * work moved. A mixed batch keeps the neutral write glyph.\n */\nconst UPSERT_CREATE_GLYPH = '+';\nconst UPSERT_UPDATE_GLYPH = '→';\n\nfunction upsertGlyph(items: readonly TaskItemMutation[]): string {\n if (items.length === 0) return ACTION_GLYPH.upsert;\n if (items.every((item) => item.id === undefined)) return UPSERT_CREATE_GLYPH;\n if (items.every((item) => item.id !== undefined)) return UPSERT_UPDATE_GLYPH;\n return ACTION_GLYPH.upsert;\n}\n\nexport function overlayStatusGlyph(status: TaskStatus, theme: Theme): string {\n return theme.fg(OVERLAY_STATUS_COLOR[status], OVERLAY_STATUS_GLYPH[status]);\n}\n\nexport function formatElapsedMs(durationMs: number): string {\n const totalSeconds = Math.max(0, Math.floor(durationMs / MILLISECONDS_PER_SECOND));\n const seconds = totalSeconds % SECONDS_PER_MINUTE;\n const totalMinutes = Math.floor(totalSeconds / SECONDS_PER_MINUTE);\n if (totalMinutes < MINUTES_PER_HOUR) {\n return totalMinutes === 0 ? `${seconds}s` : `${totalMinutes}m${String(seconds).padStart(2, '0')}s`;\n }\n const minutes = totalMinutes % MINUTES_PER_HOUR;\n const hours = Math.floor(totalMinutes / MINUTES_PER_HOUR);\n return `${hours}h${String(minutes).padStart(2, '0')}m${String(seconds).padStart(2, '0')}s`;\n}\n\nexport function formatTokenCount(tokens: number): string {\n const count = Math.max(0, Math.round(tokens));\n if (count < TOKENS_PER_KILO) return String(count);\n if (count < TOKEN_DECIMAL_LIMIT) return `${(count / TOKENS_PER_KILO).toFixed(1)}k`;\n return `${Math.round(count / TOKENS_PER_KILO)}k`;\n}\n\n/**\n * One task row for the persistent overlay.\n *\n * A delegated row carries the agent name and its current tool so the operator\n * can see that background work is progressing without opening a transcript.\n */\nexport function formatOverlayTaskLine(\n task: Task,\n theme: Theme,\n showId: boolean,\n progress?: DelegationProgress,\n nowMs = Date.now(),\n agentColor?: Parameters<Theme['fg']>[0],\n): string {\n const subjectColor =\n task.status === 'in_progress'\n ? 'accent'\n : task.status === 'completed' || task.status === 'deleted'\n ? 'muted'\n : 'text';\n let subject = theme.fg(subjectColor, task.subject);\n if (task.status === 'completed' || task.status === 'deleted') {\n subject = theme.strikethrough(subject);\n }\n\n let line = overlayStatusGlyph(task.status, theme);\n if (showId) line += ` ${theme.fg('dim', `#${task.id}`)}`;\n line += ` ${subject}`;\n\n const agent = task.delegation?.agent;\n if (agent && task.delegation?.state === 'running') {\n // No progress means no timing is known, so the chips are omitted rather than\n // reported as `[0s]`. The transcript renderer has no progress feed at all.\n const chips: string[] = [];\n if (progress) {\n chips.push(theme.fg('muted', `[${formatElapsedMs(DelegationManager.elapsedMs(progress, nowMs))}]`));\n if (progress.tokens !== undefined) chips.push(theme.fg('muted', `[${formatTokenCount(progress.tokens)}]`));\n }\n const identity = task.delegation.runId ?? task.delegation.requestId;\n chips.push(theme.fg(agentColor ?? agentIdentityColor(identity), `[${agent}]`));\n line += ` ${chips.join('')}`;\n const activity = progressText(progress?.currentTool);\n if (activity) line += ` ${theme.fg('muted', `· ${activity}`)}`;\n } else if (agent) {\n line += ` ${theme.fg('muted', `[${agent}]`)}`;\n }\n\n if (task.status === 'in_progress' && task.activeForm) {\n line += ` ${theme.fg('muted', `(${task.activeForm})`)}`;\n }\n if (task.blockedBy?.length) {\n line += ` ${theme.fg('muted', `⛓ ${task.blockedBy.map((id) => `#${id}`).join(',')}`)}`;\n }\n return line;\n}\n\n/** One task line for the `/tasks` command output. */\nexport function formatCommandTaskLine(task: Task, glyph: string): string {\n const form = task.status === 'in_progress' && task.activeForm ? ` (${task.activeForm})` : '';\n const agent = task.delegation?.agent ? ` [${task.delegation.agent}]` : '';\n const block = task.blockedBy?.length ? ` ⛓ ${task.blockedBy.map((id) => `#${id}`).join(',')}` : '';\n return ` ${glyph} #${task.id} ${task.subject}${form}${agent}${block}`;\n}\n\nexport function renderTaskCall(\n args: TaskMutationParams & { action: TaskAction },\n theme: Theme,\n tasks: readonly Task[],\n): Component {\n const items = args.action === 'upsert' ? (args.tasks ?? []) : [];\n const glyph = args.action === 'upsert' ? upsertGlyph(items) : (ACTION_GLYPH[args.action] ?? args.action);\n let text = renderToolHeading('task', `${glyph} ${args.action}`, theme);\n\n if (args.action === 'upsert') {\n // One entry reads exactly as create or update did; a batch reads as a count\n // rather than a subject it would have to pick arbitrarily.\n if (items.length === 1) {\n const only = items[0];\n if (only.id === undefined) {\n if (only.subject) text += ` ${theme.fg('dim', only.subject)}`;\n } else {\n const subject = tasks.find((task) => task.id === only.id)?.subject ?? only.subject ?? `#${only.id}`;\n text += ` ${theme.fg('accent', subject)}`;\n }\n } else if (items.length > 1) {\n text += ` ${theme.fg('dim', `${items.length} tasks`)}`;\n }\n } else if (args.action === 'assign' && args.id !== undefined) {\n const subject = tasks.find((task) => task.id === args.id)?.subject ?? `#${args.id}`;\n text += ` ${theme.fg('accent', subject)}`;\n if (args.agent) text += ` ${theme.fg('muted', `→ ${args.agent}`)}`;\n } else if ((args.action === 'get' || args.action === 'delete' || args.action === 'cancel') && args.id !== undefined) {\n const subject = tasks.find((task) => task.id === args.id)?.subject ?? `#${args.id}`;\n text += ` ${theme.fg('accent', subject)}`;\n } else if (args.action === 'list' && args.status) {\n text += ` ${theme.fg('muted', STATUS_LABEL[args.status])}`;\n }\n return new DoomToolCall(text);\n}\n\n/** Task rows kept in a collapsed result, before `ctrl+o` reveals the rest. */\nconst TRANSCRIPT_TASK_ROWS = 8;\n/** Minimum gap between a row's subject and its right-aligned status. */\nconst STATUS_GUTTER = 2;\n\nexport interface JustifiedRow {\n left: string;\n /** Pinned to the right edge. The subject is truncated before this is dropped. */\n right?: string;\n}\n\n/**\n * Rows whose trailing text is flushed right.\n *\n * `Text` cannot do this: the status has to be placed against the viewport edge,\n * which is only known at render time.\n */\nexport class JustifiedRows implements Component {\n constructor(private readonly rows: readonly JustifiedRow[]) {}\n\n /**\n * Nothing to discard: the rows are themed by the caller and held verbatim, and\n * Pi rebuilds this component from `renderResult` whenever the theme changes.\n */\n invalidate(): void {}\n\n render(width: number): string[] {\n return this.rows.map(({ left, right }) => {\n if (right === undefined || right.length === 0) return truncateToWidth(left, width);\n const rightWidth = visibleWidth(right);\n const room = width - rightWidth - STATUS_GUTTER;\n if (room <= 0) return truncateToWidth(left, width);\n const subject = truncateToWidth(left, room);\n const gap = Math.max(STATUS_GUTTER, width - visibleWidth(subject) - rightWidth);\n return subject + ' '.repeat(gap) + right;\n });\n }\n}\n\n/**\n * Self-owned task shell with the same structural divider as the bash tool.\n *\n * Task rows already carry precise per-task state, so the divider stays neutral\n * instead of competing with or appearing to animate between those states.\n */\nclass TaskResultFrame implements Component {\n constructor(\n private readonly content: Component,\n private readonly theme: Theme,\n ) {}\n\n render(width: number): string[] {\n if (width <= 0) return [];\n if (width < 3) return this.content.render(width);\n\n const contentWidth = width - 2;\n const divider = this.theme.fg('borderMuted', '─'.repeat(contentWidth));\n const lines = this.content.render(contentWidth).map((line) => ` ${line}`);\n return [` ${divider}`, ...lines, ''];\n }\n\n invalidate(): void {\n this.content.invalidate();\n }\n}\n\nexport interface TaskResultLike {\n content?: Array<{ type: string; text?: string }>;\n details?: unknown;\n isError?: boolean;\n}\n\nexport interface TaskResultOptions {\n expanded: boolean;\n isPartial: boolean;\n}\n\n/** Concatenated result text, which is all a thrown failure leaves behind. */\nfunction contentText(result: TaskResultLike): string {\n return (result.content ?? []).map((block) => block.text ?? '').join('');\n}\n\nfunction nonEmptyLines(text: string): string[] {\n return text.split('\\n').filter((line) => line.trim().length > 0);\n}\n\n/**\n * The rows `list` reported to the model.\n *\n * `details.tasks` is the whole post-mutation document, so the filters applied by\n * `formatContent` have to be applied again here or the transcript would disagree\n * with the text the model was given.\n */\nfunction listedTasks(details: TaskDetails): Task[] {\n const params = details.params as TaskMutationParams;\n let view = details.tasks;\n if (params.includeDeleted !== true) view = view.filter((task) => task.status !== 'deleted');\n if (params.status) view = view.filter((task) => task.status === params.status);\n return view;\n}\n\n/** The single task an id-bearing action acted on, so the transcript names it rather than a bare tick. */\nfunction subjectTask(details: TaskDetails): Task | undefined {\n const params = details.params as TaskMutationParams;\n if (params.id === undefined) return undefined;\n return details.tasks.find((task) => task.id === params.id);\n}\n\n/**\n * Tasks an upsert applied, resolved from the ids the reducer reported.\n *\n * The ids are read rather than guessed from the tail of the list: a batch\n * touches many rows, and a failed entry contributes none.\n */\nfunction upsertTasks(details: TaskDetails): Task[] {\n return (details.upsert?.applied ?? []).flatMap((id) => details.tasks.find((task) => task.id === id) ?? []);\n}\n\nfunction renderTaskResultBody(result: TaskResultLike, options: TaskResultOptions, theme: Theme): Component {\n const details = result.details as TaskDetails | undefined;\n\n // Running. `assign` and `cancel` stream a placeholder before the run settles.\n if (options.isPartial) {\n const text = nonEmptyLines(contentText(result)).at(-1) ?? 'working';\n return new Text(theme.fg('warning', '◐') + theme.fg('dim', ` ${text}`), 0, 0);\n }\n\n // Failed. Every failure path throws, so Pi hands back error text and no\n // details; without this the block would render a green tick on a failure.\n if (result.isError === true || details?.error !== undefined) {\n const message = details?.error ?? contentText(result);\n const all = nonEmptyLines(message);\n if (all.length <= 1) {\n return new Text(theme.fg('error', '✗') + theme.fg('dim', all[0] ? ` ${all[0]}` : ''), 0, 0);\n }\n const body = options.expanded ? all : all.slice(0, TRANSCRIPT_TASK_ROWS);\n return new Text([...body.map((line) => theme.fg('toolOutput', line)), theme.fg('error', '✗')].join('\\n'), 0, 0);\n }\n\n if (!details) return new Text(theme.fg('success', '✓'), 0, 0);\n\n /** Status rides on the task's own row, flushed right, rather than costing a line. */\n const row = (task: Task): JustifiedRow => ({\n left: formatOverlayTaskLine(task, theme, true),\n right: theme.fg(STATUS_COLOR[task.status], STATUS_LABEL[task.status]),\n });\n\n if (details.action === 'list') {\n const tasks = listedTasks(details);\n const shown = options.expanded ? tasks : tasks.slice(0, TRANSCRIPT_TASK_ROWS);\n const rows: JustifiedRow[] = shown.map(row);\n let summary = tasks.length === 0 ? 'no tasks' : `${tasks.length} task${tasks.length === 1 ? '' : 's'}`;\n if (tasks.length > shown.length) summary += ' · ctrl+o';\n rows.push({ left: theme.fg('success', '✓') + theme.fg('dim', ` ${summary}`) });\n return new JustifiedRows(rows);\n }\n\n if (details.action === 'clear') {\n return new Text(theme.fg('success', '✓') + theme.fg('dim', ' cleared'), 0, 0);\n }\n\n if (details.action === 'upsert') {\n const touched = upsertTasks(details);\n const failed = details.upsert?.failed ?? 0;\n // One applied task and nothing failed is the common case: keep the single\n // row it has always had rather than dressing it as a bulk report.\n if (touched.length === 1 && failed === 0) return new JustifiedRows([row(touched[0])]);\n\n const shown = options.expanded ? touched : touched.slice(0, TRANSCRIPT_TASK_ROWS);\n const rows: JustifiedRow[] = shown.map(row);\n let summary = `${touched.length} applied`;\n if (failed > 0) summary += ` · ${failed} failed`;\n if (touched.length > shown.length) summary += ' · ctrl+o';\n // Failed entries get no row: there is no task to render, and their messages\n // are already in the text the model was given.\n const mark = failed > 0 ? theme.fg('warning', '!') : theme.fg('success', '✓');\n rows.push({ left: mark + theme.fg('dim', ` ${summary}`) });\n return new JustifiedRows(rows);\n }\n\n const task = subjectTask(details);\n if (!task) return new Text(theme.fg('success', '✓'), 0, 0);\n return new JustifiedRows([row(task)]);\n}\n\nexport function renderTaskResult(result: TaskResultLike, options: TaskResultOptions, theme: Theme): Component {\n return new TaskResultFrame(renderTaskResultBody(result, options, theme), theme);\n}\n"],"mappings":"sPAcA,MAAa,EAA2C,CACtD,QAAS,IACT,YAAa,IACb,UAAW,IACX,OAAQ,IACR,QAAS,GACX,EAIa,EAAoD,CAC/D,QAAS,MACT,YAAa,UACb,UAAW,UACX,OAAQ,QACR,QAAS,OACX,EAEa,EAA2C,CACtD,QAAS,UACT,YAAa,cACb,UAAW,YACX,OAAQ,SACR,QAAS,SACX,EAEM,EAAmD,CACvD,GAAG,EACH,UAAW,IACX,QAAS,EAAa,MACxB,EAEM,EAA4D,CAChE,GAAG,EACH,QAAS,OACX,EAIM,EAAkB,IAElB,EAA2B,gBAGjC,SAAS,EAAa,EAAqD,CAEzE,OADa,GAAa,QAAQ,EAA0B,EAAE,CAAC,CAAC,KAAK,GACtD,IAAA,EACjB,CAEA,MAAa,EAA2C,CACtD,OAAQ,IACR,OAAQ,IACR,IAAK,IACL,KAAM,IACN,MAAO,IACP,OAAQ,IACR,OAAQ,GACV,EAUA,SAAS,EAAY,EAA4C,CAI/D,OAHI,EAAM,SAAW,EAAU,EAAa,OACxC,EAAM,MAAO,GAAS,EAAK,KAAO,IAAA,EAAS,EAAU,IACrD,EAAM,MAAO,GAAS,EAAK,KAAO,IAAA,EAAS,EAAU,IAClD,EAAa,MACtB,CAEA,SAAgB,EAAmB,EAAoB,EAAsB,CAC3E,OAAO,EAAM,GAAG,EAAqB,GAAS,EAAqB,EAAO,CAC5E,CAEA,SAAgB,EAAgB,EAA4B,CAC1D,IAAM,EAAe,KAAK,IAAI,EAAG,KAAK,MAAM,EAAa,GAAuB,CAAC,EAC3E,EAAU,EAAe,GACzB,EAAe,KAAK,MAAM,EAAe,EAAkB,EACjE,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,EAAI,EAAM,GAAG,UAAW,GAAG,EAAI,EAAM,GAAG,UAAW,GAAG,EAE5E,OADA,EAAK,KAAK,CAAE,KAAM,EAAO,EAAM,GAAG,MAAO,IAAI,GAAS,CAAE,CAAC,EAClD,IAAI,EAAc,CAAI,CAC/B,CAEA,IAAM,EAAO,EAAY,CAAO,EAEhC,OADK,EACE,IAAI,EAAc,CAAC,EAAI,CAAI,CAAC,CAAC,EADlB,IAAIA,EAAAA,KAAK,EAAM,GAAG,UAAW,GAAG,EAAG,EAAG,CAAC,CAE3D,CAEA,SAAgB,EAAiB,EAAwB,EAA4B,EAAyB,CAC5G,OAAO,IAAI,EAAgB,EAAqB,EAAQ,EAAS,CAAK,EAAG,CAAK,CAChF"}
|
|
1
|
+
{"version":3,"file":"format.cjs","names":["DelegationManager","agentIdentityColor","renderToolHeading","DoomToolCall","truncateToWidth","visibleWidth","Text"],"sources":["../../src/tui/format.ts"],"sourcesContent":["import { agentIdentityColor } from '@agimon-ai/doompi-ui/theme';\nimport { DoomToolCall, renderToolHeading } from '@agimon-ai/doompi-ui/toolChrome';\nimport type { Theme } from '@earendil-works/pi-coding-agent';\nimport { type Component, Text, truncateToWidth, visibleWidth } from '@earendil-works/pi-tui';\nimport { DelegationManager, type DelegationProgress } from '../services/delegation/manager.ts';\nimport type {\n Task,\n TaskAction,\n TaskDetails,\n TaskItemMutation,\n TaskMutationParams,\n TaskStatus,\n} from '../services/store/types.ts';\n\nexport const STATUS_GLYPH: Record<TaskStatus, string> = {\n pending: '○',\n in_progress: '◐',\n completed: '●',\n failed: '✗',\n deleted: '⊘',\n};\n\ntype TaskStatusColor = 'dim' | 'warning' | 'success' | 'error' | 'muted';\n\nexport const STATUS_COLOR: Record<TaskStatus, TaskStatusColor> = {\n pending: 'dim',\n in_progress: 'warning',\n completed: 'success',\n failed: 'error',\n deleted: 'muted',\n};\n\nexport const STATUS_LABEL: Record<TaskStatus, string> = {\n pending: 'pending',\n in_progress: 'in progress',\n completed: 'completed',\n failed: 'failed',\n deleted: 'deleted',\n};\n\nconst OVERLAY_STATUS_GLYPH: Record<TaskStatus, string> = {\n ...STATUS_GLYPH,\n completed: '✓',\n deleted: STATUS_GLYPH.failed,\n};\n\nconst OVERLAY_STATUS_COLOR: Record<TaskStatus, TaskStatusColor> = {\n ...STATUS_COLOR,\n deleted: 'error',\n};\nconst MILLISECONDS_PER_SECOND = 1000;\nconst SECONDS_PER_MINUTE = 60;\nconst MINUTES_PER_HOUR = 60;\nconst TOKENS_PER_KILO = 1000;\nconst TOKEN_DECIMAL_LIMIT = 10_000;\nconst REDUNDANT_WORKING_PREFIX = /^working:\\s*/i;\n\n/** Thinking text already communicates activity; keep only its useful content. */\nfunction progressText(currentTool: string | undefined): string | undefined {\n const text = currentTool?.replace(REDUNDANT_WORKING_PREFIX, '').trim();\n return text || undefined;\n}\n\nexport const ACTION_GLYPH: Record<TaskAction, string> = {\n upsert: '✎',\n delete: '×',\n get: '›',\n list: '☰',\n clear: '∅',\n assign: '⇒',\n cancel: '⊗',\n};\n\n/**\n * `upsert` is two operations behind one name, so a homogeneous batch narrows to\n * the glyph the operator already reads: `+` means new work appeared, `→` means\n * work moved. A mixed batch keeps the neutral write glyph.\n */\nconst UPSERT_CREATE_GLYPH = '+';\nconst UPSERT_UPDATE_GLYPH = '→';\n\nfunction upsertGlyph(items: readonly TaskItemMutation[]): string {\n if (items.length === 0) return ACTION_GLYPH.upsert;\n if (items.every((item) => item.id === undefined)) return UPSERT_CREATE_GLYPH;\n if (items.every((item) => item.id !== undefined)) return UPSERT_UPDATE_GLYPH;\n return ACTION_GLYPH.upsert;\n}\n\nexport function overlayStatusGlyph(status: TaskStatus, theme: Theme): string {\n return theme.fg(OVERLAY_STATUS_COLOR[status], OVERLAY_STATUS_GLYPH[status]);\n}\n\nexport function formatElapsedMs(durationMs: number): string {\n const totalSeconds = Math.max(0, Math.floor(durationMs / MILLISECONDS_PER_SECOND));\n const seconds = totalSeconds % SECONDS_PER_MINUTE;\n const totalMinutes = Math.floor(totalSeconds / SECONDS_PER_MINUTE);\n if (totalMinutes < MINUTES_PER_HOUR) {\n return totalMinutes === 0 ? `${seconds}s` : `${totalMinutes}m${String(seconds).padStart(2, '0')}s`;\n }\n const minutes = totalMinutes % MINUTES_PER_HOUR;\n const hours = Math.floor(totalMinutes / MINUTES_PER_HOUR);\n return `${hours}h${String(minutes).padStart(2, '0')}m${String(seconds).padStart(2, '0')}s`;\n}\n\nexport function formatTokenCount(tokens: number): string {\n const count = Math.max(0, Math.round(tokens));\n if (count < TOKENS_PER_KILO) return String(count);\n if (count < TOKEN_DECIMAL_LIMIT) return `${(count / TOKENS_PER_KILO).toFixed(1)}k`;\n return `${Math.round(count / TOKENS_PER_KILO)}k`;\n}\n\n/**\n * One task row for the persistent overlay.\n *\n * A delegated row carries the agent name and its current tool so the operator\n * can see that background work is progressing without opening a transcript.\n */\nexport function formatOverlayTaskLine(\n task: Task,\n theme: Theme,\n showId: boolean,\n progress?: DelegationProgress,\n nowMs = Date.now(),\n agentColor?: Parameters<Theme['fg']>[0],\n): string {\n const subjectColor =\n task.status === 'in_progress'\n ? 'accent'\n : task.status === 'completed' || task.status === 'deleted'\n ? 'muted'\n : 'text';\n let subject = theme.fg(subjectColor, task.subject);\n if (task.status === 'completed' || task.status === 'deleted') {\n subject = theme.strikethrough(subject);\n }\n\n let line = overlayStatusGlyph(task.status, theme);\n if (showId) line += ` ${theme.fg('dim', `#${task.id}`)}`;\n line += ` ${subject}`;\n\n const agent = task.delegation?.agent;\n if (agent && task.delegation?.state === 'running') {\n // No progress means no timing is known, so the chips are omitted rather than\n // reported as `[0s]`. The transcript renderer has no progress feed at all.\n const chips: string[] = [];\n if (progress) {\n chips.push(theme.fg('muted', `[${formatElapsedMs(DelegationManager.elapsedMs(progress, nowMs))}]`));\n if (progress.tokens !== undefined) chips.push(theme.fg('muted', `[${formatTokenCount(progress.tokens)}]`));\n }\n const identity = task.delegation.runId ?? task.delegation.requestId;\n chips.push(theme.fg(agentColor ?? agentIdentityColor(identity), `[${agent}]`));\n line += ` ${chips.join('')}`;\n const activity = progressText(progress?.currentTool);\n if (activity) line += ` ${theme.fg('muted', `· ${activity}`)}`;\n } else if (agent) {\n line += ` ${theme.fg('muted', `[${agent}]`)}`;\n }\n\n if (task.status === 'in_progress' && task.activeForm) {\n line += ` ${theme.fg('muted', `(${task.activeForm})`)}`;\n }\n if (task.blockedBy?.length) {\n line += ` ${theme.fg('muted', `⛓ ${task.blockedBy.map((id) => `#${id}`).join(',')}`)}`;\n }\n return line;\n}\n\n/** One task line for the `/tasks` command output. */\nexport function formatCommandTaskLine(task: Task, glyph: string): string {\n const form = task.status === 'in_progress' && task.activeForm ? ` (${task.activeForm})` : '';\n const agent = task.delegation?.agent ? ` [${task.delegation.agent}]` : '';\n const block = task.blockedBy?.length ? ` ⛓ ${task.blockedBy.map((id) => `#${id}`).join(',')}` : '';\n return ` ${glyph} #${task.id} ${task.subject}${form}${agent}${block}`;\n}\n\nexport function renderTaskCall(\n args: TaskMutationParams & { action: TaskAction },\n theme: Theme,\n tasks: readonly Task[],\n): Component {\n const items = args.action === 'upsert' ? (args.tasks ?? []) : [];\n const glyph = args.action === 'upsert' ? upsertGlyph(items) : (ACTION_GLYPH[args.action] ?? args.action);\n let text = renderToolHeading('task', `${glyph} ${args.action}`, theme);\n\n if (args.action === 'upsert') {\n // One entry reads exactly as create or update did; a batch reads as a count\n // rather than a subject it would have to pick arbitrarily.\n if (items.length === 1) {\n const only = items[0];\n if (only.id === undefined) {\n if (only.subject) text += ` ${theme.fg('dim', only.subject)}`;\n } else {\n const subject = tasks.find((task) => task.id === only.id)?.subject ?? only.subject ?? `#${only.id}`;\n text += ` ${theme.fg('accent', subject)}`;\n }\n } else if (items.length > 1) {\n text += ` ${theme.fg('dim', `${items.length} tasks`)}`;\n }\n } else if (args.action === 'assign') {\n const assignments = args.assignments ?? [];\n if (assignments.length === 1) {\n const only = assignments[0];\n const subject = tasks.find((task) => task.id === only.id)?.subject ?? `#${only.id}`;\n text += ` ${theme.fg('accent', subject)}`;\n if (only.agent) text += ` ${theme.fg('muted', `→ ${only.agent}`)}`;\n } else if (assignments.length > 1) {\n text += ` ${theme.fg('dim', `${assignments.length} tasks`)}`;\n }\n } else if ((args.action === 'get' || args.action === 'delete' || args.action === 'cancel') && args.id !== undefined) {\n const subject = tasks.find((task) => task.id === args.id)?.subject ?? `#${args.id}`;\n text += ` ${theme.fg('accent', subject)}`;\n } else if (args.action === 'list' && args.status) {\n text += ` ${theme.fg('muted', STATUS_LABEL[args.status])}`;\n }\n return new DoomToolCall(text);\n}\n\n/** Task rows kept in a collapsed result, before `ctrl+o` reveals the rest. */\nconst TRANSCRIPT_TASK_ROWS = 8;\n/** Minimum gap between a row's subject and its right-aligned status. */\nconst STATUS_GUTTER = 2;\n\nexport interface JustifiedRow {\n left: string;\n /** Pinned to the right edge. The subject is truncated before this is dropped. */\n right?: string;\n}\n\n/**\n * Rows whose trailing text is flushed right.\n *\n * `Text` cannot do this: the status has to be placed against the viewport edge,\n * which is only known at render time.\n */\nexport class JustifiedRows implements Component {\n constructor(private readonly rows: readonly JustifiedRow[]) {}\n\n /**\n * Nothing to discard: the rows are themed by the caller and held verbatim, and\n * Pi rebuilds this component from `renderResult` whenever the theme changes.\n */\n invalidate(): void {}\n\n render(width: number): string[] {\n return this.rows.map(({ left, right }) => {\n if (right === undefined || right.length === 0) return truncateToWidth(left, width);\n const rightWidth = visibleWidth(right);\n const room = width - rightWidth - STATUS_GUTTER;\n if (room <= 0) return truncateToWidth(left, width);\n const subject = truncateToWidth(left, room);\n const gap = Math.max(STATUS_GUTTER, width - visibleWidth(subject) - rightWidth);\n return subject + ' '.repeat(gap) + right;\n });\n }\n}\n\n/**\n * Self-owned task shell with the same structural divider as the bash tool.\n *\n * Task rows already carry precise per-task state, so the divider stays neutral\n * instead of competing with or appearing to animate between those states.\n */\nclass TaskResultFrame implements Component {\n constructor(\n private readonly content: Component,\n private readonly theme: Theme,\n ) {}\n\n render(width: number): string[] {\n if (width <= 0) return [];\n if (width < 3) return this.content.render(width);\n\n const contentWidth = width - 2;\n const divider = this.theme.fg('borderMuted', '─'.repeat(contentWidth));\n const lines = this.content.render(contentWidth).map((line) => ` ${line}`);\n return [` ${divider}`, ...lines, ''];\n }\n\n invalidate(): void {\n this.content.invalidate();\n }\n}\n\nexport interface TaskResultLike {\n content?: Array<{ type: string; text?: string }>;\n details?: unknown;\n isError?: boolean;\n}\n\nexport interface TaskResultOptions {\n expanded: boolean;\n isPartial: boolean;\n}\n\n/** Concatenated result text, which is all a thrown failure leaves behind. */\nfunction contentText(result: TaskResultLike): string {\n return (result.content ?? []).map((block) => block.text ?? '').join('');\n}\n\nfunction nonEmptyLines(text: string): string[] {\n return text.split('\\n').filter((line) => line.trim().length > 0);\n}\n\n/**\n * The rows `list` reported to the model.\n *\n * `details.tasks` is the whole post-mutation document, so the filters applied by\n * `formatContent` have to be applied again here or the transcript would disagree\n * with the text the model was given.\n */\nfunction listedTasks(details: TaskDetails): Task[] {\n const params = details.params as TaskMutationParams;\n let view = details.tasks;\n if (params.includeDeleted !== true) view = view.filter((task) => task.status !== 'deleted');\n if (params.status) view = view.filter((task) => task.status === params.status);\n return view;\n}\n\n/** The single task an id-bearing action acted on, so the transcript names it rather than a bare tick. */\nfunction subjectTask(details: TaskDetails): Task | undefined {\n const params = details.params as TaskMutationParams;\n if (params.id === undefined) return undefined;\n return details.tasks.find((task) => task.id === params.id);\n}\n\n/**\n * Tasks an upsert applied, resolved from the ids the reducer reported.\n *\n * The ids are read rather than guessed from the tail of the list: a batch\n * touches many rows, and a failed entry contributes none.\n */\nfunction upsertTasks(details: TaskDetails): Task[] {\n return (details.upsert?.applied ?? []).flatMap((id) => details.tasks.find((task) => task.id === id) ?? []);\n}\n\n/** Tasks successfully handed off by a native assignment batch. */\nfunction assignedTasks(details: TaskDetails): Task[] {\n return (details.assignment?.assigned ?? []).flatMap((id) => details.tasks.find((task) => task.id === id) ?? []);\n}\n\nfunction renderTaskResultBody(result: TaskResultLike, options: TaskResultOptions, theme: Theme): Component {\n const details = result.details as TaskDetails | undefined;\n\n // Running. `assign` and `cancel` stream a placeholder before the run settles.\n if (options.isPartial) {\n const text = nonEmptyLines(contentText(result)).at(-1) ?? 'working';\n return new Text(theme.fg('warning', '◐') + theme.fg('dim', ` ${text}`), 0, 0);\n }\n\n // Failed. Every failure path throws, so Pi hands back error text and no\n // details; without this the block would render a green tick on a failure.\n if (result.isError === true || details?.error !== undefined) {\n const message = details?.error ?? contentText(result);\n const all = nonEmptyLines(message);\n if (all.length <= 1) {\n return new Text(theme.fg('error', '✗') + theme.fg('dim', all[0] ? ` ${all[0]}` : ''), 0, 0);\n }\n const body = options.expanded ? all : all.slice(0, TRANSCRIPT_TASK_ROWS);\n return new Text([...body.map((line) => theme.fg('toolOutput', line)), theme.fg('error', '✗')].join('\\n'), 0, 0);\n }\n\n if (!details) return new Text(theme.fg('success', '✓'), 0, 0);\n\n /** Status rides on the task's own row, flushed right, rather than costing a line. */\n const row = (task: Task): JustifiedRow => ({\n left: formatOverlayTaskLine(task, theme, true),\n right: theme.fg(STATUS_COLOR[task.status], STATUS_LABEL[task.status]),\n });\n\n if (details.action === 'list') {\n const tasks = listedTasks(details);\n const shown = options.expanded ? tasks : tasks.slice(0, TRANSCRIPT_TASK_ROWS);\n const rows: JustifiedRow[] = shown.map(row);\n let summary = tasks.length === 0 ? 'no tasks' : `${tasks.length} task${tasks.length === 1 ? '' : 's'}`;\n if (tasks.length > shown.length) summary += ' · ctrl+o';\n rows.push({ left: theme.fg('success', '✓') + theme.fg('dim', ` ${summary}`) });\n return new JustifiedRows(rows);\n }\n\n if (details.action === 'clear') {\n return new Text(theme.fg('success', '✓') + theme.fg('dim', ' cleared'), 0, 0);\n }\n\n if (details.action === 'assign' && details.assignment) {\n const assigned = assignedTasks(details);\n const failed = details.assignment.failed;\n if (assigned.length === 1 && failed === 0) return new JustifiedRows([row(assigned[0])]);\n\n const shown = options.expanded ? assigned : assigned.slice(0, TRANSCRIPT_TASK_ROWS);\n const rows: JustifiedRow[] = shown.map(row);\n let summary = `${assigned.length} assigned`;\n if (failed > 0) summary += ` · ${failed} failed`;\n if (assigned.length > shown.length) summary += ' · ctrl+o';\n const mark = failed > 0 ? theme.fg('warning', '!') : theme.fg('success', '✓');\n rows.push({ left: mark + theme.fg('dim', ` ${summary}`) });\n return new JustifiedRows(rows);\n }\n\n if (details.action === 'upsert') {\n const touched = upsertTasks(details);\n const failed = details.upsert?.failed ?? 0;\n // One applied task and nothing failed is the common case: keep the single\n // row it has always had rather than dressing it as a bulk report.\n if (touched.length === 1 && failed === 0) return new JustifiedRows([row(touched[0])]);\n\n const shown = options.expanded ? touched : touched.slice(0, TRANSCRIPT_TASK_ROWS);\n const rows: JustifiedRow[] = shown.map(row);\n let summary = `${touched.length} applied`;\n if (failed > 0) summary += ` · ${failed} failed`;\n if (touched.length > shown.length) summary += ' · ctrl+o';\n // Failed entries get no row: there is no task to render, and their messages\n // are already in the text the model was given.\n const mark = failed > 0 ? theme.fg('warning', '!') : theme.fg('success', '✓');\n rows.push({ left: mark + theme.fg('dim', ` ${summary}`) });\n return new JustifiedRows(rows);\n }\n\n const task = subjectTask(details);\n if (!task) return new Text(theme.fg('success', '✓'), 0, 0);\n return new JustifiedRows([row(task)]);\n}\n\nexport function renderTaskResult(result: TaskResultLike, options: TaskResultOptions, theme: Theme): Component {\n return new TaskResultFrame(renderTaskResultBody(result, options, theme), theme);\n}\n"],"mappings":"sPAcA,MAAa,EAA2C,CACtD,QAAS,IACT,YAAa,IACb,UAAW,IACX,OAAQ,IACR,QAAS,GACX,EAIa,EAAoD,CAC/D,QAAS,MACT,YAAa,UACb,UAAW,UACX,OAAQ,QACR,QAAS,OACX,EAEa,EAA2C,CACtD,QAAS,UACT,YAAa,cACb,UAAW,YACX,OAAQ,SACR,QAAS,SACX,EAEM,EAAmD,CACvD,GAAG,EACH,UAAW,IACX,QAAS,EAAa,MACxB,EAEM,EAA4D,CAChE,GAAG,E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BAAgB,SACf;
|
|
1
|
+
{"version":3,"file":"format.d.cts","names":[],"sources":["../../src/tui/format.ts"],"mappings":";;;;;cAca,cAAc,OAAO;KAQ7B;cAEQ,cAAc,OAAO,YAAY;cAQjC,cAAc,OAAO;cA+BrB,cAAc,OAAO;iBAyBlB,mBAAmB,QAAQ,YAAY,OAAO;iBAI9C,gBAAgB;iBAYhB,iBAAiB;;;;;;;iBAajB,sBACd,MAAM,MACN,OAAO,OACP,iBACA,WAAW,oBACX,gBACA,aAAa,WAAW;;iBA6CV,sBAAsB,MAAM,MAAM;iBAOlC,eACd,MAAM;EAAuB,QAAQ;GACrC,OAAO,OACP,gBAAgB,SACf;UA2Cc;EACf;;EAEA;;;;;;;;cASW,yBAAyB;mBACP;EAAA,YAAA,eAAe;;;;;EAM5C;EAEA,OAAO;;UAwCQ;EACf,UAAU;IAAQ;IAAc;;EAChC;EACA;;UAGe;EACf;EACA;;iBAmIc,iBAAiB,QAAQ,gBAAgB,SAAS,mBAAmB,OAAO,QAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.mts","names":[],"sources":["../../src/tui/format.ts"],"mappings":";;;;;cAca,cAAc,OAAO;KAQ7B;cAEQ,cAAc,OAAO,YAAY;cAQjC,cAAc,OAAO;cA+BrB,cAAc,OAAO;iBAyBlB,mBAAmB,QAAQ,YAAY,OAAO;iBAI9C,gBAAgB;iBAYhB,iBAAiB;;;;;;;iBAajB,sBACd,MAAM,MACN,OAAO,OACP,iBACA,WAAW,oBACX,gBACA,aAAa,WAAW;;iBA6CV,sBAAsB,MAAM,MAAM;iBAOlC,eACd,MAAM;EAAuB,QAAQ;GACrC,OAAO,OACP,gBAAgB,SACf;
|
|
1
|
+
{"version":3,"file":"format.d.mts","names":[],"sources":["../../src/tui/format.ts"],"mappings":";;;;;cAca,cAAc,OAAO;KAQ7B;cAEQ,cAAc,OAAO,YAAY;cAQjC,cAAc,OAAO;cA+BrB,cAAc,OAAO;iBAyBlB,mBAAmB,QAAQ,YAAY,OAAO;iBAI9C,gBAAgB;iBAYhB,iBAAiB;;;;;;;iBAajB,sBACd,MAAM,MACN,OAAO,OACP,iBACA,WAAW,oBACX,gBACA,aAAa,WAAW;;iBA6CV,sBAAsB,MAAM,MAAM;iBAOlC,eACd,MAAM;EAAuB,QAAQ;GACrC,OAAO,OACP,gBAAgB,SACf;UA2Cc;EACf;;EAEA;;;;;;;;cASW,yBAAyB;mBACP;EAAA,YAAA,eAAe;;;;;EAM5C;EAEA,OAAO;;UAwCQ;EACf,UAAU;IAAQ;IAAc;;EAChC;EACA;;UAGe;EACf;EACA;;iBAmIc,iBAAiB,QAAQ,gBAAgB,SAAS,mBAAmB,OAAO,QAAQ"}
|
package/dist/tui/format.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{DelegationManager as e}from"../services/delegation/manager.mjs";import{Text as t,truncateToWidth as n,visibleWidth as r}from"@earendil-works/pi-tui";import{agentIdentityColor as i}from"@agimon-ai/doompi-ui/theme";import{DoomToolCall as a,renderToolHeading as o}from"@agimon-ai/doompi-ui/toolChrome";const s={pending:`○`,in_progress:`◐`,completed:`●`,failed:`✗`,deleted:`⊘`},c={pending:`dim`,in_progress:`warning`,completed:`success`,failed:`error`,deleted:`muted`},l={pending:`pending`,in_progress:`in progress`,completed:`completed`,failed:`failed`,deleted:`deleted`},u={...s,completed:`✓`,deleted:s.failed},d={...c,deleted:`error`},f=1e3,p=/^working:\s*/i;function m(e){return e?.replace(p,``).trim()||void 0}const h={upsert:`✎`,delete:`×`,get:`›`,list:`☰`,clear:`∅`,assign:`⇒`,cancel:`⊗`};function g(e){return e.length===0?h.upsert:e.every(e=>e.id===void 0)?`+`:e.every(e=>e.id!==void 0)?`→`:h.upsert}function _(e,t){return t.fg(d[e],u[e])}function v(e){let t=Math.max(0,Math.floor(e/1e3)),n=t%60,r=Math.floor(t/60);if(r<60)return r===0?`${n}s`:`${r}m${String(n).padStart(2,`0`)}s`;let i=r%60;return`${Math.floor(r/60)}h${String(i).padStart(2,`0`)}m${String(n).padStart(2,`0`)}s`}function y(e){let t=Math.max(0,Math.round(e));return t<f?String(t):t<1e4?`${(t/f).toFixed(1)}k`:`${Math.round(t/f)}k`}function b(t,n,r,a,o=Date.now(),s){let c=t.status===`in_progress`?`accent`:t.status===`completed`||t.status===`deleted`?`muted`:`text`,l=n.fg(c,t.subject);(t.status===`completed`||t.status===`deleted`)&&(l=n.strikethrough(l));let u=_(t.status,n);r&&(u+=` ${n.fg(`dim`,`#${t.id}`)}`),u+=` ${l}`;let d=t.delegation?.agent;if(d&&t.delegation?.state===`running`){let r=[];a&&(r.push(n.fg(`muted`,`[${v(e.elapsedMs(a,o))}]`)),a.tokens!==void 0&&r.push(n.fg(`muted`,`[${y(a.tokens)}]`)));let c=t.delegation.runId??t.delegation.requestId;r.push(n.fg(s??i(c),`[${d}]`)),u+=` ${r.join(``)}`;let l=m(a?.currentTool);l&&(u+=` ${n.fg(`muted`,`· ${l}`)}`)}else d&&(u+=` ${n.fg(`muted`,`[${d}]`)}`);return t.status===`in_progress`&&t.activeForm&&(u+=` ${n.fg(`muted`,`(${t.activeForm})`)}`),t.blockedBy?.length&&(u+=` ${n.fg(`muted`,`⛓ ${t.blockedBy.map(e=>`#${e}`).join(`,`)}`)}`),u}function x(e,t){let n=e.status===`in_progress`&&e.activeForm?` (${e.activeForm})`:``,r=e.delegation?.agent?` [${e.delegation.agent}]`:``,i=e.blockedBy?.length?` ⛓ ${e.blockedBy.map(e=>`#${e}`).join(`,`)}`:``;return` ${t} #${e.id} ${e.subject}${n}${r}${i}`}function S(e,t,n){let r=e.action===`upsert`?e.tasks??[]:[],i=e.action===`upsert`?g(r):h[e.action]??e.action,s=o(`task`,`${i} ${e.action}`,t);if(e.action===`upsert`){if(r.length===1){let e=r[0];if(e.id===void 0)e.subject&&(s+=` ${t.fg(`dim`,e.subject)}`);else{let r=n.find(t=>t.id===e.id)?.subject??e.subject??`#${e.id}`;s+=` ${t.fg(`accent`,r)}`}}else r.length>1&&(s+=` ${t.fg(`dim`,`${r.length} tasks`)}`)}else if(e.action===`assign
|
|
2
|
-
`).filter(e=>e.trim().length>0)}function D(e){let t=e.params,n=e.tasks;return t.includeDeleted!==!0&&(n=n.filter(e=>e.status!==`deleted`)),t.status&&(n=n.filter(e=>e.status===t.status)),n}function O(e){let t=e.params;if(t.id!==void 0)return e.tasks.find(e=>e.id===t.id)}function k(e){return(e.upsert?.applied??[]).flatMap(t=>e.tasks.find(e=>e.id===t)??[])}function A(e,n,r){let i=e.details;if(n.isPartial){let n=E(T(e)).at(-1)??`working`;return new t(r.fg(`warning`,`◐`)+r.fg(`dim`,` ${n}`),0,0)}if(e.isError===!0||i?.error!==void 0){let a=E(i?.error??T(e));if(a.length<=1)return new t(r.fg(`error`,`✗`)+r.fg(`dim`,a[0]?` ${a[0]}`:``),0,0);let o=n.expanded?a:a.slice(0,8);return new t([...o.map(e=>r.fg(`toolOutput`,e)),r.fg(`error`,`✗`)].join(`
|
|
3
|
-
`),0,0)}if(!i)return new t(r.fg(`success`,`✓`),0,0);let a=e=>({left:b(e,r,!0),right:r.fg(c[e.status],l[e.status])});if(i.action===`list`){let e=D(i),t=n.expanded?e:e.slice(0,8),o=t.map(a),s=e.length===0?`no tasks`:`${e.length} task${e.length===1?``:`s`}`;return e.length>t.length&&(s+=` · ctrl+o`),o.push({left:r.fg(`success`,`✓`)+r.fg(`dim`,` ${s}`)}),new C(o)}if(i.action===`clear`)return new t(r.fg(`success`,`✓`)+r.fg(`dim`,` cleared`),0,0);if(i.action===`upsert`){let e=k(i),t=i.upsert?.failed??0;if(e.length===1&&t===0)return new C([a(e[0])]);let o=n.expanded?e:e.slice(0,8),s=o.map(a),c=`${e.length} applied`;t>0&&(c+=` · ${t} failed`),e.length>o.length&&(c+=` · ctrl+o`);let l=t>0?r.fg(`warning`,`!`):r.fg(`success`,`✓`);return s.push({left:l+r.fg(`dim`,` ${c}`)}),new C(s)}let o=O(i);return o?new C([a(o)]):new t(r.fg(`success`,`✓`),0,0)}function
|
|
1
|
+
import{DelegationManager as e}from"../services/delegation/manager.mjs";import{Text as t,truncateToWidth as n,visibleWidth as r}from"@earendil-works/pi-tui";import{agentIdentityColor as i}from"@agimon-ai/doompi-ui/theme";import{DoomToolCall as a,renderToolHeading as o}from"@agimon-ai/doompi-ui/toolChrome";const s={pending:`○`,in_progress:`◐`,completed:`●`,failed:`✗`,deleted:`⊘`},c={pending:`dim`,in_progress:`warning`,completed:`success`,failed:`error`,deleted:`muted`},l={pending:`pending`,in_progress:`in progress`,completed:`completed`,failed:`failed`,deleted:`deleted`},u={...s,completed:`✓`,deleted:s.failed},d={...c,deleted:`error`},f=1e3,p=/^working:\s*/i;function m(e){return e?.replace(p,``).trim()||void 0}const h={upsert:`✎`,delete:`×`,get:`›`,list:`☰`,clear:`∅`,assign:`⇒`,cancel:`⊗`};function g(e){return e.length===0?h.upsert:e.every(e=>e.id===void 0)?`+`:e.every(e=>e.id!==void 0)?`→`:h.upsert}function _(e,t){return t.fg(d[e],u[e])}function v(e){let t=Math.max(0,Math.floor(e/1e3)),n=t%60,r=Math.floor(t/60);if(r<60)return r===0?`${n}s`:`${r}m${String(n).padStart(2,`0`)}s`;let i=r%60;return`${Math.floor(r/60)}h${String(i).padStart(2,`0`)}m${String(n).padStart(2,`0`)}s`}function y(e){let t=Math.max(0,Math.round(e));return t<f?String(t):t<1e4?`${(t/f).toFixed(1)}k`:`${Math.round(t/f)}k`}function b(t,n,r,a,o=Date.now(),s){let c=t.status===`in_progress`?`accent`:t.status===`completed`||t.status===`deleted`?`muted`:`text`,l=n.fg(c,t.subject);(t.status===`completed`||t.status===`deleted`)&&(l=n.strikethrough(l));let u=_(t.status,n);r&&(u+=` ${n.fg(`dim`,`#${t.id}`)}`),u+=` ${l}`;let d=t.delegation?.agent;if(d&&t.delegation?.state===`running`){let r=[];a&&(r.push(n.fg(`muted`,`[${v(e.elapsedMs(a,o))}]`)),a.tokens!==void 0&&r.push(n.fg(`muted`,`[${y(a.tokens)}]`)));let c=t.delegation.runId??t.delegation.requestId;r.push(n.fg(s??i(c),`[${d}]`)),u+=` ${r.join(``)}`;let l=m(a?.currentTool);l&&(u+=` ${n.fg(`muted`,`· ${l}`)}`)}else d&&(u+=` ${n.fg(`muted`,`[${d}]`)}`);return t.status===`in_progress`&&t.activeForm&&(u+=` ${n.fg(`muted`,`(${t.activeForm})`)}`),t.blockedBy?.length&&(u+=` ${n.fg(`muted`,`⛓ ${t.blockedBy.map(e=>`#${e}`).join(`,`)}`)}`),u}function x(e,t){let n=e.status===`in_progress`&&e.activeForm?` (${e.activeForm})`:``,r=e.delegation?.agent?` [${e.delegation.agent}]`:``,i=e.blockedBy?.length?` ⛓ ${e.blockedBy.map(e=>`#${e}`).join(`,`)}`:``;return` ${t} #${e.id} ${e.subject}${n}${r}${i}`}function S(e,t,n){let r=e.action===`upsert`?e.tasks??[]:[],i=e.action===`upsert`?g(r):h[e.action]??e.action,s=o(`task`,`${i} ${e.action}`,t);if(e.action===`upsert`){if(r.length===1){let e=r[0];if(e.id===void 0)e.subject&&(s+=` ${t.fg(`dim`,e.subject)}`);else{let r=n.find(t=>t.id===e.id)?.subject??e.subject??`#${e.id}`;s+=` ${t.fg(`accent`,r)}`}}else r.length>1&&(s+=` ${t.fg(`dim`,`${r.length} tasks`)}`)}else if(e.action===`assign`){let r=e.assignments??[];if(r.length===1){let e=r[0],i=n.find(t=>t.id===e.id)?.subject??`#${e.id}`;s+=` ${t.fg(`accent`,i)}`,e.agent&&(s+=` ${t.fg(`muted`,`→ ${e.agent}`)}`)}else r.length>1&&(s+=` ${t.fg(`dim`,`${r.length} tasks`)}`)}else if((e.action===`get`||e.action===`delete`||e.action===`cancel`)&&e.id!==void 0){let r=n.find(t=>t.id===e.id)?.subject??`#${e.id}`;s+=` ${t.fg(`accent`,r)}`}else e.action===`list`&&e.status&&(s+=` ${t.fg(`muted`,l[e.status])}`);return new a(s)}var C=class{rows;constructor(e){this.rows=e}invalidate(){}render(e){return this.rows.map(({left:t,right:i})=>{if(i===void 0||i.length===0)return n(t,e);let a=r(i),o=e-a-2;if(o<=0)return n(t,e);let s=n(t,o),c=Math.max(2,e-r(s)-a);return s+` `.repeat(c)+i})}},w=class{content;theme;constructor(e,t){this.content=e,this.theme=t}render(e){if(e<=0)return[];if(e<3)return this.content.render(e);let t=e-2,n=this.theme.fg(`borderMuted`,`─`.repeat(t)),r=this.content.render(t).map(e=>` ${e}`);return[` ${n}`,...r,``]}invalidate(){this.content.invalidate()}};function T(e){return(e.content??[]).map(e=>e.text??``).join(``)}function E(e){return e.split(`
|
|
2
|
+
`).filter(e=>e.trim().length>0)}function D(e){let t=e.params,n=e.tasks;return t.includeDeleted!==!0&&(n=n.filter(e=>e.status!==`deleted`)),t.status&&(n=n.filter(e=>e.status===t.status)),n}function O(e){let t=e.params;if(t.id!==void 0)return e.tasks.find(e=>e.id===t.id)}function k(e){return(e.upsert?.applied??[]).flatMap(t=>e.tasks.find(e=>e.id===t)??[])}function A(e){return(e.assignment?.assigned??[]).flatMap(t=>e.tasks.find(e=>e.id===t)??[])}function j(e,n,r){let i=e.details;if(n.isPartial){let n=E(T(e)).at(-1)??`working`;return new t(r.fg(`warning`,`◐`)+r.fg(`dim`,` ${n}`),0,0)}if(e.isError===!0||i?.error!==void 0){let a=E(i?.error??T(e));if(a.length<=1)return new t(r.fg(`error`,`✗`)+r.fg(`dim`,a[0]?` ${a[0]}`:``),0,0);let o=n.expanded?a:a.slice(0,8);return new t([...o.map(e=>r.fg(`toolOutput`,e)),r.fg(`error`,`✗`)].join(`
|
|
3
|
+
`),0,0)}if(!i)return new t(r.fg(`success`,`✓`),0,0);let a=e=>({left:b(e,r,!0),right:r.fg(c[e.status],l[e.status])});if(i.action===`list`){let e=D(i),t=n.expanded?e:e.slice(0,8),o=t.map(a),s=e.length===0?`no tasks`:`${e.length} task${e.length===1?``:`s`}`;return e.length>t.length&&(s+=` · ctrl+o`),o.push({left:r.fg(`success`,`✓`)+r.fg(`dim`,` ${s}`)}),new C(o)}if(i.action===`clear`)return new t(r.fg(`success`,`✓`)+r.fg(`dim`,` cleared`),0,0);if(i.action===`assign`&&i.assignment){let e=A(i),t=i.assignment.failed;if(e.length===1&&t===0)return new C([a(e[0])]);let o=n.expanded?e:e.slice(0,8),s=o.map(a),c=`${e.length} assigned`;t>0&&(c+=` · ${t} failed`),e.length>o.length&&(c+=` · ctrl+o`);let l=t>0?r.fg(`warning`,`!`):r.fg(`success`,`✓`);return s.push({left:l+r.fg(`dim`,` ${c}`)}),new C(s)}if(i.action===`upsert`){let e=k(i),t=i.upsert?.failed??0;if(e.length===1&&t===0)return new C([a(e[0])]);let o=n.expanded?e:e.slice(0,8),s=o.map(a),c=`${e.length} applied`;t>0&&(c+=` · ${t} failed`),e.length>o.length&&(c+=` · ctrl+o`);let l=t>0?r.fg(`warning`,`!`):r.fg(`success`,`✓`);return s.push({left:l+r.fg(`dim`,` ${c}`)}),new C(s)}let o=O(i);return o?new C([a(o)]):new t(r.fg(`success`,`✓`),0,0)}function M(e,t,n){return new w(j(e,t,n),n)}export{h as ACTION_GLYPH,C as JustifiedRows,c as STATUS_COLOR,s as STATUS_GLYPH,l as STATUS_LABEL,x as formatCommandTaskLine,v as formatElapsedMs,b as formatOverlayTaskLine,y as formatTokenCount,_ as overlayStatusGlyph,S as renderTaskCall,M as renderTaskResult};
|
|
4
4
|
//# sourceMappingURL=format.mjs.map
|
package/dist/tui/format.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.mjs","names":[],"sources":["../../src/tui/format.ts"],"sourcesContent":["import { agentIdentityColor } from '@agimon-ai/doompi-ui/theme';\nimport { DoomToolCall, renderToolHeading } from '@agimon-ai/doompi-ui/toolChrome';\nimport type { Theme } from '@earendil-works/pi-coding-agent';\nimport { type Component, Text, truncateToWidth, visibleWidth } from '@earendil-works/pi-tui';\nimport { DelegationManager, type DelegationProgress } from '../services/delegation/manager.ts';\nimport type {\n Task,\n TaskAction,\n TaskDetails,\n TaskItemMutation,\n TaskMutationParams,\n TaskStatus,\n} from '../services/store/types.ts';\n\nexport const STATUS_GLYPH: Record<TaskStatus, string> = {\n pending: '○',\n in_progress: '◐',\n completed: '●',\n failed: '✗',\n deleted: '⊘',\n};\n\ntype TaskStatusColor = 'dim' | 'warning' | 'success' | 'error' | 'muted';\n\nexport const STATUS_COLOR: Record<TaskStatus, TaskStatusColor> = {\n pending: 'dim',\n in_progress: 'warning',\n completed: 'success',\n failed: 'error',\n deleted: 'muted',\n};\n\nexport const STATUS_LABEL: Record<TaskStatus, string> = {\n pending: 'pending',\n in_progress: 'in progress',\n completed: 'completed',\n failed: 'failed',\n deleted: 'deleted',\n};\n\nconst OVERLAY_STATUS_GLYPH: Record<TaskStatus, string> = {\n ...STATUS_GLYPH,\n completed: '✓',\n deleted: STATUS_GLYPH.failed,\n};\n\nconst OVERLAY_STATUS_COLOR: Record<TaskStatus, TaskStatusColor> = {\n ...STATUS_COLOR,\n deleted: 'error',\n};\nconst MILLISECONDS_PER_SECOND = 1000;\nconst SECONDS_PER_MINUTE = 60;\nconst MINUTES_PER_HOUR = 60;\nconst TOKENS_PER_KILO = 1000;\nconst TOKEN_DECIMAL_LIMIT = 10_000;\nconst REDUNDANT_WORKING_PREFIX = /^working:\\s*/i;\n\n/** Thinking text already communicates activity; keep only its useful content. */\nfunction progressText(currentTool: string | undefined): string | undefined {\n const text = currentTool?.replace(REDUNDANT_WORKING_PREFIX, '').trim();\n return text || undefined;\n}\n\nexport const ACTION_GLYPH: Record<TaskAction, string> = {\n upsert: '✎',\n delete: '×',\n get: '›',\n list: '☰',\n clear: '∅',\n assign: '⇒',\n cancel: '⊗',\n};\n\n/**\n * `upsert` is two operations behind one name, so a homogeneous batch narrows to\n * the glyph the operator already reads: `+` means new work appeared, `→` means\n * work moved. A mixed batch keeps the neutral write glyph.\n */\nconst UPSERT_CREATE_GLYPH = '+';\nconst UPSERT_UPDATE_GLYPH = '→';\n\nfunction upsertGlyph(items: readonly TaskItemMutation[]): string {\n if (items.length === 0) return ACTION_GLYPH.upsert;\n if (items.every((item) => item.id === undefined)) return UPSERT_CREATE_GLYPH;\n if (items.every((item) => item.id !== undefined)) return UPSERT_UPDATE_GLYPH;\n return ACTION_GLYPH.upsert;\n}\n\nexport function overlayStatusGlyph(status: TaskStatus, theme: Theme): string {\n return theme.fg(OVERLAY_STATUS_COLOR[status], OVERLAY_STATUS_GLYPH[status]);\n}\n\nexport function formatElapsedMs(durationMs: number): string {\n const totalSeconds = Math.max(0, Math.floor(durationMs / MILLISECONDS_PER_SECOND));\n const seconds = totalSeconds % SECONDS_PER_MINUTE;\n const totalMinutes = Math.floor(totalSeconds / SECONDS_PER_MINUTE);\n if (totalMinutes < MINUTES_PER_HOUR) {\n return totalMinutes === 0 ? `${seconds}s` : `${totalMinutes}m${String(seconds).padStart(2, '0')}s`;\n }\n const minutes = totalMinutes % MINUTES_PER_HOUR;\n const hours = Math.floor(totalMinutes / MINUTES_PER_HOUR);\n return `${hours}h${String(minutes).padStart(2, '0')}m${String(seconds).padStart(2, '0')}s`;\n}\n\nexport function formatTokenCount(tokens: number): string {\n const count = Math.max(0, Math.round(tokens));\n if (count < TOKENS_PER_KILO) return String(count);\n if (count < TOKEN_DECIMAL_LIMIT) return `${(count / TOKENS_PER_KILO).toFixed(1)}k`;\n return `${Math.round(count / TOKENS_PER_KILO)}k`;\n}\n\n/**\n * One task row for the persistent overlay.\n *\n * A delegated row carries the agent name and its current tool so the operator\n * can see that background work is progressing without opening a transcript.\n */\nexport function formatOverlayTaskLine(\n task: Task,\n theme: Theme,\n showId: boolean,\n progress?: DelegationProgress,\n nowMs = Date.now(),\n agentColor?: Parameters<Theme['fg']>[0],\n): string {\n const subjectColor =\n task.status === 'in_progress'\n ? 'accent'\n : task.status === 'completed' || task.status === 'deleted'\n ? 'muted'\n : 'text';\n let subject = theme.fg(subjectColor, task.subject);\n if (task.status === 'completed' || task.status === 'deleted') {\n subject = theme.strikethrough(subject);\n }\n\n let line = overlayStatusGlyph(task.status, theme);\n if (showId) line += ` ${theme.fg('dim', `#${task.id}`)}`;\n line += ` ${subject}`;\n\n const agent = task.delegation?.agent;\n if (agent && task.delegation?.state === 'running') {\n // No progress means no timing is known, so the chips are omitted rather than\n // reported as `[0s]`. The transcript renderer has no progress feed at all.\n const chips: string[] = [];\n if (progress) {\n chips.push(theme.fg('muted', `[${formatElapsedMs(DelegationManager.elapsedMs(progress, nowMs))}]`));\n if (progress.tokens !== undefined) chips.push(theme.fg('muted', `[${formatTokenCount(progress.tokens)}]`));\n }\n const identity = task.delegation.runId ?? task.delegation.requestId;\n chips.push(theme.fg(agentColor ?? agentIdentityColor(identity), `[${agent}]`));\n line += ` ${chips.join('')}`;\n const activity = progressText(progress?.currentTool);\n if (activity) line += ` ${theme.fg('muted', `· ${activity}`)}`;\n } else if (agent) {\n line += ` ${theme.fg('muted', `[${agent}]`)}`;\n }\n\n if (task.status === 'in_progress' && task.activeForm) {\n line += ` ${theme.fg('muted', `(${task.activeForm})`)}`;\n }\n if (task.blockedBy?.length) {\n line += ` ${theme.fg('muted', `⛓ ${task.blockedBy.map((id) => `#${id}`).join(',')}`)}`;\n }\n return line;\n}\n\n/** One task line for the `/tasks` command output. */\nexport function formatCommandTaskLine(task: Task, glyph: string): string {\n const form = task.status === 'in_progress' && task.activeForm ? ` (${task.activeForm})` : '';\n const agent = task.delegation?.agent ? ` [${task.delegation.agent}]` : '';\n const block = task.blockedBy?.length ? ` ⛓ ${task.blockedBy.map((id) => `#${id}`).join(',')}` : '';\n return ` ${glyph} #${task.id} ${task.subject}${form}${agent}${block}`;\n}\n\nexport function renderTaskCall(\n args: TaskMutationParams & { action: TaskAction },\n theme: Theme,\n tasks: readonly Task[],\n): Component {\n const items = args.action === 'upsert' ? (args.tasks ?? []) : [];\n const glyph = args.action === 'upsert' ? upsertGlyph(items) : (ACTION_GLYPH[args.action] ?? args.action);\n let text = renderToolHeading('task', `${glyph} ${args.action}`, theme);\n\n if (args.action === 'upsert') {\n // One entry reads exactly as create or update did; a batch reads as a count\n // rather than a subject it would have to pick arbitrarily.\n if (items.length === 1) {\n const only = items[0];\n if (only.id === undefined) {\n if (only.subject) text += ` ${theme.fg('dim', only.subject)}`;\n } else {\n const subject = tasks.find((task) => task.id === only.id)?.subject ?? only.subject ?? `#${only.id}`;\n text += ` ${theme.fg('accent', subject)}`;\n }\n } else if (items.length > 1) {\n text += ` ${theme.fg('dim', `${items.length} tasks`)}`;\n }\n } else if (args.action === 'assign' && args.id !== undefined) {\n const subject = tasks.find((task) => task.id === args.id)?.subject ?? `#${args.id}`;\n text += ` ${theme.fg('accent', subject)}`;\n if (args.agent) text += ` ${theme.fg('muted', `→ ${args.agent}`)}`;\n } else if ((args.action === 'get' || args.action === 'delete' || args.action === 'cancel') && args.id !== undefined) {\n const subject = tasks.find((task) => task.id === args.id)?.subject ?? `#${args.id}`;\n text += ` ${theme.fg('accent', subject)}`;\n } else if (args.action === 'list' && args.status) {\n text += ` ${theme.fg('muted', STATUS_LABEL[args.status])}`;\n }\n return new DoomToolCall(text);\n}\n\n/** Task rows kept in a collapsed result, before `ctrl+o` reveals the rest. */\nconst TRANSCRIPT_TASK_ROWS = 8;\n/** Minimum gap between a row's subject and its right-aligned status. */\nconst STATUS_GUTTER = 2;\n\nexport interface JustifiedRow {\n left: string;\n /** Pinned to the right edge. The subject is truncated before this is dropped. */\n right?: string;\n}\n\n/**\n * Rows whose trailing text is flushed right.\n *\n * `Text` cannot do this: the status has to be placed against the viewport edge,\n * which is only known at render time.\n */\nexport class JustifiedRows implements Component {\n constructor(private readonly rows: readonly JustifiedRow[]) {}\n\n /**\n * Nothing to discard: the rows are themed by the caller and held verbatim, and\n * Pi rebuilds this component from `renderResult` whenever the theme changes.\n */\n invalidate(): void {}\n\n render(width: number): string[] {\n return this.rows.map(({ left, right }) => {\n if (right === undefined || right.length === 0) return truncateToWidth(left, width);\n const rightWidth = visibleWidth(right);\n const room = width - rightWidth - STATUS_GUTTER;\n if (room <= 0) return truncateToWidth(left, width);\n const subject = truncateToWidth(left, room);\n const gap = Math.max(STATUS_GUTTER, width - visibleWidth(subject) - rightWidth);\n return subject + ' '.repeat(gap) + right;\n });\n }\n}\n\n/**\n * Self-owned task shell with the same structural divider as the bash tool.\n *\n * Task rows already carry precise per-task state, so the divider stays neutral\n * instead of competing with or appearing to animate between those states.\n */\nclass TaskResultFrame implements Component {\n constructor(\n private readonly content: Component,\n private readonly theme: Theme,\n ) {}\n\n render(width: number): string[] {\n if (width <= 0) return [];\n if (width < 3) return this.content.render(width);\n\n const contentWidth = width - 2;\n const divider = this.theme.fg('borderMuted', '─'.repeat(contentWidth));\n const lines = this.content.render(contentWidth).map((line) => ` ${line}`);\n return [` ${divider}`, ...lines, ''];\n }\n\n invalidate(): void {\n this.content.invalidate();\n }\n}\n\nexport interface TaskResultLike {\n content?: Array<{ type: string; text?: string }>;\n details?: unknown;\n isError?: boolean;\n}\n\nexport interface TaskResultOptions {\n expanded: boolean;\n isPartial: boolean;\n}\n\n/** Concatenated result text, which is all a thrown failure leaves behind. */\nfunction contentText(result: TaskResultLike): string {\n return (result.content ?? []).map((block) => block.text ?? '').join('');\n}\n\nfunction nonEmptyLines(text: string): string[] {\n return text.split('\\n').filter((line) => line.trim().length > 0);\n}\n\n/**\n * The rows `list` reported to the model.\n *\n * `details.tasks` is the whole post-mutation document, so the filters applied by\n * `formatContent` have to be applied again here or the transcript would disagree\n * with the text the model was given.\n */\nfunction listedTasks(details: TaskDetails): Task[] {\n const params = details.params as TaskMutationParams;\n let view = details.tasks;\n if (params.includeDeleted !== true) view = view.filter((task) => task.status !== 'deleted');\n if (params.status) view = view.filter((task) => task.status === params.status);\n return view;\n}\n\n/** The single task an id-bearing action acted on, so the transcript names it rather than a bare tick. */\nfunction subjectTask(details: TaskDetails): Task | undefined {\n const params = details.params as TaskMutationParams;\n if (params.id === undefined) return undefined;\n return details.tasks.find((task) => task.id === params.id);\n}\n\n/**\n * Tasks an upsert applied, resolved from the ids the reducer reported.\n *\n * The ids are read rather than guessed from the tail of the list: a batch\n * touches many rows, and a failed entry contributes none.\n */\nfunction upsertTasks(details: TaskDetails): Task[] {\n return (details.upsert?.applied ?? []).flatMap((id) => details.tasks.find((task) => task.id === id) ?? []);\n}\n\nfunction renderTaskResultBody(result: TaskResultLike, options: TaskResultOptions, theme: Theme): Component {\n const details = result.details as TaskDetails | undefined;\n\n // Running. `assign` and `cancel` stream a placeholder before the run settles.\n if (options.isPartial) {\n const text = nonEmptyLines(contentText(result)).at(-1) ?? 'working';\n return new Text(theme.fg('warning', '◐') + theme.fg('dim', ` ${text}`), 0, 0);\n }\n\n // Failed. Every failure path throws, so Pi hands back error text and no\n // details; without this the block would render a green tick on a failure.\n if (result.isError === true || details?.error !== undefined) {\n const message = details?.error ?? contentText(result);\n const all = nonEmptyLines(message);\n if (all.length <= 1) {\n return new Text(theme.fg('error', '✗') + theme.fg('dim', all[0] ? ` ${all[0]}` : ''), 0, 0);\n }\n const body = options.expanded ? all : all.slice(0, TRANSCRIPT_TASK_ROWS);\n return new Text([...body.map((line) => theme.fg('toolOutput', line)), theme.fg('error', '✗')].join('\\n'), 0, 0);\n }\n\n if (!details) return new Text(theme.fg('success', '✓'), 0, 0);\n\n /** Status rides on the task's own row, flushed right, rather than costing a line. */\n const row = (task: Task): JustifiedRow => ({\n left: formatOverlayTaskLine(task, theme, true),\n right: theme.fg(STATUS_COLOR[task.status], STATUS_LABEL[task.status]),\n });\n\n if (details.action === 'list') {\n const tasks = listedTasks(details);\n const shown = options.expanded ? tasks : tasks.slice(0, TRANSCRIPT_TASK_ROWS);\n const rows: JustifiedRow[] = shown.map(row);\n let summary = tasks.length === 0 ? 'no tasks' : `${tasks.length} task${tasks.length === 1 ? '' : 's'}`;\n if (tasks.length > shown.length) summary += ' · ctrl+o';\n rows.push({ left: theme.fg('success', '✓') + theme.fg('dim', ` ${summary}`) });\n return new JustifiedRows(rows);\n }\n\n if (details.action === 'clear') {\n return new Text(theme.fg('success', '✓') + theme.fg('dim', ' cleared'), 0, 0);\n }\n\n if (details.action === 'upsert') {\n const touched = upsertTasks(details);\n const failed = details.upsert?.failed ?? 0;\n // One applied task and nothing failed is the common case: keep the single\n // row it has always had rather than dressing it as a bulk report.\n if (touched.length === 1 && failed === 0) return new JustifiedRows([row(touched[0])]);\n\n const shown = options.expanded ? touched : touched.slice(0, TRANSCRIPT_TASK_ROWS);\n const rows: JustifiedRow[] = shown.map(row);\n let summary = `${touched.length} applied`;\n if (failed > 0) summary += ` · ${failed} failed`;\n if (touched.length > shown.length) summary += ' · ctrl+o';\n // Failed entries get no row: there is no task to render, and their messages\n // are already in the text the model was given.\n const mark = failed > 0 ? theme.fg('warning', '!') : theme.fg('success', '✓');\n rows.push({ left: mark + theme.fg('dim', ` ${summary}`) });\n return new JustifiedRows(rows);\n }\n\n const task = subjectTask(details);\n if (!task) return new Text(theme.fg('success', '✓'), 0, 0);\n return new JustifiedRows([row(task)]);\n}\n\nexport function renderTaskResult(result: TaskResultLike, options: TaskResultOptions, theme: Theme): Component {\n return new TaskResultFrame(renderTaskResultBody(result, options, theme), theme);\n}\n"],"mappings":"kTAcA,MAAa,EAA2C,CACtD,QAAS,IACT,YAAa,IACb,UAAW,IACX,OAAQ,IACR,QAAS,GACX,EAIa,EAAoD,CAC/D,QAAS,MACT,YAAa,UACb,UAAW,UACX,OAAQ,QACR,QAAS,OACX,EAEa,EAA2C,CACtD,QAAS,UACT,YAAa,cACb,UAAW,YACX,OAAQ,SACR,QAAS,SACX,EAEM,EAAmD,CACvD,GAAG,EACH,UAAW,IACX,QAAS,EAAa,MACxB,EAEM,EAA4D,CAChE,GAAG,EACH,QAAS,OACX,EAIM,EAAkB,IAElB,EAA2B,gBAGjC,SAAS,EAAa,EAAqD,CAEzE,OADa,GAAa,QAAQ,EAA0B,EAAE,CAAC,CAAC,KAAK,GACtD,IAAA,EACjB,CAEA,MAAa,EAA2C,CACtD,OAAQ,IACR,OAAQ,IACR,IAAK,IAC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EAAc,CAAC,EAAI,EAAQ,EAAE,CAAC,CAAC,EAEpF,IAAM,EAAQ,EAAQ,SAAW,EAAU,EAAQ,MAAM,EAAG,CAAoB,EAC1E,EAAuB,EAAM,IAAI,CAAG,EACtC,EAAU,GAAG,EAAQ,OAAO,UAC5B,EAAS,IAAG,GAAW,MAAM,EAAO,UACpC,EAAQ,OAAS,EAAM,SAAQ,GAAW,aAG9C,IAAM,EAAO,EAAS,EAAI,EAAM,GAAG,UAAW,GAAG,EAAI,EAAM,GAAG,UAAW,GAAG,EAE5E,OADA,EAAK,KAAK,CAAE,KAAM,EAAO,EAAM,GAAG,MAAO,IAAI,GAAS,CAAE,CAAC,EAClD,IAAI,EAAc,CAAI,CAC/B,CAEA,IAAM,EAAO,EAAY,CAAO,EAEhC,OADK,EACE,IAAI,EAAc,CAAC,EAAI,CAAI,CAAC,CAAC,EADlB,IAAI,EAAK,EAAM,GAAG,UAAW,GAAG,EAAG,EAAG,CAAC,CAE3D,CAEA,SAAgB,EAAiB,EAAwB,EAA4B,EAAyB,CAC5G,OAAO,IAAI,EAAgB,EAAqB,EAAQ,EAAS,CAAK,EAAG,CAAK,CAChF"}
|
|
1
|
+
{"version":3,"file":"format.mjs","names":[],"sources":["../../src/tui/format.ts"],"sourcesContent":["import { agentIdentityColor } from '@agimon-ai/doompi-ui/theme';\nimport { DoomToolCall, renderToolHeading } from '@agimon-ai/doompi-ui/toolChrome';\nimport type { Theme } from '@earendil-works/pi-coding-agent';\nimport { type Component, Text, truncateToWidth, visibleWidth } from '@earendil-works/pi-tui';\nimport { DelegationManager, type DelegationProgress } from '../services/delegation/manager.ts';\nimport type {\n Task,\n TaskAction,\n TaskDetails,\n TaskItemMutation,\n TaskMutationParams,\n TaskStatus,\n} from '../services/store/types.ts';\n\nexport const STATUS_GLYPH: Record<TaskStatus, string> = {\n pending: '○',\n in_progress: '◐',\n completed: '●',\n failed: '✗',\n deleted: '⊘',\n};\n\ntype TaskStatusColor = 'dim' | 'warning' | 'success' | 'error' | 'muted';\n\nexport const STATUS_COLOR: Record<TaskStatus, TaskStatusColor> = {\n pending: 'dim',\n in_progress: 'warning',\n completed: 'success',\n failed: 'error',\n deleted: 'muted',\n};\n\nexport const STATUS_LABEL: Record<TaskStatus, string> = {\n pending: 'pending',\n in_progress: 'in progress',\n completed: 'completed',\n failed: 'failed',\n deleted: 'deleted',\n};\n\nconst OVERLAY_STATUS_GLYPH: Record<TaskStatus, string> = {\n ...STATUS_GLYPH,\n completed: '✓',\n deleted: STATUS_GLYPH.failed,\n};\n\nconst OVERLAY_STATUS_COLOR: Record<TaskStatus, TaskStatusColor> = {\n ...STATUS_COLOR,\n deleted: 'error',\n};\nconst MILLISECONDS_PER_SECOND = 1000;\nconst SECONDS_PER_MINUTE = 60;\nconst MINUTES_PER_HOUR = 60;\nconst TOKENS_PER_KILO = 1000;\nconst TOKEN_DECIMAL_LIMIT = 10_000;\nconst REDUNDANT_WORKING_PREFIX = /^working:\\s*/i;\n\n/** Thinking text already communicates activity; keep only its useful content. */\nfunction progressText(currentTool: string | undefined): string | undefined {\n const text = currentTool?.replace(REDUNDANT_WORKING_PREFIX, '').trim();\n return text || undefined;\n}\n\nexport const ACTION_GLYPH: Record<TaskAction, string> = {\n upsert: '✎',\n delete: '×',\n get: '›',\n list: '☰',\n clear: '∅',\n assign: '⇒',\n cancel: '⊗',\n};\n\n/**\n * `upsert` is two operations behind one name, so a homogeneous batch narrows to\n * the glyph the operator already reads: `+` means new work appeared, `→` means\n * work moved. A mixed batch keeps the neutral write glyph.\n */\nconst UPSERT_CREATE_GLYPH = '+';\nconst UPSERT_UPDATE_GLYPH = '→';\n\nfunction upsertGlyph(items: readonly TaskItemMutation[]): string {\n if (items.length === 0) return ACTION_GLYPH.upsert;\n if (items.every((item) => item.id === undefined)) return UPSERT_CREATE_GLYPH;\n if (items.every((item) => item.id !== undefined)) return UPSERT_UPDATE_GLYPH;\n return ACTION_GLYPH.upsert;\n}\n\nexport function overlayStatusGlyph(status: TaskStatus, theme: Theme): string {\n return theme.fg(OVERLAY_STATUS_COLOR[status], OVERLAY_STATUS_GLYPH[status]);\n}\n\nexport function formatElapsedMs(durationMs: number): string {\n const totalSeconds = Math.max(0, Math.floor(durationMs / MILLISECONDS_PER_SECOND));\n const seconds = totalSeconds % SECONDS_PER_MINUTE;\n const totalMinutes = Math.floor(totalSeconds / SECONDS_PER_MINUTE);\n if (totalMinutes < MINUTES_PER_HOUR) {\n return totalMinutes === 0 ? `${seconds}s` : `${totalMinutes}m${String(seconds).padStart(2, '0')}s`;\n }\n const minutes = totalMinutes % MINUTES_PER_HOUR;\n const hours = Math.floor(totalMinutes / MINUTES_PER_HOUR);\n return `${hours}h${String(minutes).padStart(2, '0')}m${String(seconds).padStart(2, '0')}s`;\n}\n\nexport function formatTokenCount(tokens: number): string {\n const count = Math.max(0, Math.round(tokens));\n if (count < TOKENS_PER_KILO) return String(count);\n if (count < TOKEN_DECIMAL_LIMIT) return `${(count / TOKENS_PER_KILO).toFixed(1)}k`;\n return `${Math.round(count / TOKENS_PER_KILO)}k`;\n}\n\n/**\n * One task row for the persistent overlay.\n *\n * A delegated row carries the agent name and its current tool so the operator\n * can see that background work is progressing without opening a transcript.\n */\nexport function formatOverlayTaskLine(\n task: Task,\n theme: Theme,\n showId: boolean,\n progress?: DelegationProgress,\n nowMs = Date.now(),\n agentColor?: Parameters<Theme['fg']>[0],\n): string {\n const subjectColor =\n task.status === 'in_progress'\n ? 'accent'\n : task.status === 'completed' || task.status === 'deleted'\n ? 'muted'\n : 'text';\n let subject = theme.fg(subjectColor, task.subject);\n if (task.status === 'completed' || task.status === 'deleted') {\n subject = theme.strikethrough(subject);\n }\n\n let line = overlayStatusGlyph(task.status, theme);\n if (showId) line += ` ${theme.fg('dim', `#${task.id}`)}`;\n line += ` ${subject}`;\n\n const agent = task.delegation?.agent;\n if (agent && task.delegation?.state === 'running') {\n // No progress means no timing is known, so the chips are omitted rather than\n // reported as `[0s]`. The transcript renderer has no progress feed at all.\n const chips: string[] = [];\n if (progress) {\n chips.push(theme.fg('muted', `[${formatElapsedMs(DelegationManager.elapsedMs(progress, nowMs))}]`));\n if (progress.tokens !== undefined) chips.push(theme.fg('muted', `[${formatTokenCount(progress.tokens)}]`));\n }\n const identity = task.delegation.runId ?? task.delegation.requestId;\n chips.push(theme.fg(agentColor ?? agentIdentityColor(identity), `[${agent}]`));\n line += ` ${chips.join('')}`;\n const activity = progressText(progress?.currentTool);\n if (activity) line += ` ${theme.fg('muted', `· ${activity}`)}`;\n } else if (agent) {\n line += ` ${theme.fg('muted', `[${agent}]`)}`;\n }\n\n if (task.status === 'in_progress' && task.activeForm) {\n line += ` ${theme.fg('muted', `(${task.activeForm})`)}`;\n }\n if (task.blockedBy?.length) {\n line += ` ${theme.fg('muted', `⛓ ${task.blockedBy.map((id) => `#${id}`).join(',')}`)}`;\n }\n return line;\n}\n\n/** One task line for the `/tasks` command output. */\nexport function formatCommandTaskLine(task: Task, glyph: string): string {\n const form = task.status === 'in_progress' && task.activeForm ? ` (${task.activeForm})` : '';\n const agent = task.delegation?.agent ? ` [${task.delegation.agent}]` : '';\n const block = task.blockedBy?.length ? ` ⛓ ${task.blockedBy.map((id) => `#${id}`).join(',')}` : '';\n return ` ${glyph} #${task.id} ${task.subject}${form}${agent}${block}`;\n}\n\nexport function renderTaskCall(\n args: TaskMutationParams & { action: TaskAction },\n theme: Theme,\n tasks: readonly Task[],\n): Component {\n const items = args.action === 'upsert' ? (args.tasks ?? []) : [];\n const glyph = args.action === 'upsert' ? upsertGlyph(items) : (ACTION_GLYPH[args.action] ?? args.action);\n let text = renderToolHeading('task', `${glyph} ${args.action}`, theme);\n\n if (args.action === 'upsert') {\n // One entry reads exactly as create or update did; a batch reads as a count\n // rather than a subject it would have to pick arbitrarily.\n if (items.length === 1) {\n const only = items[0];\n if (only.id === undefined) {\n if (only.subject) text += ` ${theme.fg('dim', only.subject)}`;\n } else {\n const subject = tasks.find((task) => task.id === only.id)?.subject ?? only.subject ?? `#${only.id}`;\n text += ` ${theme.fg('accent', subject)}`;\n }\n } else if (items.length > 1) {\n text += ` ${theme.fg('dim', `${items.length} tasks`)}`;\n }\n } else if (args.action === 'assign') {\n const assignments = args.assignments ?? [];\n if (assignments.length === 1) {\n const only = assignments[0];\n const subject = tasks.find((task) => task.id === only.id)?.subject ?? `#${only.id}`;\n text += ` ${theme.fg('accent', subject)}`;\n if (only.agent) text += ` ${theme.fg('muted', `→ ${only.agent}`)}`;\n } else if (assignments.length > 1) {\n text += ` ${theme.fg('dim', `${assignments.length} tasks`)}`;\n }\n } else if ((args.action === 'get' || args.action === 'delete' || args.action === 'cancel') && args.id !== undefined) {\n const subject = tasks.find((task) => task.id === args.id)?.subject ?? `#${args.id}`;\n text += ` ${theme.fg('accent', subject)}`;\n } else if (args.action === 'list' && args.status) {\n text += ` ${theme.fg('muted', STATUS_LABEL[args.status])}`;\n }\n return new DoomToolCall(text);\n}\n\n/** Task rows kept in a collapsed result, before `ctrl+o` reveals the rest. */\nconst TRANSCRIPT_TASK_ROWS = 8;\n/** Minimum gap between a row's subject and its right-aligned status. */\nconst STATUS_GUTTER = 2;\n\nexport interface JustifiedRow {\n left: string;\n /** Pinned to the right edge. The subject is truncated before this is dropped. */\n right?: string;\n}\n\n/**\n * Rows whose trailing text is flushed right.\n *\n * `Text` cannot do this: the status has to be placed against the viewport edge,\n * which is only known at render time.\n */\nexport class JustifiedRows implements Component {\n constructor(private readonly rows: readonly JustifiedRow[]) {}\n\n /**\n * Nothing to discard: the rows are themed by the caller and held verbatim, and\n * Pi rebuilds this component from `renderResult` whenever the theme changes.\n */\n invalidate(): void {}\n\n render(width: number): string[] {\n return this.rows.map(({ left, right }) => {\n if (right === undefined || right.length === 0) return truncateToWidth(left, width);\n const rightWidth = visibleWidth(right);\n const room = width - rightWidth - STATUS_GUTTER;\n if (room <= 0) return truncateToWidth(left, width);\n const subject = truncateToWidth(left, room);\n const gap = Math.max(STATUS_GUTTER, width - visibleWidth(subject) - rightWidth);\n return subject + ' '.repeat(gap) + right;\n });\n }\n}\n\n/**\n * Self-owned task shell with the same structural divider as the bash tool.\n *\n * Task rows already carry precise per-task state, so the divider stays neutral\n * instead of competing with or appearing to animate between those states.\n */\nclass TaskResultFrame implements Component {\n constructor(\n private readonly content: Component,\n private readonly theme: Theme,\n ) {}\n\n render(width: number): string[] {\n if (width <= 0) return [];\n if (width < 3) return this.content.render(width);\n\n const contentWidth = width - 2;\n const divider = this.theme.fg('borderMuted', '─'.repeat(contentWidth));\n const lines = this.content.render(contentWidth).map((line) => ` ${line}`);\n return [` ${divider}`, ...lines, ''];\n }\n\n invalidate(): void {\n this.content.invalidate();\n }\n}\n\nexport interface TaskResultLike {\n content?: Array<{ type: string; text?: string }>;\n details?: unknown;\n isError?: boolean;\n}\n\nexport interface TaskResultOptions {\n expanded: boolean;\n isPartial: boolean;\n}\n\n/** Concatenated result text, which is all a thrown failure leaves behind. */\nfunction contentText(result: TaskResultLike): string {\n return (result.content ?? []).map((block) => block.text ?? '').join('');\n}\n\nfunction nonEmptyLines(text: string): string[] {\n return text.split('\\n').filter((line) => line.trim().length > 0);\n}\n\n/**\n * The rows `list` reported to the model.\n *\n * `details.tasks` is the whole post-mutation document, so the filters applied by\n * `formatContent` have to be applied again here or the transcript would disagree\n * with the text the model was given.\n */\nfunction listedTasks(details: TaskDetails): Task[] {\n const params = details.params as TaskMutationParams;\n let view = details.tasks;\n if (params.includeDeleted !== true) view = view.filter((task) => task.status !== 'deleted');\n if (params.status) view = view.filter((task) => task.status === params.status);\n return view;\n}\n\n/** The single task an id-bearing action acted on, so the transcript names it rather than a bare tick. */\nfunction subjectTask(details: TaskDetails): Task | undefined {\n const params = details.params as TaskMutationParams;\n if (params.id === undefined) return undefined;\n return details.tasks.find((task) => task.id === params.id);\n}\n\n/**\n * Tasks an upsert applied, resolved from the ids the reducer reported.\n *\n * The ids are read rather than guessed from the tail of the list: a batch\n * touches many rows, and a failed entry contributes none.\n */\nfunction upsertTasks(details: TaskDetails): Task[] {\n return (details.upsert?.applied ?? []).flatMap((id) => details.tasks.find((task) => task.id === id) ?? []);\n}\n\n/** Tasks successfully handed off by a native assignment batch. */\nfunction assignedTasks(details: TaskDetails): Task[] {\n return (details.assignment?.assigned ?? []).flatMap((id) => details.tasks.find((task) => task.id === id) ?? []);\n}\n\nfunction renderTaskResultBody(result: TaskResultLike, options: TaskResultOptions, theme: Theme): Component {\n const details = result.details as TaskDetails | undefined;\n\n // Running. `assign` and `cancel` stream a placeholder before the run settles.\n if (options.isPartial) {\n const text = nonEmptyLines(contentText(result)).at(-1) ?? 'working';\n return new Text(theme.fg('warning', '◐') + theme.fg('dim', ` ${text}`), 0, 0);\n }\n\n // Failed. Every failure path throws, so Pi hands back error text and no\n // details; without this the block would render a green tick on a failure.\n if (result.isError === true || details?.error !== undefined) {\n const message = details?.error ?? contentText(result);\n const all = nonEmptyLines(message);\n if (all.length <= 1) {\n return new Text(theme.fg('error', '✗') + theme.fg('dim', all[0] ? ` ${all[0]}` : ''), 0, 0);\n }\n const body = options.expanded ? all : all.slice(0, TRANSCRIPT_TASK_ROWS);\n return new Text([...body.map((line) => theme.fg('toolOutput', line)), theme.fg('error', '✗')].join('\\n'), 0, 0);\n }\n\n if (!details) return new Text(theme.fg('success', '✓'), 0, 0);\n\n /** Status rides on the task's own row, flushed right, rather than costing a line. */\n const row = (task: Task): JustifiedRow => ({\n left: formatOverlayTaskLine(task, theme, true),\n right: theme.fg(STATUS_COLOR[task.status], STATUS_LABEL[task.status]),\n });\n\n if (details.action === 'list') {\n const tasks = listedTasks(details);\n const shown = options.expanded ? tasks : tasks.slice(0, TRANSCRIPT_TASK_ROWS);\n const rows: JustifiedRow[] = shown.map(row);\n let summary = tasks.length === 0 ? 'no tasks' : `${tasks.length} task${tasks.length === 1 ? '' : 's'}`;\n if (tasks.length > shown.length) summary += ' · ctrl+o';\n rows.push({ left: theme.fg('success', '✓') + theme.fg('dim', ` ${summary}`) });\n return new JustifiedRows(rows);\n }\n\n if (details.action === 'clear') {\n return new Text(theme.fg('success', '✓') + theme.fg('dim', ' cleared'), 0, 0);\n }\n\n if (details.action === 'assign' && details.assignment) {\n const assigned = assignedTasks(details);\n const failed = details.assignment.failed;\n if (assigned.length === 1 && failed === 0) return new JustifiedRows([row(assigned[0])]);\n\n const shown = options.expanded ? assigned : assigned.slice(0, TRANSCRIPT_TASK_ROWS);\n const rows: JustifiedRow[] = shown.map(row);\n let summary = `${assigned.length} assigned`;\n if (failed > 0) summary += ` · ${failed} failed`;\n if (assigned.length > shown.length) summary += ' · ctrl+o';\n const mark = failed > 0 ? theme.fg('warning', '!') : theme.fg('success', '✓');\n rows.push({ left: mark + theme.fg('dim', ` ${summary}`) });\n return new JustifiedRows(rows);\n }\n\n if (details.action === 'upsert') {\n const touched = upsertTasks(details);\n const failed = details.upsert?.failed ?? 0;\n // One applied task and nothing failed is the common case: keep the single\n // row it has always had rather than dressing it as a bulk report.\n if (touched.length === 1 && failed === 0) return new JustifiedRows([row(touched[0])]);\n\n const shown = options.expanded ? touched : touched.slice(0, TRANSCRIPT_TASK_ROWS);\n const rows: JustifiedRow[] = shown.map(row);\n let summary = `${touched.length} applied`;\n if (failed > 0) summary += ` · ${failed} failed`;\n if (touched.length > shown.length) summary += ' · ctrl+o';\n // Failed entries get no row: there is no task to render, and their messages\n // are already in the text the model was given.\n const mark = failed > 0 ? theme.fg('warning', '!') : theme.fg('success', '✓');\n rows.push({ left: mark + theme.fg('dim', ` ${summary}`) });\n return new JustifiedRows(rows);\n }\n\n const task = subjectTask(details);\n if (!task) return new Text(theme.fg('success', '✓'), 0, 0);\n return new JustifiedRows([row(task)]);\n}\n\nexport function renderTaskResult(result: TaskResultLike, options: TaskResultOptions, theme: Theme): Component {\n return new TaskResultFrame(renderTaskResultBody(result, options, theme), theme);\n}\n"],"mappings":"kTAcA,MAAa,EAA2C,CACtD,QAAS,IACT,YAAa,IACb,UAAW,IACX,OAAQ,IACR,QAAS,GACX,EAIa,EAAoD,CAC/D,QAAS,MACT,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