@moda-ai/cli 1.10.2 → 1.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.
- package/dist/agent-schemas.js +60 -3
- package/dist/auth.js +5 -1
- package/dist/cli.js +124 -38
- package/dist/config.js +5 -3
- package/dist/errors.d.ts +32 -0
- package/dist/errors.js +40 -0
- package/dist/exit-funnel.d.ts +14 -0
- package/dist/exit-funnel.js +49 -0
- package/dist/harness.js +18 -6
- package/dist/init/index.js +57 -4
- package/dist/init/tenant.d.ts +6 -1
- package/dist/init/tenant.js +35 -11
- package/dist/manifest.d.ts +5 -0
- package/dist/manifest.js +111 -0
- package/dist/output.d.ts +44 -4
- package/dist/output.js +337 -32
- package/dist/prompts.d.ts +2 -1
- package/dist/prompts.js +38 -13
- package/dist/redact.d.ts +2 -0
- package/dist/redact.js +81 -0
- package/dist/schemas.d.ts +2 -2
- package/dist/skills.d.ts +8 -2
- package/dist/skills.js +33 -19
- package/package.json +1 -1
- package/skills/moda-cli/SKILL.md +51 -7
package/dist/init/index.js
CHANGED
|
@@ -14,7 +14,7 @@ import { SDK_GUIDE_PATH, writeSdkIntegrationGuide } from './sdk-guide.js';
|
|
|
14
14
|
import { runSdkIntegration } from './sdk-integration.js';
|
|
15
15
|
import { createCommandContext } from '../command-context.js';
|
|
16
16
|
import { VERSION } from '../config.js';
|
|
17
|
-
import { CliInputError } from '../errors.js';
|
|
17
|
+
import { CliAuthError, CliInputError } from '../errors.js';
|
|
18
18
|
import { runHarnessCommand } from '../harness.js';
|
|
19
19
|
import { buildDoctorReport } from '../doctor.js';
|
|
20
20
|
import { renderInitBanner, renderInitComplete, renderInitNote, renderInitSetupPlan, renderInitStep, } from '../tui.js';
|
|
@@ -48,7 +48,11 @@ export async function runInit(flags, options = {}) {
|
|
|
48
48
|
let token = loadToken();
|
|
49
49
|
if (!token) {
|
|
50
50
|
if (json || agent) {
|
|
51
|
-
throw new
|
|
51
|
+
throw new CliAuthError('Browser authentication is required before non-interactive init can continue.', {
|
|
52
|
+
reason: 'no_stored_credentials',
|
|
53
|
+
login_command: ['moda', 'auth', 'login'],
|
|
54
|
+
resume_command: ['moda', 'init', ...resumeFlagsForInit(flags)],
|
|
55
|
+
}, 'Run `moda auth login`, then re-run `moda init`.');
|
|
52
56
|
}
|
|
53
57
|
let action = 'login';
|
|
54
58
|
if (!yes) {
|
|
@@ -73,7 +77,12 @@ export async function runInit(flags, options = {}) {
|
|
|
73
77
|
// Step 3: Tenant + API Key
|
|
74
78
|
log(renderInitStep(3, 7, 'Workspace & Profile'));
|
|
75
79
|
emit('workspace', 'Selecting workspace and creating API key.');
|
|
76
|
-
const { apiKey, tenantName } = await selectTenantAndCreateKey(
|
|
80
|
+
const { apiKey, tenantName } = await selectTenantAndCreateKey({
|
|
81
|
+
tenantId: stringFlag(flagValue(flags, 'tenant-id', 'tenant_id')),
|
|
82
|
+
nonInteractive: json || agent,
|
|
83
|
+
silent: !human,
|
|
84
|
+
resumeCommand: ['moda', 'init', ...resumeFlagsForInit(flags)],
|
|
85
|
+
});
|
|
77
86
|
log(renderInitNote(`Active workspace: ${tenantName}`));
|
|
78
87
|
emit('workspace', `Active workspace: ${tenantName}`, 'completed');
|
|
79
88
|
phases.push({ id: 'workspace', title: 'Workspace & Profile', status: 'completed', details: tenantName });
|
|
@@ -86,7 +95,12 @@ export async function runInit(flags, options = {}) {
|
|
|
86
95
|
positionals: ['analyze'],
|
|
87
96
|
flags: commandFlags({
|
|
88
97
|
summary: true,
|
|
89
|
-
|
|
98
|
+
// In machine mode the nested harness scan must not emit its own
|
|
99
|
+
// `needs_input` with a `moda harness analyze --yes` resume command — an
|
|
100
|
+
// orchestrator obeying it would resume the scan and silently skip the
|
|
101
|
+
// rest of init. The broad local read is part of the init flow the caller
|
|
102
|
+
// already opted into, so auto-approve it here; human init still confirms.
|
|
103
|
+
yes: yes || json || agent,
|
|
90
104
|
json: json || agent,
|
|
91
105
|
agent,
|
|
92
106
|
analyst: stringFlag(flags.analyst) ?? 'auto',
|
|
@@ -139,6 +153,15 @@ export async function runInit(flags, options = {}) {
|
|
|
139
153
|
configureCiCd: await shouldConfigureCiCd(flags, yes),
|
|
140
154
|
configureAutosync: await shouldConfigureAutosync(flags, yes),
|
|
141
155
|
});
|
|
156
|
+
if (json || agent) {
|
|
157
|
+
const skipped = setupPlan
|
|
158
|
+
.filter((action) => (action.category === 'sdk' || action.category === 'ci-cd' || action.category === 'autosync') &&
|
|
159
|
+
action.approved === false)
|
|
160
|
+
.map((action) => `${action.category}: ${action.command ?? 'explicit flag required'}`);
|
|
161
|
+
if (skipped.length > 0) {
|
|
162
|
+
emit('plan', `Non-interactive init skipped optional actions (${skipped.join('; ')}).`, 'warning');
|
|
163
|
+
}
|
|
164
|
+
}
|
|
142
165
|
log(renderInitSetupPlan(setupPlan));
|
|
143
166
|
emit('plan', 'Setup plan ready.', 'completed');
|
|
144
167
|
phases.push({ id: 'plan', title: 'Setup Plan', status: 'completed' });
|
|
@@ -497,6 +520,36 @@ function commandFlags(flags) {
|
|
|
497
520
|
function stringFlag(value) {
|
|
498
521
|
return typeof value === 'string' && value.trim().length > 0 ? value : undefined;
|
|
499
522
|
}
|
|
523
|
+
function resumeFlagsForInit(flags) {
|
|
524
|
+
const passthrough = [
|
|
525
|
+
'profile',
|
|
526
|
+
'tenant-id',
|
|
527
|
+
'offline',
|
|
528
|
+
'analyst',
|
|
529
|
+
'sdk-integrate',
|
|
530
|
+
'ci-cd',
|
|
531
|
+
'autosync',
|
|
532
|
+
'no-sdk-integrate',
|
|
533
|
+
'no-ci-cd',
|
|
534
|
+
'no-autosync',
|
|
535
|
+
'yes',
|
|
536
|
+
'agent',
|
|
537
|
+
'json',
|
|
538
|
+
'stream',
|
|
539
|
+
];
|
|
540
|
+
const out = [];
|
|
541
|
+
for (const key of passthrough) {
|
|
542
|
+
const value = flagValue(flags, key, key.replace(/-/g, '_'));
|
|
543
|
+
if (value === undefined || value === false || value === 'false')
|
|
544
|
+
continue;
|
|
545
|
+
const flag = `--${key}`;
|
|
546
|
+
if (value === true || value === 'true')
|
|
547
|
+
out.push(flag);
|
|
548
|
+
else
|
|
549
|
+
out.push(flag, String(value));
|
|
550
|
+
}
|
|
551
|
+
return out;
|
|
552
|
+
}
|
|
500
553
|
// Coding-agent capture is temporarily disabled; restore this prompt with the hooks phase.
|
|
501
554
|
// async function shouldIngestCodingAgentTraces(
|
|
502
555
|
// flags: Record<string, unknown>,
|
package/dist/init/tenant.d.ts
CHANGED
|
@@ -4,6 +4,11 @@ interface BootstrapResult {
|
|
|
4
4
|
tenantName: string;
|
|
5
5
|
tenantSlug: string;
|
|
6
6
|
}
|
|
7
|
-
export declare function selectTenantAndCreateKey(
|
|
7
|
+
export declare function selectTenantAndCreateKey(options?: {
|
|
8
|
+
tenantId?: string;
|
|
9
|
+
nonInteractive?: boolean;
|
|
10
|
+
silent?: boolean;
|
|
11
|
+
resumeCommand?: string[];
|
|
12
|
+
}): Promise<BootstrapResult>;
|
|
8
13
|
export {};
|
|
9
14
|
//# sourceMappingURL=tenant.d.ts.map
|
package/dist/init/tenant.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import { select } from '@inquirer/prompts';
|
|
3
3
|
import { authFetch } from '../auth.js';
|
|
4
4
|
import { resolveIngestUrl, saveCliConfig } from '../config.js';
|
|
5
|
-
|
|
5
|
+
import { CliInputError, CliInputRequiredError } from '../errors.js';
|
|
6
|
+
export async function selectTenantAndCreateKey(options = {}) {
|
|
6
7
|
// 1. Fetch CLI context
|
|
7
8
|
const contextRes = await authFetch('/api/cli/context');
|
|
8
9
|
if (!contextRes.ok) {
|
|
@@ -10,16 +11,39 @@ export async function selectTenantAndCreateKey() {
|
|
|
10
11
|
throw new Error(`Failed to fetch context (${contextRes.status}): ${body}`);
|
|
11
12
|
}
|
|
12
13
|
const ctx = (await contextRes.json());
|
|
13
|
-
|
|
14
|
+
if (!options.silent)
|
|
15
|
+
console.log(` Authenticated as ${ctx.user.email}`);
|
|
14
16
|
// 2. Select tenant
|
|
15
17
|
if (ctx.tenants.length === 0) {
|
|
16
|
-
|
|
17
|
-
process.exit(1);
|
|
18
|
+
throw new CliInputError('No organizations found. Create one at https://moda.dev', 'Create an organization in Moda, then rerun `moda init`.');
|
|
18
19
|
}
|
|
19
20
|
let tenantId;
|
|
20
|
-
if (
|
|
21
|
+
if (options.tenantId) {
|
|
22
|
+
const selected = ctx.tenants.find((tenant) => tenant.id === options.tenantId);
|
|
23
|
+
if (!selected) {
|
|
24
|
+
throw new CliInputError(`Tenant '${options.tenantId}' is not available for the authenticated user.`, 'Run `moda init` without --tenant-id in a human terminal, or choose a tenant from the needs_input event.');
|
|
25
|
+
}
|
|
26
|
+
tenantId = selected.id;
|
|
27
|
+
if (!options.silent)
|
|
28
|
+
console.log(` Organization: ${selected.name}`);
|
|
29
|
+
}
|
|
30
|
+
else if (ctx.tenants.length === 1) {
|
|
21
31
|
tenantId = ctx.tenants[0].id;
|
|
22
|
-
|
|
32
|
+
if (!options.silent)
|
|
33
|
+
console.log(` Organization: ${ctx.tenants[0].name}`);
|
|
34
|
+
}
|
|
35
|
+
else if (options.nonInteractive) {
|
|
36
|
+
throw new CliInputRequiredError('Multiple Moda organizations are available; choose one and re-run with --tenant-id.', {
|
|
37
|
+
id: 'init_tenant_selection',
|
|
38
|
+
question: 'Select organization',
|
|
39
|
+
kind: 'select',
|
|
40
|
+
choices: ctx.tenants.map((tenant) => ({
|
|
41
|
+
value: tenant.id,
|
|
42
|
+
label: `${tenant.name} (${tenant.role})`,
|
|
43
|
+
resume_flags: ['--tenant-id', tenant.id],
|
|
44
|
+
})),
|
|
45
|
+
resume_command: options.resumeCommand,
|
|
46
|
+
}, 'Re-run `moda init --tenant-id <tenant_id>`.');
|
|
23
47
|
}
|
|
24
48
|
else {
|
|
25
49
|
tenantId = await select({
|
|
@@ -37,9 +61,7 @@ export async function selectTenantAndCreateKey() {
|
|
|
37
61
|
body: JSON.stringify({ tenantId }),
|
|
38
62
|
});
|
|
39
63
|
if (bootstrapRes.status === 403) {
|
|
40
|
-
|
|
41
|
-
console.error(' Ask your organization owner to upgrade your role.');
|
|
42
|
-
process.exit(1);
|
|
64
|
+
throw new CliInputError('You need admin or owner access to create API keys.', 'Ask your organization owner to upgrade your role.');
|
|
43
65
|
}
|
|
44
66
|
if (!bootstrapRes.ok) {
|
|
45
67
|
const body = await bootstrapRes.text();
|
|
@@ -55,8 +77,10 @@ export async function selectTenantAndCreateKey() {
|
|
|
55
77
|
tenant_id: result.tenantId,
|
|
56
78
|
ingest_url: resolveIngestUrl(),
|
|
57
79
|
});
|
|
58
|
-
|
|
59
|
-
|
|
80
|
+
if (!options.silent) {
|
|
81
|
+
console.log(' API key + tenant saved to ~/.moda/config.json\n');
|
|
82
|
+
console.log(' (Set MODA_API_KEY / MODA_TENANT_ID to override for scripts/CI.)\n');
|
|
83
|
+
}
|
|
60
84
|
return result;
|
|
61
85
|
}
|
|
62
86
|
//# sourceMappingURL=tenant.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CommandMetadata } from './command-registry.js';
|
|
2
|
+
export declare const MANIFEST_SCHEMA_VERSION = "moda.manifest.v1";
|
|
3
|
+
export declare function buildManifest(commands: CommandMetadata[]): Record<string, unknown>;
|
|
4
|
+
export declare function renderManifestHuman(manifest: Record<string, unknown>): string;
|
|
5
|
+
//# sourceMappingURL=manifest.d.ts.map
|
package/dist/manifest.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { VERSION } from './config.js';
|
|
2
|
+
export const MANIFEST_SCHEMA_VERSION = 'moda.manifest.v1';
|
|
3
|
+
export function buildManifest(commands) {
|
|
4
|
+
return {
|
|
5
|
+
schema_version: MANIFEST_SCHEMA_VERSION,
|
|
6
|
+
cli_version: VERSION,
|
|
7
|
+
invocations: [
|
|
8
|
+
'bunx @moda-ai/cli',
|
|
9
|
+
'npx -y @moda-ai/cli',
|
|
10
|
+
'moda',
|
|
11
|
+
],
|
|
12
|
+
global_flags: [
|
|
13
|
+
'--agent',
|
|
14
|
+
'--stream',
|
|
15
|
+
'--json',
|
|
16
|
+
'--human',
|
|
17
|
+
'--profile <name>',
|
|
18
|
+
'--quiet',
|
|
19
|
+
'--no-telemetry',
|
|
20
|
+
'--no-update-check',
|
|
21
|
+
'--json-schemas',
|
|
22
|
+
],
|
|
23
|
+
env: [
|
|
24
|
+
'MODA_FORMAT',
|
|
25
|
+
'MODA_AGENT',
|
|
26
|
+
'MODA_API_KEY',
|
|
27
|
+
'MODA_TENANT_ID',
|
|
28
|
+
'MODA_PROFILE',
|
|
29
|
+
'MODA_BASE_URL',
|
|
30
|
+
'MODA_HEARTBEAT_MS',
|
|
31
|
+
'MODA_AGENT_MAX_OUTPUT_BYTES',
|
|
32
|
+
'MODA_CLI_TELEMETRY',
|
|
33
|
+
'MODA_CLI_UPDATE_CHECK',
|
|
34
|
+
],
|
|
35
|
+
exit_codes: [
|
|
36
|
+
{ code: 0, name: 'ok', meaning: 'Command completed successfully.' },
|
|
37
|
+
{ code: 1, name: 'error', meaning: 'Command, input, API, network, or unexpected failure.' },
|
|
38
|
+
{ code: 3, name: 'degraded', meaning: 'Reserved for `moda ask` local fallback.' },
|
|
39
|
+
{ code: 4, name: 'auth_required', meaning: 'Run login_command, then resume.' },
|
|
40
|
+
{ code: 5, name: 'input_required', meaning: 'Choose from input_request choices, then resume.' },
|
|
41
|
+
{ code: 130, name: 'cancelled', meaning: 'Interrupted or output consumer closed.' },
|
|
42
|
+
],
|
|
43
|
+
events: [
|
|
44
|
+
event('started', 'First event for every agent stream.', false),
|
|
45
|
+
event('progress', 'Progress update while work continues.', false),
|
|
46
|
+
event('warning', 'Non-fatal warning or skipped action.', false),
|
|
47
|
+
event('artifact', 'File or artifact produced by a command.', false),
|
|
48
|
+
event('heartbeat', 'Idle liveness event emitted after MODA_HEARTBEAT_MS without output.', false),
|
|
49
|
+
event('needs_input', 'Terminal event requesting exit-and-reinvoke input.', true),
|
|
50
|
+
event('auth_required', 'Terminal event requesting authentication before retry.', true),
|
|
51
|
+
event('completed', 'Terminal success event.', true),
|
|
52
|
+
event('error', 'Terminal failure event.', true),
|
|
53
|
+
event('cancelled', 'Terminal cancellation event.', true),
|
|
54
|
+
event('approval_required', 'Deprecated; use needs_input.', true, true),
|
|
55
|
+
],
|
|
56
|
+
schemas: [
|
|
57
|
+
'moda.agent.v1',
|
|
58
|
+
'moda.agent_event.v1',
|
|
59
|
+
'moda.intelligence.v1',
|
|
60
|
+
'production_ask.v0.1',
|
|
61
|
+
],
|
|
62
|
+
commands: commands.map((command) => ({
|
|
63
|
+
name: command.name,
|
|
64
|
+
aliases: command.aliases ?? [],
|
|
65
|
+
summary: command.description,
|
|
66
|
+
output_modes: command.outputModes,
|
|
67
|
+
streaming: command.outputModes.includes('agent-stream') || command.outputModes.includes('agent'),
|
|
68
|
+
examples: command.examples,
|
|
69
|
+
auth: command.auth,
|
|
70
|
+
mutability: command.mutability,
|
|
71
|
+
exit_codes: exitCodesForCommand(command.name),
|
|
72
|
+
})),
|
|
73
|
+
concepts: [
|
|
74
|
+
{ term: 'tenant', meaning: 'A Moda organization/workspace that owns data, prompts, skills, and API keys.' },
|
|
75
|
+
{ term: 'profile', meaning: 'A named local CLI configuration under ~/.moda that selects environment, tenant, and secret references.' },
|
|
76
|
+
{ term: 'harness', meaning: 'Moda’s local graph of runtime agents, prompts, tools, identities, and deployments in a codebase.' },
|
|
77
|
+
{ term: 'harness report', meaning: 'A cited analyst artifact under .moda/ that justifies the harness graph before sync.' },
|
|
78
|
+
{ term: 'conversation', meaning: 'A user-agent interaction thread stored in Moda analytics.' },
|
|
79
|
+
{ term: 'trace', meaning: 'Raw OTLP span evidence for one run or conversation, exposed by `moda audit`.' },
|
|
80
|
+
{ term: 'ingest key', meaning: 'A `moda_sk_` API key for SDKs, CI, and Data API calls. Treat it as a secret.' },
|
|
81
|
+
{ term: 'CLI session token', meaning: 'A local browser-auth session token used by CLI auth/bootstrap flows, not by application SDKs.' },
|
|
82
|
+
{ term: 'prompt', meaning: 'A code-first prompt file tracked by `.moda/prompts.yml` and synced to Moda.' },
|
|
83
|
+
{ term: 'skill', meaning: 'A SKILL.md agent instruction file generated by or synced to Moda.' },
|
|
84
|
+
],
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
export function renderManifestHuman(manifest) {
|
|
88
|
+
const commands = Array.isArray(manifest.commands) ? manifest.commands : [];
|
|
89
|
+
return [
|
|
90
|
+
`Moda CLI manifest ${manifest.cli_version ?? ''}`,
|
|
91
|
+
'',
|
|
92
|
+
'Commands:',
|
|
93
|
+
...commands.map((command) => {
|
|
94
|
+
const row = command;
|
|
95
|
+
return ` ${row.name ?? 'unknown'} - ${row.summary ?? ''}`;
|
|
96
|
+
}),
|
|
97
|
+
'',
|
|
98
|
+
'Run `moda manifest --json` for the full machine-readable contract.',
|
|
99
|
+
].join('\n');
|
|
100
|
+
}
|
|
101
|
+
function event(name, when, terminal, deprecated = false) {
|
|
102
|
+
return { name, event_version: 1, when, terminal, ...(deprecated ? { deprecated: true } : {}) };
|
|
103
|
+
}
|
|
104
|
+
function exitCodesForCommand(command) {
|
|
105
|
+
if (command === 'ask')
|
|
106
|
+
return [0, 1, 3, 4, 5, 130];
|
|
107
|
+
if (command === 'init' || command === 'harness')
|
|
108
|
+
return [0, 1, 4, 5, 130];
|
|
109
|
+
return [0, 1, 4, 130];
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=manifest.js.map
|
package/dist/output.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type AgentAuthRequest, type AgentInputRequest } from './errors.js';
|
|
1
2
|
export type CliOutputMode = 'human' | 'json' | 'agent' | 'agent-stream';
|
|
2
3
|
export declare const AGENT_SCHEMA_VERSION = "moda.agent.v1";
|
|
3
4
|
export declare const AGENT_EVENT_SCHEMA_VERSION = "moda.agent_event.v1";
|
|
@@ -6,12 +7,20 @@ export declare const AGENT_EVENT_SCHEMA_VERSION = "moda.agent_event.v1";
|
|
|
6
7
|
* 0 ok — grounded answer from Moda Cloud intelligence.
|
|
7
8
|
* 3 degraded — answer produced from a local/degraded fallback (lower trust).
|
|
8
9
|
* 1 error — command/input/unexpected failure (see envelope `errors[]`).
|
|
10
|
+
* 4 auth — login or token renewal required before retrying.
|
|
11
|
+
* 5 input — non-interactive caller must choose and re-invoke.
|
|
12
|
+
* 130 cancel — interrupted or the output consumer closed the pipe.
|
|
9
13
|
* `EXIT_DEGRADED` is intentionally distinct so a caller can tell a degraded
|
|
10
14
|
* answer apart from both success and hard failure without parsing the payload.
|
|
11
15
|
*/
|
|
12
16
|
export declare const EXIT_OK = 0;
|
|
13
17
|
export declare const EXIT_ERROR = 1;
|
|
14
18
|
export declare const EXIT_DEGRADED = 3;
|
|
19
|
+
export declare const EXIT_AUTH_REQUIRED = 4;
|
|
20
|
+
export declare const EXIT_INPUT_REQUIRED = 5;
|
|
21
|
+
export declare const EXIT_CANCELLED = 130;
|
|
22
|
+
export declare const AGENT_ERROR_CODES: readonly ["input_error", "api_error", "network_error", "auth_required", "input_required", "cancelled", "command_error", "unknown_error", "cloud_unavailable"];
|
|
23
|
+
export type AgentErrorCode = typeof AGENT_ERROR_CODES[number];
|
|
15
24
|
export type AgentStatus = 'ok' | 'degraded' | 'error';
|
|
16
25
|
export type AgentConfidence = 'high' | 'medium' | 'low' | 'unknown';
|
|
17
26
|
export interface AgentSummary {
|
|
@@ -54,10 +63,12 @@ export interface AgentArtifact {
|
|
|
54
63
|
description?: string;
|
|
55
64
|
}
|
|
56
65
|
export interface AgentError {
|
|
57
|
-
code: string;
|
|
66
|
+
code: AgentErrorCode | string;
|
|
58
67
|
message: string;
|
|
59
68
|
cause?: string;
|
|
60
69
|
suggested_commands?: string[];
|
|
70
|
+
input_request?: AgentInputRequest;
|
|
71
|
+
auth?: AgentAuthRequest;
|
|
61
72
|
blocking: boolean;
|
|
62
73
|
}
|
|
63
74
|
export interface AgentEnvelope {
|
|
@@ -80,9 +91,12 @@ export interface AgentEnvelope {
|
|
|
80
91
|
}
|
|
81
92
|
export interface AgentEvent {
|
|
82
93
|
schema_version: typeof AGENT_EVENT_SCHEMA_VERSION;
|
|
83
|
-
event: 'started' | 'progress' | 'artifact' | 'approval_required' | 'completed' | 'error';
|
|
94
|
+
event: 'started' | 'progress' | 'artifact' | 'approval_required' | 'completed' | 'error' | 'heartbeat' | 'needs_input' | 'auth_required' | 'cancelled' | 'warning';
|
|
84
95
|
command: string;
|
|
85
96
|
generated_at: string;
|
|
97
|
+
run_id?: string;
|
|
98
|
+
seq?: number;
|
|
99
|
+
event_version?: number;
|
|
86
100
|
status?: AgentStatus;
|
|
87
101
|
phase?: string;
|
|
88
102
|
message?: string;
|
|
@@ -90,6 +104,8 @@ export interface AgentEvent {
|
|
|
90
104
|
artifact?: AgentArtifact;
|
|
91
105
|
result?: AgentEnvelope;
|
|
92
106
|
error?: AgentError;
|
|
107
|
+
input_request?: AgentInputRequest;
|
|
108
|
+
auth?: AgentAuthRequest;
|
|
93
109
|
}
|
|
94
110
|
export interface AgentWriteOptions {
|
|
95
111
|
summary?: string | Partial<AgentSummary>;
|
|
@@ -109,7 +125,29 @@ export interface CliOutput {
|
|
|
109
125
|
meta?: Record<string, unknown>;
|
|
110
126
|
} & AgentWriteOptions): void;
|
|
111
127
|
writeEvent(event: Omit<AgentEvent, 'schema_version' | 'command' | 'generated_at'>): void;
|
|
128
|
+
writeError(error: unknown): void;
|
|
129
|
+
writeCancelled(reason?: string): void;
|
|
130
|
+
hasTerminalOutput(): boolean;
|
|
131
|
+
close(): void;
|
|
112
132
|
}
|
|
133
|
+
interface OutputRunState {
|
|
134
|
+
runId: string;
|
|
135
|
+
seq: number;
|
|
136
|
+
started: boolean;
|
|
137
|
+
terminal: boolean;
|
|
138
|
+
startedAt: number;
|
|
139
|
+
lastEventAt: number;
|
|
140
|
+
heartbeat?: NodeJS.Timeout;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* True once an EPIPE from a closed stdout/stderr consumer has been observed.
|
|
144
|
+
* The stream error listeners above own this state; expose it so callers can
|
|
145
|
+
* detect consumer-cancelled runs explicitly instead of sniffing the global
|
|
146
|
+
* `process.exitCode`.
|
|
147
|
+
*/
|
|
148
|
+
export declare function wasOutputCancelled(): boolean;
|
|
149
|
+
export declare function safeWriteStdout(text: string): boolean;
|
|
150
|
+
export declare function safeWriteStderr(text: string): boolean;
|
|
113
151
|
/** Flag-only resolution (default human). Kept for callers that only have flags. */
|
|
114
152
|
export declare function outputModeFromFlags(flags: Record<string, string>): CliOutputMode;
|
|
115
153
|
/**
|
|
@@ -127,6 +165,7 @@ export declare function createCliOutput(options: {
|
|
|
127
165
|
command: string;
|
|
128
166
|
mode: CliOutputMode;
|
|
129
167
|
quiet?: boolean;
|
|
168
|
+
runId?: string;
|
|
130
169
|
}): CliOutput;
|
|
131
170
|
export declare function createAgentEnvelope(options: {
|
|
132
171
|
command: string;
|
|
@@ -135,7 +174,8 @@ export declare function createAgentEnvelope(options: {
|
|
|
135
174
|
profile?: string;
|
|
136
175
|
meta?: Record<string, unknown>;
|
|
137
176
|
} & AgentWriteOptions): AgentEnvelope;
|
|
138
|
-
export declare function createAgentErrorEnvelope(command: string, error: AgentError): AgentEnvelope;
|
|
139
|
-
export declare function createAgentEvent(command: string, event: Omit<AgentEvent, 'schema_version' | 'command' | 'generated_at'
|
|
177
|
+
export declare function createAgentErrorEnvelope(command: string, error: AgentError, runId?: string): AgentEnvelope;
|
|
178
|
+
export declare function createAgentEvent(command: string, event: Omit<AgentEvent, 'schema_version' | 'command' | 'generated_at' | 'run_id' | 'seq'>, state?: OutputRunState): AgentEvent;
|
|
140
179
|
export declare function errorToAgentError(error: unknown): AgentError;
|
|
180
|
+
export {};
|
|
141
181
|
//# sourceMappingURL=output.d.ts.map
|