@ai-matrx/coding-sessions 0.1.83 → 0.1.86

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.
@@ -1,4 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
+ import { JsonValue } from '@ai-matrx/agents/portable';
2
3
  import { ChatThreadStore, ChatMessage } from '@ai-matrx/chat';
3
4
 
4
5
  /**
@@ -7,6 +8,7 @@ import { ChatThreadStore, ChatMessage } from '@ai-matrx/chat';
7
8
  * touches Node or the DOM, and every value is JSON-serializable because it
8
9
  * crosses a transport (WebSocket today, desktop IPC later).
9
10
  */
11
+
10
12
  /** The coding agents this package drives. "coding session" is the canonical
11
13
  * platform term (chat.coding_session, the Coding Session Bridge). */
12
14
  type CodingProvider = "claude" | "codex";
@@ -192,6 +194,10 @@ interface CodingSession {
192
194
  lastRunStatus: RunStatus | null;
193
195
  /** Prompts waiting for the active run to finish, oldest first. */
194
196
  queued: string[];
197
+ /** The AI Matrx agent loaded into every run of this session, when one was picked. */
198
+ agent?: SessionAgent | null | undefined;
199
+ /** Codex must be told, in the next prompt, that an earlier agent no longer applies. */
200
+ agentRemovedDue?: boolean | undefined;
195
201
  }
196
202
  /**
197
203
  * One normalized transcript item — the same shape from Claude and Codex, from
@@ -272,12 +278,105 @@ interface StartInput {
272
278
  prompt: string;
273
279
  model?: string | null | undefined;
274
280
  effort?: string | null | undefined;
281
+ /** An AI Matrx agent to load into the CLI. Needs the host's `agents` credentials. */
282
+ agent?: AgentSelection | null | undefined;
283
+ }
284
+ /** Which AI Matrx agent a new session loads, and the person's variable values. */
285
+ interface AgentSelection {
286
+ agentId: string;
287
+ /** Pin one saved version; omitted = the latest, pinned at start. */
288
+ versionId?: string | null | undefined;
289
+ variables?: Record<string, JsonValue> | undefined;
290
+ }
291
+ /** One part of an agent and whether this session's CLI carries it. */
292
+ interface SessionAgentPart {
293
+ part: "instructions" | "skills" | "tools";
294
+ loaded: number;
295
+ total: number;
296
+ }
297
+ /**
298
+ * The agent a session runs with. Recorded at start and never drifts: every
299
+ * later turn reloads the SAME bundle (same version, same hash).
300
+ */
301
+ interface SessionAgent {
302
+ agentId: string;
303
+ versionId: string | null;
304
+ versionNumber: number | null;
305
+ name: string;
306
+ definitionHash: string;
307
+ loaded: SessionAgentPart[];
308
+ /** What could not be carried, with the reason. */
309
+ unavailable: {
310
+ kind: string;
311
+ name: string;
312
+ reason: string;
313
+ }[];
314
+ /** The skills it carries (labels) and the tools it serves (names) — the agent's own set. */
315
+ skills?: string[] | undefined;
316
+ tools?: string[] | undefined;
317
+ /** The person's variable values, kept so "Update to vN" can reuse them. */
318
+ variables?: Record<string, JsonValue> | undefined;
319
+ /**
320
+ * The CLI must be TOLD in the next prompt (a delimited block): a Codex
321
+ * takeover or agent switch (Codex ignores developer_instructions on resume),
322
+ * or a Codex compaction that dropped the block. Cleared once delivered.
323
+ */
324
+ blockDue?: boolean | undefined;
325
+ /** When the block (or native instructions) last reached the CLI. */
326
+ deliveredAt?: string | null | undefined;
327
+ }
328
+ /** Whether this host can reach AI Matrx as a signed-in person. */
329
+ interface AgentAccess {
330
+ signedIn: boolean;
331
+ userId: string | null;
332
+ organizationId: string | null;
333
+ /** True when the host was started with no AI Matrx connection at all. */
334
+ configured: boolean;
335
+ }
336
+ /** A catalogue read the picker asks the host to make (PostgREST RPC shape). */
337
+ interface AgentCatalogRpcRequest {
338
+ fn: string;
339
+ args?: Record<string, unknown> | undefined;
340
+ count?: "exact" | "planned" | "estimated" | undefined;
341
+ range?: [number, number] | undefined;
342
+ order?: {
343
+ column: string;
344
+ ascending?: boolean | undefined;
345
+ } | undefined;
346
+ }
347
+ interface AgentCatalogRpcResult {
348
+ data: unknown;
349
+ error: {
350
+ message: string;
351
+ code?: string | undefined;
352
+ details?: string | null | undefined;
353
+ hint?: string | null | undefined;
354
+ } | null;
355
+ count?: number | null;
356
+ }
357
+ /** What a picker needs about one agent — the LIGHT read (no skills, no tools). */
358
+ interface AgentDetails {
359
+ agentId: string;
360
+ name: string;
361
+ /** Variable declarations as authored (camelCase). */
362
+ variables: Record<string, JsonValue>[];
363
+ /** Newest first. */
364
+ versions: {
365
+ id: string;
366
+ versionNumber: number;
367
+ changedAt: string | null;
368
+ }[];
369
+ /** The version "Latest" resolves to right now. */
370
+ latestVersionNumber: number | null;
371
+ latestVersionId: string | null;
275
372
  }
