@fungi.computer/oyster 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents.d.ts +2 -1
- package/dist/agents.js +63 -8
- package/dist/app-builds.d.ts +1 -1
- package/dist/app-builds.js +16 -6
- package/dist/apps/gate.d.ts +4 -0
- package/dist/apps/gate.js +3 -0
- package/dist/boot-capability.d.ts +2 -1
- package/dist/boot-capability.js +7 -5
- package/dist/boot-host-script.js +1 -1
- package/dist/build/build-jobs.d.ts +3 -3
- package/dist/build/build-jobs.js +10 -5
- package/dist/build/candidate-cli.js +5 -3
- package/dist/build/candidate-cli.mjs +238 -5
- package/dist/build/candidate-diagnostic.d.ts +2 -0
- package/dist/build/candidate-diagnostic.js +16 -0
- package/dist/channels/binding.d.ts +63 -0
- package/dist/channels/binding.js +85 -0
- package/dist/channels/conversations.d.ts +235 -0
- package/dist/channels/conversations.js +705 -0
- package/dist/channels/ids.d.ts +8 -0
- package/dist/channels/ids.js +15 -0
- package/dist/host.d.ts +1 -1
- package/dist/host.js +21 -4
- package/dist/keys.d.ts +4 -1
- package/dist/keys.js +15 -4
- package/dist/machine-link/authority.d.ts +7 -0
- package/dist/machine-link/delivery.d.ts +12 -0
- package/dist/machine-link/delivery.js +22 -1
- package/dist/machine-link/disposition.d.ts +16 -0
- package/dist/machine-link/disposition.js +65 -0
- package/dist/machine-link/host.d.ts +11 -2
- package/dist/machine-link/host.js +125 -5
- package/dist/machine-link/link.d.ts +4 -0
- package/dist/machine-link/link.js +47 -1
- package/dist/page-script.js +4 -4
- package/dist/standalone/agent-mail.js +4 -1
- package/dist/standalone/agent-model-choice.d.ts +4 -1
- package/dist/standalone/agents.d.ts +8 -0
- package/dist/standalone/agents.js +21 -2
- package/dist/standalone/app-set.d.ts +8 -1
- package/dist/standalone/app-set.js +46 -31
- package/dist/standalone/channel-session-door.d.ts +4 -0
- package/dist/standalone/channel-session-door.js +42 -0
- package/dist/standalone/install-apps-bin.d.ts +2 -0
- package/dist/standalone/install-apps-bin.js +3 -0
- package/dist/standalone/install-apps-cli.d.ts +3 -1
- package/dist/standalone/install-apps-cli.js +27 -17
- package/dist/standalone/machine-link.d.ts +2 -0
- package/dist/standalone/machine-link.js +34 -1
- package/dist/standalone/registry.d.ts +1 -1
- package/dist/testing/capabilities.d.ts +2 -0
- package/dist/testing/capabilities.js +3 -1
- package/dist/workers-git.js +1 -1
- package/dist/workers.d.ts +3 -0
- package/dist/workers.js +9 -1
- package/docs/api/agents.md +8 -4
- package/docs/api/apps.md +8 -4
- package/docs/api/browser.md +40 -16
- package/docs/api/keys.md +25 -3
- package/docs/api/workers.md +21 -14
- package/docs/site/agent-quickstart.mdx +23 -0
- package/examples/standalone/wrangler.jsonc +3 -4
- package/package.json +29 -17
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type FungiAuthor, type AuthorMeta, type MessageMetaValue } from "@fungi.computer/agar/agents";
|
|
3
|
+
import { type Handoff } from "@fungi.computer/agar/channels";
|
|
4
|
+
import { type ConversationBinding, type ChannelParty } from "./binding.js";
|
|
5
|
+
export type HandoffEvent = Readonly<{
|
|
6
|
+
expectedVersion: number;
|
|
7
|
+
}> & (Readonly<{
|
|
8
|
+
kind: "request";
|
|
9
|
+
reason: string;
|
|
10
|
+
at: number;
|
|
11
|
+
}> | Readonly<{
|
|
12
|
+
kind: "take_over";
|
|
13
|
+
member: FungiAuthor;
|
|
14
|
+
confirm: boolean;
|
|
15
|
+
at: number;
|
|
16
|
+
}> | Readonly<{
|
|
17
|
+
kind: "hand_back";
|
|
18
|
+
memberId: string;
|
|
19
|
+
confirm: boolean;
|
|
20
|
+
}> | Readonly<{
|
|
21
|
+
kind: "dismiss";
|
|
22
|
+
}>);
|
|
23
|
+
export type HandoffTransition = Readonly<{
|
|
24
|
+
kind: "ok";
|
|
25
|
+
handoff: Handoff;
|
|
26
|
+
}> | Readonly<{
|
|
27
|
+
kind: "conflict" | "confirmation_required" | "not_holder" | "not_found";
|
|
28
|
+
}>;
|
|
29
|
+
/** Decide one handoff; persistence, notifications and cancellation stay with the owner. */
|
|
30
|
+
export declare function transitionHandoff(current: Handoff | null, event: HandoffEvent): HandoffTransition;
|
|
31
|
+
export type ConversationSql = Readonly<{
|
|
32
|
+
exec: (statement: string, ...bindings: (ArrayBuffer | string | number | null)[]) => Readonly<{
|
|
33
|
+
toArray: () => readonly unknown[];
|
|
34
|
+
}>;
|
|
35
|
+
}>;
|
|
36
|
+
/** One verified inbound event from a provider edge. */
|
|
37
|
+
declare const inboundEventSchema: z.ZodObject<{
|
|
38
|
+
bindingId: z.ZodString;
|
|
39
|
+
conversation: z.ZodString;
|
|
40
|
+
eventId: z.ZodString;
|
|
41
|
+
party: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
42
|
+
kind: z.ZodLiteral<"visitor">;
|
|
43
|
+
visitorId: z.ZodString;
|
|
44
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
45
|
+
kind: z.ZodLiteral<"discord-user">;
|
|
46
|
+
guildId: z.ZodString;
|
|
47
|
+
userId: z.ZodString;
|
|
48
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
49
|
+
kind: z.ZodLiteral<"email-sender">;
|
|
50
|
+
address: z.ZodEmail;
|
|
51
|
+
dmarc: z.ZodEnum<{
|
|
52
|
+
none: "none";
|
|
53
|
+
pass: "pass";
|
|
54
|
+
fail: "fail";
|
|
55
|
+
}>;
|
|
56
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
57
|
+
kind: z.ZodLiteral<"player">;
|
|
58
|
+
worldId: z.ZodString;
|
|
59
|
+
playerId: z.ZodString;
|
|
60
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
61
|
+
kind: z.ZodLiteral<"source">;
|
|
62
|
+
source: z.ZodString;
|
|
63
|
+
}, z.core.$strict>], "kind">;
|
|
64
|
+
text: z.ZodString;
|
|
65
|
+
sourceRequestId: z.ZodOptional<z.ZodLazy<z.ZodString>>;
|
|
66
|
+
bodyDigest: z.ZodOptional<z.ZodString>;
|
|
67
|
+
}, z.core.$strict>;
|
|
68
|
+
/** One verified inbound event. */
|
|
69
|
+
export type InboundEvent = z.infer<typeof inboundEventSchema>;
|
|
70
|
+
/** Channel events and composer requests do not share the Session owner's key space. */
|
|
71
|
+
export declare function channelRequestId(bindingId: string, eventId: string): string;
|
|
72
|
+
/** Closed intake result; "said no" is distinct from "couldn't answer". */
|
|
73
|
+
export type IntakeResult = Readonly<{
|
|
74
|
+
kind: "accepted";
|
|
75
|
+
sessionId: string;
|
|
76
|
+
commandId: string;
|
|
77
|
+
delivery: "new" | "replay";
|
|
78
|
+
}> | Readonly<{
|
|
79
|
+
/** Held for a person: recorded as a party line, no run started. */
|
|
80
|
+
kind: "held";
|
|
81
|
+
sessionId: string;
|
|
82
|
+
delivery: "new" | "replay";
|
|
83
|
+
}> | Readonly<{
|
|
84
|
+
kind: "denied";
|
|
85
|
+
reason: "unmapped" | "suspended" | "banned" | "too_long" | "party_daily_limit" | "new_party_limit" | "rate_limited" | "event_conflict";
|
|
86
|
+
}>;
|
|
87
|
+
/** One channel conversation row, as owner surfaces label it. */
|
|
88
|
+
export type ChannelConversation = Readonly<{
|
|
89
|
+
bindingId: string;
|
|
90
|
+
conversation: string;
|
|
91
|
+
sessionId: string;
|
|
92
|
+
party: ChannelParty;
|
|
93
|
+
label: string;
|
|
94
|
+
createdAt: number;
|
|
95
|
+
lastEventAt: number;
|
|
96
|
+
handoff: Handoff;
|
|
97
|
+
}>;
|
|
98
|
+
export type ChannelHandoffResult = Readonly<{
|
|
99
|
+
kind: "ok";
|
|
100
|
+
conversation: ChannelConversation;
|
|
101
|
+
}> | Exclude<HandoffTransition, {
|
|
102
|
+
kind: "ok";
|
|
103
|
+
}>;
|
|
104
|
+
type ChannelTakeoverReceipt = Readonly<{
|
|
105
|
+
version: number;
|
|
106
|
+
memberId: string;
|
|
107
|
+
memberName: string;
|
|
108
|
+
previousMemberId: string | null;
|
|
109
|
+
at: number;
|
|
110
|
+
}>;
|
|
111
|
+
/** Payload-free event metadata for a Team member's channel log. */
|
|
112
|
+
export type ChannelEventReceipt = Readonly<{
|
|
113
|
+
eventId: string;
|
|
114
|
+
receivedAt: number;
|
|
115
|
+
status: "pending" | "accepted" | "held";
|
|
116
|
+
size: number;
|
|
117
|
+
sessionId: string;
|
|
118
|
+
}>;
|
|
119
|
+
/** Only the withdrawal outcomes a channel visitor can observe. */
|
|
120
|
+
export type ChannelWithdrawResult = Readonly<{
|
|
121
|
+
status: "unknown";
|
|
122
|
+
}> | Readonly<{
|
|
123
|
+
status: "accepted";
|
|
124
|
+
commandId: string;
|
|
125
|
+
sessionId?: string;
|
|
126
|
+
}>;
|
|
127
|
+
/** Only the pending fields a channel visitor can read. */
|
|
128
|
+
export type ChannelPendingPrompt = Readonly<{
|
|
129
|
+
requestId: string;
|
|
130
|
+
commandId: string;
|
|
131
|
+
text: string;
|
|
132
|
+
meta?: MessageMetaValue | undefined;
|
|
133
|
+
delivery: "steer" | "followUp";
|
|
134
|
+
images?: readonly Readonly<{
|
|
135
|
+
type: "image";
|
|
136
|
+
data: string;
|
|
137
|
+
mimeType: string;
|
|
138
|
+
}>[] | undefined;
|
|
139
|
+
}>;
|
|
140
|
+
/** The channel's narrow Session port; hosts translate to their durable client. */
|
|
141
|
+
export type SessionDoor = Readonly<{
|
|
142
|
+
withdraw: (sessionId: string, requestId: string) => Promise<ChannelWithdrawResult>;
|
|
143
|
+
latestPending: (sessionId: string, visitor: FungiAuthor) => Promise<ChannelPendingPrompt | null>;
|
|
144
|
+
createSession: (requestId: string) => Promise<string>;
|
|
145
|
+
/** Deliver this conversation Session's tool grants to the runtime. */
|
|
146
|
+
deliverGrants: (sessionId: string) => void;
|
|
147
|
+
prompt: (sessionId: string, input: Readonly<{
|
|
148
|
+
requestId: string;
|
|
149
|
+
text: string;
|
|
150
|
+
meta: AuthorMeta & Readonly<{
|
|
151
|
+
sourceRequestId?: string;
|
|
152
|
+
}>;
|
|
153
|
+
}>) => Promise<Readonly<{
|
|
154
|
+
commandId: string;
|
|
155
|
+
}>>;
|
|
156
|
+
/** Record one run-free operator or party line (Shiitake `operator`). */
|
|
157
|
+
line: (sessionId: string, input: Readonly<{
|
|
158
|
+
requestId: string;
|
|
159
|
+
text: string;
|
|
160
|
+
}> & (Readonly<{
|
|
161
|
+
author: "operator";
|
|
162
|
+
identity: FungiAuthor;
|
|
163
|
+
}> | Readonly<{
|
|
164
|
+
author: "party";
|
|
165
|
+
meta: AuthorMeta & Readonly<{
|
|
166
|
+
sourceRequestId?: string;
|
|
167
|
+
}>;
|
|
168
|
+
}>)) => Promise<void>;
|
|
169
|
+
/** Only a matching, contract-closed request clears a visitor reservation. */
|
|
170
|
+
errorKind: (error: Error, requestId: string) => "closed_request" | null;
|
|
171
|
+
}>;
|
|
172
|
+
export declare function createChannelConversations(options: Readonly<{
|
|
173
|
+
sql: ConversationSql;
|
|
174
|
+
transactionSync: <T>(body: () => T) => T;
|
|
175
|
+
binding: (bindingId: string) => ConversationBinding | null;
|
|
176
|
+
door: Pick<SessionDoor, "createSession" | "deliverGrants" | "prompt" | "line" | "errorKind">;
|
|
177
|
+
now: () => number;
|
|
178
|
+
/** Commit hook for accepted work, in the acceptance transaction. */
|
|
179
|
+
onAccepted?: (accepted: Readonly<{
|
|
180
|
+
binding: ConversationBinding;
|
|
181
|
+
event: InboundEvent;
|
|
182
|
+
sessionId: string;
|
|
183
|
+
commandId: string;
|
|
184
|
+
}>) => void;
|
|
185
|
+
}>): {
|
|
186
|
+
ensure: () => void;
|
|
187
|
+
open: (binding: ConversationBinding, conversation: string, party: ChannelParty) => Promise<Readonly<{
|
|
188
|
+
kind: "open";
|
|
189
|
+
conversation: ChannelConversation;
|
|
190
|
+
}> | Readonly<{
|
|
191
|
+
kind: "denied";
|
|
192
|
+
reason: "new_party_limit" | "banned";
|
|
193
|
+
}>>;
|
|
194
|
+
receive: (rawEvent: InboundEvent) => Promise<IntakeResult>;
|
|
195
|
+
/** A visitor bearer may never resolve another conversation's intake key. */
|
|
196
|
+
visitorEventConflict: (bindingId: string, visitorId: string, eventId: string) => boolean;
|
|
197
|
+
ban: (bindingId: string, conversation: string) => void;
|
|
198
|
+
list: (bindingId?: string) => readonly ChannelConversation[];
|
|
199
|
+
recentEvents: (bindingId: string) => readonly ChannelEventReceipt[];
|
|
200
|
+
requestHandoff: (sessionId: string, reason: string) => ChannelHandoffResult;
|
|
201
|
+
captureTurn: (sessionId: string, commandId: string) => void;
|
|
202
|
+
turnIsCurrent: (sessionId: string, commandId: string) => boolean;
|
|
203
|
+
deliverAgentReply: (sessionId: string, commandId: string, reply: Readonly<{
|
|
204
|
+
kind: "message";
|
|
205
|
+
messageId: string;
|
|
206
|
+
}> | Readonly<{
|
|
207
|
+
kind: "settlement";
|
|
208
|
+
}>) => boolean;
|
|
209
|
+
dueNotifications: (now: number) => readonly ChannelConversation[];
|
|
210
|
+
nextNotification: () => number | null;
|
|
211
|
+
scheduleNotification: (sessionId: string, dueAt: number | null) => void;
|
|
212
|
+
handoffOpen: (sessionId: string, version: number) => boolean;
|
|
213
|
+
takeOver: (sessionId: string, member: FungiAuthor, expectedVersion: number, confirm: boolean) => ChannelHandoffResult;
|
|
214
|
+
handBack: (sessionId: string, memberId: string, expectedVersion: number, confirm: boolean) => ChannelHandoffResult;
|
|
215
|
+
dismiss: (sessionId: string, expectedVersion: number) => ChannelHandoffResult;
|
|
216
|
+
takeovers: (sessionId: string) => readonly ChannelTakeoverReceipt[];
|
|
217
|
+
expired: (now: number, retentionMs: (bindingId: string) => number) => readonly ChannelConversation[];
|
|
218
|
+
nextExpiry: (retentionMs: (bindingId: string) => number) => number | null;
|
|
219
|
+
forget: (conversation: ChannelConversation) => void;
|
|
220
|
+
find: (bindingId: string, conversation: string) => Readonly<{
|
|
221
|
+
bindingId: string;
|
|
222
|
+
conversation: string;
|
|
223
|
+
sessionId: string;
|
|
224
|
+
party: ChannelParty;
|
|
225
|
+
label: string;
|
|
226
|
+
createdAt: number;
|
|
227
|
+
lastEventAt: number;
|
|
228
|
+
handoff: Handoff;
|
|
229
|
+
}> | null;
|
|
230
|
+
sessionConversation: (sessionId: string) => ChannelConversation | null;
|
|
231
|
+
sessionIds: () => readonly string[];
|
|
232
|
+
};
|
|
233
|
+
/** AgentDO's channel conversation owner. */
|
|
234
|
+
export type ChannelConversations = ReturnType<typeof createChannelConversations>;
|
|
235
|
+
export {};
|