@myagentroam/node 0.1.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.
Files changed (68) hide show
  1. package/README.md +17 -0
  2. package/dist/capabilities.d.ts +5 -0
  3. package/dist/capabilities.js +23 -0
  4. package/dist/capabilities.js.map +1 -0
  5. package/dist/claude-agent-sdk.d.ts +101 -0
  6. package/dist/claude-agent-sdk.js +341 -0
  7. package/dist/claude-agent-sdk.js.map +1 -0
  8. package/dist/claude-channel.d.ts +28 -0
  9. package/dist/claude-channel.js +45 -0
  10. package/dist/claude-channel.js.map +1 -0
  11. package/dist/codex-app-server.d.ts +96 -0
  12. package/dist/codex-app-server.js +361 -0
  13. package/dist/codex-app-server.js.map +1 -0
  14. package/dist/config.d.ts +17 -0
  15. package/dist/config.js +51 -0
  16. package/dist/config.js.map +1 -0
  17. package/dist/connector.d.ts +343 -0
  18. package/dist/connector.js +5525 -0
  19. package/dist/connector.js.map +1 -0
  20. package/dist/database.d.ts +282 -0
  21. package/dist/database.js +1347 -0
  22. package/dist/database.js.map +1 -0
  23. package/dist/event-buffer.d.ts +12 -0
  24. package/dist/event-buffer.js +29 -0
  25. package/dist/event-buffer.js.map +1 -0
  26. package/dist/fake-runner.d.ts +42 -0
  27. package/dist/fake-runner.js +130 -0
  28. package/dist/fake-runner.js.map +1 -0
  29. package/dist/health.d.ts +4 -0
  30. package/dist/health.js +4 -0
  31. package/dist/health.js.map +1 -0
  32. package/dist/main.d.ts +2 -0
  33. package/dist/main.js +47 -0
  34. package/dist/main.js.map +1 -0
  35. package/dist/native-session-history.d.ts +72 -0
  36. package/dist/native-session-history.js +647 -0
  37. package/dist/native-session-history.js.map +1 -0
  38. package/dist/operational.d.ts +30 -0
  39. package/dist/operational.js +82 -0
  40. package/dist/operational.js.map +1 -0
  41. package/dist/process-tree.d.ts +9 -0
  42. package/dist/process-tree.js +19 -0
  43. package/dist/process-tree.js.map +1 -0
  44. package/dist/runner-command-engine.d.ts +19 -0
  45. package/dist/runner-command-engine.js +47 -0
  46. package/dist/runner-command-engine.js.map +1 -0
  47. package/dist/runner-profiles.d.ts +11 -0
  48. package/dist/runner-profiles.js +138 -0
  49. package/dist/runner-profiles.js.map +1 -0
  50. package/dist/runner-usage.d.ts +33 -0
  51. package/dist/runner-usage.js +193 -0
  52. package/dist/runner-usage.js.map +1 -0
  53. package/dist/runtime-state.d.ts +174 -0
  54. package/dist/runtime-state.js +957 -0
  55. package/dist/runtime-state.js.map +1 -0
  56. package/dist/service.d.ts +4 -0
  57. package/dist/service.js +39 -0
  58. package/dist/service.js.map +1 -0
  59. package/dist/storage.d.ts +2 -0
  60. package/dist/storage.js +33 -0
  61. package/dist/storage.js.map +1 -0
  62. package/dist/terminal.d.ts +132 -0
  63. package/dist/terminal.js +417 -0
  64. package/dist/terminal.js.map +1 -0
  65. package/dist/workspace.d.ts +116 -0
  66. package/dist/workspace.js +732 -0
  67. package/dist/workspace.js.map +1 -0
  68. package/package.json +36 -0
