@dsh-cc/command-agents 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # @dsh-cc/command-agents
2
+
3
+ Human-facing `/agents` command for continuable background agents (plan
4
+ `docs/plans/2026-09-10-continuable-background-ux.md` §3.2, Slice 0 MVP).
5
+
6
+ ## Surface
7
+
8
+ - `/agents` — grouped list (Working / Idle / Ready; residency only — no
9
+ Blocked/Done groups), label-rendered rows, pin state incl. gate deny code.
10
+ - `/agents <id>` — thin detail: pin provenance (path, definition, model
11
+ selector, workspace, gate evaluation), residency, ids.
12
+ - `/agents stop <id>` — one interrupt request on a running child (the child
13
+ stays continuable/resumable); short no-op explanation otherwise.
14
+ - `/agents attach <id>` — namespace reserved, not implemented (P1).
15
+
16
+ ## Shared snapshot
17
+
18
+ `src/snapshot.ts` is a pure snapshot provider over injected services
19
+ (`subagents.listChildren` host-plane, `agents.get` registry, realm-interior
20
+ `resumePinStore`). The plugin mounts INSIDE the `cc-services` realm and
21
+ publishes the read-only `ccAgents` service on the ROOT context (CcPlugins
22
+ pattern), so the TUI local-slash path consumes the SAME snapshot. The preset
23
+ surface renders the thin detail only; the TUI adds fold-derived decorations
24
+ (provider/model, prompt excerpt, last stopReason) additively — the divergence
25
+ is deliberate and documented in the capability manifest.
package/lib/index.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Human-facing `/agents` command: list, inspect, and stop continuable
3
+ * background agents (plan docs/plans/2026-09-10-continuable-background-ux.md
4
+ * §3.2). Mounted INSIDE the `cc-services` realm (the pin store is
5
+ * realm-interior, F8); the read-only snapshot is ALSO published to the root
6
+ * realm as `ccAgents` so the TUI local-slash path — a host-plane sibling that
7
+ * cannot resolve realm-interior mounts — consumes the SAME snapshot
8
+ * (ccPlugins root-publication pattern).
9
+ * @module @dsh-cc/command-agents
10
+ */
11
+ import type { Context } from '@deepseek-ai/cordis';
12
+ export declare const name = "command-agents";
13
+ export declare const inject: string[];
14
+ /**
15
+ * Register the `/agents` command for every composed command adapter and
16
+ * publish the read-only `ccAgents` snapshot service on the ROOT context so
17
+ * host-plane siblings (the TUI local-slash path) consume the same snapshot.
18
+ * Mirrors the CcPluginsService publication: an unload effect clears the slot
19
+ * so consumers degrade to `undefined` instead of holding a dead service.
20
+ * @param ctx - context carrying the command registry, subagents registry,
21
+ * agents registry, and pin store.
22
+ */
23
+ export declare function apply(ctx: Context): void;
24
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAiBlD,eAAO,MAAM,IAAI,mBAAmB,CAAA;AACpC,eAAO,MAAM,MAAM,UAAwD,CAAA;AA8D3E;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CA+BxC"}
package/lib/index.js ADDED
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Human-facing `/agents` command: list, inspect, and stop continuable
3
+ * background agents (plan docs/plans/2026-09-10-continuable-background-ux.md
4
+ * §3.2). Mounted INSIDE the `cc-services` realm (the pin store is
5
+ * realm-interior, F8); the read-only snapshot is ALSO published to the root
6
+ * realm as `ccAgents` so the TUI local-slash path — a host-plane sibling that
7
+ * cannot resolve realm-interior mounts — consumes the SAME snapshot
8
+ * (ccPlugins root-publication pattern).
9
+ * @module @dsh-cc/command-agents
10
+ */
11
+ import { SessionId } from '@deepseek-ai/dsh-session';
12
+ import { buildAgentsSnapshot, parseAgentsInput, renderAgentDetail, renderAgentsList, stopNotRunningCopy, stopRunningCopy, unknownAgentCopy, } from "./snapshot.js";
13
+ export const name = 'command-agents';
14
+ export const inject = ['commands', 'subagents', 'agents', 'resumePinStore'];
15
+ /** Adapt the injected services to the pure snapshot seam. */
16
+ function toSnapshotServices(subagents, agents, pinStore) {
17
+ return {
18
+ listChildren: async (parentSessionId) => await subagents.listChildren(SessionId(parentSessionId)),
19
+ getAgent: id => agents.get(id),
20
+ readPin: childId => pinStore.read(childId),
21
+ pinPath: childId => pinStore.pathFor(childId),
22
+ };
23
+ }
24
+ /** Execute one parsed `/agents` invocation against the snapshot. */
25
+ async function executeAgents(snapshotServices, subagents, caller, rawInput) {
26
+ const parsed = parseAgentsInput(rawInput);
27
+ if (parsed.kind === 'error')
28
+ return { kind: 'error', text: parsed.text };
29
+ const parentSessionId = String(caller.session.id);
30
+ if (parsed.kind === 'stop') {
31
+ const rows = await buildAgentsSnapshot(snapshotServices, parentSessionId);
32
+ const row = rows.find(candidate => candidate.id === parsed.id);
33
+ if (row === undefined)
34
+ return { kind: 'error', text: unknownAgentCopy(parsed.id) };
35
+ if (row.residency !== 'running') {
36
+ return { kind: 'success', text: stopNotRunningCopy(parsed.id, row.residency) };
37
+ }
38
+ subagents.interrupt(SessionId(parsed.id), { kind: 'ancestor', agent: caller });
39
+ return { kind: 'success', text: stopRunningCopy(parsed.id) };
40
+ }
41
+ const rows = await buildAgentsSnapshot(snapshotServices, parentSessionId);
42
+ if (parsed.kind === 'list')
43
+ return { kind: 'success', text: renderAgentsList(rows) };
44
+ const row = rows.find(candidate => candidate.id === parsed.id);
45
+ if (row === undefined)
46
+ return { kind: 'error', text: unknownAgentCopy(parsed.id) };
47
+ return {
48
+ kind: 'success',
49
+ text: renderAgentDetail(row, snapshotServices.readPin(parsed.id), snapshotServices.pinPath(parsed.id), parentSessionId),
50
+ };
51
+ }
52
+ /**
53
+ * Register the `/agents` command for every composed command adapter and
54
+ * publish the read-only `ccAgents` snapshot service on the ROOT context so
55
+ * host-plane siblings (the TUI local-slash path) consume the same snapshot.
56
+ * Mirrors the CcPluginsService publication: an unload effect clears the slot
57
+ * so consumers degrade to `undefined` instead of holding a dead service.
58
+ * @param ctx - context carrying the command registry, subagents registry,
59
+ * agents registry, and pin store.
60
+ */
61
+ export function apply(ctx) {
62
+ const subagents = ctx.get('subagents');
63
+ const agents = ctx.get('agents');
64
+ const pinStore = ctx.get('resumePinStore');
65
+ const snapshotServices = toSnapshotServices(subagents, agents, pinStore);
66
+ const root = ctx.root;
67
+ const snapshotService = {
68
+ list: parentSessionId => buildAgentsSnapshot(snapshotServices, parentSessionId),
69
+ };
70
+ // First publication provides the name; a reclaim after an unload (or a
71
+ // stale sibling slot) takes the publication back via set — CcPlugins
72
+ // semantics.
73
+ if (root.get('ccAgents', false) === undefined) {
74
+ root.provide('ccAgents', snapshotService);
75
+ }
76
+ else {
77
+ root.set('ccAgents', snapshotService);
78
+ }
79
+ ctx.effect(() => () => {
80
+ if (root.get('ccAgents', false) === snapshotService)
81
+ root.set('ccAgents', undefined);
82
+ }, 'command-agents: clear host-realm ccAgents publication on unload');
83
+ ctx.commands.register({
84
+ name: 'agents',
85
+ description: 'list, inspect, or stop continuable background agents',
86
+ handler: (invocation) => executeAgents(snapshotServices, subagents, invocation.agent, invocation.rawInput),
87
+ });
88
+ }
89
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAIpD,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,GAGjB,MAAM,eAAe,CAAA;AAEtB,MAAM,CAAC,MAAM,IAAI,GAAG,gBAAgB,CAAA;AACpC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CAAA;AAkB3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ion for `@dsh-cc/command-agents`.
3
+ * @module @dsh-cc/command-agents/invariant
4
+ */
5
+ import type { Context } from '@deepseek-ai/cordis';
6
+ /** Cordis companion plugin name. */
7
+ export declare const name = "command-agents-invariant";
8
+ /** Service required before the companion can reserve package ownership. */
9
+ export declare const inject: string[];
10
+ /**
11
+ * Register this package's invariant companion.
12
+ * @param ctx - Cordis context carrying the invariant service.
13
+ * @returns the installed registration's disposer after setup succeeds.
14
+ */
15
+ export declare const apply: (ctx: Context) => Promise<() => void>;
16
+ //# sourceMappingURL=invariant.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invariant.d.ts","sourceRoot":"","sources":["../src/invariant.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAKlD,oCAAoC;AACpC,eAAO,MAAM,IAAI,6BAA6B,CAAA;AAC9C,2EAA2E;AAC3E,eAAO,MAAM,MAAM,UAAiB,CAAA;AAUpC;;;;GAIG;AACH,eAAO,MAAM,KAAK,GAAI,KAAK,OAAO,KAAG,OAAO,CAAC,MAAM,IAAI,CACU,CAAA"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Package-owned invariant companion for `@dsh-cc/command-agents`.
3
+ * @module @dsh-cc/command-agents/invariant
4
+ */
5
+ const PACKAGE_NAME = '@dsh-cc/command-agents';
6
+ /** Cordis companion plugin name. */
7
+ export const name = 'command-agents-invariant';
8
+ /** Service required before the companion can reserve package ownership. */
9
+ export const inject = ['invariants'];
10
+ /**
11
+ * No runtime invariant: this command adapter owns no event stream or state
12
+ * projection; the snapshot is a pure read over injected services (subagents,
13
+ * agents, resumePinStore), and the command registry owns registration and
14
+ * dispatch lifecycle.
15
+ */
16
+ const install = () => { };
17
+ /**
18
+ * Register this package's invariant companion.
19
+ * @param ctx - Cordis context carrying the invariant service.
20
+ * @returns the installed registration's disposer after setup succeeds.
21
+ */
22
+ export const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
23
+ /* jscpd:ignore-end */
24
+ //# sourceMappingURL=invariant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invariant.js","sourceRoot":"","sources":["../src/invariant.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,MAAM,YAAY,GAAG,wBAAwB,CAAA;AAE7C,oCAAoC;AACpC,MAAM,CAAC,MAAM,IAAI,GAAG,0BAA0B,CAAA;AAC9C,2EAA2E;AAC3E,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,YAAY,CAAC,CAAA;AAEpC;;;;;GAKG;AACH,MAAM,OAAO,GAAuB,GAAG,EAAE,GAAE,CAAC,CAAA;AAE5C;;;;GAIG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,GAAY,EAAuB,EAAE,CACzD,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC,CAAA;AACjE,sBAAsB"}
@@ -0,0 +1,135 @@
1
+ /**
2
+ * Pure `/agents` snapshot + rendering: the thin data model shared by the
3
+ * preset command handler and the TUI local-slash surface (plan
4
+ * docs/plans/2026-09-10-continuable-background-ux.md §3.2). All functions are
5
+ * pure over the injected duck-typed services, so they unit-test without
6
+ * cordis. The preset surface renders this model exactly; the TUI may ADD
7
+ * decorations (provider/model, prompt excerpt, last stopReason) from its own
8
+ * event fold — never different ids or ordering.
9
+ * @module @dsh-cc/command-agents/snapshot
10
+ */
11
+ /** Per-child residency. Derivation follows the F7 pattern, not a new source. */
12
+ export type Residency = 'running' | 'idle' | 'ready';
13
+ /** Pin state row: `blocked` carries the stable gate deny code when parseable. */
14
+ export interface AgentPinView {
15
+ readonly state: 'pinned' | 'blocked' | 'corrupt';
16
+ readonly denyCode?: string;
17
+ }
18
+ /** One thin snapshot row, shared verbatim by both surfaces. */
19
+ export interface AgentRow {
20
+ /** Durable child session id (stable across Activations). */
21
+ readonly id: string;
22
+ /** Durable creation label from the child's descriptor, when present. */
23
+ readonly label?: string;
24
+ /** Derived residency: Working / Idle / Ready. */
25
+ readonly residency: Residency;
26
+ /** Whether the child has durable subagent descendants. */
27
+ readonly hasChildren: boolean;
28
+ /** Pin state; `undefined` when the child has no resume pin. */
29
+ readonly pin?: AgentPinView;
30
+ /** The parent session id the listing was rooted at. */
31
+ readonly parentId: string;
32
+ }
33
+ /** The duck-typed `listChildren` entry subset this snapshot consumes. */
34
+ export interface ChildEntryLike {
35
+ readonly id: string;
36
+ readonly activity: 'running' | 'inactive';
37
+ readonly hasChildren: boolean;
38
+ readonly mode?: string;
39
+ readonly label?: string;
40
+ }
41
+ /** The subset of a resume pin the detail renders (schema v1 fields). */
42
+ export interface PinLike {
43
+ readonly childId: string;
44
+ readonly label?: string;
45
+ readonly mode?: string;
46
+ readonly definition?: {
47
+ readonly agentType: string;
48
+ readonly source?: string;
49
+ };
50
+ readonly modelSelector?: {
51
+ readonly raw: string;
52
+ readonly via?: string;
53
+ };
54
+ readonly workspace?: {
55
+ readonly cwd: string;
56
+ readonly branch: string;
57
+ };
58
+ readonly resume: {
59
+ readonly state: 'ok' | 'blocked';
60
+ readonly reason?: string;
61
+ };
62
+ }
63
+ /** Corrupt-pin sentinel mirrored from the PinStore. */
64
+ export interface CorruptPinLike {
65
+ readonly kind: 'corrupt';
66
+ readonly reason: string;
67
+ }
68
+ /**
69
+ * The services the snapshot reads. `listChildren` comes from the host-plane
70
+ * `subagents` registry, `getAgent` from the cordis `agents` registry, and the
71
+ * pin seam from the realm-interior `resumePinStore` service. `interrupt`
72
+ * is consumed by the command handler only — never by the read-only snapshot.
73
+ */
74
+ export interface SnapshotServices {
75
+ listChildren(parentSessionId: string): Promise<readonly ChildEntryLike[]>;
76
+ getAgent(id: string): {
77
+ status?: string;
78
+ } | undefined;
79
+ readPin(childId: string): PinLike | CorruptPinLike | undefined;
80
+ pinPath(childId: string): string;
81
+ }
82
+ /**
83
+ * Extract the stable bracketed gate deny code from a persisted deny reason
84
+ * (`[CODE] human reason`), per the gate's own copy convention.
85
+ */
86
+ export declare function denyCodeOf(reason: string): string | undefined;
87
+ /**
88
+ * Build the thin snapshot for one parent session's direct children.
89
+ * @param services - the injected read seams.
90
+ * @param parentSessionId - the listing root (the caller's session id).
91
+ */
92
+ export declare function buildAgentsSnapshot(services: SnapshotServices, parentSessionId: string): Promise<AgentRow[]>;
93
+ /** Shorten a child id for row display (first 8 of the tail hex when hyphenated). */
94
+ export declare function shortIdOf(id: string): string;
95
+ /**
96
+ * Render the grouped list. Groups follow residency only — Working / Idle /
97
+ * Ready; there is deliberately no Blocked or Done group (§3.2).
98
+ */
99
+ export declare function renderAgentsList(rows: readonly AgentRow[]): string;
100
+ /**
101
+ * Render one child's thin detail: ids, residency, children, and pin
102
+ * provenance. The preset surface renders exactly this; the TUI appends its
103
+ * fold-derived decorations additively.
104
+ */
105
+ export declare function renderAgentDetail(row: AgentRow, pin: PinLike | CorruptPinLike | undefined, pinPath: string | undefined, parentSessionId: string): string;
106
+ /**
107
+ * Parsed `/agents` input grammar.
108
+ */
109
+ export type ParsedAgentsInput = {
110
+ readonly kind: 'list';
111
+ } | {
112
+ readonly kind: 'detail';
113
+ readonly id: string;
114
+ } | {
115
+ readonly kind: 'stop';
116
+ readonly id: string;
117
+ } | {
118
+ readonly kind: 'error';
119
+ readonly text: string;
120
+ };
121
+ /** Copy for a stop request on a running child (both surfaces share it). */
122
+ export declare function stopRunningCopy(id: string): string;
123
+ /** Copy for a stop request on an idle/ready child (shared no-op explanation). */
124
+ export declare function stopNotRunningCopy(id: string, residency: string): string;
125
+ /** Copy for a stop/detail on an id the snapshot does not know. */
126
+ export declare function unknownAgentCopy(id: string): string;
127
+ /** Copy for the reserved `attach` namespace (P1). */
128
+ export declare function attachReservedCopy(): string;
129
+ /**
130
+ * Parse the raw text after `/agents`. Grammar: '' | '<id>' | 'stop <id>'.
131
+ * `attach` is a reserved namespace (P1) — named as not implemented, never
132
+ * silently dropped.
133
+ */
134
+ export declare function parseAgentsInput(raw: string): ParsedAgentsInput;
135
+ //# sourceMappingURL=snapshot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../src/snapshot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,gFAAgF;AAChF,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAA;AAEpD,iFAAiF;AACjF,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAA;IAChD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAC3B;AAED,+DAA+D;AAC/D,MAAM,WAAW,QAAQ;IACvB,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,wEAAwE;IACxE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,iDAAiD;IACjD,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;IAC7B,0DAA0D;IAC1D,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAA;IAC7B,+DAA+D;IAC/D,QAAQ,CAAC,GAAG,CAAC,EAAE,YAAY,CAAA;IAC3B,uDAAuD;IACvD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAC1B;AAED,yEAAyE;AACzE,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,QAAQ,EAAE,SAAS,GAAG,UAAU,CAAA;IACzC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAA;IAC7B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CACxB;AAED,wEAAwE;AACxE,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,KAAK,C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,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,CAc/D"}
@@ -0,0 +1,197 @@
1
+ /**
2
+ * Pure `/agents` snapshot + rendering: the thin data model shared by the
3
+ * preset command handler and the TUI local-slash surface (plan
4
+ * docs/plans/2026-09-10-continuable-background-ux.md §3.2). All functions are
5
+ * pure over the injected duck-typed services, so they unit-test without
6
+ * cordis. The preset surface renders this model exactly; the TUI may ADD
7
+ * decorations (provider/model, prompt excerpt, last stopReason) from its own
8
+ * event fold — never different ids or ordering.
9
+ * @module @dsh-cc/command-agents/snapshot
10
+ */
11
+ /**
12
+ * Extract the stable bracketed gate deny code from a persisted deny reason
13
+ * (`[CODE] human reason`), per the gate's own copy convention.
14
+ */
15
+ export function denyCodeOf(reason) {
16
+ const match = /^\[([A-Z][A-Z0-9_]+)\]/.exec(reason);
17
+ return match === null ? undefined : match[1];
18
+ }
19
+ function pinViewOf(pin) {
20
+ if (pin === undefined)
21
+ return undefined;
22
+ if ('kind' in pin && pin.kind === 'corrupt')
23
+ return { state: 'corrupt' };
24
+ const pinLike = pin;
25
+ if (pinLike.resume.state === 'blocked') {
26
+ const denyCode = pinLike.resume.reason === undefined ? undefined : denyCodeOf(pinLike.resume.reason);
27
+ if (denyCode === undefined)
28
+ return { state: 'blocked' };
29
+ return { state: 'blocked', denyCode };
30
+ }
31
+ return { state: 'pinned' };
32
+ }
33
+ /**
34
+ * Derive one child's residency: a live running activation is `running`; a
35
+ * live but not-running activation is `idle`; no live agent (settled
36
+ * continuable or persistence-only) is `ready` — resumable, per the harness's
37
+ * own ready semantics (F7 derive pattern).
38
+ */
39
+ function residencyOf(entry, live) {
40
+ if (entry.activity === 'inactive')
41
+ return 'ready';
42
+ if (live === undefined)
43
+ return 'ready';
44
+ return live.status === 'running' ? 'running' : 'idle';
45
+ }
46
+ /**
47
+ * Build the thin snapshot for one parent session's direct children.
48
+ * @param services - the injected read seams.
49
+ * @param parentSessionId - the listing root (the caller's session id).
50
+ */
51
+ export async function buildAgentsSnapshot(services, parentSessionId) {
52
+ const children = await services.listChildren(parentSessionId);
53
+ const list = [];
54
+ for (const entry of children) {
55
+ if (entry.mode === 'one-shot')
56
+ continue;
57
+ const live = services.getAgent(String(entry.id));
58
+ list.push({
59
+ id: String(entry.id),
60
+ ...(entry.label !== undefined && entry.label.length > 0 ? { label: entry.label } : {}),
61
+ residency: residencyOf(entry, live),
62
+ hasChildren: entry.hasChildren === true,
63
+ ...(() => {
64
+ const pin = pinViewOf(services.readPin(String(entry.id)));
65
+ return pin === undefined ? {} : { pin };
66
+ })(),
67
+ parentId: parentSessionId,
68
+ });
69
+ }
70
+ // Deterministic: group order is applied by the renderer; here sort by
71
+ // label-then-id so both surfaces show identical ordering.
72
+ list.sort((a, b) => (a.label ?? a.id).localeCompare(b.label ?? b.id) || a.id.localeCompare(b.id));
73
+ return list;
74
+ }
75
+ /** Marker per row residency: `●` running, `○` idle, `◇` ready (resumable). */
76
+ const MARKERS = { running: '●', idle: '○', ready: '◇' };
77
+ const GROUP_ORDER = ['running', 'idle', 'ready'];
78
+ const GROUP_TITLES = {
79
+ running: 'Working',
80
+ idle: 'Idle',
81
+ ready: 'Ready',
82
+ };
83
+ /** Shorten a child id for row display (first 8 of the tail hex when hyphenated). */
84
+ export function shortIdOf(id) {
85
+ const tail = id.includes('-') ? id.split('-').at(-1) ?? id : id;
86
+ return tail.length > 8 ? tail.slice(0, 8) : id;
87
+ }
88
+ /**
89
+ * Render the grouped list. Groups follow residency only — Working / Idle /
90
+ * Ready; there is deliberately no Blocked or Done group (§3.2).
91
+ */
92
+ export function renderAgentsList(rows) {
93
+ if (rows.length === 0)
94
+ return 'No background agents.';
95
+ const lines = ['Background agents:'];
96
+ for (const residency of GROUP_ORDER) {
97
+ const group = rows.filter(row => row.residency === residency);
98
+ if (group.length === 0)
99
+ continue;
100
+ lines.push(`${GROUP_TITLES[residency]} (${group.length}):`);
101
+ for (const row of group) {
102
+ const name = row.label ?? shortIdOf(row.id);
103
+ const tag = row.pin === undefined
104
+ ? ''
105
+ : row.pin.state === 'blocked' && row.pin.denyCode !== undefined
106
+ ? ` [gate: ${row.pin.denyCode}]`
107
+ : row.pin.state === 'blocked'
108
+ ? ' [gate denied]'
109
+ : row.pin.state === 'corrupt'
110
+ ? ' [pin unreadable]'
111
+ : ' [pinned]';
112
+ const childrenTag = row.hasChildren ? ' [has children]' : '';
113
+ lines.push(` ${MARKERS[row.residency]} ${name} · ${shortIdOf(row.id)}${tag}${childrenTag}`);
114
+ }
115
+ }
116
+ return lines.join('\n');
117
+ }
118
+ /**
119
+ * Render one child's thin detail: ids, residency, children, and pin
120
+ * provenance. The preset surface renders exactly this; the TUI appends its
121
+ * fold-derived decorations additively.
122
+ */
123
+ export function renderAgentDetail(row, pin, pinPath, parentSessionId) {
124
+ const lines = [`Agent ${row.id}`];
125
+ if (row.label !== undefined)
126
+ lines.push(` label: ${row.label}`);
127
+ lines.push(` residency: ${row.residency}`);
128
+ lines.push(` children: ${row.hasChildren ? 'present' : 'none'}`);
129
+ lines.push(` parent session: ${parentSessionId}`);
130
+ if (pin === undefined) {
131
+ lines.push(' pin: none (not pinnable or not background-spawned)');
132
+ return lines.join('\n');
133
+ }
134
+ if ('kind' in pin && pin.kind === 'corrupt') {
135
+ lines.push(` pin: UNREADABLE at ${pinPath ?? '<unknown>'} (${pin.reason})`);
136
+ return lines.join('\n');
137
+ }
138
+ const resumePin = pin;
139
+ lines.push(` pin: ${pinPath ?? '<unknown>'}`);
140
+ if (resumePin.mode !== undefined)
141
+ lines.push(` pin mode: ${resumePin.mode}`);
142
+ if (resumePin.definition !== undefined) {
143
+ const source = resumePin.definition.source === undefined ? '' : ` (${resumePin.definition.source})`;
144
+ lines.push(` pin definition: ${resumePin.definition.agentType}${source}`);
145
+ }
146
+ if (resumePin.modelSelector !== undefined) {
147
+ lines.push(` pin model: ${resumePin.modelSelector.raw}${resumePin.modelSelector.via === undefined ? '' : ` via ${resumePin.modelSelector.via}`}`);
148
+ }
149
+ if (resumePin.workspace !== undefined) {
150
+ lines.push(` pin workspace: ${resumePin.workspace.branch} @ ${resumePin.workspace.cwd}`);
151
+ }
152
+ if (resumePin.resume.state === 'blocked') {
153
+ lines.push(` gate: denied ${resumePin.resume.reason ?? ''}`.trimEnd());
154
+ }
155
+ else {
156
+ lines.push(' gate: ok (last evaluation passed)');
157
+ }
158
+ return lines.join('\n');
159
+ }
160
+ /** Copy for a stop request on a running child (both surfaces share it). */
161
+ export function stopRunningCopy(id) {
162
+ return `Interrupt requested for agent ${id}; it stays resumable — /agents for status.`;
163
+ }
164
+ /** Copy for a stop request on an idle/ready child (shared no-op explanation). */
165
+ export function stopNotRunningCopy(id, residency) {
166
+ return `Agent ${id} is not running (residency: ${residency}); nothing to stop — it is resumable.`;
167
+ }
168
+ /** Copy for a stop/detail on an id the snapshot does not know. */
169
+ export function unknownAgentCopy(id) {
170
+ return `No agent ${id} among this session's background agents; /agents lists current ids.`;
171
+ }
172
+ /** Copy for the reserved `attach` namespace (P1). */
173
+ export function attachReservedCopy() {
174
+ return '/agents attach is not implemented yet (namespace reserved).';
175
+ }
176
+ /**
177
+ * Parse the raw text after `/agents`. Grammar: '' | '<id>' | 'stop <id>'.
178
+ * `attach` is a reserved namespace (P1) — named as not implemented, never
179
+ * silently dropped.
180
+ */
181
+ export function parseAgentsInput(raw) {
182
+ const input = raw.trim();
183
+ if (input.length === 0)
184
+ return { kind: 'list' };
185
+ const parts = input.split(/\s+/);
186
+ if (parts[0] === 'stop') {
187
+ if (parts.length < 2 || parts[1].length === 0) {
188
+ return { kind: 'error', text: 'Usage: /agents stop <id>' };
189
+ }
190
+ return { kind: 'stop', id: parts[1] };
191
+ }
192
+ if (parts[0] === 'attach') {
193
+ return { kind: 'error', text: attachReservedCopy() };
194
+ }
195
+ return { kind: 'detail', id: parts[0] };
196
+ }
197
+ //# sourceMappingURL=snapshot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../src/sn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,MAAM,UAAU,gBAAgB,CAAC,EAAU;IACzC,OAAO,YAAY,EAAE,qEAAqE,CAAA;AAC5F,CAAC;AAED,qDAAqD;AACrD,MAAM,UAAU,kBAAkB;IAChC,OAAO,6DAA6D,CAAA;AACtE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAW;IAC1C,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,EAAE,CAAA;IACxB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;IAC/C,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IAChC,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CAAC;QACxB,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,CAAC,CAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC/C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,0BAA0B,EAAE,CAAA;QAC5D,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC,CAAE,EAAE,CAAA;IACxC,CAAC;IACD,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC1B,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,kBAAkB,EAAE,EAAE,CAAA;IACtD,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC,CAAE,EAAE,CAAA;AAC1C,CAAC"}
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@dsh-cc/command-agents",
3
+ "description": "Human-facing slash command to list, inspect, and stop continuable background agents",
4
+ "version": "0.5.0",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/dsh-cc/dsh-cc.git",
8
+ "directory": "packages/interaction/command-agents"
9
+ },
10
+ "type": "module",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./lib/index.d.ts",
14
+ "default": "./lib/index.js"
15
+ },
16
+ "./snapshot": {
17
+ "types": "./lib/snapshot.d.ts",
18
+ "default": "./lib/snapshot.js"
19
+ },
20
+ "./invariant": {
21
+ "types": "./lib/invariant.d.ts",
22
+ "default": "./lib/invariant.js"
23
+ },
24
+ "./src/*": "./src/*",
25
+ "./package.json": "./package.json"
26
+ },
27
+ "files": [
28
+ "lib"
29
+ ],
30
+ "license": "Apache-2.0",
31
+ "peerDependencies": {
32
+ "@deepseek-ai/dsh-commands": ">=0.1.1-rc.2",
33
+ "@deepseek-ai/dsh-invariants": ">=0.1.1-rc.2",
34
+ "@deepseek-ai/dsh-session": ">=0.1.1-rc.2",
35
+ "@deepseek-ai/cordis": ">=0.1.1-rc.2",
36
+ "@dsh-cc/subagent-resume-pins": "^0.5.0"
37
+ },
38
+ "devDependencies": {
39
+ "@deepseek-ai/cordis-plugin-loader": "link:../../../../deepseek-harness/vendor/loader",
40
+ "@deepseek-ai/dsh-agent": "link:../../../../deepseek-harness/packages/core/agent",
41
+ "@deepseek-ai/dsh-commands": "link:../../../../deepseek-harness/packages/interaction/commands",
42
+ "@deepseek-ai/dsh-invariants": "link:../../../../deepseek-harness/packages/runtime-diagnostics/invariants",
43
+ "@deepseek-ai/dsh-session": "link:../../../../deepseek-harness/packages/core/session",
44
+ "@deepseek-ai/cordis": "link:../../../../deepseek-harness/vendor/cordis",
45
+ "@dsh-cc/subagent-resume-pins": "^0.5.0"
46
+ },
47
+ "publishConfig": {
48
+ "access": "public"
49
+ }
50
+ }