@fungi.computer/shiitake 0.5.0 → 0.6.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/dist/agent-control.d.ts +93 -1
- package/dist/agent-control.js +108 -6
- package/dist/client-entry.d.ts +20 -0
- package/dist/client-entry.js +5 -0
- package/dist/client-visitor.d.ts +31 -0
- package/dist/client-visitor.js +226 -0
- package/dist/client-wire.d.ts +5 -0
- package/dist/client-wire.js +6 -0
- package/dist/client.d.ts +4 -3
- package/dist/client.js +1 -0
- package/dist/delegation.d.ts +74 -53
- package/dist/delegation.js +4 -15
- package/dist/effect.d.ts +25 -0
- package/dist/effect.js +14 -1
- package/dist/extensions.d.ts +21 -2
- package/dist/extensions.js +1 -1
- package/dist/fleet.d.ts +15 -0
- package/dist/fleet.js +32 -6
- package/dist/hosted.js +3 -0
- package/dist/http-routes.d.ts +11 -0
- package/dist/internal/accepted-run-executor.js +2 -1
- package/dist/internal/admission-door.d.ts +5 -0
- package/dist/internal/admission-door.js +27 -1
- package/dist/internal/contracts.d.ts +14 -1
- package/dist/internal/coordinator.js +8 -2
- package/dist/internal/effect-client.js +1 -1
- package/dist/internal/effect-contracts.d.ts +4 -2
- package/dist/internal/extension-command-registry.d.ts +2 -1
- package/dist/internal/extension-command-registry.js +3 -1
- package/dist/internal/extension-runtime.d.ts +3 -1
- package/dist/internal/extension-runtime.js +13 -5
- package/dist/internal/model-acquisition.js +2 -0
- package/dist/internal/observation-kernel.d.ts +2 -0
- package/dist/internal/observation-kernel.js +17 -6
- package/dist/internal/run-scope.d.ts +14 -0
- package/dist/internal/run-scope.js +32 -9
- package/dist/internal/runtime-coordinator.js +8 -1
- package/dist/internal/runtime-reconciliation.js +119 -24
- package/dist/internal/woodstock/agent-reply.d.ts +5 -0
- package/dist/internal/woodstock/agent-reply.js +3 -0
- package/dist/internal/woodstock/client-projection.js +9 -1
- package/dist/internal/woodstock/index.d.ts +4 -0
- package/dist/internal/woodstock/index.js +7 -0
- package/dist/internal/woodstock/session-delegator.d.ts +12 -0
- package/dist/internal/woodstock/session-delegator.js +44 -0
- package/dist/internal/woodstock/session-entry.d.ts +12 -2
- package/dist/internal/woodstock/session-store.d.ts +2 -0
- package/dist/internal/woodstock/session-store.js +20 -0
- package/dist/internal/woodstock/work-senders.d.ts +32 -0
- package/dist/internal/woodstock/work-senders.js +70 -0
- package/dist/remote-client.js +7 -2
- package/dist/server-visitor-stream.d.ts +13 -0
- package/dist/server-visitor-stream.js +115 -0
- package/dist/session-attention.d.ts +30 -0
- package/dist/session-attention.js +14 -0
- package/docs/api/agent-control.md +209 -13
- package/docs/api/client-entry.md +3 -0
- package/docs/api/client.md +136 -1
- package/docs/api/cloudflare.md +7 -1
- package/docs/api/delegation.md +234 -61
- package/docs/api/effect.md +16 -6
- package/docs/api/extensions.md +65 -4
- package/docs/api/fleet.md +69 -16
- package/docs/api/index.md +6 -4
- package/package.json +10 -6
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { SSEStreamingApi } from "hono/streaming";
|
|
2
|
+
import { visitorSnapshot } from "./client-visitor.js";
|
|
3
|
+
export function visitorStream(options) {
|
|
4
|
+
const { readable, writable } = new TransformStream();
|
|
5
|
+
const stream = new SSEStreamingApi(writable, readable);
|
|
6
|
+
let closing;
|
|
7
|
+
let ending = false;
|
|
8
|
+
let heartbeat;
|
|
9
|
+
const expiry = setTimeout(() => {
|
|
10
|
+
void close().catch((cause) => {
|
|
11
|
+
options.onError("channel_visitor_stream_expiry_failed", cause);
|
|
12
|
+
});
|
|
13
|
+
}, Math.max(0, options.expiresAt - options.now()));
|
|
14
|
+
const close = () => {
|
|
15
|
+
if (closing !== undefined)
|
|
16
|
+
return closing;
|
|
17
|
+
ending = true;
|
|
18
|
+
clearTimeout(expiry);
|
|
19
|
+
clearTimeout(heartbeat);
|
|
20
|
+
options.release();
|
|
21
|
+
closing = Promise.resolve().then(async () => {
|
|
22
|
+
stream.abort();
|
|
23
|
+
try {
|
|
24
|
+
await options.watch.close();
|
|
25
|
+
}
|
|
26
|
+
finally {
|
|
27
|
+
await stream.close();
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return closing;
|
|
31
|
+
};
|
|
32
|
+
stream.onAbort(() => {
|
|
33
|
+
void close().catch((cause) => {
|
|
34
|
+
options.onError("channel_visitor_stream_close_failed", cause);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
const admitted = async () => !ending &&
|
|
38
|
+
options.now() < options.expiresAt &&
|
|
39
|
+
(await options.canRead()) &&
|
|
40
|
+
!ending;
|
|
41
|
+
const beat = async () => {
|
|
42
|
+
if (!(await admitted())) {
|
|
43
|
+
await close();
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
await stream.write(": heartbeat\n\n");
|
|
47
|
+
if (!ending)
|
|
48
|
+
heartbeat = setTimeout(() => {
|
|
49
|
+
void beat().catch((cause) => {
|
|
50
|
+
options.onError("channel_visitor_stream_heartbeat_failed", cause);
|
|
51
|
+
void close().catch((closeCause) => {
|
|
52
|
+
options.onError("channel_visitor_stream_close_failed", closeCause);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
}, 30_000);
|
|
56
|
+
};
|
|
57
|
+
const publish = async (snapshot, progressOnly) => {
|
|
58
|
+
if (!(await admitted()))
|
|
59
|
+
return false;
|
|
60
|
+
const baseline = visitorSnapshot(options.filter(snapshot), options.visitorId);
|
|
61
|
+
await stream.writeSSE(progressOnly
|
|
62
|
+
? {
|
|
63
|
+
event: "frame",
|
|
64
|
+
data: JSON.stringify({
|
|
65
|
+
kind: "progress",
|
|
66
|
+
progress: baseline.progress,
|
|
67
|
+
activity: baseline.activity,
|
|
68
|
+
}),
|
|
69
|
+
}
|
|
70
|
+
: { event: "session", data: JSON.stringify(baseline) });
|
|
71
|
+
return !ending;
|
|
72
|
+
};
|
|
73
|
+
const pump = async () => {
|
|
74
|
+
try {
|
|
75
|
+
let snapshot = options.watch.snapshot;
|
|
76
|
+
if (!(await publish(snapshot, false)))
|
|
77
|
+
return;
|
|
78
|
+
heartbeat = setTimeout(() => {
|
|
79
|
+
void beat().catch((cause) => {
|
|
80
|
+
options.onError("channel_visitor_stream_heartbeat_failed", cause);
|
|
81
|
+
void close().catch((closeCause) => {
|
|
82
|
+
options.onError("channel_visitor_stream_close_failed", closeCause);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
}, 30_000);
|
|
86
|
+
for await (const frame of options.watch.changes) {
|
|
87
|
+
if (ending)
|
|
88
|
+
break;
|
|
89
|
+
if (frame.kind === "tool_output")
|
|
90
|
+
continue;
|
|
91
|
+
snapshot =
|
|
92
|
+
frame.kind === "progress"
|
|
93
|
+
? {
|
|
94
|
+
...snapshot,
|
|
95
|
+
progress: frame.progress,
|
|
96
|
+
activity: frame.activity,
|
|
97
|
+
}
|
|
98
|
+
: frame.kind === "activity"
|
|
99
|
+
? { ...snapshot, activity: frame.activity }
|
|
100
|
+
: frame.kind === "reset"
|
|
101
|
+
? frame.baseline
|
|
102
|
+
: await options.read();
|
|
103
|
+
if (!(await publish(snapshot, frame.kind === "progress")))
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
finally {
|
|
108
|
+
await close();
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
void pump().catch((cause) => {
|
|
112
|
+
options.onError("channel_visitor_stream_failed", cause);
|
|
113
|
+
});
|
|
114
|
+
return stream.responseReadable.pipeThrough(new TransformStream());
|
|
115
|
+
}
|
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
import * as Schema from "effect/Schema";
|
|
2
|
+
/**
|
|
3
|
+
* The Agent Session that sent the work an item belongs to. The host derives it
|
|
4
|
+
* from the accepted mail; it is the only party the item waits on until it is
|
|
5
|
+
* escalated.
|
|
6
|
+
*/
|
|
7
|
+
export declare const AttentionRecipientSchema: Schema.Struct<{
|
|
8
|
+
readonly agentId: Schema.NonEmptyString;
|
|
9
|
+
readonly sessionId: Schema.NonEmptyString;
|
|
10
|
+
readonly name: Schema.NonEmptyString;
|
|
11
|
+
}>;
|
|
12
|
+
/** Decoded Agent Session an attention item waits on. */
|
|
13
|
+
export type AttentionRecipient = typeof AttentionRecipientSchema.Type;
|
|
2
14
|
/**
|
|
3
15
|
* An extension-owned request for human attention; expiry is owned by its timer.
|
|
4
16
|
* Items marked `inbox: false` remain visible without changing the inbox state.
|
|
17
|
+
* An item with `waitingOn` waits on that Agent first and is never a person's
|
|
18
|
+
* inbox item until it is escalated past every Agent.
|
|
5
19
|
*/
|
|
6
20
|
export declare const AttentionItemSchema: Schema.Struct<{
|
|
7
21
|
readonly id: Schema.NonEmptyString;
|
|
@@ -11,6 +25,12 @@ export declare const AttentionItemSchema: Schema.Struct<{
|
|
|
11
25
|
readonly expiresAt: Schema.optional<Schema.Int>;
|
|
12
26
|
/** This item does not change the Session's inbox state; omission does. */
|
|
13
27
|
readonly inbox: Schema.optional<Schema.Literal<false>>;
|
|
28
|
+
/** The Agent this item waits on; absent means a person. */
|
|
29
|
+
readonly waitingOn: Schema.optional<Schema.Struct<{
|
|
30
|
+
readonly agentId: Schema.NonEmptyString;
|
|
31
|
+
readonly sessionId: Schema.NonEmptyString;
|
|
32
|
+
readonly name: Schema.NonEmptyString;
|
|
33
|
+
}>>;
|
|
14
34
|
}>;
|
|
15
35
|
/** Input to the granted attention door, scoped to the calling extension. */
|
|
16
36
|
export type AttentionItem = typeof AttentionItemSchema.Type;
|
|
@@ -23,6 +43,11 @@ export declare const SessionAttentionSchema: Schema.Struct<{
|
|
|
23
43
|
readonly since: Schema.Int;
|
|
24
44
|
readonly expiresAt: Schema.optional<Schema.Int>;
|
|
25
45
|
readonly inbox: Schema.optional<Schema.Literal<false>>;
|
|
46
|
+
readonly waitingOn: Schema.optional<Schema.Struct<{
|
|
47
|
+
readonly agentId: Schema.NonEmptyString;
|
|
48
|
+
readonly sessionId: Schema.NonEmptyString;
|
|
49
|
+
readonly name: Schema.NonEmptyString;
|
|
50
|
+
}>>;
|
|
26
51
|
}>;
|
|
27
52
|
/** One open attention item in a Session observation. */
|
|
28
53
|
export type SessionAttention = typeof SessionAttentionSchema.Type;
|
|
@@ -39,4 +64,9 @@ export declare const SessionAttentionListSchema: Schema.$Array<Schema.Struct<{
|
|
|
39
64
|
readonly since: Schema.Int;
|
|
40
65
|
readonly expiresAt: Schema.optional<Schema.Int>;
|
|
41
66
|
readonly inbox: Schema.optional<Schema.Literal<false>>;
|
|
67
|
+
readonly waitingOn: Schema.optional<Schema.Struct<{
|
|
68
|
+
readonly agentId: Schema.NonEmptyString;
|
|
69
|
+
readonly sessionId: Schema.NonEmptyString;
|
|
70
|
+
readonly name: Schema.NonEmptyString;
|
|
71
|
+
}>>;
|
|
42
72
|
}>>;
|
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import * as Schema from "effect/Schema";
|
|
2
2
|
const identity = Schema.NonEmptyString.check(Schema.isMaxLength(256));
|
|
3
3
|
const instant = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
|
|
4
|
+
/**
|
|
5
|
+
* The Agent Session that sent the work an item belongs to. The host derives it
|
|
6
|
+
* from the accepted mail; it is the only party the item waits on until it is
|
|
7
|
+
* escalated.
|
|
8
|
+
*/
|
|
9
|
+
export const AttentionRecipientSchema = Schema.Struct({
|
|
10
|
+
agentId: identity,
|
|
11
|
+
sessionId: identity,
|
|
12
|
+
name: identity,
|
|
13
|
+
});
|
|
4
14
|
/**
|
|
5
15
|
* An extension-owned request for human attention; expiry is owned by its timer.
|
|
6
16
|
* Items marked `inbox: false` remain visible without changing the inbox state.
|
|
17
|
+
* An item with `waitingOn` waits on that Agent first and is never a person's
|
|
18
|
+
* inbox item until it is escalated past every Agent.
|
|
7
19
|
*/
|
|
8
20
|
export const AttentionItemSchema = Schema.Struct({
|
|
9
21
|
id: identity,
|
|
@@ -13,6 +25,8 @@ export const AttentionItemSchema = Schema.Struct({
|
|
|
13
25
|
expiresAt: Schema.optional(instant),
|
|
14
26
|
/** This item does not change the Session's inbox state; omission does. */
|
|
15
27
|
inbox: Schema.optional(Schema.Literal(false)),
|
|
28
|
+
/** The Agent this item waits on; absent means a person. */
|
|
29
|
+
waitingOn: Schema.optional(AttentionRecipientSchema),
|
|
16
30
|
});
|
|
17
31
|
/** Public identity includes the owner so two extensions can use the same id. */
|
|
18
32
|
export const SessionAttentionSchema = AttentionItemSchema.mapFields((fields) => ({
|
|
@@ -75,8 +75,9 @@ readonly reason:
|
|
|
75
75
|
### AgentCreateRefused
|
|
76
76
|
|
|
77
77
|
A host's refusal of an Agent creating an Agent: the creator asked to give the
|
|
78
|
-
created Agent more than it holds,
|
|
79
|
-
|
|
78
|
+
created Agent more than it holds, the host cannot tell which Agent is creating,
|
|
79
|
+
or the request id belongs to another creating Agent or Session. It reaches the
|
|
80
|
+
caller as an `agents.create` failure.
|
|
80
81
|
|
|
81
82
|
#### Extends
|
|
82
83
|
|
|
@@ -92,10 +93,10 @@ new AgentCreateRefused(reason, message): AgentCreateRefused;
|
|
|
92
93
|
|
|
93
94
|
###### Parameters
|
|
94
95
|
|
|
95
|
-
| Parameter | Type
|
|
96
|
-
| --------- |
|
|
97
|
-
| `reason` | `"exceeds_creator"` \| `"no_creator"` |
|
|
98
|
-
| `message` | `string`
|
|
96
|
+
| Parameter | Type |
|
|
97
|
+
| --------- | ------------------------------------------------------------- |
|
|
98
|
+
| `reason` | `"exceeds_creator"` \| `"no_creator"` \| `"request_conflict"` |
|
|
99
|
+
| `message` | `string` |
|
|
99
100
|
|
|
100
101
|
###### Returns
|
|
101
102
|
|
|
@@ -124,11 +125,62 @@ Error.name;
|
|
|
124
125
|
##### reason
|
|
125
126
|
|
|
126
127
|
```ts
|
|
127
|
-
readonly reason: "exceeds_creator" | "no_creator";
|
|
128
|
+
readonly reason: "exceeds_creator" | "no_creator" | "request_conflict";
|
|
128
129
|
```
|
|
129
130
|
|
|
130
131
|
## Type Aliases
|
|
131
132
|
|
|
133
|
+
### AgentControlAnswerInput
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
type AgentControlAnswerInput = Readonly<{
|
|
137
|
+
agentId: string;
|
|
138
|
+
sessionId: string;
|
|
139
|
+
askId: string;
|
|
140
|
+
requestId: string;
|
|
141
|
+
answers: MyceliumJsonValue;
|
|
142
|
+
}>;
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Sender-authenticated submission for one child Session's routed Ask.
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
### AgentControlEscalateInput
|
|
150
|
+
|
|
151
|
+
```ts
|
|
152
|
+
type AgentControlEscalateInput = Readonly<{
|
|
153
|
+
agentId: string;
|
|
154
|
+
sessionId: string;
|
|
155
|
+
itemId: string;
|
|
156
|
+
note?: string;
|
|
157
|
+
}>;
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Sender-authenticated escalation of one item a child Session left waiting.
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
### AgentControlAnswerOutput
|
|
165
|
+
|
|
166
|
+
```ts
|
|
167
|
+
type AgentControlAnswerOutput = z.infer<typeof answerOutput>;
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Typed outcome of a sender's answer to a child Ask.
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
### AgentControlEscalateOutput
|
|
175
|
+
|
|
176
|
+
```ts
|
|
177
|
+
type AgentControlEscalateOutput = z.infer<typeof escalateOutput>;
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Typed outcome of a sender's escalation of a child's item.
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
132
184
|
### ArchiveRefusalReason
|
|
133
185
|
|
|
134
186
|
```ts
|
|
@@ -173,10 +225,16 @@ One host-offered model usable as an Agent's create or setModel choice.
|
|
|
173
225
|
```ts
|
|
174
226
|
type AgentDelegationInput = Readonly<{
|
|
175
227
|
agentId: string;
|
|
176
|
-
sessionId: string;
|
|
177
228
|
text: string;
|
|
178
229
|
requestId: string;
|
|
179
|
-
|
|
230
|
+
}> &
|
|
231
|
+
| Readonly<{
|
|
232
|
+
sessionId: string;
|
|
233
|
+
delivery: "steer";
|
|
234
|
+
}>
|
|
235
|
+
| Readonly<{
|
|
236
|
+
sessionId?: string;
|
|
237
|
+
delivery: "followUp";
|
|
180
238
|
}>;
|
|
181
239
|
```
|
|
182
240
|
|
|
@@ -226,6 +284,16 @@ type AgentControlDirectory = Readonly<{
|
|
|
226
284
|
invocation?,
|
|
227
285
|
) => Promise<Accepted | Held>;
|
|
228
286
|
recall?: (input, sourceSessionId, signal) => Promise<CancelResult>;
|
|
287
|
+
answer?: (
|
|
288
|
+
input,
|
|
289
|
+
senderSessionId,
|
|
290
|
+
signal,
|
|
291
|
+
) => Promise<AgentControlAnswerOutput>;
|
|
292
|
+
escalate?: (
|
|
293
|
+
input,
|
|
294
|
+
senderSessionId,
|
|
295
|
+
signal,
|
|
296
|
+
) => Promise<AgentControlEscalateOutput>;
|
|
229
297
|
create?: (input, signal) => Promise<AgentControlAgent>;
|
|
230
298
|
setModel?: (input, signal) => Promise<void>;
|
|
231
299
|
archive?: (input, signal) => Promise<void>;
|
|
@@ -248,6 +316,126 @@ Host-owned discovery and per-operation access to ordinary Agents.
|
|
|
248
316
|
|
|
249
317
|
## Variables
|
|
250
318
|
|
|
319
|
+
### answerOutput
|
|
320
|
+
|
|
321
|
+
```ts
|
|
322
|
+
const answerOutput: ZodDiscriminatedUnion<
|
|
323
|
+
[
|
|
324
|
+
ZodObject<
|
|
325
|
+
{
|
|
326
|
+
status: ZodLiteral<"answered">;
|
|
327
|
+
via: ZodEnum<{
|
|
328
|
+
in_turn: "in_turn";
|
|
329
|
+
follow_up: "follow_up";
|
|
330
|
+
}>;
|
|
331
|
+
commandId: ZodExactOptional<ZodString>;
|
|
332
|
+
},
|
|
333
|
+
$strict
|
|
334
|
+
>,
|
|
335
|
+
ZodObject<
|
|
336
|
+
{
|
|
337
|
+
status: ZodLiteral<"not_found">;
|
|
338
|
+
},
|
|
339
|
+
$strict
|
|
340
|
+
>,
|
|
341
|
+
ZodObject<
|
|
342
|
+
{
|
|
343
|
+
status: ZodLiteral<"closed">;
|
|
344
|
+
reason: ZodEnum<{
|
|
345
|
+
cancelled: "cancelled";
|
|
346
|
+
undeliverable: "undeliverable";
|
|
347
|
+
answered: "answered";
|
|
348
|
+
declined: "declined";
|
|
349
|
+
withdrawn: "withdrawn";
|
|
350
|
+
expired: "expired";
|
|
351
|
+
}>;
|
|
352
|
+
},
|
|
353
|
+
$strict
|
|
354
|
+
>,
|
|
355
|
+
ZodObject<
|
|
356
|
+
{
|
|
357
|
+
status: ZodLiteral<"refused">;
|
|
358
|
+
reason: ZodEnum<{
|
|
359
|
+
not_sender: "not_sender";
|
|
360
|
+
no_provenance: "no_provenance";
|
|
361
|
+
}>;
|
|
362
|
+
},
|
|
363
|
+
$strict
|
|
364
|
+
>,
|
|
365
|
+
ZodObject<
|
|
366
|
+
{
|
|
367
|
+
status: ZodLiteral<"unavailable">;
|
|
368
|
+
reason: ZodLiteral<"unsupported">;
|
|
369
|
+
},
|
|
370
|
+
$strict
|
|
371
|
+
>,
|
|
372
|
+
],
|
|
373
|
+
"status"
|
|
374
|
+
>;
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
Typed outcome of a sender's answer to a child Ask.
|
|
378
|
+
|
|
379
|
+
---
|
|
380
|
+
|
|
381
|
+
### escalateOutput
|
|
382
|
+
|
|
383
|
+
```ts
|
|
384
|
+
const escalateOutput: ZodDiscriminatedUnion<
|
|
385
|
+
[
|
|
386
|
+
ZodObject<
|
|
387
|
+
{
|
|
388
|
+
status: ZodLiteral<"escalated">;
|
|
389
|
+
to: ZodLiteral<"person">;
|
|
390
|
+
},
|
|
391
|
+
$strict
|
|
392
|
+
>,
|
|
393
|
+
ZodObject<
|
|
394
|
+
{
|
|
395
|
+
status: ZodLiteral<"not_found">;
|
|
396
|
+
},
|
|
397
|
+
$strict
|
|
398
|
+
>,
|
|
399
|
+
ZodObject<
|
|
400
|
+
{
|
|
401
|
+
status: ZodLiteral<"closed">;
|
|
402
|
+
reason: ZodEnum<{
|
|
403
|
+
cancelled: "cancelled";
|
|
404
|
+
undeliverable: "undeliverable";
|
|
405
|
+
answered: "answered";
|
|
406
|
+
declined: "declined";
|
|
407
|
+
withdrawn: "withdrawn";
|
|
408
|
+
expired: "expired";
|
|
409
|
+
}>;
|
|
410
|
+
},
|
|
411
|
+
$strict
|
|
412
|
+
>,
|
|
413
|
+
ZodObject<
|
|
414
|
+
{
|
|
415
|
+
status: ZodLiteral<"refused">;
|
|
416
|
+
reason: ZodEnum<{
|
|
417
|
+
not_sender: "not_sender";
|
|
418
|
+
no_provenance: "no_provenance";
|
|
419
|
+
}>;
|
|
420
|
+
},
|
|
421
|
+
$strict
|
|
422
|
+
>,
|
|
423
|
+
ZodObject<
|
|
424
|
+
{
|
|
425
|
+
status: ZodLiteral<"unavailable">;
|
|
426
|
+
reason: ZodLiteral<"unsupported">;
|
|
427
|
+
},
|
|
428
|
+
$strict
|
|
429
|
+
>,
|
|
430
|
+
],
|
|
431
|
+
"status"
|
|
432
|
+
>;
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
Typed outcome of a sender's escalation of a child's item.
|
|
436
|
+
|
|
437
|
+
---
|
|
438
|
+
|
|
251
439
|
### archiveRefusalReasons
|
|
252
440
|
|
|
253
441
|
```ts
|
|
@@ -279,10 +467,16 @@ function waitForAgentSettlement(
|
|
|
279
467
|
): Promise<
|
|
280
468
|
Readonly<{
|
|
281
469
|
acceptedSender: string | null;
|
|
470
|
+
delegator: string | null;
|
|
282
471
|
terminal: SessionTerminal;
|
|
283
472
|
content: string;
|
|
284
473
|
usage: readonly Pick<AssistantMessage, "model" | "provider" | "usage">[];
|
|
285
474
|
toolCalls: number;
|
|
475
|
+
waitingOnYou: readonly Readonly<{
|
|
476
|
+
itemId: string;
|
|
477
|
+
kind: string;
|
|
478
|
+
summary: string;
|
|
479
|
+
}>[];
|
|
286
480
|
}>
|
|
287
481
|
>;
|
|
288
482
|
```
|
|
@@ -301,10 +495,12 @@ Await one exact durable terminal without opening a transcript observation.
|
|
|
301
495
|
|
|
302
496
|
#### Returns
|
|
303
497
|
|
|
304
|
-
`Promise`\<`Readonly`\<\{ `acceptedSender`: `string` \| `null`; `
|
|
305
|
-
[`SessionTerminal`](client.md#sessionterminal);
|
|
306
|
-
readonly `Pick`\<`AssistantMessage`, `"model"` \|
|
|
307
|
-
`toolCalls`: `number`;
|
|
498
|
+
`Promise`\<`Readonly`\<\{ `acceptedSender`: `string` \| `null`; `delegator`:
|
|
499
|
+
`string` \| `null`; `terminal`: [`SessionTerminal`](client.md#sessionterminal);
|
|
500
|
+
`content`: `string`; `usage`: readonly `Pick`\<`AssistantMessage`, `"model"` \|
|
|
501
|
+
`"provider"` \| `"usage"`\>[]; `toolCalls`: `number`; `waitingOnYou`: readonly
|
|
502
|
+
`Readonly`\<\{ `itemId`: `string`; `kind`: `string`; `summary`: `string`;
|
|
503
|
+
\}\>[]; \}\>\>
|
|
308
504
|
|
|
309
505
|
---
|
|
310
506
|
|
package/docs/api/client-entry.md
CHANGED
|
@@ -172,6 +172,7 @@ const clientTimelineCellSchemaV1: Struct<{
|
|
|
172
172
|
id: String;
|
|
173
173
|
label: String;
|
|
174
174
|
input: optional<$Record<..., ...>>;
|
|
175
|
+
awaiting: optionalKey<Literal<...>>;
|
|
175
176
|
}>>>;
|
|
176
177
|
}>>;
|
|
177
178
|
}>;
|
|
@@ -222,6 +223,7 @@ const clientContributionSchemaV1: Struct<{
|
|
|
222
223
|
id: String;
|
|
223
224
|
label: String;
|
|
224
225
|
input: optional<$Record<..., ...>>;
|
|
226
|
+
awaiting: optionalKey<Literal<...>>;
|
|
225
227
|
}>>>;
|
|
226
228
|
inspection: optionalKey<Struct<{
|
|
227
229
|
commandId: String;
|
|
@@ -261,6 +263,7 @@ const clientContributionSchemaV1: Struct<{
|
|
|
261
263
|
id: String;
|
|
262
264
|
label: String;
|
|
263
265
|
input: optional<$Record<String, Codec<Json, Json, never, never>>>;
|
|
266
|
+
awaiting: optionalKey<Literal<"question">>;
|
|
264
267
|
}>;
|
|
265
268
|
}>>;
|
|
266
269
|
}>;
|
package/docs/api/client.md
CHANGED
|
@@ -10,12 +10,57 @@
|
|
|
10
10
|
|
|
11
11
|
## Type Aliases
|
|
12
12
|
|
|
13
|
+
### ParticipantPolicy
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
type ParticipantPolicy = Readonly<{
|
|
17
|
+
turnIsCurrent: (sessionId, commandId) => boolean;
|
|
18
|
+
deliverAgentReply: (sessionId, commandId, reply) => boolean;
|
|
19
|
+
}>;
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The host decides which Agent work may be delivered to this participant.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
### VisitorView
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
type VisitorView = Readonly<{
|
|
30
|
+
status: "idle" | "working";
|
|
31
|
+
lines: readonly Readonly<{
|
|
32
|
+
id: string;
|
|
33
|
+
from: "visitor" | "agent" | "operator";
|
|
34
|
+
text: string;
|
|
35
|
+
}>[];
|
|
36
|
+
progress: string | null;
|
|
37
|
+
}>;
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
What a visitor may see of their own conversation Session.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
### VisitorPendingPrompt
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
type VisitorPendingPrompt = Pick<
|
|
48
|
+
SessionPendingPrompt,
|
|
49
|
+
"commandId" | "requestId" | "text" | "delivery" | "images"
|
|
50
|
+
>;
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Public pending facts exclude the host's private metadata and admission origin.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
13
57
|
### Accepted
|
|
14
58
|
|
|
15
59
|
```ts
|
|
16
60
|
type Accepted = Readonly<{
|
|
17
61
|
status: "accepted";
|
|
18
62
|
commandId: string;
|
|
63
|
+
sessionId?: string;
|
|
19
64
|
}>;
|
|
20
65
|
```
|
|
21
66
|
|
|
@@ -115,6 +160,7 @@ type SessionCommandHandler = {
|
|
|
115
160
|
Readonly<{
|
|
116
161
|
status: "accepted";
|
|
117
162
|
commandId: string;
|
|
163
|
+
sessionId?: string;
|
|
118
164
|
}>
|
|
119
165
|
>;
|
|
120
166
|
(input): Promise<CancelResult>;
|
|
@@ -142,6 +188,7 @@ Execute one retained type-discriminated Session command.
|
|
|
142
188
|
(input): Promise<Readonly<{
|
|
143
189
|
status: "accepted";
|
|
144
190
|
commandId: string;
|
|
191
|
+
sessionId?: string;
|
|
145
192
|
}>>;
|
|
146
193
|
```
|
|
147
194
|
|
|
@@ -155,7 +202,8 @@ Accept a prompt or a compaction request as queued Session work.
|
|
|
155
202
|
|
|
156
203
|
##### Returns
|
|
157
204
|
|
|
158
|
-
`Promise`\<`Readonly`\<\{ `status`: `"accepted"`; `commandId`: `string`;
|
|
205
|
+
`Promise`\<`Readonly`\<\{ `status`: `"accepted"`; `commandId`: `string`;
|
|
206
|
+
`sessionId?`: `string`; \}\>\>
|
|
159
207
|
|
|
160
208
|
#### Call Signature
|
|
161
209
|
|
|
@@ -978,6 +1026,93 @@ A delegated send is accepted by its owner or held in durable mail custody.
|
|
|
978
1026
|
|
|
979
1027
|
## Functions
|
|
980
1028
|
|
|
1029
|
+
### participantSnapshot()
|
|
1030
|
+
|
|
1031
|
+
```ts
|
|
1032
|
+
function participantSnapshot(snapshot, owner): SessionSnapshot;
|
|
1033
|
+
```
|
|
1034
|
+
|
|
1035
|
+
Filter participant delivery only; the holder's stored Session is unchanged.
|
|
1036
|
+
|
|
1037
|
+
#### Parameters
|
|
1038
|
+
|
|
1039
|
+
| Parameter | Type |
|
|
1040
|
+
| ---------- | ----------------------------------------- |
|
|
1041
|
+
| `snapshot` | [`SessionSnapshot`](#sessionsnapshot) |
|
|
1042
|
+
| `owner` | [`ParticipantPolicy`](#participantpolicy) |
|
|
1043
|
+
|
|
1044
|
+
#### Returns
|
|
1045
|
+
|
|
1046
|
+
[`SessionSnapshot`](#sessionsnapshot)
|
|
1047
|
+
|
|
1048
|
+
---
|
|
1049
|
+
|
|
1050
|
+
### visitorPendingPrompt()
|
|
1051
|
+
|
|
1052
|
+
```ts
|
|
1053
|
+
function visitorPendingPrompt(prompt, visitorId): VisitorPendingPrompt;
|
|
1054
|
+
```
|
|
1055
|
+
|
|
1056
|
+
Project one owner-selected prompt without exposing host identity or correlation
|
|
1057
|
+
metadata.
|
|
1058
|
+
|
|
1059
|
+
#### Parameters
|
|
1060
|
+
|
|
1061
|
+
| Parameter | Type |
|
|
1062
|
+
| ----------- | ----------------------------------------------- |
|
|
1063
|
+
| `prompt` | [`SessionPendingPrompt`](#sessionpendingprompt) |
|
|
1064
|
+
| `visitorId` | `string` |
|
|
1065
|
+
|
|
1066
|
+
#### Returns
|
|
1067
|
+
|
|
1068
|
+
[`VisitorPendingPrompt`](#visitorpendingprompt)
|
|
1069
|
+
|
|
1070
|
+
---
|
|
1071
|
+
|
|
1072
|
+
### visitorSnapshot()
|
|
1073
|
+
|
|
1074
|
+
```ts
|
|
1075
|
+
function visitorSnapshot(snapshot, visitorId): SessionSnapshot;
|
|
1076
|
+
```
|
|
1077
|
+
|
|
1078
|
+
Visitor-scoped Session facts use the visitor's public address, never the
|
|
1079
|
+
internal Session ID.
|
|
1080
|
+
|
|
1081
|
+
#### Parameters
|
|
1082
|
+
|
|
1083
|
+
| Parameter | Type |
|
|
1084
|
+
| ----------- | ------------------------------------- |
|
|
1085
|
+
| `snapshot` | [`SessionSnapshot`](#sessionsnapshot) |
|
|
1086
|
+
| `visitorId` | `string` |
|
|
1087
|
+
|
|
1088
|
+
#### Returns
|
|
1089
|
+
|
|
1090
|
+
[`SessionSnapshot`](#sessionsnapshot)
|
|
1091
|
+
|
|
1092
|
+
---
|
|
1093
|
+
|
|
1094
|
+
### visitorView()
|
|
1095
|
+
|
|
1096
|
+
```ts
|
|
1097
|
+
function visitorView(snapshot, visitorId): VisitorView;
|
|
1098
|
+
```
|
|
1099
|
+
|
|
1100
|
+
Project only this visitor's host-attributed prompts, their replies, and explicit
|
|
1101
|
+
operator replies.
|
|
1102
|
+
|
|
1103
|
+
#### Parameters
|
|
1104
|
+
|
|
1105
|
+
| Parameter | Type |
|
|
1106
|
+
| ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1107
|
+
| `snapshot` | \| `Readonly`\<\{ `sessionId`: `string`; `cursor`: `string` \| `null`; `hasMore`: `boolean`; `oldestCursor?`: `string` \| `null`; `messages`: readonly `Readonly`\<\{ `requestId?`: `string`; `meta?`: [`Json`](extensions.md#json); `data?`: [`Json`](extensions.md#json); `origin?`: `Readonly`\<\{ `extensionId`: `string`; `correlation`: `string` \| `null`; \}\>; `id`: `string`; `sequence`: `number`; `commandId`: `string` \| `null`; `value`: [`ModelMessage`](#modelmessage); \}\>[]; `terminals`: readonly `Readonly`\<\{ `commandId`: `string`; `outcome`: `"completed"` \| `"failed"` \| `"cancelled"` \| `"interrupted"`; `sequence`: `number`; `diagnostic`: `string` \| `null`; `meta?`: [`Json`](extensions.md#json); \}\>[]; `compactions?`: readonly `Readonly`\<\{ `id`: `string`; `sequence`: `number`; `at`: `number`; `tokensBefore`: `number`; `tokensAfter`: `number` \| `null`; `trigger`: [`SessionCompactionTrigger`](#sessioncompactiontrigger) \| `null`; \}\>[]; `compactionNotices?`: readonly `Readonly`\<\{ `id`: `string`; `sequence`: `number`; `at`: `number`; `trigger`: [`SessionCompactionTrigger`](#sessioncompactiontrigger); `result`: `"failed"` \| `"nothing_to_compact"` \| `"stale"` \| `"insufficient"`; `diagnostic`: `string` \| `null`; \}\>[]; `sandboxFailures?`: readonly `object`[]; `pending`: [`SessionPendingPrompts`](#sessionpendingprompts); `activity`: [`SessionActivity`](#sessionactivity); `progress`: \| `Readonly`\<\{ `messageId`: `string`; `revision`: `number`; `text`: `string`; `thinking`: `string`; `textTruncated`: `boolean`; `thinkingTruncated`: `boolean`; \}\> \| `null`; `toolOutput`: readonly `Readonly`\<\{ `toolCallId`: `string`; `revision`: `number`; `tail`: `string`; `droppedBytes`: `number`; `totalBytes`: `number`; \}\>[]; `extensions`: [`SessionExtensionSlots`](#sessionextensionslots); `attention`: readonly `object`[]; `context?`: `Readonly`\<\{ `tokens`: `number`; `window`: `number` \| `null`; \}\>; \}\> \| `null` |
|
|
1108
|
+
| `visitorId` | `string` |
|
|
1109
|
+
|
|
1110
|
+
#### Returns
|
|
1111
|
+
|
|
1112
|
+
[`VisitorView`](#visitorview)
|
|
1113
|
+
|
|
1114
|
+
---
|
|
1115
|
+
|
|
981
1116
|
### parseDelegationReceipt()
|
|
982
1117
|
|
|
983
1118
|
```ts
|