276
373
  interface TakeoverInput {
277
374
  provider: CodingProvider;
278
375
  providerSessionId: string;
279
376
  cwd: string;
280
377
  title?: string | undefined;
378
+ /** Continue the chat WITH an AI Matrx agent ("Continue with agent"). */
379
+ agent?: AgentSelection | null | undefined;
281
380
  }
282
381
  interface SendResult {
283
382
  session: CodingSession;
@@ -348,6 +447,18 @@ interface CodingSessionsApi {
348
447
  model?: string | null;
349
448
  effort?: string | null;
350
449
  }): Promise<CodingSession>;
450
+ /** Is this host signed in to AI Matrx (so agents can load)? */
451
+ agentAccess(): Promise<AgentAccess>;
452
+ /** One allowlisted agent-catalogue read, made by the host as the signed-in person. */
453
+ agentCatalogRpc(request: AgentCatalogRpcRequest): Promise<AgentCatalogRpcResult>;
454
+ /** An agent's variables and saved versions, for the New session form. */
455
+ agentDetails(agentId: string): Promise<AgentDetails>;
456
+ /**
457
+ * Load a different agent into a session from its next message on (or
458
+ * remove it, with `null`). Claude reads it every turn; Codex is told in the
459
+ * next prompt.
460
+ */
461
+ setAgent(sessionId: string, agent: AgentSelection | null): Promise<CodingSession>;
351
462
  }