@@ -0,0 +1,282 @@
1
+ import { DatabaseSync } from 'node:sqlite';
2
+ import { type AgentRunStatus, type RunnerDefaultConfiguration, type RunnerName } from '@myagentroam/protocol';
3
+ import type { NativeSessionHistory } from './native-session-history.js';
4
+ export type RunRecoveryState = 'ACTIVE' | 'SUSPECT' | 'LOST';
5
+ export type ApprovalStatus = 'PENDING' | 'APPROVED' | 'REJECTED' | 'EXPIRED';
6
+ /** Whether a native session ID was created by this Node or merely discovered. */
7
+ export type NativeSessionControl = 'MAR_MANAGED' | 'EXTERNAL';
8
+ export interface NodeWorkspace {
9
+ readonly id: string;
10
+ readonly path: string;
11
+ readonly kind: 'DIRECTORY' | 'GIT_WORKSPACE';
12
+ readonly gitSummary: unknown | null;
13
+ }
14
+ export interface NodeAgentSession {
15
+ readonly id: string;
16
+ readonly nodeId: string;
17
+ readonly workspaceId: string;
18
+ readonly runner: RunnerName;
19
+ readonly externalSessionId: string | null;
20
+ readonly nativeControl: NativeSessionControl;
21
+ readonly channelToken: string | null;
22
+ readonly cwd: string;
23
+ /** Runner preferences chosen when this managed session was created. */
24
+ readonly model: string | null;
25
+ readonly effort: string | null;
26
+ readonly access: string | null;
27
+ readonly customTitle: string | null;
28
+ readonly runnerTitle: string | null;
29
+ readonly pinnedAt: number | null;
30
+ readonly titleSource: 'AUTO' | 'RUNNER' | 'CUSTOM';
31
+ readonly lastActivityAt: number;
32
+ readonly createdAt: number;
33
+ }
34
+ export interface NativeSessionMetadata {
35
+ readonly customTitle: string | null;
36
+ readonly runnerTitle: string | null;
37
+ readonly runnerTitlePending: boolean;
38
+ readonly pinnedAt: number | null;
39
+ readonly model: string | null;
40
+ readonly effort: string | null;
41
+ readonly access: string | null;
42
+ }
43
+ export interface NodeAgentRun {
44
+ readonly id: string;
45
+ readonly sessionId: string;
46
+ readonly nodeId: string;
47
+ readonly workspaceId: string;
48
+ readonly runner: RunnerName;
49
+ readonly status: AgentRunStatus;
50
+ readonly recoveryState: RunRecoveryState;
51
+ readonly version: number;
52
+ readonly clientMessageId: string;
53
+ readonly createdAt: number;
54
+ readonly updatedAt: number;
55
+ }
56
+ export interface NodeRunEvent {
57
+ readonly id: number;
58
+ readonly runId: string;
59
+ readonly sequence: number;
60
+ readonly eventType: string;
61
+ readonly payload: unknown;
62
+ /** The authoritative lifecycle state carried by a Runner terminal event. */
63
+ readonly status?: AgentRunStatus;
64
+ readonly createdAt: number;
65
+ }
66
+ export interface WorkspaceActivityEvent {
67
+ readonly id: number;
68
+ readonly workspaceId: string;
69
+ readonly eventType: string;
70
+ readonly payload: unknown;
71
+ readonly createdAt: number;
72
+ }
73
+ export interface ConversationPage {
74
+ readonly turns: readonly NodeConversationTurn[];
75
+ readonly nextCursor: string | null;
76
+ }
77
+ export interface ConversationItemPage {
78
+ readonly items: readonly NodeConversationItem[];
79
+ readonly nextCursor: string | null;
80
+ }
81
+ /** Local structural projection; protocol validation remains at the boundary. */
82
+ export interface NodeConversationItem {
83
+ readonly id: string;
84
+ readonly sessionId: string;
85
+ readonly turnId: string;
86
+ readonly runId: string | null;
87
+ readonly parentItemId: string | null;
88
+ readonly sourceSequence: number | null;
89
+ readonly revision: number;
90
+ readonly kind: string;
91
+ readonly status: string;
92
+ readonly payload: unknown;
93
+ readonly startedAt: number | null;
94
+ readonly completedAt: number | null;
95
+ }
96
+ export interface NodeConversationTurn {
97
+ readonly id: string;
98
+ readonly sessionId: string;
99
+ readonly runId: string | null;
100
+ readonly userItemId: string | null;
101
+ readonly status: string;
102
+ readonly model: string | null;
103
+ readonly effort: string | null;
104
+ readonly access: string | null;
105
+ readonly items: readonly NodeConversationItem[];
106
+ readonly startedAt: number | null;
107
+ readonly completedAt: number | null;
108
+ }
109
+ export interface NodeMessageAttachmentInput {
110
+ readonly name: string;
111
+ readonly mime: string;
112
+ readonly dataBase64: string;
113
+ }
114
+ export interface WorkspaceActivityPage {
115
+ readonly events: readonly WorkspaceActivityEvent[];
116
+ readonly nextCursor: string | null;
117
+ }
118
+ export interface NodeApproval {
119
+ readonly id: string;
120
+ readonly runId: string;
121
+ readonly status: ApprovalStatus;
122
+ readonly payload: unknown;
123
+ readonly expiresAt: number;
124
+ readonly createdAt: number;
125
+ readonly decidedAt: number | null;
126
+ }
127
+ /** Terminal output and input are deliberately never part of this projection. */
128
+ export interface NodeTerminalSession {
129
+ readonly id: string;
130
+ readonly workspaceId: string | null;
131
+ readonly profileId: string;
132
+ readonly state: 'RUNNING' | 'EXITED' | 'CLOSED';
133
+ readonly exitCode: number | null;
134
+ readonly rows: number;
135
+ readonly cols: number;
136
+ readonly latestSequence: number;
137
+ readonly createdAt: number;
138
+ readonly updatedAt: number;
139
+ }
140
+ export declare class NodeDatabase {
141
+ private readonly now;
142
+ activeWorkspaceLeaseCount(): number;
143
+ readonly raw: DatabaseSync;
144
+ constructor(path: string, nodeId: string | (() => string), now?: () => number);
145
+ close(): void;
146
+ getRunnerDefaults(): readonly RunnerDefaultConfiguration[];
147
+ saveRunnerDefaults(input: RunnerDefaultConfiguration): RunnerDefaultConfiguration;
148
+ /**
149
+ * Stores only terminal lifecycle metadata. PTY input/output must remain in
150
+ * the Node-local bounded replay buffer and must never be passed here.
151
+ */
152
+ saveTerminalSession(input: NodeTerminalSession): NodeTerminalSession;
153
+ getTerminalSession(id: string): NodeTerminalSession | undefined;
154
+ listTerminalSessions(): readonly NodeTerminalSession[];
155
+ /** A restart cannot safely reattach an orphaned PTY, so record it as closed. */
156
+ closeRunningTerminalSessions(): void;
157
+ saveWorkspace(input: Omit<NodeWorkspace, 'id'> & {
158
+ readonly id?: string;
159
+ }): NodeWorkspace;
160
+ listWorkspaces(): readonly NodeWorkspace[];
161
+ getWorkspace(id: string): NodeWorkspace | undefined;
162
+ /** Unregisters a Workspace registration without deleting its local directory. */
163
+ removeWorkspace(id: string): NodeWorkspace;
164
+ createAgentSession(input: {
165
+ readonly workspaceId: string;
166
+ readonly runner: RunnerName;
167
+ readonly externalSessionId?: string;
168
+ /** A caller-supplied native ID is always treated as an unverified external session. */
169
+ readonly nativeControl?: NativeSessionControl;
170
+ readonly cwd: string;
171
+ /** Runner/native history title; never treated as a user override. */
172
+ readonly title?: string;
173
+ readonly model?: string;
174
+ readonly effort?: string;
175
+ readonly access?: string;
176
+ }): NodeAgentSession;
177
+ getAgentSession(id: string): NodeAgentSession | undefined;
178
+ updateAgentSessionConfiguration(input: {
179
+ readonly sessionId: string;
180
+ readonly model: string;
181
+ readonly effort: string;
182
+ readonly access: string;
183
+ }): NodeAgentSession;
184
+ listAgentSessions(): readonly NodeAgentSession[];
185
+ findAgentSessionByExternalSession(runner: RunnerName, externalSessionId: string): NodeAgentSession | undefined;
186
+ setNativeControl(sessionId: string, nativeControl: NativeSessionControl): void;
187
+ setExternalSessionId(sessionId: string, externalSessionId: string): void;
188
+ setChannelToken(sessionId: string, token: string): void;
189
+ updateSessionMetadata(input: {
190
+ readonly sessionId: string;
191
+ readonly customTitle?: string | null;
192
+ readonly pinned?: boolean;
193
+ }): NodeAgentSession;
194
+ getNativeSessionMetadata(runner: RunnerName, externalSessionId: string, workspaceId: string): NativeSessionMetadata | undefined;
195
+ saveNativeSessionMetadata(input: {
196
+ readonly runner: RunnerName;
197
+ readonly externalSessionId: string;
198
+ readonly workspaceId: string;
199
+ readonly customTitle?: string | null;
200
+ readonly runnerTitle?: string | null;
201
+ readonly runnerTitlePending?: boolean;
202
+ readonly pinned?: boolean;
203
+ readonly model?: string | null;
204
+ readonly effort?: string | null;
205
+ readonly access?: string | null;
206
+ }): NativeSessionMetadata;
207
+ /**
208
+ * Replaces only transcript-derived, run-less history. Managed Run turns are
209
+ * never touched by a vendor file scan.
210
+ */
211
+ syncNativeTranscript(sessionId: string, history: NativeSessionHistory): boolean;
212
+ createMessageRun(input: {
213
+ readonly sessionId: string;
214
+ readonly clientMessageId: string;
215
+ readonly content: string;
216
+ readonly attachments?: readonly NodeMessageAttachmentInput[];
217
+ }): {
218
+ readonly run: NodeAgentRun;
219
+ readonly created: boolean;
220
+ };
221
+ getRun(id: string): NodeAgentRun | undefined;
222
+ listRunsForSession(sessionId: string): readonly NodeAgentRun[];
223
+ getRunInput(id: string): string | undefined;
224
+ transitionRun(runId: string, next: AgentRunStatus): NodeAgentRun;
225
+ appendRunEvent(input: {
226
+ readonly runId: string;
227
+ readonly sequence: number;
228
+ readonly eventType: string;
229
+ readonly payload: unknown;
230
+ readonly status?: AgentRunStatus;
231
+ }): NodeRunEvent | undefined;
232
+ listRunEvents(runId: string, after?: number): readonly NodeRunEvent[];
233
+ /**
234
+ * Returns durable final item snapshots. Run events stay internal to the
235
+ * replay path; callers never need to reconstruct native runner payloads.
236
+ */
237
+ listConversationTurns(input: {
238
+ readonly sessionId: string;
239
+ readonly cursor?: string;
240
+ readonly limit?: number;
241
+ /** File transcript history takes precedence when it is available and no managed Run is live. */
242
+ readonly nativeOnly?: boolean;
243
+ }): ConversationPage;
244
+ hasNativeTranscript(sessionId: string): boolean;
245
+ /** Session detail cursor is intentionally distinct from history paging. */
246
+ listConversationItems(input: {
247
+ readonly sessionId: string;
248
+ readonly cursor?: string;
249
+ readonly limit?: number;
250
+ }): ConversationItemPage;
251
+ listWorkspaceActivity(input: {
252
+ readonly workspaceId: string;
253
+ readonly cursor?: string;
254
+ readonly limit?: number;
255
+ }): WorkspaceActivityPage;
256
+ createApproval(input: {
257
+ readonly runId: string;
258
+ readonly approvalId: string;
259
+ readonly payload: unknown;
260
+ readonly expiresAt: number;
261
+ }): NodeApproval;
262
+ getApproval(id: string): NodeApproval | undefined;
263
+ listApprovals(runId: string): readonly NodeApproval[];
264
+ /** Persists an expiry so a later decision cannot resurrect an old prompt. */
265
+ expireApproval(id: string): NodeApproval;
266
+ expireDueApprovals(): readonly NodeApproval[];
267
+ decideApproval(id: string, decision: 'APPROVED' | 'REJECTED'): NodeApproval;
268
+ listNonterminalRuns(): readonly NodeAgentRun[];
269
+ lastRunSequence(runId: string): number;
270
+ saveSnapshot(runId: string, snapshot: unknown): void;
271
+ getSnapshot(runId: string): unknown | undefined;
272
+ markActiveRunsSuspect(): void;
273
+ hasActiveWorkspaceLease(workspaceId: string): boolean;
274
+ reconcileRun(runId: string, active: boolean): void;
275
+ private releaseLease;
276
+ private recordWorkspaceActivity;
277
+ private recordConversationItemChange;
278
+ private projectApproval;
279
+ private readConversationTurn;
280
+ private projectRunEvent;
281
+ private readonly nodeIdProvider;
282
+ }