castle-web-cli 0.4.202 → 0.4.203

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.
@@ -445,7 +445,10 @@ class DevSessionServerImpl {
445
445
  }
446
446
  async handleStorageRequest(reqId, op, args) {
447
447
  const deckId = readCastleJson(this.projectDir)?.deckId;
448
- const result = await runDevStorageOperation(deckId, op, args);
448
+ // Local serve has no host credential to stamp a remote player's authority. Its
449
+ // authenticated OPEN roster proves presence here; GraphQL separately restricts
450
+ // funded audience sends to the signed-in CLI user's own subject.
451
+ const result = await runDevStorageOperation(deckId, op, args, this.connectedPlayers().map((player) => player.userId));
449
452
  // The child may have restarted while this was out; its replacement never asked, so
450
453
  // there is nobody to tell.
451
454
  this.sendPlatform({
@@ -6,4 +6,4 @@ export interface DevStorageResult {
6
6
  message: string;
7
7
  };
8
8
  }
9
- export declare function runDevStorageOperation(deckId: string | undefined, op: string, args: Record<string, unknown>): Promise<DevStorageResult>;
9
+ export declare function runDevStorageOperation(deckId: string | undefined, op: string, args: Record<string, unknown>, connectedUserIds?: readonly string[]): Promise<DevStorageResult>;
@@ -5,6 +5,48 @@ const SCOPE_ARGS = `
5
5
  $subject: ID
6
6
  `;
7
7
  const OPERATIONS = {
8
+ characterSendWithAudience: {
9
+ field: 'cauldronCharacterSendWithAudience',
10
+ query: `mutation CastleDevCharacterSendWithAudience(
11
+ $deckId: ID!
12
+ $subject: ID!
13
+ $generation: Int!
14
+ $operationId: String!
15
+ $characterId: ID!
16
+ $input: String!
17
+ $audience: CauldronCharacterAudienceInput!
18
+ ) {
19
+ cauldronCharacterSendWithAudience(
20
+ deckId: $deckId
21
+ subject: $subject
22
+ generation: $generation
23
+ operationId: $operationId
24
+ characterId: $characterId
25
+ input: $input
26
+ audience: $audience
27
+ asServer: true
28
+ ) { operationId characterId status result archived }
29
+ }`,
30
+ },
31
+ characterEvaluateInformation: {
32
+ field: 'cauldronCharacterWorldCommand',
33
+ query: `mutation CastleDevCharacterEvaluateInformation(
34
+ $deckId: ID!
35
+ $subject: ID!
36
+ $generation: Int!
37
+ $operationId: String!
38
+ $command: Json!
39
+ ) {
40
+ cauldronCharacterWorldCommand(
41
+ deckId: $deckId
42
+ subject: $subject
43
+ generation: $generation
44
+ operationId: $operationId
45
+ command: $command
46
+ asServer: true
47
+ ) { operationId characterId status result archived }
48
+ }`,
49
+ },
8
50
  characterStatus: {
9
51
  field: 'cauldronCharacterStatus',
10
52
  query: `query CastleDevCharacterStatus($deckId: ID!, $subject: ID!, $generation: Int!, $operationId: String!) {
@@ -268,7 +310,7 @@ const OPERATIONS = {
268
310
  }`,
269
311
  },
270
312
  };
271
- export async function runDevStorageOperation(deckId, op, args) {
313
+ export async function runDevStorageOperation(deckId, op, args, connectedUserIds = []) {
272
314
  const operation = OPERATIONS[op];
273
315
  if (!operation) {
274
316
  return failure('CAULDRON_STORAGE_INVALID_ARGUMENT', `unknown storage operation ${op}`);
@@ -276,8 +318,26 @@ export async function runDevStorageOperation(deckId, op, args) {
276
318
  if (!deckId || deckId === 'dev') {
277
319
  return failure('CAULDRON_STORAGE_UNAVAILABLE', 'Storage needs a published deck. Run `castle-web save-deck` first, then restart serve.');
278
320
  }
321
+ if (op === 'characterSendWithAudience' &&
322
+ (typeof args.subject !== 'string' || !connectedUserIds.includes(args.subject))) {
323
+ return failure('CAULDRON_CHARACTER_UNAVAILABLE', 'the target player is not connected to this session');
324
+ }
279
325
  try {
280
- const response = await graphql(operation.query, { ...args, deckId });
326
+ const variables = op === 'characterEvaluateInformation'
327
+ ? {
328
+ deckId,
329
+ subject: args.subject,
330
+ generation: args.generation,
331
+ operationId: args.operationId,
332
+ command: {
333
+ type: 'evaluate_information',
334
+ ...(args.maxDeliveries === undefined
335
+ ? {}
336
+ : { maxDeliveries: args.maxDeliveries }),
337
+ },
338
+ }
339
+ : { ...args, deckId };
340
+ const response = await graphql(operation.query, variables);
281
341
  const error = response.errors?.[0];
282
342
  if (error) {
283
343
  const code = error.extensions?.code;
package/dist/init.js CHANGED
@@ -56,7 +56,7 @@ if (!(await mountEditorRoute())) startGame(initCard());
56
56
  // Registry version of castle-web-sdk to inject when scaffolding from a
57
57
  // globally-installed castle-web (not from inside the workspace). Bumped
58
58
  // alongside cli/sdk version bumps.
59
- const PUBLISHED_SDK_VERSION = '0.4.33';
59
+ const PUBLISHED_SDK_VERSION = '0.4.34';
60
60
  // Range, not a pin: `castle-web-fonts` is its own package precisely so a tenth
61
61
  // face can ship without a cli release, and a caret range means an existing
62
62
  // deck's next install picks it up. Nothing here has to move when it does.
@@ -82,7 +82,7 @@
82
82
  "title": "base",
83
83
  "deckId": "yRcmH4_aYllE",
84
84
  "cardId": "zkFdingmIm3m",
85
- "publishedVersion": "2026-09-23T05:44:46.889Z",
85
+ "publishedVersion": "2026-09-23T08:30:22.540Z",
86
86
  "provides": [
87
87
  "castle-web-sdk"
88
88
  ]
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "../../sdk": {
16
16
  "name": "castle-web-sdk",
17
- "version": "0.4.33",
17
+ "version": "0.4.34",
18
18
  "dev": true,
19
19
  "devDependencies": {
20
20
  "eslint": "^9.0.0",
@@ -102,17 +102,57 @@ export interface CompleteCharacterBeatInput {
102
102
  eventOccurrenceId: string;
103
103
  outcomeId: string;
104
104
  }
105
+ export interface EvaluateCharacterInformationInput {
106
+ operationId: string;
107
+ maxDeliveries?: number;
108
+ }
109
+ export interface CharacterInformationEvaluationResult {
110
+ generation: number;
111
+ evaluatedAt: string;
112
+ snapshotCandidateCount: number;
113
+ deliveries: Array<{
114
+ ruleId: string;
115
+ rootId: string;
116
+ recipientCharacterId: string;
117
+ status: "delivered" | "already_known";
118
+ }>;
119
+ cancelled: Array<{
120
+ ruleId: string;
121
+ rootId: string;
122
+ }>;
123
+ blocked: Array<{
124
+ ruleId: string;
125
+ rootId: string;
126
+ recipientCharacterId: string;
127
+ code: "testimony_backlog_full" | "information_limit" | "storage_capacity";
128
+ }>;
129
+ remainingCount: number;
130
+ }
131
+ export type CharacterInformationEvaluationOperation = Omit<CharacterOperation, "result"> & {
132
+ result: CharacterInformationEvaluationResult | null;
133
+ };
134
+ export interface SendCharacterInput {
135
+ operationId: string;
136
+ characterId: string;
137
+ input: string;
138
+ audience: {
139
+ listenerCharacterIds: string[];
140
+ };
141
+ }
105
142
  /**
106
143
  * Narrative commands do not run a model. They record creator-validated events,
107
144
  * knowledge delivery and beat completion inside this immutable playthrough.
108
145
  */
109
146
  export interface ServerPlaythroughCharacters {
147
+ /** Queues a funded turn whose admitted listeners are fixed at enqueue time. */
148
+ send(input: SendCharacterInput): Promise<CharacterOperation>;
110
149
  recordEvent(input: RecordCharacterEventInput): Promise<CharacterOperation>;
111
150
  setGameState(input: SetCharacterGameStateInput): Promise<CharacterOperation>;
112
151
  shareClaim(input: ShareCharacterClaimInput): Promise<CharacterOperation>;
113
152
  inspect(): Promise<Json>;
114
153
  deliverKnowledge(input: DeliverCharacterKnowledgeInput): Promise<CharacterOperation>;
115
154
  completeBeat(input: CompleteCharacterBeatInput): Promise<CharacterOperation>;
155
+ evaluateInformation(input: EvaluateCharacterInformationInput): Promise<CharacterInformationEvaluationOperation>;
116
156
  status(operationId: string): Promise<CharacterOperation>;
117
157
  history(options?: ServerCharacterHistoryOptions): Promise<CharacterHistory>;
118
158
  }
@@ -84,6 +84,17 @@ export function createServerStorage(platformHandle) {
84
84
  }
85
85
  function createPlaythrough(call, subject, generation) {
86
86
  const characters = Object.freeze({
87
+ async send(input) {
88
+ const characterId = assertNarrativeId(input?.characterId, "characterId");
89
+ return call("characterSendWithAudience", {
90
+ subject,
91
+ generation,
92
+ operationId: assertOperationId(input?.operationId),
93
+ characterId,
94
+ input: assertCharacterInput(input?.input),
95
+ audience: assertCharacterAudience(input?.audience, characterId),
96
+ });
97
+ },
87
98
  async recordEvent(input) {
88
99
  return call("characterRecordEvent", {
89
100
  subject,
@@ -139,6 +150,15 @@ function createPlaythrough(call, subject, generation) {
139
150
  outcomeId: assertNarrativeId(input?.outcomeId, "outcomeId"),
140
151
  });
141
152
  },
153
+ async evaluateInformation(input) {
154
+ const maxDeliveries = assertInformationMaxDeliveries(input?.maxDeliveries);
155
+ return call("characterEvaluateInformation", {
156
+ subject,
157
+ generation,
158
+ operationId: assertOperationId(input?.operationId),
159
+ ...(maxDeliveries === undefined ? {} : { maxDeliveries }),
160
+ });
161
+ },
142
162
  async status(operationId) {
143
163
  return call("characterStatus", {
144
164
  subject,
@@ -351,6 +371,33 @@ function assertNarrativeIds(value, field) {
351
371
  }
352
372
  return value.map((item) => assertNarrativeId(item, field));
353
373
  }
374
+ function assertCharacterInput(value) {
375
+ if (typeof value !== "string" ||
376
+ value.length === 0 ||
377
+ value.length > 2000 ||
378
+ value.includes("\0") ||
379
+ hasUnpairedSurrogate(value)) {
380
+ throw characterArgumentError("input must be valid non-empty text of at most 2000 characters.");
381
+ }
382
+ return value;
383
+ }
384
+ function assertCharacterAudience(value, targetCharacterId) {
385
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
386
+ throw characterArgumentError("audience must contain listenerCharacterIds.");
387
+ }
388
+ const audience = value;
389
+ if (Object.keys(audience).some((key) => key !== "listenerCharacterIds") ||
390
+ !Array.isArray(audience.listenerCharacterIds) ||
391
+ audience.listenerCharacterIds.length > 3) {
392
+ throw characterArgumentError("audience must contain at most three listener character ids.");
393
+ }
394
+ const listenerCharacterIds = audience.listenerCharacterIds.map((id) => assertNarrativeId(id, "audience.listenerCharacterIds"));
395
+ if (new Set(listenerCharacterIds).size !== listenerCharacterIds.length ||
396
+ listenerCharacterIds.includes(targetCharacterId)) {
397
+ throw characterArgumentError("audience listeners must be unique and must not include the target character.");
398
+ }
399
+ return { listenerCharacterIds };
400
+ }
354
401
  function assertKnowledgeSource(value) {
355
402
  if (!value || typeof value !== "object" || Array.isArray(value)) {
356
403
  throw storageError("CAULDRON_CHARACTER_INVALID_ARGUMENT", "source must name creator_event or a character.", "session.storage.playthrough.characters.deliverKnowledge");
@@ -402,6 +449,14 @@ function assertStateRevision(value) {
402
449
  }
403
450
  return value;
404
451
  }
452
+ function assertInformationMaxDeliveries(value) {
453
+ if (value === undefined)
454
+ return undefined;
455
+ if (!Number.isSafeInteger(value) || value < 1 || value > 32) {
456
+ throw characterArgumentError("maxDeliveries must be an integer from 1 through 32.");
457
+ }
458
+ return value;
459
+ }
405
460
  function assertStateChanges(value, hasObjectChanges = false) {
406
461
  if (!Array.isArray(value) || value.length > 32 || (!hasObjectChanges && value.length < 1)) {
407
462
  throw characterArgumentError(hasObjectChanges
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "castle-web-cli",
3
- "version": "0.4.202",
3
+ "version": "0.4.203",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/castle-xyz/castle-experimental-web.git"