dsh-loop-engine-allinone 0.0.0-stage → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/CHANGELOG.md +119 -0
  2. package/CONTRIBUTING.md +78 -0
  3. package/LICENSE +23 -0
  4. package/NOTICE +45 -0
  5. package/README.md +223 -2
  6. package/README.zh.md +179 -0
  7. package/SECURITY.md +39 -0
  8. package/cordis.patch.yml +3 -0
  9. package/lib/client.js +2166 -0
  10. package/lib/index.js +11621 -0
  11. package/lib/invariant.js +453 -0
  12. package/lib/types/agent-preset-ids.d.ts +276 -0
  13. package/lib/types/client/LoopEngineBadge.d.ts +71 -0
  14. package/lib/types/client/LoopEngineComposerSelect.d.ts +126 -0
  15. package/lib/types/client/LoopEngineSection.d.ts +35 -0
  16. package/lib/types/client/engine-marks.d.ts +87 -0
  17. package/lib/types/client/index.d.ts +39 -0
  18. package/lib/types/client/locales.d.ts +182 -0
  19. package/lib/types/client/reload.d.ts +135 -0
  20. package/lib/types/client/session-engine.d.ts +508 -0
  21. package/lib/types/client/store.d.ts +103 -0
  22. package/lib/types/client/turn-status.d.ts +234 -0
  23. package/lib/types/client/use-session-engine.d.ts +74 -0
  24. package/lib/types/commands.d.ts +77 -0
  25. package/lib/types/compat.d.ts +25 -0
  26. package/lib/types/driver-acp/agent.d.ts +289 -0
  27. package/lib/types/driver-acp/approval.d.ts +27 -0
  28. package/lib/types/driver-acp/capabilities.d.ts +200 -0
  29. package/lib/types/driver-acp/client.d.ts +297 -0
  30. package/lib/types/driver-acp/executable.d.ts +53 -0
  31. package/lib/types/driver-acp/mapping.d.ts +76 -0
  32. package/lib/types/driver-acp/profile.d.ts +126 -0
  33. package/lib/types/driver-acp/runtime.d.ts +45 -0
  34. package/lib/types/driver-acp/subprocess.d.ts +19 -0
  35. package/lib/types/driver-acp/terminal.d.ts +98 -0
  36. package/lib/types/driver-acp/transport.d.ts +43 -0
  37. package/lib/types/driver-acp/types.d.ts +152 -0
  38. package/lib/types/driver-cli/capability.d.ts +42 -0
  39. package/lib/types/driver-cli/cli-agent.d.ts +258 -0
  40. package/lib/types/driver-cli/cli-loop.d.ts +46 -0
  41. package/lib/types/driver-cli/flatten.d.ts +35 -0
  42. package/lib/types/driver-cli/frames.d.ts +128 -0
  43. package/lib/types/driver-cli/ndjson.d.ts +106 -0
  44. package/lib/types/driver-cli/session-sink.d.ts +333 -0
  45. package/lib/types/driver-cli/stream-json.d.ts +61 -0
  46. package/lib/types/driver-cli/text.d.ts +66 -0
  47. package/lib/types/driver-cli/transport.d.ts +84 -0
  48. package/lib/types/driver-core/agents-md-skill-provider.d.ts +72 -0
  49. package/lib/types/driver-core/assistant-stream.d.ts +68 -0
  50. package/lib/types/driver-core/context-files.d.ts +62 -0
  51. package/lib/types/driver-core/host-servers.d.ts +119 -0
  52. package/lib/types/driver-core/hosted-engine-runtime.d.ts +190 -0
  53. package/lib/types/driver-core/hosted-tool-vocabulary.d.ts +78 -0
  54. package/lib/types/driver-core/idle-child.d.ts +57 -0
  55. package/lib/types/driver-core/image-access.d.ts +25 -0
  56. package/lib/types/driver-core/inbox.d.ts +104 -0
  57. package/lib/types/driver-core/model-handover.d.ts +134 -0
  58. package/lib/types/driver-core/ownership.d.ts +41 -0
  59. package/lib/types/driver-core/permission-knobs.d.ts +26 -0
  60. package/lib/types/driver-core/prompt.d.ts +64 -0
  61. package/lib/types/driver-core/session-lifetime.d.ts +62 -0
  62. package/lib/types/driver-core/session-model.d.ts +128 -0
  63. package/lib/types/driver-core/skill-inject.d.ts +59 -0
  64. package/lib/types/driver-core/step-close.d.ts +49 -0
  65. package/lib/types/driver-core/step-images.d.ts +62 -0
  66. package/lib/types/driver-core/step-tools.d.ts +43 -0
  67. package/lib/types/driver-core/system-head.d.ts +43 -0
  68. package/lib/types/engine-agy/agent.d.ts +67 -0
  69. package/lib/types/engine-agy/frames.d.ts +90 -0
  70. package/lib/types/engine-agy/loop.d.ts +64 -0
  71. package/lib/types/engine-agy/process.d.ts +173 -0
  72. package/lib/types/engine-claude/agent.d.ts +186 -0
  73. package/lib/types/engine-claude/loop.d.ts +73 -0
  74. package/lib/types/engine-claude/mapping.d.ts +108 -0
  75. package/lib/types/engine-claude/permission.d.ts +41 -0
  76. package/lib/types/engine-claude/process.d.ts +59 -0
  77. package/lib/types/engine-claude/sdk.d.ts +67 -0
  78. package/lib/types/engine-claude/types.d.ts +28 -0
  79. package/lib/types/engine-codex/agent.d.ts +216 -0
  80. package/lib/types/engine-codex/appserver/client.d.ts +80 -0
  81. package/lib/types/engine-codex/appserver/mapping.d.ts +67 -0
  82. package/lib/types/engine-codex/appserver/thread.d.ts +66 -0
  83. package/lib/types/engine-codex/appserver/types.d.ts +225 -0
  84. package/lib/types/engine-codex/loop.d.ts +75 -0
  85. package/lib/types/engine-codex/model-handover.d.ts +56 -0
  86. package/lib/types/engine-codex/permission.d.ts +126 -0
  87. package/lib/types/engine-codex/skills.d.ts +28 -0
  88. package/lib/types/engine-codex/types.d.ts +36 -0
  89. package/lib/types/engine-drivers.d.ts +132 -0
  90. package/lib/types/engine-grok/agent.d.ts +24 -0
  91. package/lib/types/engine-grok/loop.d.ts +61 -0
  92. package/lib/types/engine-grok/process.d.ts +46 -0
  93. package/lib/types/engine-grok/profile.d.ts +82 -0
  94. package/lib/types/engine-hermes/agent.d.ts +47 -0
  95. package/lib/types/engine-hermes/loop.d.ts +56 -0
  96. package/lib/types/engine-hermes/process.d.ts +92 -0
  97. package/lib/types/engine-kimi/acp/client.d.ts +123 -0
  98. package/lib/types/engine-kimi/acp/mapping.d.ts +73 -0
  99. package/lib/types/engine-kimi/acp/types.d.ts +143 -0
  100. package/lib/types/engine-kimi/agent.d.ts +24 -0
  101. package/lib/types/engine-kimi/commands.d.ts +44 -0
  102. package/lib/types/engine-kimi/loop.d.ts +62 -0
  103. package/lib/types/engine-kimi/model-handover.d.ts +32 -0
  104. package/lib/types/engine-kimi/permission.d.ts +28 -0
  105. package/lib/types/engine-kimi/process.d.ts +47 -0
  106. package/lib/types/engine-kimi/profile.d.ts +19 -0
  107. package/lib/types/engine-kimi/skills.d.ts +52 -0
  108. package/lib/types/engine-kimi/types.d.ts +25 -0
  109. package/lib/types/engine-minimaxcode/agent.d.ts +24 -0
  110. package/lib/types/engine-minimaxcode/loop.d.ts +83 -0
  111. package/lib/types/engine-minimaxcode/process.d.ts +53 -0
  112. package/lib/types/engine-minimaxcode/profile.d.ts +72 -0
  113. package/lib/types/engine-of-session.d.ts +97 -0
  114. package/lib/types/engine-pi/agent.d.ts +230 -0
  115. package/lib/types/engine-pi/loop.d.ts +72 -0
  116. package/lib/types/engine-pi/model-handover.d.ts +84 -0
  117. package/lib/types/engine-pi/permission.d.ts +47 -0
  118. package/lib/types/engine-pi/rpc/client.d.ts +107 -0
  119. package/lib/types/engine-pi/rpc/mapping.d.ts +37 -0
  120. package/lib/types/engine-pi/rpc/types.d.ts +249 -0
  121. package/lib/types/engine-pi/skills.d.ts +47 -0
  122. package/lib/types/engine-pi/types.d.ts +36 -0
  123. package/lib/types/engine-qoderclicn/agent.d.ts +59 -0
  124. package/lib/types/engine-qoderclicn/loop.d.ts +51 -0
  125. package/lib/types/engine-qoderclicn/process.d.ts +113 -0
  126. package/lib/types/engine-registry.d.ts +584 -0
  127. package/lib/types/engine-remote.d.ts +192 -0
  128. package/lib/types/engine-surface.d.ts +36 -0
  129. package/lib/types/engine-zcode/agent.d.ts +50 -0
  130. package/lib/types/engine-zcode/loop.d.ts +47 -0
  131. package/lib/types/engine-zcode/process.d.ts +111 -0
  132. package/lib/types/index.d.ts +205 -0
  133. package/lib/types/invariant.d.ts +26 -0
  134. package/lib/types/model-selection-reset.d.ts +271 -0
  135. package/lib/types/namespace.d.ts +25 -0
  136. package/lib/types/patch-manager.d.ts +104 -0
  137. package/lib/types/preset.d.ts +254 -0
  138. package/lib/types/provider-route.d.ts +245 -0
  139. package/lib/types/router-loop.d.ts +458 -0
  140. package/lib/types/session-engine-store.d.ts +138 -0
  141. package/lib/types/settings.d.ts +60 -0
  142. package/lib/types/skills.d.ts +85 -0
  143. package/package.json +152 -6
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Strict-LF JSONL client for the Pi RPC subprocess (`pi --mode rpc`).
3
+ *
4
+ * The driver hands the client a process handle carrying its stdin/stdout/stderr
5
+ * (projected from the dsh subprocess seam, so the whole `pi` child is sandboxed
6
+ * by the harness). The client frames records on a bare `\n` only — not on
7
+ * Unicode separators — using a byte decoder, tolerates a trailing `\r`, and
8
+ * correlates command responses by the optional `id` field while dispatching
9
+ * every non-response line to a buffered event stream.
10
+ *
11
+ * @module dsh-loop-engine-allinone/engine-pi/rpc/client
12
+ */
13
+ import type { ChildProcess } from 'node:child_process';
14
+ import type { Readable, Writable } from 'node:stream';
15
+ import type { PiCommand, PiEvent, PiImage, PiResponse } from './types.ts';
16
+ /** A spawned Pi RPC process as the protocol transport needs it. */
17
+ export interface PiProcess {
18
+ /** Child stdin (command JSON lines). */
19
+ readonly stdin: Writable;
20
+ /** Child stdout (response + event JSON lines). */
21
+ readonly stdout: Readable;
22
+ /** Child stderr (diagnostics; buffered and dropped). */
23
+ readonly stderr: Readable;
24
+ /** Register a single human-readable termination callback. */
25
+ onExit(handler: () => void): void;
26
+ /** Request process-tree termination. */
27
+ terminate(): void;
28
+ }
29
+ /** The exact argv/cwd/env the driver requests for one `pi --mode rpc` child. */
30
+ export interface PiSpawnSpec {
31
+ /** The program plus its flags; `argv[0]` is the Pi CLI entrypoint. */
32
+ readonly argv: readonly string[];
33
+ readonly cwd: string;
34
+ readonly env: Record<string, string>;
35
+ }
36
+ /** Spawns one Pi RPC process over the given spec (the driver's spawn capability). */
37
+ export type PiSpawnCapability = (spec: PiSpawnSpec) => PiProcess;
38
+ /** Callback receiving every non-response event line. */
39
+ export type PiEventHandler = (event: PiEvent) => void;
40
+ /** Options for one `prompt` command. */
41
+ export interface PiPromptOptions {
42
+ readonly streamingBehavior?: 'steer' | 'followUp';
43
+ /** Images sent with this prompt, as the protocol takes them. */
44
+ readonly images?: readonly PiImage[];
45
+ }
46
+ /** Project a `node:child_process` child onto the Pi protocol transport. */
47
+ export declare function fromChildProcess(child: ChildProcess): PiProcess;
48
+ /** Prompt the agent and stream its events. */
49
+ export declare class PiRpcClient {
50
+ private readonly process;
51
+ private reqId;
52
+ private pending;
53
+ private readonly eventBuffer;
54
+ private eventWake;
55
+ private eventHandler;
56
+ private disposed;
57
+ private readonly decoder;
58
+ private buffer;
59
+ private readonly onStderr;
60
+ /** Whether this client was disposed or its process exited. */
61
+ get closed(): boolean;
62
+ /** Mount a client over an already-spawned Pi RPC process. */
63
+ constructor(process: PiProcess);
64
+ /**
65
+ * Create a client, spawning the Pi RPC child through the supplied capability
66
+ * (or the default node-runtime spawn when none is given).
67
+ * @param spec - the Pi CLI argv/cwd/env the child should run with.
68
+ * @param spawn - optional process-spawn capability (the subprocess seam);
69
+ * absent falls back to the plain node child spawn.
70
+ * @returns the connected client.
71
+ */
72
+ static create(spec: PiSpawnSpec, spawn?: PiSpawnCapability): PiRpcClient;
73
+ /** Register the event dispatch handler. */
74
+ onEvent(handler: PiEventHandler): void;
75
+ /** Drop any events still buffered from a previous step (stateless per-step sessions). */
76
+ clearEvents(): void;
77
+ /** Start a fresh Pi session. */
78
+ newSession(): Promise<PiResponse>;
79
+ /** Prompt the agent and await the acceptance response. */
80
+ prompt(message: string, options?: PiPromptOptions): Promise<PiResponse>;
81
+ /** Abort the current agent operation. */
82
+ abort(): Promise<PiResponse>;
83
+ /** Query session stats. */
84
+ getSessionStats(): Promise<PiResponse>;
85
+ /** Send a command without awaiting its response (fire-and-forget). */
86
+ send(command: PiCommand): void;
87
+ /**
88
+ * Send a command and await the correlated response. Assigns a fresh `id`
89
+ * when the command carries none, so responses always round-trip.
90
+ */
91
+ request(command: PiCommand): Promise<PiResponse>;
92
+ /**
93
+ * Consume every buffered event as an async generator, waking as fresh lines
94
+ * arrive. The caller bounds the iteration by a terminal event; unmatched
95
+ * lines stay buffered for a later iteration.
96
+ */
97
+ events(): AsyncGenerator<PiEvent, void, void>;
98
+ /** Dispose the client and request child termination. */
99
+ dispose(): void;
100
+ /** Feed one chunk of stdout into the framing state machine. */
101
+ private feed;
102
+ /** Dispatch one parsed line to the pending map or the event queue. */
103
+ private dispatch;
104
+ /** Drain decoded stderr bytes (no-op consumer keeps the pipe flowing). */
105
+ private consumeStderr;
106
+ }
107
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Maps Pi RPC messages and end-of-execution events to dsh session-log events.
3
+ * Token-level streaming deltas are folded inline by the driver's step loop
4
+ * (they carry live progress); this module projects the end-state items — a
5
+ * completed tool call, a completed tool execution, and a finished turn's usage
6
+ * — into the durable `tool/call`, `tool/result`, and usage events.
7
+ *
8
+ * @module dsh-loop-engine-allinone/engine-pi/rpc/mapping
9
+ */
10
+ import type { TokenUsage, ToolResultMessage } from '@deepseek-ai/dsh-llm';
11
+ import type { PiUsage } from './types.ts';
12
+ /** Map one Pi usage snapshot to dsh TokenUsage. */
13
+ export declare function mapUsage(usage: PiUsage): TokenUsage;
14
+ /**
15
+ * Derive the compact transcript text of a Pi content block, joining nested
16
+ * text segments so the durable tool-result block carries the read model text.
17
+ * @param content - the result payload (e.g. `{ content: [{ type, text }, ...] }`).
18
+ * @returns the joined text.
19
+ */
20
+ export declare function resultText(content: unknown): string;
21
+ /** Map a completed Pi tool-execution end event to the durable tool/result message. */
22
+ export declare function mapToolResult(ev: {
23
+ toolCallId: string;
24
+ result: unknown;
25
+ isError: boolean;
26
+ }): ToolResultMessage;
27
+ /** Map the identity of a Pi message tool call or execution start to a durable tool/call. */
28
+ export declare function mapToolCall(ev: {
29
+ callId: string;
30
+ name: string;
31
+ arguments: unknown;
32
+ }): {
33
+ callId: string;
34
+ name: string;
35
+ arguments: string;
36
+ };
37
+ //# sourceMappingURL=mapping.d.ts.map
@@ -0,0 +1,249 @@
1
+ /**
2
+ * Pi RPC protocol type definitions. A minimal subset of the upstream
3
+ * `pi --mode rpc` protocol, covering only what the driver needs: the commands
4
+ * it sends (`new_session`, `prompt`, `abort`, `get_session_stats`), the
5
+ * response envelope, and the streaming events it maps into the durable dsh
6
+ * session log. Types only — no runtime code.
7
+ *
8
+ * The protocol is strict LF (`\n`) JSONL: records are delimited only by a bare
9
+ * `\n` (a trailing `\r` is tolerated), and Unicode separators such as U+2028 /
10
+ * U+2029 are ordinary characters inside JSON strings — so a generic line reader
11
+ * that treats them as newlines is not compliant.
12
+ *
13
+ * @module dsh-loop-engine-allinone/engine-pi/rpc/types
14
+ */
15
+ /** Optional per-command correlation id; echoed back on the response. */
16
+ export interface PiCommandCorrelation {
17
+ readonly id?: number;
18
+ }
19
+ /** Start a fresh Pi session (the driver issues one per dsh step). */
20
+ export interface PiNewSessionCommand extends PiCommandCorrelation {
21
+ readonly type: 'new_session';
22
+ readonly parentSession?: string;
23
+ }
24
+ /** Send a user prompt to the agent and begin streaming events. */
25
+ export interface PiPromptCommand extends PiCommandCorrelation {
26
+ readonly type: 'prompt';
27
+ readonly message: string;
28
+ readonly images?: readonly PiImage[];
29
+ readonly streamingBehavior?: 'steer' | 'followUp';
30
+ }
31
+ /** Abort the current agent operation. */
32
+ export interface PiAbortCommand extends PiCommandCorrelation {
33
+ readonly type: 'abort';
34
+ }
35
+ /** Query session stats (usage/cost fallback when a message carries none). */
36
+ export interface PiGetSessionStatsCommand extends PiCommandCorrelation {
37
+ readonly type: 'get_session_stats';
38
+ }
39
+ /** Every command the client can send. */
40
+ export type PiCommand = PiNewSessionCommand | PiPromptCommand | PiAbortCommand | PiGetSessionStatsCommand;
41
+ /** Message attachment (images) accepted by `prompt`. */
42
+ export interface PiImage {
43
+ readonly type: 'image';
44
+ readonly data: string;
45
+ readonly mimeType: string;
46
+ }
47
+ /** Successful or failed command response. */
48
+ export interface PiResponse {
49
+ readonly type: 'response';
50
+ readonly command?: string;
51
+ readonly success: boolean;
52
+ readonly error?: string;
53
+ readonly id?: number;
54
+ readonly data?: unknown;
55
+ }
56
+ /** Session statistics returned by `get_session_stats`. */
57
+ export interface PiSessionStats {
58
+ readonly tokens?: {
59
+ readonly input?: number;
60
+ readonly output?: number;
61
+ readonly cacheRead?: number;
62
+ readonly cacheWrite?: number;
63
+ readonly total?: number;
64
+ };
65
+ readonly contextUsage?: {
66
+ readonly tokens?: number | null;
67
+ readonly contextWindow?: number;
68
+ readonly percent?: number | null;
69
+ };
70
+ }
71
+ /** Provider-reported token usage attached to messages and updates. */
72
+ export interface PiUsage {
73
+ readonly input?: number;
74
+ readonly output?: number;
75
+ readonly cacheRead?: number;
76
+ readonly cacheWrite?: number;
77
+ readonly totalTokens?: number;
78
+ }
79
+ /** A content block of a Pi message. */
80
+ export type PiContent = {
81
+ readonly type: 'text';
82
+ readonly text: string;
83
+ } | {
84
+ readonly type: 'thinking';
85
+ readonly thinking: string;
86
+ } | {
87
+ readonly type: 'toolCall';
88
+ readonly id: string;
89
+ readonly name: string;
90
+ readonly arguments: unknown;
91
+ };
92
+ /** One role-tagged Pi message. */
93
+ export interface PiMessage {
94
+ readonly role: 'user' | 'assistant' | 'toolResult' | 'system';
95
+ readonly content: string | readonly PiContent[];
96
+ readonly usage?: PiUsage;
97
+ readonly isError?: boolean;
98
+ /**
99
+ * Pi's own verdict on the turn this assistant message belongs to
100
+ * (`stop`, `toolUse`, `length`, `error`, …). Absent on the messages that
101
+ * state none — user and tool-result messages — so it is only read on the
102
+ * assistant message a `turn_end`/`message_end` carries.
103
+ */
104
+ readonly stopReason?: string;
105
+ /**
106
+ * Pi's failure text, accompanying `stopReason: 'error'`: the reason the turn
107
+ * did not produce a reply (an unregistered `api`, a refused connection, …).
108
+ * This is the only place that reason exists — pi's RPC `response` envelope
109
+ * reports command success, not turn outcome.
110
+ */
111
+ readonly errorMessage?: string;
112
+ readonly toolCallId?: string;
113
+ readonly toolName?: string;
114
+ readonly timestamp?: number;
115
+ readonly id?: string;
116
+ }
117
+ /** A tool result as carried by `turn_end.toolResults`. */
118
+ export interface PiToolResult {
119
+ readonly role: 'toolResult';
120
+ readonly toolCallId: string;
121
+ readonly toolName: string;
122
+ readonly content: readonly PiContent[];
123
+ readonly isError?: boolean;
124
+ readonly usage?: PiUsage;
125
+ }
126
+ /** The `assistantMessageEvent` delta union of `message_update`. */
127
+ export type PiAssistantMessageEvent = {
128
+ readonly type: 'text_start';
129
+ readonly contentIndex: number;
130
+ } | {
131
+ readonly type: 'text_delta';
132
+ readonly contentIndex: number;
133
+ readonly delta: string;
134
+ } | {
135
+ readonly type: 'text_end';
136
+ readonly contentIndex: number;
137
+ readonly content?: string;
138
+ } | {
139
+ readonly type: 'thinking_start';
140
+ readonly contentIndex: number;
141
+ } | {
142
+ readonly type: 'thinking_delta';
143
+ readonly contentIndex: number;
144
+ readonly delta: string;
145
+ } | {
146
+ readonly type: 'thinking_end';
147
+ readonly contentIndex: number;
148
+ readonly thinking?: string;
149
+ } | {
150
+ readonly type: 'toolcall_start';
151
+ readonly contentIndex: number;
152
+ readonly id: string;
153
+ readonly toolName: string;
154
+ } | {
155
+ readonly type: 'toolcall_delta';
156
+ readonly contentIndex: number;
157
+ readonly delta: string;
158
+ } | {
159
+ readonly type: 'toolcall_end';
160
+ readonly contentIndex: number;
161
+ readonly toolCall: {
162
+ readonly id: string;
163
+ readonly name: string;
164
+ readonly arguments: unknown;
165
+ };
166
+ };
167
+ /** An `extension_ui_request` (dialog or fire-and-forget). */
168
+ export interface PiExtensionUiRequest {
169
+ readonly type: 'extension_ui_request';
170
+ readonly id: string;
171
+ readonly method: 'select' | 'confirm' | 'input' | 'editor' | 'notify' | 'setStatus' | 'setWidget' | 'setTitle' | 'set_editor_text';
172
+ readonly title?: string;
173
+ readonly options?: readonly string[];
174
+ readonly message?: string;
175
+ readonly [key: string]: unknown;
176
+ }
177
+ /** A tool-execution event (start / update / end). */
178
+ export type PiToolExecutionEvent = {
179
+ readonly type: 'tool_execution_start';
180
+ readonly toolCallId: string;
181
+ readonly toolName: string;
182
+ readonly args: unknown;
183
+ } | {
184
+ readonly type: 'tool_execution_update';
185
+ readonly toolCallId: string;
186
+ readonly toolName: string;
187
+ readonly args: unknown;
188
+ readonly partialResult: unknown;
189
+ } | {
190
+ readonly type: 'tool_execution_end';
191
+ readonly toolCallId: string;
192
+ readonly toolName: string;
193
+ readonly result: unknown;
194
+ readonly isError: boolean;
195
+ };
196
+ /** Every agent event the driver consumes or ignores. */
197
+ export type PiEvent = {
198
+ readonly type: 'response';
199
+ } & PiResponse | {
200
+ readonly type: 'agent_start';
201
+ } | {
202
+ readonly type: 'agent_end';
203
+ readonly messages?: readonly PiMessage[];
204
+ readonly willRetry?: boolean;
205
+ } | {
206
+ readonly type: 'agent_settled';
207
+ } | {
208
+ readonly type: 'turn_start';
209
+ } | {
210
+ readonly type: 'turn_end';
211
+ readonly message?: PiMessage;
212
+ readonly toolResults?: readonly PiToolResult[];
213
+ } | {
214
+ readonly type: 'message_start';
215
+ readonly message: PiMessage;
216
+ } | {
217
+ readonly type: 'message_update';
218
+ readonly usage?: PiUsage;
219
+ readonly assistantMessageEvent: PiAssistantMessageEvent;
220
+ } | {
221
+ readonly type: 'message_end';
222
+ readonly message: PiMessage;
223
+ } | PiToolExecutionEvent | {
224
+ readonly type: 'compaction_start';
225
+ readonly reason?: string;
226
+ } | {
227
+ readonly type: 'compaction_end';
228
+ readonly reason?: string;
229
+ readonly aborted?: boolean;
230
+ readonly willRetry?: boolean;
231
+ readonly result?: unknown;
232
+ } | {
233
+ readonly type: 'auto_retry_start';
234
+ readonly attempt?: number;
235
+ } | {
236
+ readonly type: 'auto_retry_end';
237
+ readonly success?: boolean;
238
+ readonly attempt?: number;
239
+ readonly finalError?: string;
240
+ } | {
241
+ readonly type: 'queue_update';
242
+ readonly steering?: readonly string[];
243
+ readonly followUp?: readonly string[];
244
+ } | {
245
+ readonly type: 'bash_execution_update';
246
+ readonly id?: string;
247
+ readonly delta?: string;
248
+ } | PiExtensionUiRequest;
249
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Pi skill provider: exposes the Pi CLI's instruction files and skills as DSH
3
+ * skills.
4
+ *
5
+ * Pi reads per-directory context files (`AGENTS.md`, or `CLAUDE.md`,
6
+ * preferring `AGENTS.override.md` where one exists) from the session cwd up to
7
+ * the git root, plus a global `AGENTS.md` under the pi config directory
8
+ * (`PI_CODING_AGENT_DIR` or `~/.pi/agent`), and installs skills from
9
+ * `skills/` directories (`~/.pi/agent/skills/` and project `.pi/skills/`
10
+ * walking up). Each context-file set is surfaced as one user-invocable
11
+ * `agents-md` skill whose body is the concatenated file contents; every found
12
+ * `SKILL.md` catalog entry is surfaced under its own name, so the dsh
13
+ * skill-injection seam (`/name` gestures) can carry them into the prompt.
14
+ *
15
+ * `.agents/skills` roots are deliberately not scanned here: dsh's own
16
+ * `skill-filesystem` provider already exposes them through the same registry
17
+ * in the web profile. Pi settings/CLI/package skills are only discoverable
18
+ * through a running `pi --mode rpc` probe, which the engine does not perform
19
+ * at composition time — the filesystem subset above is authoritative for the
20
+ * web menu.
21
+ *
22
+ * The discovery algorithm itself lives in {@link AgentsMdSkillProvider}; this
23
+ * module supplies only Pi's locations and ranks.
24
+ *
25
+ * @module dsh-loop-engine-allinone/engine-pi/skills
26
+ */
27
+ import { AgentsMdSkillProvider } from '../driver-core/agents-md-skill-provider.ts';
28
+ import type { SkillProviderControl } from '../skills.ts';
29
+ /**
30
+ * Resolve the pi config directory, honoring the `PI_CODING_AGENT_DIR`
31
+ * environment override and falling back to `~/.pi/agent`.
32
+ * @returns the absolute pi config directory.
33
+ */
34
+ export declare function piAgentDir(): string;
35
+ /**
36
+ * Skill provider that discovers context files and skills from pi's standard
37
+ * locations:
38
+ * - project context files between the cwd and the git root (plus
39
+ * `~/.pi/agent/AGENTS.md`) — surfaced as one `agents-md` skill;
40
+ * - project `.pi/skills/` and user `~/.pi/agent/skills/` — each `SKILL.md`
41
+ * entry surfaced under its own name.
42
+ */
43
+ export declare class PiSkillProvider extends AgentsMdSkillProvider {
44
+ constructor(control: SkillProviderControl);
45
+ }
46
+ export default PiSkillProvider;
47
+ //# sourceMappingURL=skills.d.ts.map
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Public types of the Pi loop driver. Types only — no runtime code.
3
+ *
4
+ * Pi carries no native permission system ("runs with the permissions of the
5
+ * user"), so the declarative stance this driver resolves is a sandbox mode plus
6
+ * the tool set the process is allowed to use; the rest of the driver then
7
+ * either wraps the whole `pi --mode rpc` child in the dsh subprocess sandbox or
8
+ * prunes its `--tools` accordingly.
9
+ *
10
+ * @module dsh-loop-engine-allinone/engine-pi/types
11
+ */
12
+ /** Pi sandbox stances the driver can resolve, mapped from the dsh session knobs. */
13
+ export type PiSandboxMode = 'read-only' | 'workspace-write' | 'danger-full-access';
14
+ /** Driver configuration after defaults and load-time validation. */
15
+ export interface ResolvedConfig {
16
+ /** Pinned sandbox mode; `undefined` follows the session's dsh permission knobs per query. */
17
+ readonly sandboxMode: PiSandboxMode | undefined;
18
+ /** LLM provider the `pi` RPC process is launched with (`--provider`), when the session selects no model. */
19
+ readonly provider: string | undefined;
20
+ /** Fallback model pattern for the `pi` RPC process (`--model`), used when the session selects none. */
21
+ readonly model: string | undefined;
22
+ /** Thinking/reasoning level for the model (`--model <id>:<level>` or set at runtime). */
23
+ readonly thinkingLevel: string | undefined;
24
+ /** Explicit environment entries layered over the credential-scrubbed parent environment. */
25
+ readonly env: Record<string, string>;
26
+ /**
27
+ * An EXTERNAL Pi CLI entrypoint to run instead of this package's bundled
28
+ * `@earendil-works/pi-coding-agent`, or `undefined` to keep the bundled copy.
29
+ *
30
+ * Pi's CLI is a Node script either way, so the driver always runs the
31
+ * resolved entrypoint under the current node — the only thing a pinned path
32
+ * changes is which script that is.
33
+ */
34
+ readonly bin: string | undefined;
35
+ }
36
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Qoder CN agent: one `qoderclicn -p … --output-format stream-json` child per
3
+ * dsh step, with the durable session log as the sole source of model context.
4
+ *
5
+ * The whole engine-specific surface is {@link QoderclicnAgent.runStep}: serialize
6
+ * the transcript, spawn, decode the NDJSON dialect, and let the shared sink write
7
+ * the durable log. Everything else — the turn loop, the inbox, cancellation, the
8
+ * step rotation, the tool-call/result pairing — is inherited from
9
+ * {@link CliHostedAgent}.
10
+ *
11
+ * ## Why one child per step
12
+ *
13
+ * Qoder's `-p` is inherently one-shot: it answers and exits. That suits this
14
+ * plugin's model exactly, because the plugin is stateless by design — every step
15
+ * replays the durable transcript as the prompt, so nothing is lost by not
16
+ * carrying a session across steps, and nothing leaks between them either. The
17
+ * cost is process startup per step, which is what `capabilities.sessionResume`
18
+ * describes rather than hides.
19
+ *
20
+ * @module dsh-loop-engine-allinone/engine-qoderclicn/agent
21
+ */
22
+ import type { AgentOptions } from '@deepseek-ai/dsh-agent';
23
+ import type { Session, SessionId, UserMessage } from '@deepseek-ai/dsh-session';
24
+ import type { Context } from '@deepseek-ai/cordis';
25
+ import type { HostedEngineId } from '../engine-registry.ts';
26
+ import { CliHostedAgent } from '../driver-cli/cli-agent.ts';
27
+ import type { SinkPosition } from '../driver-cli/session-sink.ts';
28
+ import type { CliSpawnCapability } from '../driver-cli/transport.ts';
29
+ /** Deployment-resolved configuration for the Qoder engine. */
30
+ export interface ResolvedQoderclicnConfig {
31
+ /** Pinned executable, when the deployment named one. */
32
+ readonly bin: string | undefined;
33
+ /** Explicit environment entries layered over the scrubbed parent environment. */
34
+ readonly env: Record<string, string>;
35
+ /** Pinned model, when the deployment named one. */
36
+ readonly model: string | undefined;
37
+ /** Pinned permission mode, overriding the session's knobs. */
38
+ readonly permissionMode: string | undefined;
39
+ }
40
+ /** The engine id this driver registers under. */
41
+ export declare const QODERCLICN_ENGINE: HostedEngineId;
42
+ /**
43
+ * Drives one session through turn and step boundaries on Qoder CN.
44
+ *
45
+ * Named for the engine rather than generically so a stack trace says which
46
+ * driver failed; the shared machinery it inherits is what makes the class this
47
+ * small.
48
+ */
49
+ export declare class QoderclicnAgent extends CliHostedAgent {
50
+ private readonly config;
51
+ private readonly spawn;
52
+ constructor(loopCtx: Context, id: SessionId, options: AgentOptions, session: Session, config: ResolvedQoderclicnConfig, spawn: CliSpawnCapability);
53
+ protected runStep(messages: readonly UserMessage[], position: SinkPosition, signal: AbortSignal): Promise<{
54
+ kind: 'completed';
55
+ } | null>;
56
+ /** Resolve the permission mode for this step: the pin wins, else the session's knobs. */
57
+ private permissionMode;
58
+ }
59
+ //# sourceMappingURL=agent.d.ts.map
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Qoder CN loop engine module: drives every session it is handed through one
3
+ * `qoderclicn -p --output-format stream-json` child per dsh step, with the
4
+ * durable session log as the sole source of model context. The router routes a
5
+ * session here on the plugin's own engine record, else its agent preset; this
6
+ * module is a library, not a Cordis plugin entry.
7
+ *
8
+ * Qoder's CLI has a permission-mode switch but no channel this driver can
9
+ * forward a human approval question through, so the effective boundary is the
10
+ * dsh subprocess sandbox the whole child is spawned under (default read-only)
11
+ * plus the mode mapped in `./process.ts`.
12
+ *
13
+ * @module dsh-loop-engine-allinone/engine-qoderclicn
14
+ */
15
+ import type { Context } from '@deepseek-ai/cordis';
16
+ import z from '@deepseek-ai/schemastery';
17
+ import type { AgentOptions } from '@deepseek-ai/dsh-agent';
18
+ import type { Session, SessionId } from '@deepseek-ai/dsh-session';
19
+ import { CliEngineRuntime } from '../driver-cli/cli-loop.ts';
20
+ import { QoderclicnAgent, type ResolvedQoderclicnConfig } from './agent.ts';
21
+ /** Deployment-owned configuration for the Qoder CN engine. */
22
+ export interface Config {
23
+ /** Model for the CLI (`--model`); Qoder's own configuration owns the model when omitted. */
24
+ model?: string;
25
+ /** Explicit environment entries passed to the child. */
26
+ env?: Record<string, string>;
27
+ /** The `qoderclicn` executable; PATH (and the CLI's own install dir) when not pinned. */
28
+ bin?: string;
29
+ /** Pinned permission mode, overriding the session's dsh permission knobs. */
30
+ permissionMode?: string;
31
+ }
32
+ /** Schema of the Qoder CN engine configuration. */
33
+ export declare const Config: z<Config>;
34
+ /** Host-face ctx key this engine's runtime is registered under. */
35
+ export declare const QODERCLICN_ENGINE_LABEL = "agentLoopQoderclicn";
36
+ declare module '@deepseek-ai/cordis' {
37
+ interface Context {
38
+ agentLoopQoderclicn: QoderclicnLoop;
39
+ }
40
+ }
41
+ /**
42
+ * Creation/resume machinery for the Qoder CN engine. The process-wide
43
+ * AgentFactory slot belongs to the router, which delegates each session to the
44
+ * engine its preset names; this class is that engine's driver, not a plugin.
45
+ */
46
+ export declare class QoderclicnLoop extends CliEngineRuntime<ResolvedQoderclicnConfig, QoderclicnAgent> {
47
+ constructor(ctx: Context, config: Config);
48
+ /** Construct the Qoder driver for one prepared session. */
49
+ protected buildAgent(loopCtx: Context, id: SessionId, options: AgentOptions, session: Session): QoderclicnAgent;
50
+ }
51
+ //# sourceMappingURL=loop.d.ts.map