@byok-sdk/client 0.8.0-beta.0 → 0.8.1

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
@@ -108,6 +108,14 @@ createDaemon({
108
108
  });
109
109
  ```
110
110
 
111
+ For task-free desired-state projection, use
112
+ `createAgentHomeProjectionConsumer`. Its hook must atomically and idempotently
113
+ ensure its opaque product bytes. BYOK may invoke it again under the same
114
+ canonical-home writer lease when a new request carries the exact current
115
+ revision/hash; the terminal outcome remains `idempotent`. This permits repair
116
+ of locally lost derived files without giving the SDK product path or schema
117
+ knowledge. Stale and same-revision/different-hash requests do not invoke it.
118
+
111
119
  Startup materializes and write-probes the canonical root before publishing
112
120
  `agent-home-contract`. `agentHome` and `gitWorkspace` are mutually exclusive;
113
121
  strict Agent execution has one workspace authority and never falls back to a
@@ -131,6 +139,13 @@ keeps runtime activity metadata/status-only; enabling it is an explicit product
131
139
  decision and requires the server capability. Reliable events are fsynced under
132
140
  the canonical Agent home and retire only after an exact ack.
133
141
 
142
+ Hosts that need cold setup or diagnostic state use
143
+ `readDeviceEnrollmentStatus({ productId, storeDir })`. It validates the
144
+ complete SDK-owned record but returns only `unpaired`, `paired` with
145
+ `deviceId`, or `re_pair_required`; tenant, token, expiry and device keys are
146
+ never projected. Only explicit pairing may replace `re_pair_required` state,
147
+ while filesystem-safety failures remain errors.
148
+
134
149
  ```ts
135
150
  createDaemon({
136
151
  // ...normal device, transport and agentHome configuration
@@ -1,7 +1,8 @@
1
- import { type AgentRef } from '@byok-sdk/protocol';
1
+ import { type AgentHomeProjectionOutcome, type AgentHomeProjectionPayload, type AgentRef } from '@byok-sdk/protocol';
2
2
  export type { AgentRef } from '@byok-sdk/protocol';
3
3
  export declare const AGENT_HOME_DIRECTORY = "agents";
4
4
  export declare const AGENT_HOME_INTERNAL_DIRECTORY = ".byok";
5
+ export declare const AGENT_HOME_PROJECTION_STATE_FILE = "agent-home-projection.json";
5
6
  export declare class AgentHomeError extends Error {
6
7
  constructor(message: string);
7
8
  }
@@ -34,15 +35,28 @@ export interface AgentHomeResolution {
34
35
  export interface AgentHomeProjectionInput extends AgentHomeResolution {
35
36
  readonly cwd: string;
36
37
  }
38
+ export interface AgentHomeProjectionApplyInput extends AgentHomeProjectionInput {
39
+ readonly requestId: string;
40
+ readonly projectionHash: string;
41
+ readonly projection: unknown;
42
+ }
37
43
  /**
38
44
  * Optional downstream projection hook. The SDK supplies the canonical home;
39
45
  * the host supplies opaque, redacted product content and never joins
40
46
  * `agents/<agentId>` itself. The SDK does not parse the projected content.
41
47
  */
42
48
  export interface AgentHomeProjection {
43
- prepare(input: AgentHomeProjectionInput): void | Promise<void>;
49
+ /** Optional creation/task-time host preparation retained as a distinct lifecycle. */
50
+ prepare?(input: AgentHomeProjectionInput): void | Promise<void>;
51
+ /**
52
+ * Task-free opaque desired-state consumer. It must atomically and
53
+ * idempotently ensure its own durable bytes because exact revision/hash
54
+ * requests may replay after local derived-file loss or transport failure.
55
+ */
56
+ apply?(input: AgentHomeProjectionApplyInput): void | Promise<void>;
44
57
  }
45
58
  export type AgentHomeProjectionFunction = (input: AgentHomeProjectionInput) => void | Promise<void>;
59
+ export type AgentHomeProjectionApplyFunction = (input: AgentHomeProjectionApplyInput) => void | Promise<void>;
46
60
  export interface AgentHomeLease {
47
61
  readonly leaseId: string;
48
62
  readonly agentRef: AgentRef;
@@ -72,7 +86,15 @@ export declare class AgentHomeLayout {
72
86
  * file is created by this preflight.
73
87
  */
74
88
  preflight(): Promise<void>;
89
+ /**
90
+ * Construction-time validation is deliberately non-mutating. The actual
91
+ * writable preflight runs asynchronously after daemon ownership is acquired
92
+ * and before transport/capability publication, where it can participate in
93
+ * the cross-process relocation gate without a sync shadow lock.
94
+ */
95
+ preflightSync(): void;
75
96
  private resolveRoot;
97
+ private acquireRootMutationGate;
76
98
  }
77
99
  export declare function stableAgentHomeOwnerId(storeDir: string, productId: string): string;
78
100
  /** One-writer lease backed by both a process registry and an exclusive marker. */
@@ -98,9 +120,26 @@ export declare class AgentHomeManager {
98
120
  prepare(agentRef: AgentRef): Promise<AgentHomeBinding>;
99
121
  /** Validate the configured root before capability publication. */
100
122
  preflight(): Promise<void>;
123
+ /** Synchronous construction-time preflight for strict Agent-only admission. */
124
+ preflightSync(): void;
101
125
  /** Resolve and lease without applying downstream projection side effects. */
102
126
  acquire(agentRef: AgentRef): Promise<AgentHomeBinding>;
103
127
  /** Initialize only after any requested session exact-match has succeeded. */
104
128
  initialize(binding: AgentHomeBinding): Promise<void>;
129
+ supportsTaskFreeProjection(): boolean;
130
+ /**
131
+ * Apply one task-free projection under the same canonical-home writer lease
132
+ * used by Agent execution. The host hook owns an atomic/idempotent ensure of
133
+ * its opaque product bytes, so an exact desired-state replay invokes it again
134
+ * before returning `idempotent`. Only a successful new-state hook followed
135
+ * by the SDK-owned fsynced ordering record can return `applied`.
136
+ */
137
+ project(input: AgentHomeProjectionPayload): Promise<AgentHomeProjectionOutcome>;
105
138
  }
106
139
  export declare function createAgentHomeProjection(prepare: AgentHomeProjectionFunction): AgentHomeProjection;
140
+ /**
141
+ * Create the task-free atomic/idempotent opaque desired-state consumer.
142
+ * Exact revision/hash delivery may invoke it again before an idempotent receipt;
143
+ * no task-time fallback is inferred.
144
+ */
145
+ export declare function createAgentHomeProjectionConsumer(apply: AgentHomeProjectionApplyFunction): AgentHomeProjection;