@theoremjs/agents 0.3.4-next.604.ge4d5866 → 0.3.4-next.608.gd007c52

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.
@@ -11,8 +11,9 @@ export interface RunSessionOptions extends ProviderHostOptions {
11
11
  /** The host's keys by slot; the session uses the slots its profile names. */
12
12
  vault?: KeyVault;
13
13
  /**
14
- * Milliseconds a gated call waits for its decision (default 30 minutes). A later decision is
15
- * refused (`session.gate_expired`), and the model reads the call as abandoned.
14
+ * Milliseconds a gated call waits for its decision. A later decision is refused
15
+ * (`session.gate_expired`), and the model reads the call as abandoned. Unset, the call waits
16
+ * until it is decided or the session closes.
16
17
  */
17
18
  gateTtlMs?: number;
18
19
  /**
@@ -437,8 +437,8 @@ function buildLiveSession(args) {
437
437
  };
438
438
  /**
439
439
  * A call that ran into `gate`. A sign-in gate this session answers at once tells the model its
440
- * pending note and releases the call; a call already released stays released. Either waits
441
- * `gateTtlMs` for its outcome. False: the call is not released, and the caller holds it.
440
+ * pending note and releases the call; a call already released stays released. Either waits for
441
+ * its outcome, for `gateTtlMs` when it is set. False: the call is not released, and the caller holds it.
442
442
  */
443
443
  const releaseGated = (callId, held, wasReleased, gate, readBack) => {
444
444
  const answersNow = signInGate === 'answer' && gate.kind === 'auth' && readBack !== undefined;
@@ -448,7 +448,10 @@ function buildLiveSession(args) {
448
448
  answerModel(callId, held, readBack);
449
449
  clearTimeout(held.lapse);
450
450
  held.state = { gate, createdAt: Date.now(), released: true };
451
- held.lapse = setTimeout(() => lapseReleased(callId, held), gateTtlMs);
451
+ held.lapse =
452
+ gateTtlMs === undefined
453
+ ? undefined
454
+ : setTimeout(() => lapseReleased(callId, held), gateTtlMs);
452
455
  return true;
453
456
  };
454
457
  /**
@@ -4,10 +4,13 @@ import type { ToolAuthChallenge } from '../turn-events.js';
4
4
  import type { InvokeToolResume, PageAnswer } from './types.js';
5
5
  /** What a sign-in gate asks for, minus the challenge's OAuth details. */
6
6
  export type ToolGateAuth = Pick<ToolAuthChallenge, 'slot' | 'authType' | 'service'>;
7
- /** A bad value is refused when `owner` is built, not when a gate expires. */
8
- export declare function resolveGateTtlMs(owner: string, gateTtlMs: number | undefined): number;
9
- /** True when the gate has waited as long as its time limit. */
10
- export declare function gateExpired(createdAt: number, now: number, ttlMs: number): boolean;
7
+ /**
8
+ * A bad value is refused when `owner` is built, not when a gate expires. Unset, a gate waits until
9
+ * it is answered.
10
+ */
11
+ export declare function resolveGateTtlMs(owner: string, gateTtlMs: number | undefined): number | undefined;
12
+ /** True when the gate has waited as long as its time limit. With no limit, never. */
13
+ export declare function gateExpired(createdAt: number, now: number, ttlMs: number | undefined): boolean;
11
14
  /** How a user can answer a tool gate: approve it, deny it, or walk away. */
12
15
  export declare const GATE_DECISIONS: readonly ["approve", "deny", "abandon"];
13
16
  /** One of {@linkcode GATE_DECISIONS}. */
@@ -1,17 +1,20 @@
1
1
  import { TheoremError } from '../../guardrails/error.js';
2
2
  import { credentialForSignInGate } from '../auth/typed-secret.js';
3
- const DEFAULT_GATE_TTL_MS = 30 * 60 * 1000;
4
- /** A bad value is refused when `owner` is built, not when a gate expires. */
3
+ /**
4
+ * A bad value is refused when `owner` is built, not when a gate expires. Unset, a gate waits until
5
+ * it is answered.
6
+ */
5
7
  export function resolveGateTtlMs(owner, gateTtlMs) {
6
- const ttl = gateTtlMs ?? DEFAULT_GATE_TTL_MS;
7
- if (!Number.isFinite(ttl) || ttl <= 0) {
8
- throw new TheoremError('config', `${owner} gateTtlMs must be a positive number of milliseconds; got ${ttl}.`);
8
+ if (gateTtlMs === undefined)
9
+ return undefined;
10
+ if (!Number.isFinite(gateTtlMs) || gateTtlMs <= 0) {
11
+ throw new TheoremError('config', `${owner} gateTtlMs must be a positive number of milliseconds; got ${gateTtlMs}.`);
9
12
  }
10
- return ttl;
13
+ return gateTtlMs;
11
14
  }
12
- /** True when the gate has waited as long as its time limit. */
15
+ /** True when the gate has waited as long as its time limit. With no limit, never. */
13
16
  export function gateExpired(createdAt, now, ttlMs) {
14
- return now - createdAt >= ttlMs;
17
+ return ttlMs !== undefined && now - createdAt >= ttlMs;
15
18
  }
16
19
  /** How a user can answer a tool gate: approve it, deny it, or walk away. */
17
20
  export const GATE_DECISIONS = ['approve', 'deny', 'abandon'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theoremjs/agents",
3
- "version": "0.3.4-next.604.ge4d5866",
3
+ "version": "0.3.4-next.608.gd007c52",
4
4
  "description": "A flat TypeScript agent kernel for typed profiles, deterministic turn execution, registered tools, provider adapters, guardrails, and host-injected traces.",
5
5
  "keywords": [
6
6
  "agent",