@fungi.computer/oyster 0.19.26 → 0.19.28
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 +1 -1
- package/dist/agents.js +7 -1
- package/dist/apps/permissions.d.ts +5 -0
- package/dist/apps/permissions.js +5 -0
- package/dist/embed-metafiles.js +1 -1
- package/dist/embed-scripts.js +2 -2
- package/dist/host.js +13 -0
- package/dist/page/app-permissions.js +28 -29
- package/dist/page-script.js +3 -3
- package/dist/standalone/agent-model-choice.js +6 -2
- package/dist/standalone/agents.d.ts +5 -0
- package/dist/standalone/agents.js +17 -1
- package/dist/standalone/computer.js +1 -1
- package/dist/standalone/model-key-vault.d.ts +17 -5
- package/dist/standalone/model-key-vault.js +59 -12
- package/dist/standalone/try-cli.d.ts +1 -0
- package/dist/standalone/try-cli.js +50 -18
- package/docs/api/agents.md +19 -16
- package/docs/api/apps.md +8 -2
- package/docs/api/workers-git.md +7 -7
- package/package.json +5 -5
|
@@ -29,6 +29,8 @@ const defaultChoice = {
|
|
|
29
29
|
};
|
|
30
30
|
/** Pi's maintained catalog for a provider a key may be brought for. */
|
|
31
31
|
async function byokCatalog(provider) {
|
|
32
|
+
if (provider === "cloudflare-workers-ai")
|
|
33
|
+
return cloudflareWorkersAIProvider().getModels();
|
|
32
34
|
if (provider === "anthropic")
|
|
33
35
|
return (await import("@earendil-works/pi-ai/providers/anthropic"))
|
|
34
36
|
.anthropicProvider()
|
|
@@ -59,7 +61,8 @@ export async function resolveDefaultChoice(ready) {
|
|
|
59
61
|
for (const { keyId, provider } of ready.keys) {
|
|
60
62
|
if (provider !== "anthropic" &&
|
|
61
63
|
provider !== "openai" &&
|
|
62
|
-
provider !== "openrouter"
|
|
64
|
+
provider !== "openrouter" &&
|
|
65
|
+
provider !== "cloudflare-workers-ai")
|
|
63
66
|
continue;
|
|
64
67
|
const catalog = await byokCatalog(provider);
|
|
65
68
|
const model = catalog.find((entry) => "default" in entry && entry.default === true) ??
|
|
@@ -78,7 +81,8 @@ export async function selectAgentModel(choice) {
|
|
|
78
81
|
const { providerId, modelId, reasoning } = choice.model;
|
|
79
82
|
if (choice.keySource === "byok") {
|
|
80
83
|
// Only a catalogued provider's own models; an OpenAI-compatible base has none.
|
|
81
|
-
if (
|
|
84
|
+
if (providerId !== "cloudflare-workers-ai" &&
|
|
85
|
+
(!isModelKeyProvider(providerId) || providerId === "openai-compatible"))
|
|
82
86
|
throw new AgentModelRefused("unsupported_key_source");
|
|
83
87
|
const found = (await byokCatalog(providerId)).find((item) => item.id === modelId);
|
|
84
88
|
if (found === undefined || (reasoning !== undefined && !found.reasoning))
|
|
@@ -290,6 +290,11 @@ export declare class AgentDirectory extends DurableObject<StandaloneAgentEnv> {
|
|
|
290
290
|
error: ModelKeyRefusal;
|
|
291
291
|
}>>;
|
|
292
292
|
listModelKeys(): Promise<readonly ModelKeyRecord[]>;
|
|
293
|
+
modelKeyBaseUrl(keyId: string): Promise<Readonly<{
|
|
294
|
+
baseUrl: string;
|
|
295
|
+
}> | Readonly<{
|
|
296
|
+
error: ModelKeyRefusal;
|
|
297
|
+
}>>;
|
|
293
298
|
modelKey(keyId: string): Promise<ModelKeyRecord | null>;
|
|
294
299
|
removeModelKey(keyId: string): Promise<"deleted" | "absent">;
|
|
295
300
|
/** Host-only: the one place a stored key meets a provider request. */
|
|
@@ -953,7 +953,13 @@ export class StandaloneAgentBase extends ShiitakeDO {
|
|
|
953
953
|
};
|
|
954
954
|
if (choice.model.reasoning !== undefined)
|
|
955
955
|
streamOptions.reasoning = choice.model.reasoning;
|
|
956
|
-
|
|
956
|
+
const configuration = await directory.modelKeyBaseUrl(keyId);
|
|
957
|
+
if ("error" in configuration)
|
|
958
|
+
throw new AgentModelRefused(configuration.error === "key_removed"
|
|
959
|
+
? "key_removed"
|
|
960
|
+
: "key_not_connected");
|
|
961
|
+
const { baseUrl } = configuration;
|
|
962
|
+
return observedModels(normalizeModel({ ...modelChoice, baseUrl }), streamOptions);
|
|
957
963
|
}
|
|
958
964
|
if (choice.keySource === "ai-gateway") {
|
|
959
965
|
const egress = configuredProviderEgress(this.env);
|
|
@@ -1277,6 +1283,16 @@ export class AgentDirectory extends DurableObject {
|
|
|
1277
1283
|
listModelKeys() {
|
|
1278
1284
|
return this.modelKeys().list();
|
|
1279
1285
|
}
|
|
1286
|
+
async modelKeyBaseUrl(keyId) {
|
|
1287
|
+
try {
|
|
1288
|
+
return { baseUrl: await this.modelKeys().baseUrl(keyId) };
|
|
1289
|
+
}
|
|
1290
|
+
catch (error) {
|
|
1291
|
+
if (error instanceof ModelKeyRefused)
|
|
1292
|
+
return { error: error.reason };
|
|
1293
|
+
throw error;
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1280
1296
|
modelKey(keyId) {
|
|
1281
1297
|
return this.modelKeys().get(keyId);
|
|
1282
1298
|
}
|
|
@@ -245,7 +245,7 @@ export class ComputerDO extends NativeComputerDO {
|
|
|
245
245
|
return { terminal: "ready" };
|
|
246
246
|
return {
|
|
247
247
|
terminal: "missing",
|
|
248
|
-
terminalReason: "
|
|
248
|
+
terminalReason: "The local command runner is not connected. Restart oyster try in your terminal.",
|
|
249
249
|
};
|
|
250
250
|
}
|
|
251
251
|
/** Observe an admitted fleet Computer without starting its backend. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CredentialRecord, type CredentialStorage } from "@fungi.computer/veil/credential-store";
|
|
2
|
-
import { type ModelKeyRecord
|
|
2
|
+
import { type ModelKeyRecord as HostedModelKeyRecord } from "@fungi.computer/veil/model-keys";
|
|
3
3
|
/**
|
|
4
4
|
* This instance's own model-key owner. Provider API keys are sealed (AES-GCM)
|
|
5
5
|
* under a key derived from the instance master secret, a host secret that never
|
|
@@ -12,12 +12,16 @@ export declare class ModelKeyRefused extends Error {
|
|
|
12
12
|
readonly reason: ModelKeyRefusal;
|
|
13
13
|
constructor(reason: ModelKeyRefusal);
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
/** Standalone custody also accepts an owner’s Cloudflare account and token. */
|
|
16
|
+
export type ModelKeyRecord = Omit<HostedModelKeyRecord, "provider"> & {
|
|
17
|
+
readonly provider: HostedModelKeyRecord["provider"] | "cloudflare-workers-ai";
|
|
18
|
+
};
|
|
16
19
|
/** What the owner submits to seal one provider key. */
|
|
17
20
|
export type ModelKeySealInput = Readonly<{
|
|
18
21
|
provider: string;
|
|
19
22
|
label: string;
|
|
20
23
|
apiKey: string;
|
|
24
|
+
accountId?: string;
|
|
21
25
|
}>;
|
|
22
26
|
export type ModelKeyStorage = CredentialStorage;
|
|
23
27
|
/**
|
|
@@ -45,6 +49,14 @@ export declare function createModelKeyVault(options: {
|
|
|
45
49
|
credentialKey: string | undefined;
|
|
46
50
|
fetch?: typeof globalThis.fetch;
|
|
47
51
|
now?: () => number;
|
|
48
|
-
}):
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
}): {
|
|
53
|
+
/** Validate with one cheap authenticated read, then store only the sealed key. */
|
|
54
|
+
seal(input: ModelKeySealInput): Promise<ModelKeyRecord>;
|
|
55
|
+
list(): Promise<readonly ModelKeyRecord[]>;
|
|
56
|
+
get(keyId: string): Promise<ModelKeyRecord | null>;
|
|
57
|
+
/** Host-only model configuration; the token never leaves its sealed callback. */
|
|
58
|
+
baseUrl(keyId: string): Promise<string>;
|
|
59
|
+
remove(keyId: string): Promise<"deleted" | "absent">;
|
|
60
|
+
/** Send one provider request with the key attached; the caller's auth is dropped. */
|
|
61
|
+
send(keyId: string, request: Request): Promise<Response>;
|
|
62
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
1
2
|
import { createCredentialSealer, createCredentialStore, CredentialError, } from "@fungi.computer/veil/credential-store";
|
|
2
3
|
import { isModelKeyProvider, modelKeyForwardedHeaders, modelKeyBaseUrl, modelKeyTarget, modelKeyValidationRequest, modelKeyValidationResult, } from "@fungi.computer/veil/model-keys";
|
|
3
4
|
export class ModelKeyRefused extends Error {
|
|
@@ -8,10 +9,33 @@ export class ModelKeyRefused extends Error {
|
|
|
8
9
|
this.name = "ModelKeyRefused";
|
|
9
10
|
}
|
|
10
11
|
}
|
|
12
|
+
const isProvider = (value) => value === "cloudflare-workers-ai" || isModelKeyProvider(value);
|
|
13
|
+
const cloudflareCredentialSchema = Schema.Struct({
|
|
14
|
+
apiKey: Schema.NonEmptyString,
|
|
15
|
+
accountId: Schema.String.check(Schema.isPattern(/^[a-f0-9]{32}$/u)),
|
|
16
|
+
});
|
|
17
|
+
const decodeCloudflareCredential = Schema.decodeUnknownOption(Schema.fromJsonString(cloudflareCredentialSchema));
|
|
18
|
+
function readCloudflareCredential(secret) {
|
|
19
|
+
const parsed = decodeCloudflareCredential(secret);
|
|
20
|
+
if (parsed._tag === "None")
|
|
21
|
+
throw new ModelKeyRefused("custody_unavailable");
|
|
22
|
+
return parsed.value;
|
|
23
|
+
}
|
|
24
|
+
const cloudflareBase = (accountId) => `https://api.cloudflare.com/client/v4/accounts/${accountId}/ai/v1`;
|
|
25
|
+
function providerConfiguration(provider, secret) {
|
|
26
|
+
if (provider === "cloudflare-workers-ai") {
|
|
27
|
+
const credential = readCloudflareCredential(secret);
|
|
28
|
+
return {
|
|
29
|
+
apiKey: credential.apiKey,
|
|
30
|
+
baseUrl: cloudflareBase(credential.accountId),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return { apiKey: secret, baseUrl: modelKeyBaseUrl(provider) };
|
|
34
|
+
}
|
|
11
35
|
const kindOf = (provider) => `model-key/${provider}`;
|
|
12
36
|
const providerOf = (kind) => {
|
|
13
37
|
const provider = kind.slice("model-key/".length);
|
|
14
|
-
if (!
|
|
38
|
+
if (!isProvider(provider))
|
|
15
39
|
throw new ModelKeyRefused("invalid_key");
|
|
16
40
|
return provider;
|
|
17
41
|
};
|
|
@@ -75,7 +99,7 @@ export function createModelKeyVault(options) {
|
|
|
75
99
|
/** Validate with one cheap authenticated read, then store only the sealed key. */
|
|
76
100
|
async seal(input) {
|
|
77
101
|
const { provider, label, apiKey } = input;
|
|
78
|
-
if (!
|
|
102
|
+
if (!isProvider(provider) ||
|
|
79
103
|
provider === "openai-compatible" ||
|
|
80
104
|
label.length === 0 ||
|
|
81
105
|
label.length > 64 ||
|
|
@@ -84,8 +108,27 @@ export function createModelKeyVault(options) {
|
|
|
84
108
|
throw new ModelKeyRefused("invalid_key");
|
|
85
109
|
if (credentialKey === undefined)
|
|
86
110
|
throw new ModelKeyRefused("custody_unavailable");
|
|
87
|
-
|
|
88
|
-
|
|
111
|
+
let secret = apiKey;
|
|
112
|
+
let probe;
|
|
113
|
+
if (provider === "cloudflare-workers-ai") {
|
|
114
|
+
const credential = Schema.decodeUnknownOption(cloudflareCredentialSchema)({
|
|
115
|
+
apiKey,
|
|
116
|
+
accountId: input.accountId,
|
|
117
|
+
});
|
|
118
|
+
if (credential._tag === "None")
|
|
119
|
+
throw new ModelKeyRefused("invalid_key");
|
|
120
|
+
secret = JSON.stringify(credential.value);
|
|
121
|
+
// Cloudflare’s authenticated model search spends no inference tokens.
|
|
122
|
+
probe = new Request(`https://api.cloudflare.com/client/v4/accounts/${credential.value.accountId}/ai/models/search?per_page=1`, {
|
|
123
|
+
headers: { accept: "application/json" },
|
|
124
|
+
signal: AbortSignal.timeout(15_000),
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
if (input.accountId !== undefined)
|
|
129
|
+
throw new ModelKeyRefused("invalid_key");
|
|
130
|
+
probe = modelKeyValidationRequest({ provider, baseUrl: modelKeyBaseUrl(provider) }, AbortSignal.timeout(15_000));
|
|
131
|
+
}
|
|
89
132
|
let status;
|
|
90
133
|
try {
|
|
91
134
|
const response = await send(new Request(probe, {
|
|
@@ -103,7 +146,7 @@ export function createModelKeyVault(options) {
|
|
|
103
146
|
throw new ModelKeyRefused("key_rejected");
|
|
104
147
|
if (verdict === "unavailable")
|
|
105
148
|
throw new ModelKeyRefused("provider_unavailable");
|
|
106
|
-
return publicRecord(await custody(() => credentials.put({ kind: kindOf(provider), label, secret
|
|
149
|
+
return publicRecord(await custody(() => credentials.put({ kind: kindOf(provider), label, secret })));
|
|
107
150
|
},
|
|
108
151
|
async list() {
|
|
109
152
|
return (await custody(() => store().list()))
|
|
@@ -114,20 +157,24 @@ export function createModelKeyVault(options) {
|
|
|
114
157
|
const record = await custody(() => store().get(keyId));
|
|
115
158
|
return record === null ? null : publicRecord(record);
|
|
116
159
|
},
|
|
160
|
+
/** Host-only model configuration; the token never leaves its sealed callback. */
|
|
161
|
+
baseUrl(keyId) {
|
|
162
|
+
return custody(() => store().withSecret(keyId, (secret, record) => {
|
|
163
|
+
const provider = providerOf(record.kind);
|
|
164
|
+
return Promise.resolve(providerConfiguration(provider, secret).baseUrl);
|
|
165
|
+
}));
|
|
166
|
+
},
|
|
117
167
|
remove(keyId) {
|
|
118
168
|
return custody(() => store().remove(keyId));
|
|
119
169
|
},
|
|
120
170
|
/** Send one provider request with the key attached; the caller's auth is dropped. */
|
|
121
171
|
send(keyId, request) {
|
|
122
|
-
return custody(() => store().withSecret(keyId, (
|
|
172
|
+
return custody(() => store().withSecret(keyId, (secret, record) => {
|
|
123
173
|
const provider = providerOf(record.kind);
|
|
174
|
+
const credential = providerConfiguration(provider, secret);
|
|
124
175
|
let target;
|
|
125
176
|
try {
|
|
126
|
-
target = modelKeyTarget({
|
|
127
|
-
locator: record.credentialId,
|
|
128
|
-
provider,
|
|
129
|
-
baseUrl: modelKeyBaseUrl(provider),
|
|
130
|
-
}, request);
|
|
177
|
+
target = modelKeyTarget({ baseUrl: credential.baseUrl }, request);
|
|
131
178
|
}
|
|
132
179
|
catch {
|
|
133
180
|
throw new ModelKeyRefused("target_denied");
|
|
@@ -135,7 +182,7 @@ export function createModelKeyVault(options) {
|
|
|
135
182
|
// `duplex` is a Node/Workers extension lib.dom's RequestInit omits.
|
|
136
183
|
const init = {
|
|
137
184
|
method: request.method,
|
|
138
|
-
headers: authenticated(provider, modelKeyForwardedHeaders(request), apiKey),
|
|
185
|
+
headers: authenticated(provider, modelKeyForwardedHeaders(request), credential.apiKey),
|
|
139
186
|
body: request.method === "GET" ? null : request.body,
|
|
140
187
|
signal: request.signal,
|
|
141
188
|
duplex: "half",
|
|
@@ -80,6 +80,7 @@ export type TryEffects = Readonly<{
|
|
|
80
80
|
export type Manager = "npm" | "pnpm";
|
|
81
81
|
/** pnpm when it ran this command (`pnpm dlx`), otherwise npm. */
|
|
82
82
|
export declare function detectManager(userAgent: string | undefined): "pnpm" | "npm";
|
|
83
|
+
export declare function installTryDependencies(directory: string, manager: Manager, verbose: boolean, signal: AbortSignal): Promise<void>;
|
|
83
84
|
/**
|
|
84
85
|
* `wrangler dev` for one local Oyster. The devtools inspector takes a port the
|
|
85
86
|
* kernel assigns (0): wrangler's default probes 9229 upward and binds it later,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// config this package ships, plus a package.json), installs it with the
|
|
4
4
|
// caller's package manager, runs `wrangler dev` locally, installs the Hello
|
|
5
5
|
// App and opens the browser. Running it again in the same directory restarts
|
|
6
|
-
// the server
|
|
6
|
+
// the server after refreshing the generated project files and dependencies.
|
|
7
7
|
//
|
|
8
8
|
// npx @fungi.computer/oyster try [directory] [--port 8787] [--no-open] [--verbose]
|
|
9
9
|
//
|
|
@@ -20,7 +20,7 @@ import { runGit } from "../build/local-build.js";
|
|
|
20
20
|
import { CleanupError, stopProcessGroup, awaitCleanup, } from "../build/process-group.js";
|
|
21
21
|
import { InstallationObservationError } from "../installation-client.js";
|
|
22
22
|
import { createWriteStream } from "node:fs";
|
|
23
|
-
import {
|
|
23
|
+
import { mkdir, mkdtemp, rename, readdir, rm, readFile, stat, writeFile, } from "node:fs/promises";
|
|
24
24
|
import { createServer } from "node:net";
|
|
25
25
|
import { basename, dirname, delimiter, join, resolve } from "node:path";
|
|
26
26
|
import process from "node:process";
|
|
@@ -39,7 +39,8 @@ const tryHelp = `${tryUsage}
|
|
|
39
39
|
Creates ./my-oyster (or <directory>) with a local Oyster, installs it, starts it
|
|
40
40
|
on http://127.0.0.1:<port> and installs a Hello App from <directory>/hello-app,
|
|
41
41
|
a git repository you can edit. Commit an edit and run this again, from inside
|
|
42
|
-
that directory or by naming it, to restart
|
|
42
|
+
that directory or by naming it, to restart with the current Oyster. Generated
|
|
43
|
+
configuration is refreshed; your app source and owner key are kept.
|
|
43
44
|
Press Ctrl-C to stop.
|
|
44
45
|
|
|
45
46
|
Options:
|
|
@@ -117,7 +118,8 @@ export function createTryCli(args) {
|
|
|
117
118
|
function innermostError(cause) {
|
|
118
119
|
let current = cause instanceof Error ? cause : new Error(String(cause));
|
|
119
120
|
for (let depth = 0; depth < 10; depth += 1) {
|
|
120
|
-
|
|
121
|
+
// An aggregate has multiple causes; its summary preserves both failures.
|
|
122
|
+
if (current instanceof AggregateError || !(current.cause instanceof Error))
|
|
121
123
|
break;
|
|
122
124
|
current = current.cause;
|
|
123
125
|
}
|
|
@@ -195,19 +197,36 @@ const pnpmWorkspace = `allowBuilds:
|
|
|
195
197
|
async function exists(path) {
|
|
196
198
|
return stat(path).then(() => true, () => false);
|
|
197
199
|
}
|
|
200
|
+
/** Refresh only try-owned configuration; app sources and owner custody stay put. */
|
|
201
|
+
async function refreshProject(directory, own, spec, manager, signal) {
|
|
202
|
+
const examples = join(import.meta.dirname, "../../examples/standalone");
|
|
203
|
+
const files = new Map([
|
|
204
|
+
["worker.ts", await readFile(join(examples, "worker.ts"), "utf8")],
|
|
205
|
+
[
|
|
206
|
+
"wrangler.jsonc",
|
|
207
|
+
await readFile(join(examples, "wrangler.jsonc"), "utf8"),
|
|
208
|
+
],
|
|
209
|
+
["package.json", projectManifest(own, spec)],
|
|
210
|
+
]);
|
|
211
|
+
if (manager === "pnpm")
|
|
212
|
+
files.set("pnpm-workspace.yaml", pnpmWorkspace);
|
|
213
|
+
for (const [name, content] of files) {
|
|
214
|
+
signal.throwIfAborted();
|
|
215
|
+
const path = join(directory, name);
|
|
216
|
+
if ((await exists(path)) && (await readFile(path, "utf8")) === content)
|
|
217
|
+
continue;
|
|
218
|
+
// Mark before the first change, so an interrupted refresh/install is retried.
|
|
219
|
+
await mkdir(join(directory, ".oyster"), { recursive: true });
|
|
220
|
+
await writeFile(join(directory, pendingInstall), "Dependencies have not finished installing.\n");
|
|
221
|
+
await writeFile(path, content);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
198
224
|
async function scaffold(directory, own, spec, manager, signal) {
|
|
199
225
|
signal.throwIfAborted();
|
|
200
226
|
await mkdir(dirname(directory), { recursive: true });
|
|
201
227
|
const stage = await mkdtemp(join(dirname(directory), ".oyster-try-"));
|
|
202
228
|
try {
|
|
203
|
-
|
|
204
|
-
for (const name of ["worker.ts", "wrangler.jsonc"]) {
|
|
205
|
-
signal.throwIfAborted();
|
|
206
|
-
await copyFile(join(examples, name), join(stage, name));
|
|
207
|
-
}
|
|
208
|
-
await writeFile(join(stage, "package.json"), projectManifest(own, spec));
|
|
209
|
-
if (manager === "pnpm")
|
|
210
|
-
await writeFile(join(stage, "pnpm-workspace.yaml"), pnpmWorkspace);
|
|
229
|
+
await refreshProject(stage, own, spec, manager, signal);
|
|
211
230
|
await writeFile(join(stage, ".gitignore"), ".oyster/\n.wrangler/\nnode_modules/\n.oyster-owner\n");
|
|
212
231
|
const key = Array.from(randomBytes(24), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
213
232
|
await writeFile(join(stage, ownerKeyFile), key + "\n", {
|
|
@@ -270,7 +289,7 @@ function npmFailureCode(output) {
|
|
|
270
289
|
return undefined;
|
|
271
290
|
}
|
|
272
291
|
}
|
|
273
|
-
async function
|
|
292
|
+
export async function installTryDependencies(directory, manager, verbose, signal) {
|
|
274
293
|
signal.throwIfAborted();
|
|
275
294
|
await mkdir(join(directory, ".oyster"), { recursive: true });
|
|
276
295
|
signal.throwIfAborted();
|
|
@@ -284,7 +303,12 @@ async function runInstall(directory, manager, verbose, signal) {
|
|
|
284
303
|
]));
|
|
285
304
|
const stop = () => awaitCleanup(beginStop());
|
|
286
305
|
try {
|
|
287
|
-
child = spawn(manager,
|
|
306
|
+
child = spawn(manager,
|
|
307
|
+
// Refresh tag dependencies such as Truffle too: install alone can retain
|
|
308
|
+
// their old locked version even after Oyster itself is upgraded.
|
|
309
|
+
manager === "npm"
|
|
310
|
+
? ["update", "--no-save", "--json"]
|
|
311
|
+
: ["update", "--no-save"], {
|
|
288
312
|
cwd: directory,
|
|
289
313
|
detached: process.platform !== "win32",
|
|
290
314
|
signal,
|
|
@@ -315,7 +339,7 @@ async function runInstall(directory, manager, verbose, signal) {
|
|
|
315
339
|
done();
|
|
316
340
|
else {
|
|
317
341
|
const errorCode = npmFailureCode(diagnostic);
|
|
318
|
-
fail(Object.assign(new Error(`${manager}
|
|
342
|
+
fail(Object.assign(new Error(`${manager} update failed (${errorCode === undefined ? "" : `${errorCode}; `}exit ${String(code)}).`), { code: errorCode }));
|
|
319
343
|
}
|
|
320
344
|
});
|
|
321
345
|
});
|
|
@@ -481,13 +505,17 @@ function startWrangler(input) {
|
|
|
481
505
|
: readiness === "exited"
|
|
482
506
|
? `Oyster stopped before readiness (${child.signalCode === null ? `exit ${String(child.exitCode)}` : `signal ${child.signalCode}`}).`
|
|
483
507
|
: "Oyster did not answer within 120 seconds.";
|
|
484
|
-
await stop();
|
|
485
508
|
throw new TryError(diagnostic, `Read ${log} for the server output.`);
|
|
486
509
|
}
|
|
487
510
|
return { stop, exited };
|
|
488
511
|
}
|
|
489
512
|
catch (cause) {
|
|
490
|
-
|
|
513
|
+
try {
|
|
514
|
+
await stop();
|
|
515
|
+
}
|
|
516
|
+
catch (cleanup) {
|
|
517
|
+
throw new AggregateError([cause, cleanup], `${innermostError(cause).message} Cleanup also failed: ${innermostError(cleanup).message}`, { cause: cleanup });
|
|
518
|
+
}
|
|
491
519
|
throw cause;
|
|
492
520
|
}
|
|
493
521
|
})();
|
|
@@ -520,7 +548,7 @@ function isTryCancellation(cause, signal) {
|
|
|
520
548
|
cause instanceof InstallationObservationError));
|
|
521
549
|
}
|
|
522
550
|
const realEffects = {
|
|
523
|
-
installDependencies:
|
|
551
|
+
installDependencies: installTryDependencies,
|
|
524
552
|
startServer: startWrangler,
|
|
525
553
|
installHello: installHelloApp,
|
|
526
554
|
installDesktop: async ({ directory, ...input }) => {
|
|
@@ -633,6 +661,10 @@ export async function tryOyster(args, effects = realEffects, ui = createTryCli(a
|
|
|
633
661
|
else {
|
|
634
662
|
key = (await readFile(keyPath, "utf8")).trim();
|
|
635
663
|
ui.info(`Restarting the Oyster in ${directory}`);
|
|
664
|
+
const manager = (await exists(join(directory, "pnpm-workspace.yaml")))
|
|
665
|
+
? "pnpm"
|
|
666
|
+
: "npm";
|
|
667
|
+
await task("Refreshing Oyster project", async () => refreshProject(directory, await ownManifest(), values.package, manager, signal));
|
|
636
668
|
}
|
|
637
669
|
if (fresh ||
|
|
638
670
|
(await exists(join(directory, pendingInstall))) ||
|
package/docs/api/agents.md
CHANGED
|
@@ -330,23 +330,9 @@ type OysterAgents = Readonly<{
|
|
|
330
330
|
media: "ready" | "missing";
|
|
331
331
|
}>
|
|
332
332
|
>;
|
|
333
|
-
modelKeys: Promise<
|
|
334
|
-
readonly Readonly<{
|
|
335
|
-
keyId: string;
|
|
336
|
-
provider: ModelKeyProvider;
|
|
337
|
-
label: string;
|
|
338
|
-
createdAt: number;
|
|
339
|
-
validatedAt: number;
|
|
340
|
-
}>[]
|
|
341
|
-
>;
|
|
333
|
+
modelKeys: Promise<readonly ModelKeyRecord[]>;
|
|
342
334
|
sealModelKey: Promise<
|
|
343
|
-
|
|
|
344
|
-
keyId: string;
|
|
345
|
-
provider: ModelKeyProvider;
|
|
346
|
-
label: string;
|
|
347
|
-
createdAt: number;
|
|
348
|
-
validatedAt: number;
|
|
349
|
-
}>
|
|
335
|
+
| ModelKeyRecord
|
|
350
336
|
| Readonly<{
|
|
351
337
|
error: ModelKeyRefusal;
|
|
352
338
|
}>
|
|
@@ -465,6 +451,22 @@ Why a key could not be stored or used; stable, secret-free.
|
|
|
465
451
|
|
|
466
452
|
---
|
|
467
453
|
|
|
454
|
+
### ModelKeyRecord
|
|
455
|
+
|
|
456
|
+
```ts
|
|
457
|
+
type ModelKeyRecord = Omit<HostedModelKeyRecord, "provider"> & object;
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
Standalone custody also accepts an owner’s Cloudflare account and token.
|
|
461
|
+
|
|
462
|
+
#### Type Declaration
|
|
463
|
+
|
|
464
|
+
| Name | Type |
|
|
465
|
+
| ---------- | ------------------------------------------------------------------- |
|
|
466
|
+
| `provider` | `HostedModelKeyRecord`\[`"provider"`\] \| `"cloudflare-workers-ai"` |
|
|
467
|
+
|
|
468
|
+
---
|
|
469
|
+
|
|
468
470
|
### ModelKeySealInput
|
|
469
471
|
|
|
470
472
|
```ts
|
|
@@ -472,6 +474,7 @@ type ModelKeySealInput = Readonly<{
|
|
|
472
474
|
provider: string;
|
|
473
475
|
label: string;
|
|
474
476
|
apiKey: string;
|
|
477
|
+
accountId?: string;
|
|
475
478
|
}>;
|
|
476
479
|
```
|
|
477
480
|
|
package/docs/api/apps.md
CHANGED
|
@@ -26,6 +26,7 @@ readonly read(appKey): Promise<
|
|
|
26
26
|
installationId: string;
|
|
27
27
|
appId: string;
|
|
28
28
|
appName: string;
|
|
29
|
+
appCalls: object[];
|
|
29
30
|
artifactDigest: Sha256Digest;
|
|
30
31
|
permissions: {
|
|
31
32
|
authority: {
|
|
@@ -139,8 +140,8 @@ and the available resources.
|
|
|
139
140
|
###### Returns
|
|
140
141
|
|
|
141
142
|
`Promise`\< \| `"unavailable"` \| \{ `storeGeneration`: `string`;
|
|
142
|
-
`installationId`: `string`; `appId`: `string`; `appName`: `string`;
|
|
143
|
-
`artifactDigest`: `Sha256Digest`; `permissions`: \{ `authority`: \{
|
|
143
|
+
`installationId`: `string`; `appId`: `string`; `appName`: `string`; `appCalls`:
|
|
144
|
+
`object`[]; `artifactDigest`: `Sha256Digest`; `permissions`: \{ `authority`: \{
|
|
144
145
|
`authorityVersion`: `number`; `declaredOperationsDigest`: `Sha256Digest`;
|
|
145
146
|
`approvedGrants`: readonly `Readonly`\<\{ `capability`: \| `"computer.list"` \|
|
|
146
147
|
`"computer.readFile"` \| `"computer.writeFile"` \| `"computer.execute"` \|
|
|
@@ -1556,6 +1557,11 @@ const appPermissionPageSchema: ZodObject<{
|
|
|
1556
1557
|
installationId: ZodString;
|
|
1557
1558
|
appId: ZodString;
|
|
1558
1559
|
appName: ZodString;
|
|
1560
|
+
appCalls: ZodArray<ZodObject<{
|
|
1561
|
+
operation: ZodString;
|
|
1562
|
+
method: ZodString;
|
|
1563
|
+
targetName: ZodString;
|
|
1564
|
+
}, $strict>>;
|
|
1559
1565
|
artifactDigest: ZodPipe<ZodUnknown, ZodTransform<Sha256Digest, unknown>>;
|
|
1560
1566
|
permissions: ZodObject<{
|
|
1561
1567
|
authority: ZodObject<{
|