@pimote/sdk 0.16.0-rc.1 → 0.16.0-rc.2
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/README.md +9 -0
- package/dist/subagents/index.d.ts +2 -1
- package/dist/subagents/presentation.d.ts +228 -0
- package/dist/subagents/presentation.js +1 -0
- package/dist/subagents/provider.d.ts +7 -4
- package/dist/subagents/provider.js +2 -1
- package/dist/subagents/types.d.ts +7 -127
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,6 +5,7 @@ Pimote's extensibility SDK provides APIs for [Pi](https://github.com/earendil-wo
|
|
|
5
5
|
- **`@pimote/sdk/panels`** — push structured card data to the Pimote web client
|
|
6
6
|
- **`@pimote/sdk/folders`** — type-only folder discovery entries for Pimote extensions
|
|
7
7
|
- **`@pimote/sdk/activity`** — answer Pimote's idle-reap background-activity poll
|
|
8
|
+
- **`@pimote/sdk/subagents`** — register or discover a typed per-session subagent provider
|
|
8
9
|
- **`@pimote/sdk/pimote`** — define global `PimoteExtension` factories for sources and Settings files
|
|
9
10
|
|
|
10
11
|
The root `@pimote/sdk` import re-exports session-scoped modules and Pimote extension types.
|
|
@@ -113,6 +114,14 @@ Detection uses pi's EventBus for a synchronous in-process round-trip — pimote'
|
|
|
113
114
|
|
|
114
115
|
When pimote isn't present, the EventBus emit fires with no listener, `detect()` returns `null`, and there's zero overhead.
|
|
115
116
|
|
|
117
|
+
## Subagents — `@pimote/sdk/subagents`
|
|
118
|
+
|
|
119
|
+
This module defines the per-session presentation provider for interactive subagent views. A provider publishes a root-relative hierarchy, typed subagent operations, one ordered replay cursor, and leases to existing child sessions. Pimote discovers providers on the root session's EventBus; child runtimes stay owned by the extension that created them.
|
|
120
|
+
|
|
121
|
+
Use `registerProvider(pi, provider)` to publish a provider. Use `discoverProvider(pi, onProvider)` or the discovery handle to find providers, including late registration and replacement. Registration and discovery return cleanup functions or handles. Cleanup stops discovery or registration; it does not dispose the provider or child sessions. The `SubagentPresentationProvider` contract, typed operation data, cursors, snapshots, and borrowed-session lease types are exported from this module. The my-pi subagents extension implements this provider for Pimote.
|
|
122
|
+
|
|
123
|
+
Provider operations carry typed placement through `toolCallId` and `contentIndex`, or through the containing custom entry's `entryId`. Pimote's server projector suppresses the declared native renderers and places each operation as typed subagent content inside its originating assistant row, preserving surrounding native content order. Router correlation IDs stay inside my-pi. Pimote restores persisted operations through provider hydration rather than decoding extension details.
|
|
124
|
+
|
|
116
125
|
## Pimote extensions — `@pimote/sdk/pimote`
|
|
117
126
|
|
|
118
127
|
Pimote extensions are process-global modules. The host loads direct JavaScript/TypeScript modules and entry-bearing directories from `$XDG_CONFIG_HOME/pimote/extensions/`. User-scoped Pi packages can contribute entries through their `pimote.extensions` manifest field. Project packages and `pi.extensions` entries never load in this host. A module listed in both sections is an explicit dual-host module and runs twice with independent lifecycles.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export type { AgentPath, BorrowedAgentSession, BorrowedSessionManager,
|
|
1
|
+
export type { AgentPath, BorrowedAgentSession, BorrowedSessionManager, FeedCursor, PiEventRef, SubagentAwaitChildStatus, SubagentCapabilities, SubagentLease, SubagentLeaseEvent, SubagentNode, SubagentNodeEventData, SubagentNodeSnapshot, SubagentNodeState, SubagentOperation, SubagentOwnerControlPort, SubagentProviderDiscovery, SubagentProviderRequest, SubagentProviderResponse, SubagentResurrectRequest, SubagentResurrectResult, SubagentState, SubagentStopRequest, SubagentTeardownReason, SubagentTeardownResult, SubagentUsage, SubagentUsageSnapshot, SubagentRuntimeReplacedData, SubagentCostBreakdown, } from './types.js';
|
|
2
2
|
export { SUBAGENT_PROVIDER_REQUEST, SUBAGENT_PROVIDER_RESPONSE, discover, discoverProvider, register, registerProvider } from './provider.js';
|
|
3
3
|
export type { DiscoverProviderOptions } from './provider.js';
|
|
4
|
+
export type { ActiveSubagentOperation, PersistedSubagentContent, SubagentDelegatedChild, SubagentInterruptResult, SubagentInterruptTarget, SubagentResurrectedAgent, SubagentAwaitResult, SubagentAwaitStatus, SubagentCompletionResult, SubagentDeltaData, SubagentDeltaEvent, SubagentEndData, SubagentEndEvent, SubagentFiniteData, SubagentFiniteEvent, SubagentFinalData, SubagentOperationKind, SubagentOperationTarget, SubagentPlacement, SubagentPresentationManifest, SubagentPresentationProvider, SubagentPresentationReplay, SubagentProtocolErrorData, SubagentProviderEvent, SubagentProviderSnapshot, SubagentStartData, SubagentStartEvent, SubagentTopologyEvent, } from './presentation.js';
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import type { AgentPath, BorrowedAgentSession, FeedCursor, PiEventRef, SubagentNodeEventData, SubagentNodeSnapshot, SubagentProviderControls, SubagentRuntimeReplacedData, SubagentUsage } from './types.js';
|
|
2
|
+
export type SubagentPresentationManifest = Readonly<{
|
|
3
|
+
hiddenToolNames: readonly string[];
|
|
4
|
+
hiddenCustomTypes: readonly string[];
|
|
5
|
+
}>;
|
|
6
|
+
export type SubagentOperationKind = 'send' | 'respond' | 'await' | 'delegation' | 'completion' | 'interrupt' | 'teardown' | 'resurrect';
|
|
7
|
+
export type SubagentPlacement = Readonly<{
|
|
8
|
+
toolCallId: string;
|
|
9
|
+
contentIndex: number;
|
|
10
|
+
entryId?: string;
|
|
11
|
+
}> | Readonly<{
|
|
12
|
+
entryId: string;
|
|
13
|
+
}>;
|
|
14
|
+
export type SubagentOperationTarget = Readonly<{
|
|
15
|
+
operationId: string;
|
|
16
|
+
kind: SubagentOperationKind;
|
|
17
|
+
path: AgentPath;
|
|
18
|
+
placement?: SubagentPlacement;
|
|
19
|
+
}>;
|
|
20
|
+
export type SubagentAwaitStatus = Readonly<{
|
|
21
|
+
path: AgentPath;
|
|
22
|
+
state: 'running' | 'waiting' | 'idle' | 'errored' | 'dead' | 'stopped';
|
|
23
|
+
output?: string;
|
|
24
|
+
error?: string;
|
|
25
|
+
sessionId?: string;
|
|
26
|
+
}>;
|
|
27
|
+
export type SubagentCompletionResult = Readonly<{
|
|
28
|
+
state: 'idle' | 'errored' | 'dead' | 'stopped';
|
|
29
|
+
output?: string;
|
|
30
|
+
error?: string;
|
|
31
|
+
usage?: SubagentUsage;
|
|
32
|
+
}>;
|
|
33
|
+
export type SubagentAwaitResult = Readonly<{
|
|
34
|
+
statuses: readonly SubagentAwaitStatus[];
|
|
35
|
+
interrupted?: boolean;
|
|
36
|
+
error?: string;
|
|
37
|
+
}>;
|
|
38
|
+
export type SubagentStartData = Readonly<{
|
|
39
|
+
operation: 'send';
|
|
40
|
+
to: AgentPath;
|
|
41
|
+
request: string;
|
|
42
|
+
response: string;
|
|
43
|
+
phase: 'ready' | 'sending' | 'waiting' | 'responding';
|
|
44
|
+
}> | Readonly<{
|
|
45
|
+
operation: 'respond';
|
|
46
|
+
body: string;
|
|
47
|
+
}> | Readonly<{
|
|
48
|
+
operation: 'await';
|
|
49
|
+
requested: readonly AgentPath[];
|
|
50
|
+
statuses: readonly SubagentAwaitStatus[];
|
|
51
|
+
}>;
|
|
52
|
+
export type SubagentDeltaData = Readonly<{
|
|
53
|
+
operation: 'send';
|
|
54
|
+
field: 'request' | 'response';
|
|
55
|
+
delta: string;
|
|
56
|
+
}> | Readonly<{
|
|
57
|
+
operation: 'send';
|
|
58
|
+
phase: 'waiting' | 'responding';
|
|
59
|
+
}> | Readonly<{
|
|
60
|
+
operation: 'respond';
|
|
61
|
+
delta: string;
|
|
62
|
+
}> | Readonly<{
|
|
63
|
+
operation: 'await';
|
|
64
|
+
statuses: readonly SubagentAwaitStatus[];
|
|
65
|
+
}>;
|
|
66
|
+
export type SubagentEndData = Readonly<{
|
|
67
|
+
operation: 'send';
|
|
68
|
+
to: AgentPath;
|
|
69
|
+
request: string;
|
|
70
|
+
response: string;
|
|
71
|
+
error?: string;
|
|
72
|
+
}> | Readonly<{
|
|
73
|
+
operation: 'respond';
|
|
74
|
+
body: string;
|
|
75
|
+
error?: string;
|
|
76
|
+
}> | Readonly<{
|
|
77
|
+
operation: 'await';
|
|
78
|
+
result: SubagentAwaitResult;
|
|
79
|
+
}>;
|
|
80
|
+
export type SubagentDelegatedChild = Readonly<{
|
|
81
|
+
path: AgentPath;
|
|
82
|
+
task: string;
|
|
83
|
+
persona?: string;
|
|
84
|
+
}>;
|
|
85
|
+
export type SubagentInterruptTarget = Readonly<{
|
|
86
|
+
path: AgentPath;
|
|
87
|
+
output?: string;
|
|
88
|
+
error?: string;
|
|
89
|
+
}>;
|
|
90
|
+
export type SubagentInterruptResult = Readonly<{
|
|
91
|
+
interrupted: readonly SubagentInterruptTarget[];
|
|
92
|
+
pending: readonly SubagentInterruptTarget[];
|
|
93
|
+
failed: readonly SubagentInterruptTarget[];
|
|
94
|
+
}>;
|
|
95
|
+
export type SubagentResurrectedAgent = Readonly<{
|
|
96
|
+
path: AgentPath;
|
|
97
|
+
sessionId: string;
|
|
98
|
+
incarnation: string;
|
|
99
|
+
state: 'idle' | 'running';
|
|
100
|
+
usage: SubagentUsage;
|
|
101
|
+
output?: string;
|
|
102
|
+
error?: string;
|
|
103
|
+
}>;
|
|
104
|
+
export type SubagentFiniteData = Readonly<{
|
|
105
|
+
operation: 'delegation';
|
|
106
|
+
children: readonly SubagentDelegatedChild[];
|
|
107
|
+
}> | Readonly<{
|
|
108
|
+
operation: 'completion';
|
|
109
|
+
result: SubagentCompletionResult;
|
|
110
|
+
}> | Readonly<{
|
|
111
|
+
operation: 'interrupt';
|
|
112
|
+
result: SubagentInterruptResult;
|
|
113
|
+
}> | Readonly<{
|
|
114
|
+
operation: 'teardown';
|
|
115
|
+
result: Readonly<{
|
|
116
|
+
affectedAgents: readonly Readonly<{
|
|
117
|
+
path: AgentPath;
|
|
118
|
+
sessionId: string;
|
|
119
|
+
incarnation: string;
|
|
120
|
+
state: SubagentAwaitStatus['state'];
|
|
121
|
+
usage: SubagentUsage;
|
|
122
|
+
output?: string;
|
|
123
|
+
error?: string;
|
|
124
|
+
}>[];
|
|
125
|
+
status: 'removed' | 'already_removed' | 'not_found';
|
|
126
|
+
}>;
|
|
127
|
+
}> | Readonly<{
|
|
128
|
+
operation: 'resurrect';
|
|
129
|
+
result: Readonly<{
|
|
130
|
+
affectedAgents: readonly SubagentResurrectedAgent[];
|
|
131
|
+
}>;
|
|
132
|
+
}> | Readonly<{
|
|
133
|
+
operation: 'protocol_error';
|
|
134
|
+
message: string;
|
|
135
|
+
}>;
|
|
136
|
+
export type SubagentFinalData = SubagentEndData | SubagentFiniteData;
|
|
137
|
+
export type SubagentProtocolErrorData = Readonly<{
|
|
138
|
+
operationId: string;
|
|
139
|
+
operation: SubagentOperationKind;
|
|
140
|
+
message: string;
|
|
141
|
+
}>;
|
|
142
|
+
export type ActiveSubagentOperation = Readonly<{
|
|
143
|
+
target: SubagentOperationTarget;
|
|
144
|
+
data: SubagentStartData;
|
|
145
|
+
}>;
|
|
146
|
+
type PresentationEventBase = Readonly<{
|
|
147
|
+
eventId: string;
|
|
148
|
+
cursor: FeedCursor;
|
|
149
|
+
target: SubagentOperationTarget;
|
|
150
|
+
}>;
|
|
151
|
+
export type SubagentStartEvent = PresentationEventBase & Readonly<{
|
|
152
|
+
type: 'subagent_start';
|
|
153
|
+
data: SubagentStartData;
|
|
154
|
+
}>;
|
|
155
|
+
export type SubagentDeltaEvent = PresentationEventBase & Readonly<{
|
|
156
|
+
type: 'subagent_delta';
|
|
157
|
+
data: SubagentDeltaData;
|
|
158
|
+
}>;
|
|
159
|
+
export type SubagentEndEvent = PresentationEventBase & Readonly<{
|
|
160
|
+
type: 'subagent_end';
|
|
161
|
+
state: 'complete' | 'error' | 'aborted';
|
|
162
|
+
data: SubagentEndData;
|
|
163
|
+
}>;
|
|
164
|
+
export type SubagentFiniteEvent = PresentationEventBase & Readonly<{
|
|
165
|
+
type: 'subagent_snapshot_event';
|
|
166
|
+
state: 'complete' | 'error' | 'aborted';
|
|
167
|
+
data: SubagentFinalData;
|
|
168
|
+
}>;
|
|
169
|
+
type SubagentTopologyData = Readonly<{
|
|
170
|
+
kind: 'node_added' | 'node_updated';
|
|
171
|
+
data: SubagentNodeEventData;
|
|
172
|
+
}> | Readonly<{
|
|
173
|
+
kind: 'node_removed';
|
|
174
|
+
data: Readonly<{
|
|
175
|
+
node: SubagentNodeSnapshot;
|
|
176
|
+
reason: string;
|
|
177
|
+
}>;
|
|
178
|
+
}> | Readonly<{
|
|
179
|
+
kind: 'runtime_replaced';
|
|
180
|
+
data: SubagentRuntimeReplacedData;
|
|
181
|
+
}>;
|
|
182
|
+
export type SubagentTopologyEvent = Readonly<{
|
|
183
|
+
eventId: string;
|
|
184
|
+
cursor: FeedCursor;
|
|
185
|
+
path: AgentPath;
|
|
186
|
+
relatedPiEvents: readonly PiEventRef[];
|
|
187
|
+
}> & SubagentTopologyData;
|
|
188
|
+
export type SubagentProviderEvent = SubagentTopologyEvent | SubagentStartEvent | SubagentDeltaEvent | SubagentEndEvent | SubagentFiniteEvent;
|
|
189
|
+
export type PersistedSubagentContent = Readonly<{
|
|
190
|
+
operationId: string;
|
|
191
|
+
kind: SubagentOperationKind;
|
|
192
|
+
state: 'complete' | 'error' | 'aborted';
|
|
193
|
+
data: SubagentFinalData;
|
|
194
|
+
}> & (Readonly<{
|
|
195
|
+
source: 'tool';
|
|
196
|
+
placement: Extract<SubagentPlacement, {
|
|
197
|
+
toolCallId: string;
|
|
198
|
+
}>;
|
|
199
|
+
}> | Readonly<{
|
|
200
|
+
source: 'custom_entry';
|
|
201
|
+
placement?: Extract<SubagentPlacement, {
|
|
202
|
+
entryId: string;
|
|
203
|
+
}>;
|
|
204
|
+
}>);
|
|
205
|
+
export type SubagentProviderSnapshot = Readonly<{
|
|
206
|
+
manifest: SubagentPresentationManifest;
|
|
207
|
+
nodes: readonly SubagentNodeSnapshot[];
|
|
208
|
+
cursor: FeedCursor;
|
|
209
|
+
activeOperations: readonly ActiveSubagentOperation[];
|
|
210
|
+
}>;
|
|
211
|
+
export type SubagentPresentationReplay = Readonly<{
|
|
212
|
+
kind: 'events';
|
|
213
|
+
cursor: FeedCursor;
|
|
214
|
+
events: readonly SubagentProviderEvent[];
|
|
215
|
+
}> | Readonly<{
|
|
216
|
+
kind: 'snapshot_required';
|
|
217
|
+
reason: 'epoch_changed' | 'history_unavailable';
|
|
218
|
+
}>;
|
|
219
|
+
export interface SubagentPresentationProvider extends SubagentProviderControls {
|
|
220
|
+
snapshot(): SubagentProviderSnapshot;
|
|
221
|
+
subscribe(listener: (event: SubagentProviderEvent) => void): () => void;
|
|
222
|
+
replay(after?: FeedCursor): SubagentPresentationReplay;
|
|
223
|
+
rehydrate(input: {
|
|
224
|
+
session: BorrowedAgentSession;
|
|
225
|
+
path: AgentPath;
|
|
226
|
+
}): Promise<void>;
|
|
227
|
+
}
|
|
228
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import type { ExtensionAPI } from '@earendil-works/pi-coding-agent';
|
|
2
|
-
import type { SubagentEventBusOwner,
|
|
2
|
+
import type { SubagentEventBusOwner, SubagentProviderDiscovery } from './types.js';
|
|
3
|
+
import type { SubagentPresentationProvider } from './presentation.js';
|
|
4
|
+
type RegisteredProvider = SubagentPresentationProvider;
|
|
3
5
|
/** EventBus channel emitted by a Pimote host to discover a provider. */
|
|
4
6
|
export declare const SUBAGENT_PROVIDER_REQUEST: "pimote:subagents:request";
|
|
5
7
|
/** EventBus channel carrying the currently registered provider. */
|
|
6
8
|
export declare const SUBAGENT_PROVIDER_RESPONSE: "pimote:subagents:response";
|
|
7
|
-
export declare function registerProvider(owner: SubagentEventBusOwner | ExtensionAPI, provider:
|
|
9
|
+
export declare function registerProvider(owner: SubagentEventBusOwner | ExtensionAPI, provider: RegisteredProvider): () => void;
|
|
8
10
|
export interface DiscoverProviderOptions {
|
|
9
11
|
/** Called whenever the provider first appears or is replaced. */
|
|
10
|
-
onProvider?: (provider:
|
|
12
|
+
onProvider?: (provider: RegisteredProvider) => void;
|
|
11
13
|
}
|
|
12
14
|
/**
|
|
13
15
|
* Discover the provider on a session EventBus and keep listening for late
|
|
@@ -19,9 +21,10 @@ export interface DiscoverProviderOptions {
|
|
|
19
21
|
* after installing its response listener, so a provider registered before or
|
|
20
22
|
* during the handshake cannot be missed.
|
|
21
23
|
*/
|
|
22
|
-
export declare function discoverProvider(owner: SubagentEventBusOwner | ExtensionAPI, onProvider: (provider:
|
|
24
|
+
export declare function discoverProvider(owner: SubagentEventBusOwner | ExtensionAPI, onProvider: (provider: RegisteredProvider) => void): () => void;
|
|
23
25
|
export declare function discoverProvider(owner: SubagentEventBusOwner | ExtensionAPI, options?: DiscoverProviderOptions): SubagentProviderDiscovery;
|
|
24
26
|
/** Short alias for hosts that use the request/response verb. */
|
|
25
27
|
export declare const discover: typeof discoverProvider;
|
|
26
28
|
/** Short alias for extensions that use the registration verb. */
|
|
27
29
|
export declare const register: typeof registerProvider;
|
|
30
|
+
export {};
|
|
@@ -91,7 +91,7 @@ export function discoverProvider(owner, callbackOrOptions) {
|
|
|
91
91
|
};
|
|
92
92
|
if (callback)
|
|
93
93
|
return close;
|
|
94
|
-
|
|
94
|
+
const discovery = {
|
|
95
95
|
get provider() {
|
|
96
96
|
return current;
|
|
97
97
|
},
|
|
@@ -116,6 +116,7 @@ export function discoverProvider(owner, callbackOrOptions) {
|
|
|
116
116
|
},
|
|
117
117
|
close,
|
|
118
118
|
};
|
|
119
|
+
return discovery;
|
|
119
120
|
}
|
|
120
121
|
/** Short alias for hosts that use the request/response verb. */
|
|
121
122
|
export const discover = discoverProvider;
|
|
@@ -13,46 +13,6 @@ export type PiEventRef = Readonly<{
|
|
|
13
13
|
toolCallId?: string;
|
|
14
14
|
kind: 'message' | 'tool_call' | 'custom_message' | 'lifecycle';
|
|
15
15
|
}>;
|
|
16
|
-
export type SubagentEventKind = 'node_added' | 'node_updated' | 'node_removed' | 'runtime_replaced' | 'delegation' | 'message_thread' | 'await_started' | 'child_settled' | 'await_interrupted' | 'await_released' | 'completion' | 'interrupt' | 'teardown' | 'resurrect';
|
|
17
|
-
export type SubagentDelegationData = Readonly<{
|
|
18
|
-
invocationId: string;
|
|
19
|
-
awaitsResult: boolean;
|
|
20
|
-
children: readonly Readonly<{
|
|
21
|
-
path: AgentPath;
|
|
22
|
-
task: string;
|
|
23
|
-
persona?: string;
|
|
24
|
-
}>[];
|
|
25
|
-
}>;
|
|
26
|
-
/** Alias used by the my-pi provider implementation. */
|
|
27
|
-
export type DelegationData = SubagentDelegationData;
|
|
28
|
-
export type SubagentCompletionData = Readonly<{
|
|
29
|
-
status: 'idle' | 'errored' | 'dead' | 'stopped';
|
|
30
|
-
output?: string;
|
|
31
|
-
error?: string;
|
|
32
|
-
usage?: SubagentUsage;
|
|
33
|
-
}> & (Readonly<{
|
|
34
|
-
delivery: 'awaited';
|
|
35
|
-
invocationId: string;
|
|
36
|
-
}> | Readonly<{
|
|
37
|
-
delivery: 'asynchronous';
|
|
38
|
-
invocationId?: string;
|
|
39
|
-
}>);
|
|
40
|
-
/** Alias used by the my-pi provider implementation. */
|
|
41
|
-
export type CompletionData = SubagentCompletionData;
|
|
42
|
-
export type SubagentMessageData = Readonly<{
|
|
43
|
-
from: AgentPath;
|
|
44
|
-
to: AgentPath;
|
|
45
|
-
text: string;
|
|
46
|
-
correlationId?: string;
|
|
47
|
-
responseExpected: boolean;
|
|
48
|
-
}> & (Readonly<{
|
|
49
|
-
phase: 'sent' | 'received' | 'response';
|
|
50
|
-
}> | Readonly<{
|
|
51
|
-
phase: 'failure';
|
|
52
|
-
error: string;
|
|
53
|
-
}>);
|
|
54
|
-
/** Alias used by the my-pi provider implementation. */
|
|
55
|
-
export type CommunicationData = SubagentMessageData;
|
|
56
16
|
/** One child state included in await progress and settlement facts. */
|
|
57
17
|
export type SubagentAwaitChildStatus = Readonly<{
|
|
58
18
|
path: AgentPath;
|
|
@@ -61,31 +21,6 @@ export type SubagentAwaitChildStatus = Readonly<{
|
|
|
61
21
|
error?: string;
|
|
62
22
|
sessionId?: string;
|
|
63
23
|
}>;
|
|
64
|
-
/** Await progress, interruption, and release details. */
|
|
65
|
-
export type SubagentAwaitData = Readonly<{
|
|
66
|
-
invocationId?: string;
|
|
67
|
-
requested?: readonly AgentPath[];
|
|
68
|
-
statuses?: readonly SubagentAwaitChildStatus[];
|
|
69
|
-
path?: AgentPath;
|
|
70
|
-
output?: string;
|
|
71
|
-
error?: string;
|
|
72
|
-
reason?: 'settled' | 'detach' | 'stop' | 'message';
|
|
73
|
-
message?: SubagentMessageData;
|
|
74
|
-
/** Provider implementations can carry additional typed await facts. */
|
|
75
|
-
readonly [key: string]: unknown;
|
|
76
|
-
}>;
|
|
77
|
-
/** Lifecycle operation details carried by interrupt, teardown, and resurrection facts. */
|
|
78
|
-
export type SubagentLifecycleData = Readonly<{
|
|
79
|
-
operation?: 'interrupt' | 'teardown' | 'resurrect';
|
|
80
|
-
outcome?: string;
|
|
81
|
-
path?: AgentPath;
|
|
82
|
-
output?: string;
|
|
83
|
-
error?: string;
|
|
84
|
-
sessionId?: string;
|
|
85
|
-
recovery?: Readonly<Record<string, unknown>>;
|
|
86
|
-
/** Provider implementations can carry operation-specific recovery data. */
|
|
87
|
-
readonly [key: string]: unknown;
|
|
88
|
-
}>;
|
|
89
24
|
/** A public node projection carried by topology events and snapshots. */
|
|
90
25
|
export type SubagentNodeSnapshot = Readonly<{
|
|
91
26
|
path: AgentPath;
|
|
@@ -104,7 +39,6 @@ export type SubagentNodeSnapshot = Readonly<{
|
|
|
104
39
|
contextFill?: number;
|
|
105
40
|
channels: readonly string[];
|
|
106
41
|
waitingFor: readonly AgentPath[];
|
|
107
|
-
pendingCorrelations: readonly string[];
|
|
108
42
|
hasSubgroup: boolean;
|
|
109
43
|
lastOutput?: string;
|
|
110
44
|
lastError?: string;
|
|
@@ -120,44 +54,6 @@ export type SubagentRuntimeReplacedData = Readonly<{
|
|
|
120
54
|
oldSessionId: string;
|
|
121
55
|
newSessionId: string;
|
|
122
56
|
}>;
|
|
123
|
-
export type SubagentEventData = Readonly<{
|
|
124
|
-
kind: 'node_added' | 'node_updated';
|
|
125
|
-
data: SubagentNodeEventData;
|
|
126
|
-
}> | Readonly<{
|
|
127
|
-
kind: 'node_removed';
|
|
128
|
-
data: Readonly<{
|
|
129
|
-
node: SubagentNodeSnapshot;
|
|
130
|
-
reason: string;
|
|
131
|
-
}>;
|
|
132
|
-
}> | Readonly<{
|
|
133
|
-
kind: 'runtime_replaced';
|
|
134
|
-
data: SubagentRuntimeReplacedData;
|
|
135
|
-
}> | Readonly<{
|
|
136
|
-
kind: 'delegation';
|
|
137
|
-
data: SubagentDelegationData;
|
|
138
|
-
}> | Readonly<{
|
|
139
|
-
kind: 'message_thread';
|
|
140
|
-
data: SubagentMessageData;
|
|
141
|
-
}> | Readonly<{
|
|
142
|
-
kind: 'await_started' | 'child_settled' | 'await_interrupted' | 'await_released';
|
|
143
|
-
data: SubagentAwaitData;
|
|
144
|
-
}> | Readonly<{
|
|
145
|
-
kind: 'completion';
|
|
146
|
-
data: SubagentCompletionData;
|
|
147
|
-
}> | Readonly<{
|
|
148
|
-
kind: 'interrupt' | 'teardown' | 'resurrect';
|
|
149
|
-
data: SubagentLifecycleData;
|
|
150
|
-
}>;
|
|
151
|
-
/** A semantic overlay. Native Pi entries remain the transcript source. */
|
|
152
|
-
export type SubagentSemanticFact = Readonly<{
|
|
153
|
-
eventId: string;
|
|
154
|
-
path: AgentPath;
|
|
155
|
-
relatedPiEvents: readonly PiEventRef[];
|
|
156
|
-
}> & SubagentEventData;
|
|
157
|
-
/** A typed live feed event with its provider-owned replay cursor. */
|
|
158
|
-
export type SubagentEvent = SubagentSemanticFact & Readonly<{
|
|
159
|
-
cursor: FeedCursor;
|
|
160
|
-
}>;
|
|
161
57
|
export type SubagentState = 'running' | 'waiting' | 'idle' | 'errored' | 'dead';
|
|
162
58
|
export type SubagentNodeState = SubagentState;
|
|
163
59
|
export type SubagentCostBreakdown = Readonly<{
|
|
@@ -176,19 +72,6 @@ export type SubagentUsage = Readonly<{
|
|
|
176
72
|
costBreakdown?: SubagentCostBreakdown;
|
|
177
73
|
turns: number;
|
|
178
74
|
}>;
|
|
179
|
-
/** Snapshot boundary for the current provider epoch. */
|
|
180
|
-
export type SubagentSnapshot = Readonly<{
|
|
181
|
-
cursor: FeedCursor;
|
|
182
|
-
nodes: readonly SubagentNodeSnapshot[];
|
|
183
|
-
}>;
|
|
184
|
-
export type ReplayResult = Readonly<{
|
|
185
|
-
kind: 'events';
|
|
186
|
-
cursor: FeedCursor;
|
|
187
|
-
events: readonly SubagentEvent[];
|
|
188
|
-
}> | Readonly<{
|
|
189
|
-
kind: 'snapshot_required';
|
|
190
|
-
reason: 'epoch_changed' | 'history_unavailable';
|
|
191
|
-
}>;
|
|
192
75
|
export type SubagentTeardownReason = 'not_found' | 'already_removed' | 'removed';
|
|
193
76
|
export type SubagentTeardownResult = Readonly<{
|
|
194
77
|
path: AgentPath;
|
|
@@ -287,11 +170,8 @@ export interface SubagentOwnerControlPort {
|
|
|
287
170
|
stop(request: SubagentStopRequest): Promise<void>;
|
|
288
171
|
resurrect(request: SubagentResurrectRequest): Promise<SubagentResurrectResult>;
|
|
289
172
|
}
|
|
290
|
-
/**
|
|
291
|
-
export interface
|
|
292
|
-
subscribe(listener: (event: SubagentEvent) => void): () => void;
|
|
293
|
-
snapshot(): SubagentSnapshot;
|
|
294
|
-
replay(after?: FeedCursor): ReplayResult;
|
|
173
|
+
/** Provider-owned leases and guarded lifecycle controls shared by the presentation seam. */
|
|
174
|
+
export interface SubagentProviderControls {
|
|
295
175
|
acquire(path: AgentPath): Promise<SubagentLease>;
|
|
296
176
|
teardown(path: AgentPath, incarnation: string): Promise<SubagentTeardownResult>;
|
|
297
177
|
stop(request: SubagentStopRequest): Promise<void>;
|
|
@@ -304,16 +184,16 @@ export type SubagentProviderRequest = Readonly<{
|
|
|
304
184
|
}>;
|
|
305
185
|
/** EventBus response payload used by provider registration and discovery. */
|
|
306
186
|
export type SubagentProviderResponse = Readonly<{
|
|
307
|
-
provider:
|
|
187
|
+
provider: import('./presentation.js').SubagentPresentationProvider;
|
|
308
188
|
}>;
|
|
309
189
|
/** A live discovery handle that tracks late registration and replacement. */
|
|
310
190
|
export interface SubagentProviderDiscovery {
|
|
311
|
-
readonly provider:
|
|
191
|
+
readonly provider: import('./presentation.js').SubagentPresentationProvider | undefined;
|
|
312
192
|
/** Alias for callers that model discovery as a mutable current value. */
|
|
313
|
-
readonly current:
|
|
314
|
-
subscribe(listener: (provider:
|
|
193
|
+
readonly current: import('./presentation.js').SubagentPresentationProvider | undefined;
|
|
194
|
+
subscribe(listener: (provider: import('./presentation.js').SubagentPresentationProvider | undefined) => void): () => void;
|
|
315
195
|
/** Alias for subscribe, useful at the host event boundary. */
|
|
316
|
-
onProvider(listener: (provider:
|
|
196
|
+
onProvider(listener: (provider: import('./presentation.js').SubagentPresentationProvider | undefined) => void): () => void;
|
|
317
197
|
close(): void;
|
|
318
198
|
}
|
|
319
199
|
/** Extract the EventBus from either ExtensionAPI or an EventBus itself. */
|
package/package.json
CHANGED