@cmodjs/core 8.10.4 → 8.11.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.
@@ -51,7 +51,7 @@ export function subagentTranscript(sessionTranscript: string | undefined, task:
51
51
  return sessionTranscript?.endsWith('.jsonl') === true ? `${sessionTranscript.slice(0, -'.jsonl'.length)}/subagents/agent-${task}.jsonl` : undefined
52
52
  }
53
53
 
54
- const sessionFields: Readonly<Record<keyof SessionData, true>> = { id: true, title: true, color: true, project: true, cwd: true, transcriptPath: true, model: true, startedAt: true, lastAt: true, forkedFrom: true, isRunning: true, agentType: true, visitedAt: true, device: true, status: true, waitingFor: true, contextPercent: true, lastTurn: true }
54
+ const sessionFields: Readonly<Record<keyof SessionData, true>> = { id: true, title: true, color: true, project: true, cwd: true, transcriptPath: true, model: true, startedAt: true, lastAt: true, forkedFrom: true, isRunning: true, agentType: true, visitedAt: true, device: true, status: true, waitingFor: true, contextPercent: true, lastTurn: true, openCall: true }
55
55
 
56
56
  export function pickedColor(args: string): string | undefined {
57
57
  const picked = args.trim().toLowerCase()
@@ -29,6 +29,7 @@ export type SessionData = {
29
29
  readonly waitingFor?: Session['waitingFor']
30
30
  readonly contextPercent?: number
31
31
  readonly lastTurn?: Session['lastTurn']
32
+ readonly openCall?: Session['openCall']
32
33
  }
33
34
 
34
35
  export type ContextData = Pick<Context, 'number' | 'openedAt' | 'closedAt' | 'task'>
@@ -177,7 +177,8 @@ export type Session = Pick<RecordPart, 'search'> & {
177
177
  readonly status?: 'busy' | 'shell' | 'idle' | 'waiting'
178
178
  readonly waitingFor?: { readonly dialog: string; readonly tool?: string; readonly input?: Readonly<Record<string, unknown>>; readonly question?: string }
179
179
  readonly contextPercent?: number
180
- readonly lastTurn?: { readonly reason: 'answered' | 'stopped' | 'failed'; readonly at: string; readonly failure?: string }
180
+ readonly lastTurn?: { readonly reason: 'answered' | 'stopped' | 'failed'; readonly at: string; readonly failure?: string; readonly reply?: string }
181
+ readonly openCall?: { readonly tool: string; readonly summary: string }
181
182
  readonly goal: Goal
182
183
  context(): Promise<Context>
183
184
  contexts(): Promise<Context[]>
package/src/utils/text.ts CHANGED
@@ -7,6 +7,18 @@ export function firstLine(text: string): string {
7
7
  return text.split('\n').find((line) => line.trim() !== '')?.trim() ?? ''
8
8
  }
9
9
 
10
+ const summaryChars = 200
11
+
12
+ export function questionOf(input: Readonly<Record<string, unknown>>): string | undefined {
13
+ const question = (input['questions'] as readonly { readonly question?: unknown }[] | undefined)?.[0]?.question
14
+ return typeof question === 'string' ? question : undefined
15
+ }
16
+
17
+ export function callSummary(input: Readonly<Record<string, unknown>>): string {
18
+ const named = [input['command'], input['file_path'], input['path'], input['pattern'], input['url'], input['query'], questionOf(input), input['description'], input['prompt']].find((value) => typeof value === 'string')
19
+ return firstLine(typeof named === 'string' ? named : JSON.stringify(input)).slice(0, summaryChars)
20
+ }
21
+
10
22
  export function messageOf(error: unknown): string {
11
23
  return error instanceof Error ? error.message : String(error)
12
24
  }
package/utils/text.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  export declare function listed(items: readonly string[]): string;
2
2
  export declare function firstLine(text: string): string;
3
+ export declare function questionOf(input: Readonly<Record<string, unknown>>): string | undefined;
4
+ export declare function callSummary(input: Readonly<Record<string, unknown>>): string;
3
5
  export declare function messageOf(error: unknown): string;
4
6
  export declare function formatExit(code: number | null, reason: string): string;
5
7
  //# sourceMappingURL=text.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../src/utils/text.ts"],"names":[],"mappings":"AAAA,wBAAgB,MAAM,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAGvD;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEhD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAItE"}
1
+ {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../src/utils/text.ts"],"names":[],"mappings":"AAAA,wBAAgB,MAAM,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAGvD;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9C;AAID,wBAAgB,UAAU,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,MAAM,GAAG,SAAS,CAGvF;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,MAAM,CAG5E;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEhD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAItE"}
package/utils/text.js CHANGED
@@ -6,6 +6,15 @@ export function listed(items) {
6
6
  export function firstLine(text) {
7
7
  return text.split('\n').find((line) => line.trim() !== '')?.trim() ?? '';
8
8
  }
9
+ const summaryChars = 200;
10
+ export function questionOf(input) {
11
+ const question = input['questions']?.[0]?.question;
12
+ return typeof question === 'string' ? question : undefined;
13
+ }
14
+ export function callSummary(input) {
15
+ const named = [input['command'], input['file_path'], input['path'], input['pattern'], input['url'], input['query'], questionOf(input), input['description'], input['prompt']].find((value) => typeof value === 'string');
16
+ return firstLine(typeof named === 'string' ? named : JSON.stringify(input)).slice(0, summaryChars);
17
+ }
9
18
  export function messageOf(error) {
10
19
  return error instanceof Error ? error.message : String(error);
11
20
  }