352
463
  type RawTranscript = {
353
464
  available: true;
@@ -501,14 +612,8 @@ declare class CodingSessionsClient {
501
612
  refreshAll: () => Promise<void>;
502
613
  transcript(sessionId: string): SessionTranscript;
503
614
  readPreview(provider: CodingProvider, providerSessionId: string, maxBytes?: number): Promise<PreviewState>;
504
- start(input: {
505
- provider: CodingProvider;
506
- cwd: string;
507
- prompt: string;
508
- model?: string | null;
509
- effort?: string | null;
510
- }): Promise<SendResult>;
511
- takeover(session: DiscoveredSession): Promise<CodingSession>;
615
+ start(input: StartInput): Promise<SendResult>;
616
+ takeover(session: DiscoveredSession, agent?: AgentSelection | null): Promise<CodingSession>;
512
617
  send(sessionId: string, prompt: string): Promise<SendResult>;
513
618
  stop(runId: string): Promise<RunRecord | null>;
514
619
  }
@@ -1,4 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
+ import { JsonValue } from '@ai-matrx/agents/portable';
2
3
  import { ChatThreadStore, ChatMessage } from '@ai-matrx/chat';
3
4
 
4
5
  /**
@@ -7,6 +8,7 @@ import { ChatThreadStore, ChatMessage } from '@ai-matrx/chat';
7
8
  * touches Node or the DOM, and every value is JSON-serializable because it
8
9
  * crosses a transport (WebSocket today, desktop IPC later).
9
10
  */
11
+
10
12
  /** The coding agents this package drives. "coding session" is the canonical
11
13
  * platform term (chat.coding_session, the Coding Session Bridge). */
12
14
  type CodingProvider = "claude" | "codex";
@@ -192,6 +194,10 @@ interface CodingSession {
192
194
  lastRunStatus: RunStatus | null;
193
195
  /** Prompts waiting for the active run to finish, oldest first. */
194
196
  queued: string[];
197
+ /** The AI Matrx agent loaded into every run of this session, when one was picked. */
198
+ agent?: SessionAgent | null | undefined;
199
+ /** Codex must be told, in the next prompt, that an earlier agent no longer applies. */
200
+ agentRemovedDue?: boolean | undefined;
195
201
  }
196
202
  /**
197
203
  * One normalized transcript item — the same shape from Claude and Codex, from
@@ -272,12 +278,105 @@ interface StartInput {
272
278
  prompt: string;
273
279
  model?: string | null | undefined;
274
280
  effort?: string | null | undefined;
281
+ /** An AI Matrx agent to load into the CLI. Needs the host's `agents` credentials. */
282
+ agent?: AgentSelection | null | undefined;
283
+ }
284
+ /** Which AI Matrx agent a new session loads, and the person's variable values. */
285
+ interface AgentSelection {
286
+ agentId: string;
287
+ /** Pin one saved version; omitted = the latest, pinned at start. */
288
+ versionId?: string | null | undefined;
289
+ variables?: Record<string, JsonValue> | undefined;
290
+ }
291
+ /** One part of an agent and whether this session's CLI carries it. */
292
+ interface SessionAgentPart {
293
+ part: "instructions" | "skills" | "tools";
294
+ loaded: number;
295
+ total: number;
296
+ }
297
+ /**
298
+ * The agent a session runs with. Recorded at start and never drifts: every
299
+ * later turn reloads the SAME bundle (same version, same hash).
300
+ */
301
+ interface SessionAgent {
302
+ agentId: string;
303
+ versionId: string | null;
304
+ versionNumber: number | null;
305
+ name: string;
306
+ definitionHash: string;
307
+ loaded: SessionAgentPart[];
308
+ /** What could not be carried, with the reason. */
309
+ unavailable: {
310
+ kind: string;
311
+ name: string;
312
+ reason: string;
313
+ }[];
314
+ /** The skills it carries (labels) and the tools it serves (names) — the agent's own set. */
315
+ skills?: string[] | undefined;
316
+ tools?: string[] | undefined;
317
+ /** The person's variable values, kept so "Update to vN" can reuse them. */
318
+ variables?: Record<string, JsonValue> | undefined;
319
+ /**
320
+ * The CLI must be TOLD in the next prompt (a delimited block): a Codex
321
+ * takeover or agent switch (Codex ignores developer_instructions on resume),
322
+ * or a Codex compaction that dropped the block. Cleared once delivered.
323
+ */
324
+ blockDue?: boolean | undefined;
325
+ /** When the block (or native instructions) last reached the CLI. */
326
+ deliveredAt?: string | null | undefined;
327
+ }
328
+ /** Whether this host can reach AI Matrx as a signed-in person. */
329
+ interface AgentAccess {
330
+ signedIn: boolean;
331
+ userId: string | null;
332
+ organizationId: string | null;
333
+ /** True when the host was started with no AI Matrx connection at all. */
334
+ configured: boolean;
335
+ }
336
+ /** A catalogue read the picker asks the host to make (PostgREST RPC shape). */
337
+ interface AgentCatalogRpcRequest {
338
+ fn: string;
339
+ args?: Record<string, unknown> | undefined;
340
+ count?: "exact" | "planned" | "estimated" | undefined;
341
+ range?: [number, number] | undefined;
342
+ order?: {
343
+ column: string;
344
+ ascending?: boolean | undefined;
345
+ } | undefined;
346
+ }
347
+ interface AgentCatalogRpcResult {
348
+ data: unknown;
349
+ error: {
350
+ message: string;
351
+ code?: string | undefined;
352
+ details?: string | null | undefined;
353
+ hint?: string | null | undefined;
354
+ } | null;
355
+ count?: number | null;
356
+ }
357
+ /** What a picker needs about one agent — the LIGHT read (no skills, no tools). */
358
+ interface AgentDetails {
359
+ agentId: string;
360
+ name: string;
361
+ /** Variable declarations as authored (camelCase). */
362
+ variables: Record<string, JsonValue>[];
363
+ /** Newest first. */
364
+ versions: {
365
+ id: string;
366
+ versionNumber: number;
367
+ changedAt: string | null;
368
+ }[];
369
+ /** The version "Latest" resolves to right now. */
370
+ latestVersionNumber: number | null;
371
+ latestVersionId: string | null;
275
372
  }
