@fungi.computer/oyster 0.20.0 → 0.20.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.
@@ -21,14 +21,29 @@ export declare class AgentModelRefused extends Error {
21
21
  readonly reason: AgentModelRefusal;
22
22
  constructor(reason: AgentModelRefusal);
23
23
  }
24
+ /**
25
+ * Pi 1.3's Model/getModels contract has no tool-calling flag (reasoning and
26
+ * supportsStrictMode are not capability flags). Until it does, keep this small
27
+ * Agent shortlist beside the existing catalog, never copy names or prices.
28
+ * DeepSeek passed Grove's write/read proof on 2026-11-10; Granite failed its
29
+ * first execute call. Kimi is the existing Workers AI Agent default. The other
30
+ * entries are the providers' tool-capable Sonnet/Luna choices:
31
+ * https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview
32
+ * https://platform.openai.com/docs/guides/function-calling
33
+ * OpenRouter exposes that same Luna model. Other entries remain selectable as chat only;
34
+ * this is an admission policy for Agents, not a claim they cannot chat.
35
+ * Replace this fallback when Pi exposes its source's tool-calling flag.
36
+ */
37
+ export declare function agentModelSupportsTools(model: Pick<Model<Api>, "provider" | "id">): boolean;
24
38
  /** A supported model and Pi's USD prices per million tokens, without credentials. */
25
39
  export type SupportedAgentModel = Readonly<{
26
40
  id: string;
27
41
  name: string;
28
42
  input: number;
29
43
  output: number;
44
+ tools: boolean;
30
45
  }>;
31
- /** Settings and selection share Pi's catalog; cheapest combined token rate first. */
46
+ /** Pi's full catalog: verified tools first, then chat only; each group by price. */
32
47
  export declare function supportedAgentModels(provider: "anthropic" | "openai" | "openrouter" | "cloudflare-workers-ai"): Promise<readonly SupportedAgentModel[]>;
