esoul-sdk 0.19.1 → 0.21.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.
Files changed (50) hide show
  1. package/CHANGELOG.md +72 -0
  2. package/README.md +1 -0
  3. package/api-reference.md +859 -15
  4. package/dist/manifest.d.ts +609 -22
  5. package/dist/manifest.js +241 -7
  6. package/dist/react.d.ts +35 -0
  7. package/dist/react.js +13 -0
  8. package/dist/server.d.ts +182 -2
  9. package/dist/server.js +78 -0
  10. package/dist/testing/index.d.ts +8 -0
  11. package/dist/testing/index.js +6 -0
  12. package/dist/testing/llm.d.ts +45 -0
  13. package/dist/testing/llm.js +76 -0
  14. package/dist/testing/sim-gmail/bytes.d.ts +21 -0
  15. package/dist/testing/sim-gmail/bytes.js +125 -0
  16. package/dist/testing/sim-gmail/corpus.d.ts +69 -0
  17. package/dist/testing/sim-gmail/corpus.js +471 -0
  18. package/dist/testing/sim-gmail/errors.d.ts +26 -0
  19. package/dist/testing/sim-gmail/errors.js +71 -0
  20. package/dist/testing/sim-gmail/faults.d.ts +74 -0
  21. package/dist/testing/sim-gmail/faults.js +108 -0
  22. package/dist/testing/sim-gmail/http.d.ts +81 -0
  23. package/dist/testing/sim-gmail/http.js +793 -0
  24. package/dist/testing/sim-gmail/index.d.ts +149 -0
  25. package/dist/testing/sim-gmail/index.js +416 -0
  26. package/dist/testing/sim-gmail/mime.d.ts +78 -0
  27. package/dist/testing/sim-gmail/mime.js +352 -0
  28. package/dist/testing/sim-gmail/names.d.ts +22 -0
  29. package/dist/testing/sim-gmail/names.js +83 -0
  30. package/dist/testing/sim-gmail/personas.d.ts +40 -0
  31. package/dist/testing/sim-gmail/personas.js +250 -0
  32. package/dist/testing/sim-gmail/query.d.ts +51 -0
  33. package/dist/testing/sim-gmail/query.js +280 -0
  34. package/dist/testing/sim-gmail/random.d.ts +33 -0
  35. package/dist/testing/sim-gmail/random.js +116 -0
  36. package/dist/testing/sim-gmail/render.d.ts +30 -0
  37. package/dist/testing/sim-gmail/render.js +89 -0
  38. package/dist/testing/sim-gmail/types.d.ts +243 -0
  39. package/dist/testing/sim-gmail/types.js +2 -0
  40. package/dist/testing/sim-gmail/world.d.ts +217 -0
  41. package/dist/testing/sim-gmail/world.js +657 -0
  42. package/dist/types.d.ts +15 -0
  43. package/docs/02-manifest.md +2 -2
  44. package/docs/08-connections.md +146 -8
  45. package/docs/10-testing.md +14 -0
  46. package/docs/19-model-calls.md +149 -0
  47. package/llms-full.txt +316 -10
  48. package/llms.txt +1 -0
  49. package/package.json +3 -2
  50. package/schemas/plugin.schema.json +83 -2
