@byok-sdk/cloud 0.18.0 → 0.20.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.
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Durable remote input-preparation facts.
3
+ *
4
+ * Exactly the composition `agent-home-projections.ts` uses, for exactly the
5
+ * same reason: the desired request and the terminal completion are two
6
+ * IMMUTABLE first-write-wins receipts in the tenant-scoped receipt store, so
7
+ * this module needs no second mutable authority merely to survive a restart,
8
+ * and a replayed write is decided by comparing bodies rather than by trusting
9
+ * whichever writer arrived last.
10
+ *
11
+ * The one idempotency key is `(deviceId, agentRef, requestId)`, minted by the
12
+ * Host and carried unchanged through the cloud receipt, the device's durable
13
+ * namespace and the completion. A Host that times out therefore RE-READS
14
+ * status; it never mints a second requestId for the same turn, which is what
15
+ * keeps a duplicate from becoming a second counter call downstream.
16
+ */
17
+ import { type AgentInputPreparationPayload, type InputPreparationCompletionRequest, type InputPreparationReadback } from '@byok-sdk/protocol';
18
+ import type { TenantId } from '@byok-sdk/core';
19
+ import type { TenantBoundReceipts } from './tenant-stores';
20
+ /** Exact request identity a host must echo to read back durable preparation status. */
21
+ export interface InputPreparationReceiptInput {
22
+ readonly requestId: string;
23
+ readonly agentRef: AgentInputPreparationPayload['agentRef'];
24
+ }
25
+ export declare function inputPreparationRequestKey(deviceId: string, agentRef: AgentInputPreparationPayload['agentRef'], requestId: string): string;
26
+ export declare function inputPreparationCompletionKey(deviceId: string, agentRef: AgentInputPreparationPayload['agentRef'], requestId: string): string;
27
+ /**
28
+ * Whole-body equality, not a field subset.
29
+ *
30
+ * The desired fact is the ENTIRE authorized request — source digest, model
31
+ * selection, deadline, context and required toolsets alike. Comparing only the
32
+ * identity fields would let the same requestId silently re-bind to a different
33
+ * model, a different context or a looser deadline, which is precisely the
34
+ * substitution the immutable receipt exists to prevent. Both sides are already
35
+ * schema-parsed, so key order is the only degree of freedom left, and the
36
+ * stored body is re-serialized from a parse for that reason.
37
+ */
38
+ export declare function sameInputPreparationRequest(expected: AgentInputPreparationPayload, actual: AgentInputPreparationPayload): boolean;
39
+ export declare function receiptMatchesInputPreparation(request: AgentInputPreparationPayload, receipt: InputPreparationCompletionRequest): boolean;
40
+ export declare function statusInputMatchesInputPreparation(request: AgentInputPreparationPayload, input: InputPreparationReceiptInput): boolean;
41
+ export declare function readInputPreparationStatus(receipts: TenantBoundReceipts, tenant: TenantId, deviceId: string, input: InputPreparationReceiptInput): Promise<InputPreparationReadback | undefined>;
42
+ export declare function recordInputPreparationCompletion(receipts: TenantBoundReceipts, tenant: TenantId, deviceId: string, receiptInput: InputPreparationCompletionRequest): Promise<InputPreparationReadback>;
@@ -1,4 +1,4 @@
1
- import { type AgentRef, type BlobRef, type Envelope, type TerminalInferenceUsage, type TaskFailPayload } from '@byok-sdk/protocol';
1
+ import { type AgentRef, type BlobRef, type Envelope, type TerminalInferenceUsage, type TerminalPreparedObservation, type TaskFailPayload } from '@byok-sdk/protocol';
2
2
  import type { RequestReceipt } from './stores/ports';
3
3
  /** Canonical device evidence, independent of the Host cancellation projection. */
4
4
  export interface DeviceTerminal {
@@ -39,6 +39,14 @@ export interface TerminalResult {
39
39
  * or entitlement authority.
40
40
  */
41
41
  readonly usage?: TerminalInferenceUsage;
42
+ /**
43
+ * The prepared-only observation copied verbatim from a prepared Execution's
44
+ * winning `task.complete` / `task.fail`: the frozen request digest, the
45
+ * first provider call's prompt tokens and the largest. Unlike `usage` it is
46
+ * evidence the Host checks its own budget ruling against; the cloud performs
47
+ * no arithmetic over it.
48
+ */
49
+ readonly preparedObservation?: TerminalPreparedObservation;
42
50
  readonly reason?: string;
43
51
  /** Terminal cause projection; currently the protocol's terminal reason. */
44
52
  readonly terminalCause?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@byok-sdk/cloud",
3
- "version": "0.18.0",
3
+ "version": "0.20.0",
4
4
  "description": "BYOK SDK hosted device surface: stateless frozen-v1 HTTP handlers over tenant-first @byok-sdk/core ports",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -44,8 +44,8 @@
44
44
  "clean": "rm -rf dist"
45
45
  },
46
46
  "dependencies": {
47
- "@byok-sdk/core": "0.18.0",
48
- "@byok-sdk/protocol": "0.18.0",
47
+ "@byok-sdk/core": "0.20.0",
48
+ "@byok-sdk/protocol": "0.20.0",
49
49
  "hono": "^4.12.30",
50
50
  "zod": "^4.4.3"
51
51
  }