33
48
  /**
34
49
  * An Agent with no saved choice runs on a model its host can reach, chosen when
@@ -43,7 +43,35 @@ async function byokCatalog(provider) {
43
43
  .openrouterProvider()
44
44
  .getModels();
45
45
  }
46
- /** Settings and selection share Pi's catalog; cheapest combined token rate first. */
46
+ /**
47
+ * Pi 1.3's Model/getModels contract has no tool-calling flag (reasoning and
48
+ * supportsStrictMode are not capability flags). Until it does, keep this small
49
+ * Agent shortlist beside the existing catalog, never copy names or prices.
50
+ * DeepSeek passed Grove's write/read proof on 2026-11-10; Granite failed its
51
+ * first execute call. Kimi is the existing Workers AI Agent default. The other
52
+ * entries are the providers' tool-capable Sonnet/Luna choices:
53
+ * https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview
54
+ * https://platform.openai.com/docs/guides/function-calling
55
+ * OpenRouter exposes that same Luna model. Other entries remain selectable as chat only;
56
+ * this is an admission policy for Agents, not a claim they cannot chat.
57
+ * Replace this fallback when Pi exposes its source's tool-calling flag.
58
+ */
59
+ export function agentModelSupportsTools(model) {
60
+ switch (model.provider) {
61
+ case "cloudflare-workers-ai":
62
+ return (model.id === "@cf/deepseek-ai/deepseek-v4-flash-0731" ||
63
+ model.id === "@cf/moonshotai/kimi-k2.6");
64
+ case "anthropic":
65
+ return model.id === "claude-sonnet-4-6";
66
+ case "openai":
67
+ return model.id === "gpt-6-luna" || model.id === "openai/gpt-6-luna";
68
+ case "openrouter":
69
+ return model.id === "openai/gpt-6-luna";
70
+ default:
71
+ return false;
72
+ }
73
+ }
74
+ /** Pi's full catalog: verified tools first, then chat only; each group by price. */
47
75
  export async function supportedAgentModels(provider) {
48
76
  return (await byokCatalog(provider))
49
77
  .map((model) => ({
@@ -51,8 +79,11 @@ export async function supportedAgentModels(provider) {
51
79
  name: model.name,
52
80
  input: model.cost.input,
53
81
  output: model.cost.output,
82
+ tools: agentModelSupportsTools(model),
54
83
  }))
55
- .sort((a, b) => a.input + a.output - b.input - b.output || a.id.localeCompare(b.id));
84
+ .sort((a, b) => Number(b.tools) - Number(a.tools) ||
85
+ a.input + a.output - b.input - b.output ||
86
+ a.id.localeCompare(b.id));
56
87
  }
57
88
  /**
58
89
  * An Agent with no saved choice runs on a model its host can reach, chosen when
@@ -75,7 +106,7 @@ export async function resolveDefaultChoice(ready) {
75
106
  provider !== "openrouter" &&
76
107
  provider !== "cloudflare-workers-ai")
77
108
  continue;
78
- const catalog = await byokCatalog(provider);
109
+ const catalog = (await byokCatalog(provider)).filter(agentModelSupportsTools);
79
110
  const model = catalog.find((entry) => "default" in entry && entry.default === true) ??
80
111
  catalog[0];
81
112
  if (model !== undefined)
@@ -43,7 +43,7 @@ import { standaloneBrowserLiveView, standaloneBrowserSource, } from "./browser.j
43
43
  import { standaloneWebSource } from "./web.js";
44
44
  import { configuredProviderEgress, providerFetch, } from "@fungi.computer/veil/gatekeeper";
45
45
  import { createAssistantMessageEventStream } from "@earendil-works/pi-ai/utils/event-stream";
46
- import { agentModelChoice, agentModelChoiceSchema, AgentModelRefused, resolveDefaultChoice, selectAgentModel, } from "./agent-model-choice.js";
46
+ import { agentModelChoice, agentModelChoiceSchema, AgentModelRefused, agentModelSupportsTools, resolveDefaultChoice, selectAgentModel, } from "./agent-model-choice.js";
47
47
  import { CLOUDFLARE_GATEWAY_BINDING_AUTH_SENTINEL, createAiBindingFetch, } from "@earendil-works/pi-ai/api/cloudflare-ai-binding";
48
48
  import { cloudflareAccountReady } from "./cloudflare-account.js";
49
49
  import { cloudflareWorkersAIProvider } from "@earendil-works/pi-ai/providers/cloudflare-workers-ai";
@@ -173,17 +173,17 @@ function observedModels(model, defaults) {
173
173
  /** The refusal a run ends with when no model provider is connected, in the host's own failure wording. */
174
174
  const setupRequiredFailure = "Model request failed (setup_required). Connect a model first.";
175
175
  /**
176
- * A run with no connected model provider: end it at once with the typed setup
177
- * failure. A transport error would read as an outage and be retried.
176
+ * A run refused before contacting the model: end with the host’s stable reason.
177
+ * A transport error would read as an outage and be retried.
178
178
  */
179
- function unconfiguredModels(model) {
179
+ function refusedModels(model, reason) {
180
180
  return {
181
181
  acquire: () => {
182
182
  const failed = new WeakSet();
183
183
  return Promise.resolve({
184
184
  model,
185
185
  retryable: () => false,
186
- failureReason: (message) => failed.has(message) ? setupRequiredFailure : undefined,
186
+ failureReason: (message) => (failed.has(message) ? reason : undefined),
187
187
  stream: () => {
188
188
  const events = createAssistantMessageEventStream();
189
189
  const terminal = {
@@ -207,7 +207,7 @@ function unconfiguredModels(model) {
207
207
  },
208
208
  },
209
209
  stopReason: "error",
210
- errorMessage: setupRequiredFailure,
210
+ errorMessage: reason,
211
211
  timestamp: Date.now(),
212
212
  };
213
213
  failed.add(terminal);
@@ -929,6 +929,10 @@ export class StandaloneAgentBase extends ShiitakeDO {
929
929
  }
930
930
  async sourceFor(choice) {
931
931
  const modelChoice = await selectAgentModel(choice);
932
+ // Saved choices remain readable, but an Agent needs tools. Stop before a
933
+ // provider request instead of letting a chat-only choice fail opaquely.
934
+ if (!agentModelSupportsTools(modelChoice))
935
+ return refusedModels(normalizeModel(modelChoice), "Model request failed (tools_unsupported). Pick a model marked tools.");
932
936
  if (choice.keySource === "byok" && choice.keyId !== undefined) {
933
937
  await this.admitKey(choice);
934
938
  const directory = await this.keyDirectory();
@@ -983,7 +987,7 @@ export class StandaloneAgentBase extends ShiitakeDO {
983
987
  throw new AgentModelRefused("key_not_connected");
984
988
  // The AI binding is declared everywhere; only a Cloudflare account answers it.
985
989
  if (!cloudflareAccountReady(this.env))
986
- return unconfiguredModels(normalizeModel(modelChoice));
990
+ return refusedModels(normalizeModel(modelChoice), setupRequiredFailure);
987
991
  let options = { model: modelChoice.id };
988
992
  if (this.env.OYSTER_AI_GATEWAY !== undefined)
989
993
  options = { ...options, gateway: this.env.OYSTER_AI_GATEWAY };
@@ -41,5 +41,6 @@ export declare function localDesktopState(input: Readonly<{
41
41
  export declare function installLocalStarter(app: StarterApp, input: Readonly<{
42
42
  url: string;
43
43
  key: string;
44
+ packageStoreDirectory: string;
44
45
  signal?: AbortSignal;
45
46
  }>): Promise<void>;
@@ -126,6 +126,7 @@ export async function installLocalStarter(app, input) {
126
126
  appId: app.appId,
127
127
  sourceDirectory: source,
128
128
  sourceRevision: `git:${commit}`,
129
+ packageStoreDirectory: input.packageStoreDirectory,
129
130
  recipe: appBuildRecipe(readBuildManifest(await git(source, ["show", `${commit}:package.json`], signal)), ""),
130
131
  outDirectory: release,
131
132
  signal,
@@ -38,6 +38,7 @@ export type TryEffects = Readonly<{
38
38
  /** Prepare Tourtois without changing an existing installation or its approval. */
39
39
  installDesktop: (input: {
40
40
  directory: string;
41
+ packageStoreDirectory: string;
41
42
  url: string;
42
43
  key: string;
43
44
  signal: AbortSignal;
@@ -46,6 +47,7 @@ export type TryEffects = Readonly<{
46
47
  installStarter: (app: StarterApp, input: {
47
48
  url: string;
48
49
  key: string;
50
+ packageStoreDirectory: string;
49
51
  signal: AbortSignal;
50
52
  }) => Promise<"installed" | "already-installed">;
51
53
  /** Tell the Oyster which starter Apps are not ready yet. */
@@ -762,6 +762,7 @@ export async function tryOyster(args, effects = realEffects, ui = createTryCli(a
762
762
  ui.warn(`The Computer runtime is unavailable (${innermostError(cause).message}).`, "Files remain available. Fix the runtime and restart oyster try to run commands.");
763
763
  }
764
764
  });
765
+ const packageStoreDirectory = join(directory, ".oyster", "package-store");
765
766
  const desktop = await setupTask(fresh
766
767
  ? "Installing Hello and building Tourtois"
767
768
  : "Installing Hello and checking Tourtois", async () => {
@@ -771,6 +772,7 @@ export async function tryOyster(args, effects = realEffects, ui = createTryCli(a
771
772
  const preparation = new AbortController();
772
773
  const input = {
773
774
  directory,
775
+ packageStoreDirectory,
774
776
  url,
775
777
  key,
776
778
  signal: AbortSignal.any([signal, preparation.signal]),
@@ -876,7 +878,7 @@ export async function tryOyster(args, effects = realEffects, ui = createTryCli(a
876
878
  // Agents answer with a model; say up front, once, what to do when none is.
877
879
  if ((await effects.modelSetup({ url, key, signal })) === "missing")
878
880
  ui.warn("No model is connected yet, so Agents can't answer.", `Open Oyster, choose Keys, then Model keys, and add a key. Guide: ${modelKeyGuideUrl}`);
879
- // The rest of the starter Apps build here, one at a time, while the desktop
881
+ // The rest of the starter Apps build here, two at a time, while the desktop
880
882
  // is already usable. Each reports one line; a failure never stops the rest.
881
883
  const starters = trialStarterOrder.map((id) => {
882
884
  const app = standaloneAppSet.find((item) => item.installationId === id);
@@ -892,13 +894,19 @@ export async function tryOyster(args, effects = realEffects, ui = createTryCli(a
892
894
  const stopped = () => trialSignal.aborted;
893
895
  // What the desktop shows for each starter App that is not ready yet.
894
896
  const pending = new Map();
895
- const trial = { url, key, signal: trialSignal };
896
- const publish = () => effects
897
- .reportStarters(trial, [...pending.values()])
898
- .then(undefined, (cause) => {
899
- if (!stopped())
900
- ui.warn(`The desktop could not be told which Apps are installing (${innermostError(cause).message}).`, "Installs continue; the desktop will not show their progress.");
901
- });
897
+ const trial = { url, key, packageStoreDirectory, signal: trialSignal };
898
+ let publishing = Promise.resolve();
899
+ const publish = () => {
900
+ const installing = [...pending.values()];
901
+ // Concurrent builds still publish their state transitions in order.
902
+ publishing = publishing
903
+ .then(() => effects.reportStarters(trial, installing))
904
+ .then(undefined, (cause) => {
905
+ if (!stopped())
906
+ ui.warn(`The desktop could not be told which Apps are installing (${innermostError(cause).message}).`, "Installs continue; the desktop will not show their progress.");
907
+ });
908
+ return publishing;
909
+ };
902
910
  const failureReason = (cause) => {
903
911
  const failure = innermostError(cause);
904
912
  return {
@@ -956,11 +964,22 @@ export async function tryOyster(args, effects = realEffects, ui = createTryCli(a
956
964
  state: "installing",
957
965
  });
958
966
  await publish();
959
- for (const app of starters) {
960
- if (stopped())
961
- return;
962
- await installOne(app);
963
- }
967
+ let next = 0;
968
+ const installNext = async () => {
969
+ while (!stopped()) {
970
+ const app = starters[next++];
971
+ if (app === undefined)
972
+ return;
973
+ await installOne(app);
974
+ }
975
+ };
976
+ const installs = await Promise.allSettled([
977
+ installNext(),
978
+ installNext(),
979
+ ]);
980
+ for (const result of installs)
981
+ if (result.status === "rejected")
982
+ throw result.reason;
964
983
  // Then answer the desktop's retry asks until the trial stops.
965
984
  while (!stopped()) {
966
985
  const waited = await sleep(retryPollMs, undefined, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungi.computer/oyster",
3
- "version": "0.20.0",
3
+ "version": "0.20.2",
4
4
  "author": "Levi <levi@technomancy.dev>",
5
5
  "description": "Oyster by Fungi: open-source Apps for people and AI agents. Try with one command or run on your own Cloudflare account.",
6
6
  "homepage": "https://docs.fungi.computer/oyster",
@@ -356,7 +356,7 @@
356
356
  "@fungi.computer/lantern": "0.4.2",
357
357
  "@fungi.computer/mycelium": "0.3.8",
358
358
  "@fungi.computer/nacre": "0.4.5",
359
- "@fungi.computer/parakeet": "0.11.11",
359
+ "@fungi.computer/parakeet": "0.11.12",
360
360
  "@fungi.computer/puffball": "0.5.5",
361
361
  "@fungi.computer/seam": "0.2.5",
362
362
  "@fungi.computer/shiitake": "0.13.0",