package/CHANGELOG.md ADDED
@@ -0,0 +1,72 @@
1
+ # esoul-sdk changelog
2
+
3
+ Releases before 0.20.0 are recorded in the repository history only.
4
+
5
+ ## 0.21.0
6
+
7
+ ### Added
8
+
9
+ - **Model calls, billed: `llm` in `plugin.json` and `llm(ctx).generate(req)` in `esoul-sdk/server`.**
10
+ Declare `"llm": { "why", "dailyBudgetUsd"? (default 5, at most 100), "models"? }` and call
11
+ `llm(ctx).generate({ purpose, model?, system?, messages, tools?, schema?, maxOutputTokens?, temperature? })`
12
+ from an op or a route — or `ctx.llm.generate(…)` from a task. The app instance's workspace **owner**
13
+ pays from their AI credits; every call is recorded with the app, the instance and `purpose`; the
14
+ app's spend per owner per UTC day is capped by `dailyBudgetUsd`. `model` is a tier (`fast`,
15
+ `balanced`, `best`) or a gateway id on the platform's allowlist (DeepSeek, Claude, GPT mini/nano,
16
+ Gemini Flash) or in `llm.models`. `tools` are definitions: the model's calls come back in
17
+ `toolCalls`, never executed by the platform. `schema` (JSON Schema) returns the answer parsed in
18
+ `object`. A refusal throws `LlmUnavailable` (`isLlmUnavailable`) with `code` `not_declared` |
19
+ `not_allowed` | `no_credits` | `budget_exceeded` | `model_not_allowed` | `provider_unavailable`.
20
+ Schema: `PluginLlmSchema`. See `docs/19-model-calls.md`.
21
+ - **`scriptedModel(policy?)` in `esoul-sdk/testing`.** A deterministic stand-in for `llm(ctx)`: scripted
22
+ texts, objects and tool calls by matching the last user message (or a function), a short echo by
23
+ default, zero cost, every request in `.calls`. The Forge box answers every model call with one.
24
+
25
+ ### Changed
26
+
27
+ - **App files may not import a model SDK** (`ai`, `@ai-sdk/*`, `openai`, `@anthropic-ai/*`,
28
+ `@google/genai`, `@inngest/ai`) — the box check and the install inspection refuse it, tests
29
+ included. Apps call models through `llm(ctx)`.
30
+
31
+ ## 0.20.0
32
+
33
+ ### Added
34
+
35
+ - **Platform accounts (Google): `credentials` in `plugin.json`.** An app declares one slot,
36
+ `credentials: { <slot>: { family: "google", scopes, why, label?, background? } }`, with scopes
37
+ from `gmail.readonly`, `gmail.modify`, `gmail.send`, `gmail.compose`, `gmail.labels`,
38
+ `calendar.events`, `calendar.readonly`, `contacts`, `contacts.readonly`, `drive.readonly`,
39
+ `drive.file` (short or full URL). The person assigns a Google account to the app in Account
40
+ settings → Google. Schema: `PluginCredentialsSchema`, `GOOGLE_CREDENTIAL_SCOPES`,
41
+ `normaliseCredentialScopes`. See `docs/08-connections.md` → "Platform accounts (Google)".
42
+ - **`credentials(ctx).slot(name)` in `esoul-sdk/server`: a proxy, never a token.** `.fetch(url, init)`
43
+ is the standard `fetch` with the account's access added by the platform, sent only when the URL
44
+ is a clean `https://` Google API URL that one of the slot's scopes reaches for that method, and
45
+ the caller is the account's owner (or the app's own background work when the slot declares
46
+ `background: true`). `.status()` answers `{ state: "ready" | "not_bound" | "needs_consent" |
47
+ "reconnect" | "not_allowed", account?, missingScopes?, connectUrl?, reason? }`. A refusal throws
48
+ `CredentialUnavailable` (`isCredentialUnavailable`) with a `code` a tool can relay.
49
+ - **`useCredential(slot, { nodeId })` and `<ConnectAccount/>` in `esoul-sdk/react`.** The screen
50
+ asks the same question `status()` answers, for the person looking at it; `connect()` sends the
51
+ owner to consent, a reconnect, or Account settings → Google.
52
+ - **`simGmail()` in `esoul-sdk/testing`: a fake Gmail at the HTTP level.** The endpoints the
53
+ platform's mail code calls, with Gmail's wire shapes and error envelopes; mailboxes that deliver
54
+ to each other and thread like Gmail; history and push; scripted counterparties (`addPersona`,
55
+ `crowd`) on a virtual clock (`advance`); deterministic faults; a seeded, production-shaped
56
+ synthetic corpus (300 messages by default); `snapshot()` / `simGmail({ restore })`.
57
+ Also `DEFAULT_SIM_ACCOUNT`, `DEFAULT_CROWD_MIX`. See `src/testing/sim-gmail/README.md` in the
58
+ repository. No Node built-ins: it runs in jest, Node, Next.js and the browser.
59
+ - In a Forge box (esoul-app-host 0.3.0), the Google slot is bound to one simulated account and
60
+ answered by `simGmail`; the installed app uses the person's real account.
61
+
62
+ ### Changed
63
+
64
+ - **The env-name rule (W-060).** A `connections` entry's `clientIdEnv` / `clientSecretEnv` must
65
+ name the app's OWN env vars: `PLUGIN_<APP ID upper-cased, - as _>__<NAME>`, e.g.
66
+ `PLUGIN_MY_APP__CLIENT_ID`. Any other name is refused by the manifest schema; a name ending in
67
+ `_WEBHOOK_TOKEN` is the platform's and is refused too (`pluginEnvPrefix`,
68
+ `pluginEnvNameProblem`). An app that named `GOOGLE_CLIENT_ID` or any other platform variable
69
+ must rename it and have the owner set the new name.
70
+ - `authorizeUrl` / `tokenUrl` must be `https://` (plain `http://` only to the loopback, for a mock
71
+ provider such as `startMockOAuth`) — `pluginEndpointProblem`.
72
+ - The package no longer ships compiled test files (`src/**/*.test.ts` are excluded from `dist/`).
package/README.md CHANGED
@@ -573,6 +573,7 @@ Exits 0 when the folder is a well-formed application package; otherwise prints e
573
573
  | [14. Your own tables](docs/14-database.md) | `db`, rules, scopes, sealed fields, indexes, migrations |
574
574
  | [15. Realtime](docs/15-realtime.md) | Topics, audiences, addressing |
575
575
  | [16. Bindings](docs/16-bindings.md) | Slots, contracts, reaching another application |
576
+ | [19. Model calls](docs/19-model-calls.md) | `llm(ctx)`: billed model calls, budgets, `scriptedModel()` for tests |
576
577
 
577
578
  ## Versions
578
579