@fungi.computer/oyster 0.49.0 → 0.49.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.
- package/dist/app-region.js +16 -5
- package/dist/computer-control-port.d.ts +17 -0
- package/dist/embed-metafiles.js +1 -1
- package/dist/mcp.d.ts +61 -0
- package/dist/mcp.js +54 -0
- package/dist/standalone/computer-control.js +31 -0
- package/dist/standalone/registry.d.ts +1 -1
- package/docs/api/mcp.md +74 -46
- package/docs/api/workers.md +16 -16
- package/package.json +3 -3
package/dist/app-region.js
CHANGED
|
@@ -90,13 +90,26 @@ export function createAppRegion(native, deliver) {
|
|
|
90
90
|
};
|
|
91
91
|
const connects = new Map();
|
|
92
92
|
const regionFull = (reason) => Response.json({ error: "region_full", reason }, { status: 429 });
|
|
93
|
+
// Each socket's decoded host stamp, filled when connect stamps it or, after
|
|
94
|
+
// a hibernation wake, by the first read of its native attachment. Only the
|
|
95
|
+
// supervisor writes an attachment, once at admission, so a cached stamp
|
|
96
|
+
// never goes stale; connect and every reply then cost no parse per socket.
|
|
97
|
+
const stamps = new WeakMap();
|
|
98
|
+
const remember = (socket, connection, caller) => {
|
|
99
|
+
const stamp = { connection, caller, key: callerKey(caller) };
|
|
100
|
+
stamps.set(socket, stamp);
|
|
101
|
+
return stamp;
|
|
102
|
+
};
|
|
93
103
|
const attachment = (socket) => {
|
|
104
|
+
const known = stamps.get(socket);
|
|
105
|
+
if (known !== undefined)
|
|
106
|
+
return known;
|
|
94
107
|
const parsed = attachmentSchema.safeParse(socket.deserializeAttachment());
|
|
95
108
|
if (!parsed.success)
|
|
96
109
|
return null;
|
|
97
110
|
const caller = appMethodCallerSchema.safeParse(parsed.data.caller);
|
|
98
111
|
return caller.success
|
|
99
|
-
?
|
|
112
|
+
? remember(socket, parsed.data.connection, caller.data)
|
|
100
113
|
: null;
|
|
101
114
|
};
|
|
102
115
|
const apply = async (raw) => {
|
|
@@ -153,10 +166,7 @@ export function createAppRegion(native, deliver) {
|
|
|
153
166
|
if (sockets.length >= appRegionLimits.socketsPerInstance)
|
|
154
167
|
return regionFull("Region socket limit reached");
|
|
155
168
|
const key = callerKey(stamped);
|
|
156
|
-
const held = sockets.filter((socket) =>
|
|
157
|
-
const stamp = attachment(socket);
|
|
158
|
-
return stamp !== null && callerKey(stamp.caller) === key;
|
|
159
|
-
}).length;
|
|
169
|
+
const held = sockets.filter((socket) => attachment(socket)?.key === key).length;
|
|
160
170
|
if (held >= appRegionLimits.socketsPerCaller)
|
|
161
171
|
return regionFull("Region socket share reached");
|
|
162
172
|
const now = native.now();
|
|
@@ -175,6 +185,7 @@ export function createAppRegion(native, deliver) {
|
|
|
175
185
|
const connection = regionIds.connection.generate();
|
|
176
186
|
native.accept(server);
|
|
177
187
|
server.serializeAttachment({ connection, caller: stamped });
|
|
188
|
+
remember(server, connection, stamped);
|
|
178
189
|
try {
|
|
179
190
|
await apply(await deliverConnect({
|
|
180
191
|
kind: "connect",
|
|
@@ -14,6 +14,23 @@ export type ComputerControlPort = Readonly<{
|
|
|
14
14
|
state(computerId: string, context: InvocationContext): Promise<z.output<typeof computerStateSchema>>;
|
|
15
15
|
/** Start one inventoried hosted Computer through the host's admission. */
|
|
16
16
|
start(computerId: string, context: InvocationContext): Promise<z.output<typeof computerStateSchema>>;
|
|
17
|
+
/** Stop one Computer now; its files are kept. Only the signed-in owner may. */
|
|
18
|
+
stop(computerId: string, context: InvocationContext): Promise<{
|
|
19
|
+
kind: "stopped";
|
|
20
|
+
} | {
|
|
21
|
+
kind: "denied" | "busy" | "uncertain";
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* Delete one Computer and erase its Workspace. The caller has already matched
|
|
25
|
+
* the person's typed handle to the Computer's name. Only the signed-in owner
|
|
26
|
+
* may; a host with no delete path answers "unsupported". "uncertain" means
|
|
27
|
+
* retry: a delete cut short finishes on the next attempt.
|
|
28
|
+
*/
|
|
29
|
+
delete(computerId: string, context: InvocationContext): Promise<{
|
|
30
|
+
kind: "deleted";
|
|
31
|
+
} | {
|
|
32
|
+
kind: "denied" | "unsupported" | "uncertain";
|
|
33
|
+
}>;
|
|
17
34
|
/** Create or replay a durable receipt tied to this request identity. */
|
|
18
35
|
create(input: z.output<typeof computerCreateRequestSchema>, context: InvocationContext): Promise<{
|
|
19
36
|
kind: "created";
|