@moda-ai/cli 1.9.6 → 1.10.1
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.
- package/README.md +0 -8
- package/dist/agent-schemas.d.ts +3 -0
- package/dist/agent-schemas.js +298 -0
- package/dist/api-client.d.ts +12 -1
- package/dist/api-client.js +10 -8
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +68 -94
- package/dist/command-context.d.ts +6 -0
- package/dist/command-context.js +1 -1
- package/dist/intelligence-schema.d.ts +349 -0
- package/dist/intelligence-schema.js +174 -0
- package/dist/output.d.ts +25 -2
- package/dist/output.js +71 -2
- package/dist/production-intelligence.d.ts +21 -4
- package/dist/production-intelligence.js +360 -107
- package/dist/schemas.d.ts +20 -43
- package/dist/schemas.js +10 -26
- package/package.json +1 -1
- package/skills/moda-cli/SKILL.md +152 -56
package/dist/cli.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { validateConfig, VERSION, resolveApiKey } from './config.js';
|
|
4
4
|
import { callDataAPI, ApiError, getApiRequestCount, resetApiRequestCount, } from './api-client.js';
|
|
5
|
-
import { OverviewSchema, ClustersSchema, ClusterConversationsSchema, ConversationsSchema, SearchSchema, WorldStateSchema, ContextSchema, FrustrationsSchema, ToolFailuresSchema, ToolFailureDetailSchema,
|
|
5
|
+
import { OverviewSchema, ClustersSchema, ClusterConversationsSchema, ConversationsSchema, SearchSchema, WorldStateSchema, ContextSchema, AuditSchema, FrustrationsSchema, ToolFailuresSchema, ToolFailureDetailSchema, LoopsSchema, LoopDetailSchema, } from './schemas.js';
|
|
6
6
|
import { withFrustrationAnchors, withToolFailureAnchors, embeddedWindowSize, asRecord, asString, asNumber } from './transforms.js';
|
|
7
7
|
import { runPromptsCommand } from './prompts.js';
|
|
8
8
|
// Coding-agent capture (shadow workspace / Shadow Spark / trace hooks) is temporarily
|
|
@@ -17,7 +17,8 @@ import { buildSearchAdoptionTelemetry, isTelemetryDisabled, SEARCH_MODES, sendCl
|
|
|
17
17
|
import { isUpdateCheckDisabled, printUpdateNotice, startUpdateCheck, stripUpdateCheckFlag, } from './update-check.js';
|
|
18
18
|
import { createCommandContext } from './command-context.js';
|
|
19
19
|
import { createCommandRegistry } from './command-registry.js';
|
|
20
|
-
import { createAgentErrorEnvelope, errorToAgentError,
|
|
20
|
+
import { createAgentErrorEnvelope, errorToAgentError, resolveOutputMode, } from './output.js';
|
|
21
|
+
import { renderJsonSchemas } from './agent-schemas.js';
|
|
21
22
|
import { runAuthCommand, runConfigCommand, runKeysCommand, runProfilesCommand } from './profile-commands.js';
|
|
22
23
|
import { runAgentCommand } from './agent.js';
|
|
23
24
|
import { runProductionCommand } from './production-intelligence.js';
|
|
@@ -51,6 +52,9 @@ export function parseArgs(argv) {
|
|
|
51
52
|
const GLOBAL_BOOLEAN_FLAGS = new Set([
|
|
52
53
|
'agent',
|
|
53
54
|
'json',
|
|
55
|
+
'human',
|
|
56
|
+
'prose',
|
|
57
|
+
'json-schemas',
|
|
54
58
|
'help',
|
|
55
59
|
'version',
|
|
56
60
|
'quiet',
|
|
@@ -126,7 +130,6 @@ Commands:
|
|
|
126
130
|
agent evidence <ref> Expand one evidence reference
|
|
127
131
|
investigate Rank production issues with evidence
|
|
128
132
|
failures Show production failures worth fixing first
|
|
129
|
-
why-failed <run_id> Explain a failed or partial production run
|
|
130
133
|
ask "question" Ask Moda a production/harness question
|
|
131
134
|
sync Sync the local harness graph to Moda Cloud
|
|
132
135
|
sync harness Sync the local harness graph to Moda Cloud
|
|
@@ -140,14 +143,11 @@ Commands:
|
|
|
140
143
|
search "<query>" Search conversation messages (keyword/semantic/hybrid)
|
|
141
144
|
world-state <conversation_id> Get a conversation's world state (slots/threads/events)
|
|
142
145
|
context <conversation_id> Get windowed conversation context
|
|
146
|
+
audit <conversation_id|trace_id> Raw span/trace audit (spans, hierarchy, orphans, duplicates)
|
|
143
147
|
frustrations Get user frustration detections
|
|
144
148
|
tool-failures Get tool failure overview
|
|
145
149
|
tool-failure-detail <tool_name> Get per-tool failure detail
|
|
146
150
|
|
|
147
|
-
Agent runs runtime:
|
|
148
|
-
workflows Recurring workflow catalog (per-class 30d health)
|
|
149
|
-
runs List workflow executions with classified outcomes
|
|
150
|
-
run <run_id> Get single execution + side-effect receipts
|
|
151
151
|
loops Currently-active loop detections
|
|
152
152
|
loop <detection_id> Single loop detail
|
|
153
153
|
|
|
@@ -169,6 +169,7 @@ Commands:
|
|
|
169
169
|
Options:
|
|
170
170
|
--help Show this help message
|
|
171
171
|
--version Show version number
|
|
172
|
+
--json-schemas Print JSON Schemas for the agent output contract
|
|
172
173
|
|
|
173
174
|
Common flags:
|
|
174
175
|
--days-back=N Number of days to look back (1-90)
|
|
@@ -179,6 +180,13 @@ Common flags:
|
|
|
179
180
|
--json Emit machine-readable JSON
|
|
180
181
|
--agent Emit schema-versioned agent JSON
|
|
181
182
|
--stream With --agent, emit NDJSON agent events
|
|
183
|
+
--human Force human prose (overrides auto-detection)
|
|
184
|
+
|
|
185
|
+
Output auto-detection (no flags needed):
|
|
186
|
+
Piped/redirected stdout, CI, or an agent env (CLAUDECODE/CURSOR/MODA_AGENT)
|
|
187
|
+
=> schema-versioned agent JSON. An interactive terminal => human prose.
|
|
188
|
+
Override with the flags above or MODA_FORMAT=human|json|agent|agent-stream.
|
|
189
|
+
Exit codes: 0 ok, 3 degraded (local fallback), 1 error.
|
|
182
190
|
--dry-run Show the planned mutation when supported
|
|
183
191
|
--yes Accept explicit automation defaults
|
|
184
192
|
--tui Force the human analyst dashboard when supported
|
|
@@ -203,11 +211,6 @@ World-state flags:
|
|
|
203
211
|
--summary-only Return segment summaries only (omit the event stream)
|
|
204
212
|
--event-limit=N Max world-state events to return (1-5000, default 2000)
|
|
205
213
|
|
|
206
|
-
Runs flags:
|
|
207
|
-
--outcome=OUTCOME Filter by outcome (running|succeeded|partial|failed|loop|abandoned|unknown)
|
|
208
|
-
--class-id=ID Filter to a single workflow class (e.g. cron:helpscout-triage-hourly)
|
|
209
|
-
--user-id=ID Filter to a single user
|
|
210
|
-
|
|
211
214
|
Init flags:
|
|
212
215
|
--yes Accept all defaults (non-interactive)
|
|
213
216
|
--analyst=auto|claude|codex|cursor|local-scan
|
|
@@ -243,7 +246,6 @@ Examples:
|
|
|
243
246
|
moda agent evidence doctor:harness_report_approved_synced
|
|
244
247
|
moda investigate
|
|
245
248
|
moda failures
|
|
246
|
-
moda why-failed 12345678-1234-1234-1234-1234567890ab
|
|
247
249
|
moda ask "what should I fix first?"
|
|
248
250
|
moda sync --dry-run
|
|
249
251
|
moda sync harness --profile=prod
|
|
@@ -261,10 +263,8 @@ Examples:
|
|
|
261
263
|
moda world-state <conversation_id> --summary-only
|
|
262
264
|
moda frustrations --days-back=14 --limit=20
|
|
263
265
|
moda context <conversation_id> --window=3
|
|
264
|
-
moda
|
|
265
|
-
moda
|
|
266
|
-
moda runs --class-id=cron:helpscout-triage-hourly --limit=20
|
|
267
|
-
moda run 12345678-1234-1234-1234-1234567890ab
|
|
266
|
+
moda audit <conversation_id|trace_id>
|
|
267
|
+
moda audit <trace_id> --kind=trace --json
|
|
268
268
|
moda loops --limit=10
|
|
269
269
|
moda loop 12345678-1234-1234-1234-1234567890ab
|
|
270
270
|
moda prompts status
|
|
@@ -386,15 +386,12 @@ export async function runCommand(command, positional, flags, positionals = posit
|
|
|
386
386
|
case 'overview': {
|
|
387
387
|
const args = flagsToArgs(flags);
|
|
388
388
|
OverviewSchema.parse(args);
|
|
389
|
-
await runProductionCommand(context);
|
|
390
|
-
break;
|
|
389
|
+
return (await runProductionCommand(context)).exitCode;
|
|
391
390
|
}
|
|
392
391
|
case 'investigate':
|
|
393
392
|
case 'failures':
|
|
394
|
-
case 'why-failed':
|
|
395
393
|
case 'ask': {
|
|
396
|
-
await runProductionCommand(context);
|
|
397
|
-
break;
|
|
394
|
+
return (await runProductionCommand(context)).exitCode;
|
|
398
395
|
}
|
|
399
396
|
case 'clusters': {
|
|
400
397
|
const args = flagsToArgs(flags);
|
|
@@ -519,6 +516,25 @@ export async function runCommand(command, positional, flags, positionals = posit
|
|
|
519
516
|
context.output.writeData(data);
|
|
520
517
|
break;
|
|
521
518
|
}
|
|
519
|
+
case 'audit':
|
|
520
|
+
case 'trace': {
|
|
521
|
+
if (!positional) {
|
|
522
|
+
throw new CliInputError('<conversation_id|trace_id> is required', 'Usage: moda audit <conversation_id|trace_id> [--kind=auto|trace|conversation] [--include-raw] [--limit=N]');
|
|
523
|
+
}
|
|
524
|
+
const args = flagsToArgs(flags, 'id', positional);
|
|
525
|
+
const params = AuditSchema.parse(args);
|
|
526
|
+
const query = new URLSearchParams();
|
|
527
|
+
if (params.kind && params.kind !== 'auto')
|
|
528
|
+
query.set('kind', params.kind);
|
|
529
|
+
if (params.include_raw === true)
|
|
530
|
+
query.set('include_raw', '1');
|
|
531
|
+
if (params.limit)
|
|
532
|
+
query.set('limit', params.limit.toString());
|
|
533
|
+
const queryString = query.toString() ? `?${query.toString()}` : '';
|
|
534
|
+
const data = await callDataAPI(`/audit/${encodeURIComponent(params.id)}${queryString}`);
|
|
535
|
+
context.output.writeData(data);
|
|
536
|
+
break;
|
|
537
|
+
}
|
|
522
538
|
case 'frustrations': {
|
|
523
539
|
const args = flagsToArgs(flags);
|
|
524
540
|
const params = FrustrationsSchema.parse(args);
|
|
@@ -562,51 +578,6 @@ export async function runCommand(command, positional, flags, positionals = posit
|
|
|
562
578
|
await printWithOptionalWindows(withToolFailureAnchors(data), 'examples', params.include_window === true, params.window ?? 1, context.output);
|
|
563
579
|
break;
|
|
564
580
|
}
|
|
565
|
-
// ─── Workflows + Runs ──────────────────────────────────────
|
|
566
|
-
case 'workflows': {
|
|
567
|
-
const args = flagsToArgs(flags);
|
|
568
|
-
const params = WorkflowsSchema.parse(args);
|
|
569
|
-
const query = new URLSearchParams();
|
|
570
|
-
if (params.time_range)
|
|
571
|
-
query.set('time_range', params.time_range);
|
|
572
|
-
if (params.user_id)
|
|
573
|
-
query.set('user_id', params.user_id);
|
|
574
|
-
const queryString = query.toString() ? `?${query.toString()}` : '';
|
|
575
|
-
const data = await callDataAPI(`/workflows${queryString}`);
|
|
576
|
-
context.output.writeData(data);
|
|
577
|
-
break;
|
|
578
|
-
}
|
|
579
|
-
case 'runs': {
|
|
580
|
-
const args = flagsToArgs(flags);
|
|
581
|
-
const params = RunsSchema.parse(args);
|
|
582
|
-
const query = new URLSearchParams();
|
|
583
|
-
if (params.time_range)
|
|
584
|
-
query.set('time_range', params.time_range);
|
|
585
|
-
if (params.outcome)
|
|
586
|
-
query.set('outcome', params.outcome);
|
|
587
|
-
if (params.class_id)
|
|
588
|
-
query.set('class_id', params.class_id);
|
|
589
|
-
if (params.user_id)
|
|
590
|
-
query.set('user_id', params.user_id);
|
|
591
|
-
if (params.limit)
|
|
592
|
-
query.set('limit', params.limit.toString());
|
|
593
|
-
if (params.offset !== undefined)
|
|
594
|
-
query.set('offset', params.offset.toString());
|
|
595
|
-
const queryString = query.toString() ? `?${query.toString()}` : '';
|
|
596
|
-
const data = await callDataAPI(`/runs${queryString}`);
|
|
597
|
-
context.output.writeData(data);
|
|
598
|
-
break;
|
|
599
|
-
}
|
|
600
|
-
case 'run': {
|
|
601
|
-
if (!positional) {
|
|
602
|
-
throw new CliInputError('<run_id> is required', 'Usage: moda run <run_id>');
|
|
603
|
-
}
|
|
604
|
-
const args = flagsToArgs(flags, 'run_id', positional);
|
|
605
|
-
const params = RunDetailSchema.parse(args);
|
|
606
|
-
const data = await callDataAPI(`/runs/${params.run_id}`);
|
|
607
|
-
context.output.writeData(data);
|
|
608
|
-
break;
|
|
609
|
-
}
|
|
610
581
|
case 'loops': {
|
|
611
582
|
const args = flagsToArgs(flags);
|
|
612
583
|
const params = LoopsSchema.parse(args);
|
|
@@ -631,13 +602,14 @@ export async function runCommand(command, positional, flags, positionals = posit
|
|
|
631
602
|
default:
|
|
632
603
|
throw new CliInputError(`Unknown command '${command}'`, 'Run "moda --help" for usage information.');
|
|
633
604
|
}
|
|
605
|
+
return 0;
|
|
634
606
|
}
|
|
635
607
|
function legacyCommand(metadata) {
|
|
636
608
|
return {
|
|
637
609
|
...metadata,
|
|
638
610
|
handler: async (context) => {
|
|
639
|
-
await runCommand(context.command, context.positional, context.flags, context.positionals, context);
|
|
640
|
-
return { exitCode
|
|
611
|
+
const exitCode = await runCommand(context.command, context.positional, context.flags, context.positionals, context);
|
|
612
|
+
return { exitCode };
|
|
641
613
|
},
|
|
642
614
|
};
|
|
643
615
|
}
|
|
@@ -894,12 +866,6 @@ export const commandRegistry = createCommandRegistry([
|
|
|
894
866
|
examples: ['moda failures', 'moda failures --tool lookupCustomer'],
|
|
895
867
|
...dataApiDefaults,
|
|
896
868
|
}),
|
|
897
|
-
legacyCommand({
|
|
898
|
-
name: 'why-failed',
|
|
899
|
-
description: 'Explain a failed or partial production run',
|
|
900
|
-
examples: ['moda why-failed 12345678-1234-1234-1234-1234567890ab'],
|
|
901
|
-
...dataApiDefaults,
|
|
902
|
-
}),
|
|
903
869
|
legacyCommand({
|
|
904
870
|
name: 'ask',
|
|
905
871
|
description: 'Ask Moda a production intelligence question',
|
|
@@ -952,6 +918,17 @@ export const commandRegistry = createCommandRegistry([
|
|
|
952
918
|
examples: ['moda context <conversation_id> --window=3'],
|
|
953
919
|
...dataApiDefaults,
|
|
954
920
|
}),
|
|
921
|
+
legacyCommand({
|
|
922
|
+
name: 'audit',
|
|
923
|
+
aliases: ['trace'],
|
|
924
|
+
description: 'Raw non-deduped span/trace audit (hierarchy, tool spans, orphans, duplicates)',
|
|
925
|
+
examples: [
|
|
926
|
+
'moda audit <conversation_id|trace_id>',
|
|
927
|
+
'moda audit <trace_id> --kind=trace --json',
|
|
928
|
+
'moda audit <conversation_id> --include-raw',
|
|
929
|
+
],
|
|
930
|
+
...dataApiDefaults,
|
|
931
|
+
}),
|
|
955
932
|
legacyCommand({
|
|
956
933
|
name: 'frustrations',
|
|
957
934
|
description: 'Get user frustration detections',
|
|
@@ -970,24 +947,6 @@ export const commandRegistry = createCommandRegistry([
|
|
|
970
947
|
examples: ['moda tool-failure-detail search --include-window'],
|
|
971
948
|
...dataApiDefaults,
|
|
972
949
|
}),
|
|
973
|
-
legacyCommand({
|
|
974
|
-
name: 'workflows',
|
|
975
|
-
description: 'Recurring workflow catalog',
|
|
976
|
-
examples: ['moda workflows --time-range=7d'],
|
|
977
|
-
...dataApiDefaults,
|
|
978
|
-
}),
|
|
979
|
-
legacyCommand({
|
|
980
|
-
name: 'runs',
|
|
981
|
-
description: 'List workflow executions',
|
|
982
|
-
examples: ['moda runs --time-range=24h --outcome=partial'],
|
|
983
|
-
...dataApiDefaults,
|
|
984
|
-
}),
|
|
985
|
-
legacyCommand({
|
|
986
|
-
name: 'run',
|
|
987
|
-
description: 'Get a single workflow execution',
|
|
988
|
-
examples: ['moda run 12345678-1234-1234-1234-1234567890ab'],
|
|
989
|
-
...dataApiDefaults,
|
|
990
|
-
}),
|
|
991
950
|
legacyCommand({
|
|
992
951
|
name: 'loops',
|
|
993
952
|
description: 'List currently-active loop detections',
|
|
@@ -1139,6 +1098,10 @@ export async function dispatchParsedCommand(parsed, startedAt = Date.now()) {
|
|
|
1139
1098
|
printHelp();
|
|
1140
1099
|
return 0;
|
|
1141
1100
|
}
|
|
1101
|
+
if (command === '--json-schemas' || flags['json-schemas'] === 'true') {
|
|
1102
|
+
console.log(renderJsonSchemas());
|
|
1103
|
+
return 0;
|
|
1104
|
+
}
|
|
1142
1105
|
if (!command) {
|
|
1143
1106
|
printHelp();
|
|
1144
1107
|
return 1;
|
|
@@ -1146,7 +1109,11 @@ export async function dispatchParsedCommand(parsed, startedAt = Date.now()) {
|
|
|
1146
1109
|
const definition = commandRegistry.find(command);
|
|
1147
1110
|
if (!definition) {
|
|
1148
1111
|
const error = new CliInputError(`Unknown command '${command}'`, 'Run "moda --help" for usage information.');
|
|
1149
|
-
|
|
1112
|
+
const mode = resolveOutputMode(commandFlags, {
|
|
1113
|
+
isTTY: process.stdout.isTTY,
|
|
1114
|
+
env: process.env,
|
|
1115
|
+
});
|
|
1116
|
+
if (mode === 'agent' || mode === 'agent-stream') {
|
|
1150
1117
|
printAgentCliError(command, error);
|
|
1151
1118
|
}
|
|
1152
1119
|
else {
|
|
@@ -1173,6 +1140,13 @@ export async function dispatchParsedCommand(parsed, startedAt = Date.now()) {
|
|
|
1173
1140
|
commandFlags,
|
|
1174
1141
|
rawFlags: flags,
|
|
1175
1142
|
startedAt,
|
|
1143
|
+
// Agent-safe output auto-selection happens here (not in createCommandContext)
|
|
1144
|
+
// so direct callers/tests keep flag-only behavior. We resolve from the real
|
|
1145
|
+
// stdout TTY + environment, leaving `commandFlags` (and telemetry) untouched.
|
|
1146
|
+
outputMode: resolveOutputMode(commandFlags, {
|
|
1147
|
+
isTTY: process.stdout.isTTY,
|
|
1148
|
+
env: process.env,
|
|
1149
|
+
}),
|
|
1176
1150
|
});
|
|
1177
1151
|
try {
|
|
1178
1152
|
const result = await definition.handler(context);
|
|
@@ -45,5 +45,11 @@ export declare function createCommandContext(input: CommandContextInput, options
|
|
|
45
45
|
startedAt?: number;
|
|
46
46
|
cwd?: string;
|
|
47
47
|
env?: NodeJS.ProcessEnv;
|
|
48
|
+
/**
|
|
49
|
+
* Pre-resolved output mode from the dispatcher (TTY/env auto-detection).
|
|
50
|
+
* When omitted we fall back to flag-only resolution so direct callers
|
|
51
|
+
* (tests, internal helpers) keep their explicit behavior.
|
|
52
|
+
*/
|
|
53
|
+
outputMode?: CliOutputMode;
|
|
48
54
|
}): CommandContext;
|
|
49
55
|
//# sourceMappingURL=command-context.d.ts.map
|
package/dist/command-context.js
CHANGED
|
@@ -5,7 +5,7 @@ function flagEnabled(flags, key) {
|
|
|
5
5
|
export function createCommandContext(input, options = {}) {
|
|
6
6
|
const flags = options.commandFlags ?? input.flags;
|
|
7
7
|
const rawFlags = options.rawFlags ?? input.flags;
|
|
8
|
-
const outputMode = outputModeFromFlags(flags);
|
|
8
|
+
const outputMode = options.outputMode ?? outputModeFromFlags(flags);
|
|
9
9
|
const quiet = flagEnabled(flags, 'quiet');
|
|
10
10
|
const interactive = outputMode === 'human' &&
|
|
11
11
|
!quiet &&
|
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* moda.intelligence.v1 — the unified Moda intelligence wire format (MODA-388).
|
|
3
|
+
*
|
|
4
|
+
* ONE versioned payload that every surface projects from:
|
|
5
|
+
* - CLI `moda ask --json` / `--agent` (the agent-facing contract),
|
|
6
|
+
* - the backend `POST /api/cli/ask` response,
|
|
7
|
+
* - the (future) MCP server's `structuredContent`,
|
|
8
|
+
* - the dashboard UI.
|
|
9
|
+
*
|
|
10
|
+
* Design rules:
|
|
11
|
+
* - snake_case everywhere (no mixed casing — the prior split between the
|
|
12
|
+
* snake_case envelope and the camelCase `production_ask.v0.1` data payload
|
|
13
|
+
* was the main source of agent-integration pain).
|
|
14
|
+
* - It is a SUPERSET. Differentiation between a human reader and an agent is a
|
|
15
|
+
* RENDERING concern at the edge, not a forked schema:
|
|
16
|
+
* · human projection → narrative `answer_markdown`, `summary.confidence`
|
|
17
|
+
* as a word, raw ids/anchors hidden.
|
|
18
|
+
* · agent projection → full `evidence_refs` (with `anchor` + `grounding`),
|
|
19
|
+
* `answer_claims` (claim → evidence), structured
|
|
20
|
+
* `next_commands`.
|
|
21
|
+
* - Additive evolution only within v1; breaking changes bump the version.
|
|
22
|
+
*
|
|
23
|
+
* This module is the SINGLE SOURCE OF TRUTH for the shape. The backend mirrors
|
|
24
|
+
* these field names on the wire and the contract tests validate real CLI output
|
|
25
|
+
* against {@link MODA_INTELLIGENCE_V1_JSON_SCHEMA}.
|
|
26
|
+
*/
|
|
27
|
+
export declare const INTELLIGENCE_SCHEMA_VERSION: "moda.intelligence.v1";
|
|
28
|
+
export type IntelligenceConfidence = 'high' | 'medium' | 'low' | 'unknown';
|
|
29
|
+
/** Where the answer came from. `local_fallback` ⇒ degraded (lower trust). */
|
|
30
|
+
export type IntelligenceSource = 'cloud' | 'local_fallback';
|
|
31
|
+
/** How a signal was derived — a measured fact vs a model/heuristic estimate. */
|
|
32
|
+
export type Provenance = 'measured' | 'inferred';
|
|
33
|
+
/** Whether a suggested command reads, writes, or syncs state. */
|
|
34
|
+
export type CommandMutability = 'read' | 'write' | 'sync' | 'unknown';
|
|
35
|
+
/** Classification of a single quantitative/factual claim in the answer. */
|
|
36
|
+
export type ClaimKind = 'percentage' | 'count' | 'qualitative';
|
|
37
|
+
/**
|
|
38
|
+
* Verdict for one claim made in the answer, checked against the structured tool
|
|
39
|
+
* data the agent actually saw (MODA-377/378). `unverifiable` means the claim is
|
|
40
|
+
* not a checkable figure (or there was no tool data to check it against).
|
|
41
|
+
*/
|
|
42
|
+
export type ClaimStatus = 'grounded' | 'ungrounded' | 'unverifiable';
|
|
43
|
+
export interface IntelligenceSummary {
|
|
44
|
+
text: string;
|
|
45
|
+
confidence: IntelligenceConfidence;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* A structured locator so a surface can deep-link a piece of evidence. All
|
|
49
|
+
* fields optional — different evidence kinds populate different anchors.
|
|
50
|
+
*/
|
|
51
|
+
export interface EvidenceAnchor {
|
|
52
|
+
conversation_id?: string;
|
|
53
|
+
message_index?: number;
|
|
54
|
+
run_id?: string;
|
|
55
|
+
tool_name?: string;
|
|
56
|
+
}
|
|
57
|
+
export interface IntelligenceEvidenceRef {
|
|
58
|
+
/** Stable id, referenced by `findings[].evidence_ref_ids` and `answer_claims[].evidence_ref_ids`. */
|
|
59
|
+
id: string;
|
|
60
|
+
/** 'overview' | 'conversation' | 'message' | 'tool_failure' | 'run' | 'frustration' | 'cluster' | ... */
|
|
61
|
+
kind: string;
|
|
62
|
+
label: string;
|
|
63
|
+
anchor?: EvidenceAnchor;
|
|
64
|
+
/** Short human-readable excerpt of the underlying value. */
|
|
65
|
+
snippet?: string;
|
|
66
|
+
/** measured (exact) vs inferred (model-derived estimate) — MODA-379. */
|
|
67
|
+
grounding: Provenance;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* A claim extracted from the answer with its grounding verdict. `value` is set
|
|
71
|
+
* for numeric claims; `evidence_ref_ids` links to the evidence that supports it
|
|
72
|
+
* (empty when ungrounded/unverifiable).
|
|
73
|
+
*/
|
|
74
|
+
export interface IntelligenceClaim {
|
|
75
|
+
text: string;
|
|
76
|
+
value?: number;
|
|
77
|
+
kind: ClaimKind;
|
|
78
|
+
status: ClaimStatus;
|
|
79
|
+
evidence_ref_ids: string[];
|
|
80
|
+
/** Path into the structured tool data where the value matched, when grounded. */
|
|
81
|
+
matched_path?: string;
|
|
82
|
+
}
|
|
83
|
+
export interface IntelligenceRecommendedAction {
|
|
84
|
+
id: string;
|
|
85
|
+
title: string;
|
|
86
|
+
rationale?: string;
|
|
87
|
+
command?: string;
|
|
88
|
+
mutability: CommandMutability;
|
|
89
|
+
requires_approval: boolean;
|
|
90
|
+
}
|
|
91
|
+
export interface IntelligenceFinding {
|
|
92
|
+
id: string;
|
|
93
|
+
title: string;
|
|
94
|
+
severity?: 'critical' | 'high' | 'medium' | 'low' | 'info';
|
|
95
|
+
description?: string;
|
|
96
|
+
evidence_ref_ids: string[];
|
|
97
|
+
recommended_actions: IntelligenceRecommendedAction[];
|
|
98
|
+
}
|
|
99
|
+
export interface IntelligenceNextCommand {
|
|
100
|
+
command: string;
|
|
101
|
+
purpose?: string;
|
|
102
|
+
mutability: CommandMutability;
|
|
103
|
+
requires_approval: boolean;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The canonical `moda.intelligence.v1` payload. Emitted by the backend ask
|
|
107
|
+
* endpoint and surfaced as the CLI agent envelope's `data` (and by `--json`).
|
|
108
|
+
*/
|
|
109
|
+
export interface ModaIntelligenceV1 {
|
|
110
|
+
schema_version: typeof INTELLIGENCE_SCHEMA_VERSION;
|
|
111
|
+
generated_at: string;
|
|
112
|
+
/** The originating command, e.g. "ask". */
|
|
113
|
+
command: string;
|
|
114
|
+
source: IntelligenceSource;
|
|
115
|
+
/** True when the answer was NOT produced by Moda Cloud intelligence. */
|
|
116
|
+
degraded: boolean;
|
|
117
|
+
question: string;
|
|
118
|
+
summary: IntelligenceSummary;
|
|
119
|
+
/** Full markdown answer (the human-facing narrative). */
|
|
120
|
+
answer_markdown: string;
|
|
121
|
+
/** Per-claim grounding verdicts (agent projection). */
|
|
122
|
+
answer_claims: IntelligenceClaim[];
|
|
123
|
+
/** Ranked findings; may be empty for a plain `ask`. */
|
|
124
|
+
findings: IntelligenceFinding[];
|
|
125
|
+
evidence_refs: IntelligenceEvidenceRef[];
|
|
126
|
+
next_commands: IntelligenceNextCommand[];
|
|
127
|
+
warnings: string[];
|
|
128
|
+
meta?: Record<string, unknown>;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Published draft-07 JSON Schema for {@link ModaIntelligenceV1}. This is what
|
|
132
|
+
* `moda --json-schemas` emits and what the contract tests validate CLI/backend
|
|
133
|
+
* output against. Keep in lockstep with the interfaces above.
|
|
134
|
+
*/
|
|
135
|
+
export declare const MODA_INTELLIGENCE_V1_JSON_SCHEMA: {
|
|
136
|
+
readonly $schema: "http://json-schema.org/draft-07/schema#";
|
|
137
|
+
readonly $id: "moda.intelligence.v1";
|
|
138
|
+
readonly title: "Moda Intelligence v1";
|
|
139
|
+
readonly type: "object";
|
|
140
|
+
readonly additionalProperties: false;
|
|
141
|
+
readonly required: readonly ["schema_version", "generated_at", "command", "source", "degraded", "question", "summary", "answer_markdown", "answer_claims", "findings", "evidence_refs", "next_commands", "warnings"];
|
|
142
|
+
readonly properties: {
|
|
143
|
+
readonly schema_version: {
|
|
144
|
+
readonly const: "moda.intelligence.v1";
|
|
145
|
+
};
|
|
146
|
+
readonly generated_at: {
|
|
147
|
+
readonly type: "string";
|
|
148
|
+
readonly format: "date-time";
|
|
149
|
+
};
|
|
150
|
+
readonly command: {
|
|
151
|
+
readonly type: "string";
|
|
152
|
+
};
|
|
153
|
+
readonly source: {
|
|
154
|
+
readonly type: "string";
|
|
155
|
+
readonly enum: readonly ["cloud", "local_fallback"];
|
|
156
|
+
};
|
|
157
|
+
readonly degraded: {
|
|
158
|
+
readonly type: "boolean";
|
|
159
|
+
};
|
|
160
|
+
readonly question: {
|
|
161
|
+
readonly type: "string";
|
|
162
|
+
};
|
|
163
|
+
readonly summary: {
|
|
164
|
+
readonly type: "object";
|
|
165
|
+
readonly additionalProperties: false;
|
|
166
|
+
readonly required: readonly ["text", "confidence"];
|
|
167
|
+
readonly properties: {
|
|
168
|
+
readonly text: {
|
|
169
|
+
readonly type: "string";
|
|
170
|
+
};
|
|
171
|
+
readonly confidence: {
|
|
172
|
+
readonly type: "string";
|
|
173
|
+
readonly enum: readonly ["high", "medium", "low", "unknown"];
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
readonly answer_markdown: {
|
|
178
|
+
readonly type: "string";
|
|
179
|
+
};
|
|
180
|
+
readonly answer_claims: {
|
|
181
|
+
readonly type: "array";
|
|
182
|
+
readonly items: {
|
|
183
|
+
readonly type: "object";
|
|
184
|
+
readonly additionalProperties: false;
|
|
185
|
+
readonly required: readonly ["text", "kind", "status", "evidence_ref_ids"];
|
|
186
|
+
readonly properties: {
|
|
187
|
+
readonly text: {
|
|
188
|
+
readonly type: "string";
|
|
189
|
+
};
|
|
190
|
+
readonly value: {
|
|
191
|
+
readonly type: "number";
|
|
192
|
+
};
|
|
193
|
+
readonly kind: {
|
|
194
|
+
readonly type: "string";
|
|
195
|
+
readonly enum: readonly ["percentage", "count", "qualitative"];
|
|
196
|
+
};
|
|
197
|
+
readonly status: {
|
|
198
|
+
readonly type: "string";
|
|
199
|
+
readonly enum: readonly ["grounded", "ungrounded", "unverifiable"];
|
|
200
|
+
};
|
|
201
|
+
readonly evidence_ref_ids: {
|
|
202
|
+
readonly type: "array";
|
|
203
|
+
readonly items: {
|
|
204
|
+
readonly type: "string";
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
readonly matched_path: {
|
|
208
|
+
readonly type: "string";
|
|
209
|
+
};
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
readonly findings: {
|
|
214
|
+
readonly type: "array";
|
|
215
|
+
readonly items: {
|
|
216
|
+
readonly type: "object";
|
|
217
|
+
readonly additionalProperties: false;
|
|
218
|
+
readonly required: readonly ["id", "title", "evidence_ref_ids", "recommended_actions"];
|
|
219
|
+
readonly properties: {
|
|
220
|
+
readonly id: {
|
|
221
|
+
readonly type: "string";
|
|
222
|
+
};
|
|
223
|
+
readonly title: {
|
|
224
|
+
readonly type: "string";
|
|
225
|
+
};
|
|
226
|
+
readonly severity: {
|
|
227
|
+
readonly type: "string";
|
|
228
|
+
readonly enum: readonly ["critical", "high", "medium", "low", "info"];
|
|
229
|
+
};
|
|
230
|
+
readonly description: {
|
|
231
|
+
readonly type: "string";
|
|
232
|
+
};
|
|
233
|
+
readonly evidence_ref_ids: {
|
|
234
|
+
readonly type: "array";
|
|
235
|
+
readonly items: {
|
|
236
|
+
readonly type: "string";
|
|
237
|
+
};
|
|
238
|
+
};
|
|
239
|
+
readonly recommended_actions: {
|
|
240
|
+
readonly type: "array";
|
|
241
|
+
readonly items: {
|
|
242
|
+
readonly type: "object";
|
|
243
|
+
readonly additionalProperties: false;
|
|
244
|
+
readonly required: readonly ["id", "title", "mutability", "requires_approval"];
|
|
245
|
+
readonly properties: {
|
|
246
|
+
readonly id: {
|
|
247
|
+
readonly type: "string";
|
|
248
|
+
};
|
|
249
|
+
readonly title: {
|
|
250
|
+
readonly type: "string";
|
|
251
|
+
};
|
|
252
|
+
readonly rationale: {
|
|
253
|
+
readonly type: "string";
|
|
254
|
+
};
|
|
255
|
+
readonly command: {
|
|
256
|
+
readonly type: "string";
|
|
257
|
+
};
|
|
258
|
+
readonly mutability: {
|
|
259
|
+
readonly type: "string";
|
|
260
|
+
readonly enum: readonly ["read", "write", "sync", "unknown"];
|
|
261
|
+
};
|
|
262
|
+
readonly requires_approval: {
|
|
263
|
+
readonly type: "boolean";
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
};
|
|
267
|
+
};
|
|
268
|
+
};
|
|
269
|
+
};
|
|
270
|
+
};
|
|
271
|
+
readonly evidence_refs: {
|
|
272
|
+
readonly type: "array";
|
|
273
|
+
readonly items: {
|
|
274
|
+
readonly type: "object";
|
|
275
|
+
readonly additionalProperties: false;
|
|
276
|
+
readonly required: readonly ["id", "kind", "label", "grounding"];
|
|
277
|
+
readonly properties: {
|
|
278
|
+
readonly id: {
|
|
279
|
+
readonly type: "string";
|
|
280
|
+
};
|
|
281
|
+
readonly kind: {
|
|
282
|
+
readonly type: "string";
|
|
283
|
+
};
|
|
284
|
+
readonly label: {
|
|
285
|
+
readonly type: "string";
|
|
286
|
+
};
|
|
287
|
+
readonly anchor: {
|
|
288
|
+
readonly type: "object";
|
|
289
|
+
readonly additionalProperties: false;
|
|
290
|
+
readonly properties: {
|
|
291
|
+
readonly conversation_id: {
|
|
292
|
+
readonly type: "string";
|
|
293
|
+
};
|
|
294
|
+
readonly message_index: {
|
|
295
|
+
readonly type: "number";
|
|
296
|
+
};
|
|
297
|
+
readonly run_id: {
|
|
298
|
+
readonly type: "string";
|
|
299
|
+
};
|
|
300
|
+
readonly tool_name: {
|
|
301
|
+
readonly type: "string";
|
|
302
|
+
};
|
|
303
|
+
};
|
|
304
|
+
};
|
|
305
|
+
readonly snippet: {
|
|
306
|
+
readonly type: "string";
|
|
307
|
+
};
|
|
308
|
+
readonly grounding: {
|
|
309
|
+
readonly type: "string";
|
|
310
|
+
readonly enum: readonly ["measured", "inferred"];
|
|
311
|
+
};
|
|
312
|
+
};
|
|
313
|
+
};
|
|
314
|
+
};
|
|
315
|
+
readonly next_commands: {
|
|
316
|
+
readonly type: "array";
|
|
317
|
+
readonly items: {
|
|
318
|
+
readonly type: "object";
|
|
319
|
+
readonly additionalProperties: false;
|
|
320
|
+
readonly required: readonly ["command", "mutability", "requires_approval"];
|
|
321
|
+
readonly properties: {
|
|
322
|
+
readonly command: {
|
|
323
|
+
readonly type: "string";
|
|
324
|
+
};
|
|
325
|
+
readonly purpose: {
|
|
326
|
+
readonly type: "string";
|
|
327
|
+
};
|
|
328
|
+
readonly mutability: {
|
|
329
|
+
readonly type: "string";
|
|
330
|
+
readonly enum: readonly ["read", "write", "sync", "unknown"];
|
|
331
|
+
};
|
|
332
|
+
readonly requires_approval: {
|
|
333
|
+
readonly type: "boolean";
|
|
334
|
+
};
|
|
335
|
+
};
|
|
336
|
+
};
|
|
337
|
+
};
|
|
338
|
+
readonly warnings: {
|
|
339
|
+
readonly type: "array";
|
|
340
|
+
readonly items: {
|
|
341
|
+
readonly type: "string";
|
|
342
|
+
};
|
|
343
|
+
};
|
|
344
|
+
readonly meta: {
|
|
345
|
+
readonly type: "object";
|
|
346
|
+
};
|
|
347
|
+
};
|
|
348
|
+
};
|
|
349
|
+
//# sourceMappingURL=intelligence-schema.d.ts.map
|