castle-web-sdk 0.4.40 → 0.4.41

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/README.md CHANGED
@@ -731,9 +731,11 @@ be coalesced, so it's safe to call on frequent events.
731
731
  ## Agent
732
732
 
733
733
  `Agent` asks a language model for one chat completion. The host sends it
734
- through Castle's oracle on the player's own Castle account, so the deck
735
- holds no key. Agent.chat is limited to Castle admins for now; every other
736
- player gets `'refused'`.
734
+ through Castle's deck-agent service, so the deck holds no key. Castle pays
735
+ for each player's calls out of a daily play allowance, which Castle
736
+ characters draw from too; once a player has used it up, calls resolve
737
+ `'allowance_exhausted'` until it resets at midnight UTC. Agent.chat is
738
+ limited to Castle admins for now; every other player gets `'refused'`.
737
739
 
738
740
  ### `Agent.chat(params): Promise<AgentChatResult>`
739
741
 
@@ -745,9 +747,11 @@ player gets `'refused'`.
745
747
  - `tools` — optional function tools, in the OpenAI function-tool schema.
746
748
  - `toolChoice` — optional: `'auto'` (the default), `'none'`, `'required'`,
747
749
  or `{ type: 'function', function: { name } }` to force one tool.
748
- - `model` — optional OpenRouter model id. Defaults to
749
- `'meta/muse-spark-1.3'`.
750
- - `maxTokens` — optional cap on the reply's length.
750
+ - `model` — optional OpenRouter model id: `'meta/muse-spark-1.3-contributor'`
751
+ (the default), `'meta/muse-spark-1.3'` or `'openai/gpt-4.1-mini'`. Any
752
+ other model resolves `'error'`.
753
+ - `maxTokens` — optional cap on the reply's length. Defaults to 4096; the
754
+ service caps it at 16384.
751
755
  - `reasoning` — optional `{ effort: 'minimal' | 'low' | 'medium' | 'high' }`,
752
756
  how hard the model thinks before it answers. Lower effort answers sooner.
753
757
  Left out, the model uses its own default. Muse can't turn reasoning off;
@@ -819,9 +823,12 @@ for (let round = 0; round < 8; round++) {
819
823
  `'tool_calls'` or `'length'`. `usage` carries `prompt_tokens`,
820
824
  `completion_tokens` and `total_tokens`.
821
825
  - `'refused'` — the player is not a Castle admin. The model was not called.
822
- - `'unavailable'` — this host has no route to the oracle.
826
+ - `'allowance_exhausted'` — the player's play allowance for the day is used
827
+ up. The model was not called. It resets at midnight UTC.
828
+ - `'unavailable'` — this host has no route to the deck-agent service, or
829
+ the service is down.
823
830
  - `'cancelled'` — the call's `signal` was aborted.
824
- - `'error'` — the oracle or the model failed; `reason` says how.
831
+ - `'error'` — the service or the model failed; `reason` says how.
825
832
 
826
833
  Every status but `'ok'` carries a `reason`.
827
834
 
package/dist/agent.js CHANGED
@@ -1,12 +1,15 @@
1
- // Agent — one chat completion from a language model, run by the host through
2
- // Castle's oracle with the player's own Castle account. Messages and tools
3
- // follow the OpenAI chat completions format. The reply streams: `onDelta` gets
4
- // text and reasoning as they arrive and each tool call once its arguments are
5
- // complete, and the promise resolves with the whole message. A deck runs any
6
- // tool calls itself and calls Agent.chat again with the results.
1
+ // Agent — one chat completion from a language model, run through Castle's
2
+ // deck-agent service. Castle funds each player's calls from a daily play
3
+ // allowance that characters share. Messages and tools follow the OpenAI chat
4
+ // completions format. The reply streams: `onDelta` gets text and reasoning as
5
+ // they arrive and each tool call once its arguments are complete, and the
6
+ // promise resolves with the whole message. A deck runs any tool calls itself
7
+ // and calls Agent.chat again with the results.
7
8
  //
8
9
  // Agent.chat is limited to Castle admins for now: every other player gets
9
- // `refused`. A host with no route to the oracle answers `unavailable`.
10
+ // `refused`. A player whose allowance for the day is spent gets
11
+ // `allowance_exhausted`. A host with no route to the service answers
12
+ // `unavailable`.
10
13
  import { CastleError } from "./errors";
11
14
  import { hostRequest } from "./transport";
12
15
  async function chat(params) {
@@ -255,7 +255,7 @@ export type AgentChatResult = {
255
255
  finishReason: string | null;
256
256
  usage?: AgentUsage;
257
257
  } | {
258
- status: "unavailable" | "refused" | "error" | "cancelled";
258
+ status: "unavailable" | "refused" | "allowance_exhausted" | "error" | "cancelled";
259
259
  reason: string;
260
260
  };
261
261
  export interface DeckSummary {
package/dist/commands.js CHANGED
@@ -15,7 +15,7 @@ export const COMMAND_TIMEOUTS_MS = {
15
15
  "decks.saved": 30_000,
16
16
  };
17
17
  // Once a host streams a command, each stream envelope restarts the wait at this
18
- // length instead. The oracle sends a heartbeat every 15 seconds, and the host
18
+ // length instead. The deck-agent service sends a heartbeat every 15 seconds, and the host
19
19
  // passes each one on.
20
20
  export const STREAM_IDLE_TIMEOUT_MS = 60_000;
21
21
  export function isResponseEnvelope(value) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "castle-web-sdk",
3
- "version": "0.4.40",
3
+ "version": "0.4.41",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/castle-xyz/castle-experimental-web.git"