agent-afk 5.38.7 → 5.40.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,11 @@
1
+ export declare const DEFAULT_MODEL_TTFB_TIMEOUT_MS = 180000;
2
+ export declare function resolveTtfbTimeoutMs(): number;
3
+ export declare const TTFB_TIMEOUT_MESSAGE = "model_ttfb_timeout";
4
+ export declare function isTtfbTimeoutError(err: unknown): boolean;
5
+ export interface FirstByteTimeoutHandle {
6
+ readonly signal: AbortSignal;
7
+ timedOut(): boolean;
8
+ firstByteSeen(): void;
9
+ dispose(): void;
10
+ }
11
+ export declare function armFirstByteTimeout(baseSignal: AbortSignal, timeoutMs: number): FirstByteTimeoutHandle;
@@ -0,0 +1,87 @@
1
+ import type { AgentModelInput } from '../types.js';
2
+ export type SessionSurface = 'cli' | 'telegram' | 'daemon';
3
+ export type SessionStatus = 'active' | 'archived';
4
+ export type HandleId = string & {
5
+ readonly __brand: 'HandleId';
6
+ };
7
+ export declare function asHandleId(id: string): HandleId;
8
+ export interface BindingRef {
9
+ surface: SessionSurface;
10
+ key: string;
11
+ }
12
+ export interface SessionBinding extends BindingRef {
13
+ boundAt: number;
14
+ lastActiveAt: number;
15
+ }
16
+ export interface SessionHandle {
17
+ id: HandleId;
18
+ sdkSessionId?: string;
19
+ surface: SessionSurface;
20
+ name?: string;
21
+ model: AgentModelInput;
22
+ cwd?: string;
23
+ createdAt: number;
24
+ lastActiveAt: number;
25
+ status: SessionStatus;
26
+ bindings: SessionBinding[];
27
+ }
28
+ export interface CreateSessionOptions {
29
+ surface: SessionSurface;
30
+ model: AgentModelInput;
31
+ key: string;
32
+ cwd?: string;
33
+ name?: string;
34
+ sdkSessionId?: string;
35
+ id?: HandleId;
36
+ createdAt?: number;
37
+ }
38
+ export interface ListFilter {
39
+ surface?: SessionSurface;
40
+ status?: SessionStatus;
41
+ }
42
+ export interface SessionRegistry {
43
+ create(opts: CreateSessionOptions): SessionHandle;
44
+ load(handle: SessionHandle): void;
45
+ get(id: HandleId): SessionHandle | undefined;
46
+ getBySdkSessionId(sdkSessionId: string): SessionHandle | undefined;
47
+ resolve(surface: SessionSurface, key: string): SessionHandle | undefined;
48
+ bind(id: HandleId, ref: BindingRef): void;
49
+ unbind(surface: SessionSurface, key: string): void;
50
+ attachSdkSessionId(id: HandleId, sdkSessionId: string): void;
51
+ rename(id: HandleId, name: string): void;
52
+ touch(id: HandleId): void;
53
+ archive(id: HandleId): void;
54
+ list(filter?: ListFilter): SessionHandle[];
55
+ }
56
+ export declare class SessionRegistryError extends Error {
57
+ constructor(message: string);
58
+ }
59
+ export declare class InMemorySessionRegistry implements SessionRegistry {
60
+ private readonly byId;
61
+ private readonly byBinding;
62
+ private readonly bySdk;
63
+ private readonly now;
64
+ constructor(opts?: {
65
+ now?: () => number;
66
+ });
67
+ create(opts: CreateSessionOptions): SessionHandle;
68
+ load(handle: SessionHandle): void;
69
+ get(id: HandleId): SessionHandle | undefined;
70
+ getBySdkSessionId(sdkSessionId: string): SessionHandle | undefined;
71
+ resolve(surface: SessionSurface, key: string): SessionHandle | undefined;
72
+ bind(id: HandleId, ref: BindingRef): void;
73
+ unbind(surface: SessionSurface, key: string): void;
74
+ attachSdkSessionId(id: HandleId, sdkSessionId: string): void;
75
+ rename(id: HandleId, name: string): void;
76
+ touch(id: HandleId): void;
77
+ archive(id: HandleId): void;
78
+ list(filter?: ListFilter): SessionHandle[];
79
+ private bindingKey;
80
+ private require;
81
+ private pointBinding;
82
+ private clone;
83
+ }
84
+ export declare function createSessionRegistry(opts?: {
85
+ now?: () => number;
86
+ }): SessionRegistry;
87
+ export declare const sessionRegistry: SessionRegistry;
@@ -1,6 +1,7 @@
1
1
  import type { SessionStats, TurnRecord } from './slash/types.js';
2
2
  import type { AgentModelInput } from '../agent/types.js';
3
3
  import type { TraceActor } from '../agent/session/session-identity.js';
4
+ import { type SessionBinding, type SessionHandle } from '../agent/session/session-registry.js';
4
5
  export interface StoredSession {
5
6
  sessionId?: string;
6
7
  name?: string;
@@ -18,6 +19,8 @@ export interface StoredSession {
18
19
  forkedAt?: number;
19
20
  actor?: TraceActor;
20
21
  cwd?: string;
22
+ handleId?: string;
23
+ bindings?: SessionBinding[];
21
24
  }
22
25
  export interface SessionListEntry {
23
26
  path: string;
@@ -26,6 +29,7 @@ export interface SessionListEntry {
26
29
  name?: string;
27
30
  source?: 'cli' | 'telegram' | 'daemon';
28
31
  actor?: TraceActor;
32
+ telegramChatId?: number;
29
33
  model: AgentModelInput;
30
34
  startedAt: number;
31
35
  savedAt: number;
@@ -49,3 +53,6 @@ export declare function loadSession(idOrPath: string): StoredSession | undefined
49
53
  export declare function findSession(idOrName: string): FoundSession | undefined;
50
54
  export declare function listSessions(): SessionListEntry[];
51
55
  export declare function sdkSessionIdFor(idOrName: string): string | undefined;
56
+ export declare function bindingsForStored(stored: StoredSession): SessionBinding[];
57
+ export declare function storedToHandle(stored: StoredSession, sidecarId: string): SessionHandle;
58
+ export declare function storedFieldsFromHandle(handle: SessionHandle): Pick<StoredSession, 'handleId' | 'bindings'>;