276
373
  interface TakeoverInput {
277
374
  provider: CodingProvider;
278
375
  providerSessionId: string;
279
376
  cwd: string;
280
377
  title?: string | undefined;
378
+ /** Continue the chat WITH an AI Matrx agent ("Continue with agent"). */
379
+ agent?: AgentSelection | null | undefined;
281
380
  }
282
381
  interface SendResult {
283
382
  session: CodingSession;
@@ -348,6 +447,18 @@ interface CodingSessionsApi {
348
447
  model?: string | null;
349
448
  effort?: string | null;
350
449
  }): Promise<CodingSession>;
450
+ /** Is this host signed in to AI Matrx (so agents can load)? */
451
+ agentAccess(): Promise<AgentAccess>;
452
+ /** One allowlisted agent-catalogue read, made by the host as the signed-in person. */
453
+ agentCatalogRpc(request: AgentCatalogRpcRequest): Promise<AgentCatalogRpcResult>;
454
+ /** An agent's variables and saved versions, for the New session form. */
455
+ agentDetails(agentId: string): Promise<AgentDetails>;
456
+ /**
457
+ * Load a different agent into a session from its next message on (or
458
+ * remove it, with `null`). Claude reads it every turn; Codex is told in the
459
+ * next prompt.
460
+ */
461
+ setAgent(sessionId: string, agent: AgentSelection | null): Promise<CodingSession>;
351
462
  }
352
463
  type RawTranscript = {
353
464
  available: true;
@@ -501,14 +612,8 @@ declare class CodingSessionsClient {
501
612
  refreshAll: () => Promise<void>;
502
613
  transcript(sessionId: string): SessionTranscript;
503
614
  readPreview(provider: CodingProvider, providerSessionId: string, maxBytes?: number): Promise<PreviewState>;
504
- start(input: {
505
- provider: CodingProvider;
506
- cwd: string;
507
- prompt: string;
508
- model?: string | null;
509
- effort?: string | null;
510
- }): Promise<SendResult>;
511
- takeover(session: DiscoveredSession): Promise<CodingSession>;
615
+ start(input: StartInput): Promise<SendResult>;
616
+ takeover(session: DiscoveredSession, agent?: AgentSelection | null): Promise<CodingSession>;
512
617
  send(sessionId: string, prompt: string): Promise<SendResult>;
513
618
  stop(runId: string): Promise<RunRecord | null>;
514
619
  }