@inixiative/agent-session 0.11.0 → 0.11.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inixiative/agent-session",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "description": "Drive coding-agent CLIs as persistent, streaming, event-captured sessions over interchangeable transports, with primed decision sessions, subscription pools, routing, limit polling and continuity.",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "devDependencies": {
43
43
  "@biomejs/biome": "2.5.2",
44
- "@inixiative/config": "^0.5.185",
44
+ "@inixiative/config": "^0.5.186",
45
45
  "@types/bun": "1.4.4",
46
46
  "lefthook": "2.1.9",
47
47
  "typescript": "6.0.3"
@@ -187,7 +187,7 @@ function bridge(
187
187
  const awaiting = new Map<string, (response: unknown) => void>();
188
188
  const ask = (request: Record<string, unknown>, signal?: AbortSignal) =>
189
189
  new Promise<unknown>((resolve) => {
190
- const id = `sdk-bridge-${crypto.randomUUID()}`;
190
+ const id = `sdk-bridge-${Bun.randomUUIDv7()}`;
191
191
  awaiting.set(id, resolve);
192
192
  signal?.addEventListener(
193
193
  'abort',
@@ -379,7 +379,7 @@ export class ClaudeCodeSession implements HarnessSession {
379
379
  private _steerAcks = new Map<string, (state: SteerState) => void>();
380
380
  /** Steers written and not yet ended natively: a late `completed` after their turn settled is theirs. */
381
381
  private _steerUuids = new Set<string>();
382
- private readonly _hookCallbackId = `agent-session-pre-tool-${crypto.randomUUID()}`;
382
+ private readonly _hookCallbackId = `agent-session-pre-tool-${Bun.randomUUIDv7()}`;
383
383
  private _limits?: LimitSnapshot;
384
384
  private _controlSeq = 0;
385
385
  private _control = new Map<
@@ -555,7 +555,7 @@ export class ClaudeCodeSession implements HarnessSession {
555
555
  if (!turn || !a || a.dispatch !== 'attempted' || a.nativeOutcome !== 'unknown')
556
556
  return ignored('no owned in-flight turn');
557
557
  if (!this._proc || !this._alive) return ignored('session not running');
558
- const uuid = crypto.randomUUID();
558
+ const uuid = Bun.randomUUIDv7();
559
559
  turn.steers ??= new Map();
560
560
  const steers = turn.steers;
561
561
  steers.set(uuid, 'written');
@@ -999,7 +999,7 @@ export class ClaudeCodeSession implements HarnessSession {
999
999
  timeoutMs: number,
1000
1000
  ): Promise<Record<string, unknown>> {
1001
1001
  if (!this._proc || !this._alive) return Promise.reject(new Error('Session not running'));
1002
- const requestId = `agent-session-${++this._controlSeq}-${crypto.randomUUID()}`;
1002
+ const requestId = `agent-session-${++this._controlSeq}-${Bun.randomUUIDv7()}`;
1003
1003
  return new Promise((resolve, reject) => {
1004
1004
  const timer = setTimeout(() => {
1005
1005
  this._control.delete(requestId);
@@ -1068,7 +1068,7 @@ export class ClaudeInSessionDecisions implements PrimedSessions, ClaudeSessionEx
1068
1068
  }
1069
1069
 
1070
1070
  private async _admit(member: Member): Promise<boolean> {
1071
- member.admissionId ??= crypto.randomUUID();
1071
+ member.admissionId ??= Bun.randomUUIDv7();
1072
1072
  if (member.admitted) return true;
1073
1073
  try {
1074
1074
  await Promise.race([
@@ -472,7 +472,7 @@ export class ClaudeSubagentSessions implements PrimedSessions {
472
472
 
473
473
  /** Admit a decision onto its spare; the input goes out when the spare's moment call is held. */
474
474
  private async _reserve(spare: Spare, member: Member): Promise<void> {
475
- member.admissionId = crypto.randomUUID();
475
+ member.admissionId = Bun.randomUUIDv7();
476
476
  const ours = () => spare.member === member && member.spare === spare;
477
477
  try {
478
478
  await Promise.race([
@@ -789,7 +789,7 @@ export class ClaudeSubagentSessions implements PrimedSessions {
789
789
  return;
790
790
  }
791
791
  const spares = [...side.spares.values()];
792
- const uuid = crypto.randomUUID();
792
+ const uuid = Bun.randomUUIDv7();
793
793
  const turnEnded = new Promise<void>((resolve) => {
794
794
  side.onResult = resolve;
795
795
  });
@@ -1041,7 +1041,7 @@ export class ClaudeSubagentSessions implements PrimedSessions {
1041
1041
  }
1042
1042
 
1043
1043
  private _control(side: Side, request: Record<string, unknown>, timeoutMs = 30_000) {
1044
- const id = `c-${crypto.randomUUID()}`;
1044
+ const id = `c-${Bun.randomUUIDv7()}`;
1045
1045
  return new Promise<Record<string, unknown>>((resolve, reject) => {
1046
1046
  const timer = setTimeout(() => {
1047
1047
  side.control.delete(id);
@@ -1417,7 +1417,7 @@ export class ClaudeSubagentSessions implements PrimedSessions {
1417
1417
  await Promise.all(
1418
1418
  chunk.map(async (m) => {
1419
1419
  if (m.settled) return;
1420
- m.admissionId ??= crypto.randomUUID();
1420
+ m.admissionId ??= Bun.randomUUIDv7();
1421
1421
  try {
1422
1422
  if (!retry && !m.admitted)
1423
1423
  await Promise.race([
@@ -1463,7 +1463,7 @@ export class ClaudeSubagentSessions implements PrimedSessions {
1463
1463
  m.token = `m${i + 1}`;
1464
1464
  });
1465
1465
  side.members = new Map(admitted.map((m) => [m.token, m]));
1466
- const uuid = crypto.randomUUID();
1466
+ const uuid = Bun.randomUUIDv7();
1467
1467
  const turnEnded = new Promise<void>((resolve) => {
1468
1468
  side.onResult = resolve;
1469
1469
  });
@@ -1335,7 +1335,7 @@ export class CodexPrimedSessions implements PrimedSessions {
1335
1335
  if (session) session.model ??= model;
1336
1336
  const branchMs = Math.round(performance.now() - t1);
1337
1337
  let branch = opened.branch;
1338
- admissionId = crypto.randomUUID();
1338
+ admissionId = Bun.randomUUIDv7();
1339
1339
  try {
1340
1340
  await request.onAdmission?.({ admissionId, key: spec.key, runtime: 'codex', threadId });
1341
1341
  } catch (cause) {
package/src/pool.ts CHANGED
@@ -584,7 +584,7 @@ export class SubscriptionPool {
584
584
  utilizationPercent: number | null,
585
585
  rank: number,
586
586
  ): Lease {
587
- const leaseId = crypto.randomUUID();
587
+ const leaseId = Bun.randomUUIDv7();
588
588
  state.leases.add(leaseId);
589
589
  let released = false;
590
590
  const lease: Lease = {
package/src/turn-state.ts CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  import { retainEvidence } from './retained-evidence';
10
10
  /** Per-admission evidence. Caller settlement never transfers native ownership. */
11
11
  export class TurnState {
12
- readonly admissionId = crypto.randomUUID();
12
+ readonly admissionId = Bun.randomUUIDv7();
13
13
  identity: SessionIdentity = {};
14
14
  nativeOutcome: SessionAttempt['nativeOutcome'] = 'unknown';
15
15
  localOutcome: SessionAttempt['localOutcome'] = 'pending';