@byok-sdk/client 0.11.0 → 0.12.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.
package/README.md CHANGED
@@ -175,9 +175,21 @@ strict Agent execution has one workspace authority and never falls back to a
175
175
  task-scoped Git workspace.
176
176
 
177
177
  Successful startup with this configuration advertises `agent-home-contract`. Agent offers are distinct
178
- from legacy task offers and fail closed when identity, profile revision,
179
- session/runtime/cwd evidence, or the one-writer lease does not match. Agent
180
- files other than the SDK-reserved `.byok` namespace are opaque; there is no
178
+ from legacy task offers and fail closed when identity, profile revision, or
179
+ session/runtime/cwd evidence does not match. Within one daemon process,
180
+ execution leases are scoped to `(agentId, sessionRef)`: different sessions of
181
+ one Agent may run concurrently in the same canonical home, while the same
182
+ session remains serialized. Fresh
183
+ tasks bind their task-scoped admission lease to the runtime-created session
184
+ before the SDK exposes that session. Shared `.byok` metadata mutations use a
185
+ short per-home gate. Agent-memory hosted projection serializes the complete
186
+ close-time outbox transaction per home because its durable outbox is one CAS
187
+ authority; the publish wait remains timeout-bounded and does not serialize the
188
+ sessions' runtime execution. The process-owned home activity marker remains
189
+ held until the final active session exits so relocation stays fail-closed. A
190
+ second daemon process remains excluded by that marker; cross-process session
191
+ multiplexing is not provided. Agent files
192
+ other than the SDK-reserved `.byok` namespace are opaque; there is no
181
193
  required `artifacts/` directory and the client does not parse or index their
182
194
  contents.
183
195
 
@@ -73,6 +73,14 @@ export interface AgentHomeBinding {
73
73
  readonly resolution: AgentHomeResolution;
74
74
  readonly lease: AgentHomeLease;
75
75
  }
76
+ export interface AgentHomeExecutionLease extends AgentHomeLease {
77
+ /** Fresh tasks are task-keyed until the runtime returns its durable session id. */
78
+ bindSession(sessionRef: string): Promise<void>;
79
+ }
80
+ export interface AgentHomeExecutionBinding {
81
+ readonly resolution: AgentHomeResolution;
82
+ readonly lease: AgentHomeExecutionLease;
83
+ }
76
84
  export declare function validateAgentRef(value: unknown): AgentRef;
77
85
  /**
78
86
  * SDK-owned deterministic Agent-home layout. The downstream supplies exactly
@@ -112,11 +120,29 @@ export declare class AgentHomeLeaseManager {
112
120
  acquire(resolution: AgentHomeResolution): Promise<AgentHomeLease>;
113
121
  private openLeaseMarker;
114
122
  }
123
+ /**
124
+ * Session-scoped execution leases share one process-owned home marker. The
125
+ * marker remains until the final session exits, so relocation still sees the
126
+ * Agent home as active, while different sessions no longer exclude each other.
127
+ */
128
+ export declare class AgentHomeExecutionLeaseManager {
129
+ private readonly manager;
130
+ private static readonly groups;
131
+ private static readonly queues;
132
+ constructor(manager: AgentHomeLeaseManager);
133
+ acquire(resolution: AgentHomeResolution, input: {
134
+ readonly taskId: string;
135
+ readonly sessionRef?: string;
136
+ }): Promise<AgentHomeExecutionLease>;
137
+ mutate<T>(binding: AgentHomeExecutionBinding, operation: () => Promise<T>): Promise<T>;
138
+ private exclusive;
139
+ }
115
140
  /** Coordinates SDK-owned initialization, optional projection, and the lease. */
116
141
  export declare class AgentHomeManager {
117
142
  readonly layout: AgentHomeLayout;
118
143
  readonly projection?: AgentHomeProjection;
119
144
  readonly leaseManager: AgentHomeLeaseManager;
145
+ readonly executionLeaseManager: AgentHomeExecutionLeaseManager;
120
146
  constructor(options: {
121
147
  hostStorageRoot: string;
122
148
  projection?: AgentHomeProjection;
@@ -129,8 +155,15 @@ export declare class AgentHomeManager {
129
155
  preflightSync(): void;
130
156
  /** Resolve and lease without applying downstream projection side effects. */
131
157
  acquire(agentRef: AgentRef): Promise<AgentHomeBinding>;
158
+ acquireExecution(agentRef: AgentRef, input: {
159
+ readonly taskId: string;
160
+ readonly sessionRef?: string;
161
+ }): Promise<AgentHomeExecutionBinding>;
132
162
  /** Initialize only after any requested session exact-match has succeeded. */
133
163
  initialize(binding: AgentHomeBinding): Promise<void>;
164
+ initializeExecution(binding: AgentHomeExecutionBinding): Promise<void>;
165
+ mutateExecution<T>(binding: AgentHomeExecutionBinding, operation: () => Promise<T>): Promise<T>;
166
+ private initializeResolved;
134
167
  supportsTaskFreeProjection(): boolean;
135
168
  /**
136
169
  * Apply one task-free projection under the same canonical-home writer lease
@@ -1,4 +1,4 @@
1
- import { randomUUID, createHash } from 'crypto';
1
+ import { createHash, randomUUID } from 'crypto';
2
2
  import { constants, existsSync, promises } from 'fs';
3
3
  import path2 from 'path';
4
4
  import '@byok-sdk/protocol';
@@ -292,21 +292,24 @@ async function recordAuditWarning(context, kind, values) {
292
292
  }
293
293
  }
294
294
  var agentMemoryHomeQueues = /* @__PURE__ */ new Map();
295
- async function exclusiveAgentMemoryHome(home, fn) {
296
- const previous = agentMemoryHomeQueues.get(home) ?? Promise.resolve();
295
+ async function exclusiveAgentMemoryHomeQueue(queues, home, fn) {
296
+ const previous = queues.get(home) ?? Promise.resolve();
297
297
  let release;
298
298
  const next = new Promise((resolve) => {
299
299
  release = resolve;
300
300
  });
301
- agentMemoryHomeQueues.set(home, next);
301
+ queues.set(home, next);
302
302
  await previous;
303
303
  try {
304
304
  return await fn();
305
305
  } finally {
306
306
  release();
307
- if (agentMemoryHomeQueues.get(home) === next) agentMemoryHomeQueues.delete(home);
307
+ if (queues.get(home) === next) queues.delete(home);
308
308
  }
309
309
  }
310
+ async function exclusiveAgentMemoryHome(home, fn) {
311
+ return exclusiveAgentMemoryHomeQueue(agentMemoryHomeQueues, home, fn);
312
+ }
310
313
  var AgentMemoryService = class {
311
314
  constructor(input) {
312
315
  this.input = input;