@mono-agent/agent-app 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.
- package/README.md +85 -0
- package/dist/app-config.d.ts +36 -0
- package/dist/app-config.d.ts.map +1 -0
- package/dist/app-config.js +164 -0
- package/dist/app-config.js.map +1 -0
- package/dist/app.d.ts +60 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +416 -0
- package/dist/app.js.map +1 -0
- package/dist/channels.d.ts +110 -0
- package/dist/channels.d.ts.map +1 -0
- package/dist/channels.js +304 -0
- package/dist/channels.js.map +1 -0
- package/dist/cli.d.ts +14 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +240 -0
- package/dist/cli.js.map +1 -0
- package/dist/doctor.d.ts +24 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +181 -0
- package/dist/doctor.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/init.d.ts +30 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +126 -0
- package/dist/init.js.map +1 -0
- package/package.json +47 -0
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# @mono-agent/agent-app
|
|
2
|
+
|
|
3
|
+
Config-first mono-agent host. Reads one `mono-agent.config.json` in a folder,
|
|
4
|
+
builds the configured responder, and starts every configured communication
|
|
5
|
+
channel plus the local operator console and traceability. Ships the
|
|
6
|
+
`mono-agent` CLI (`init`, `validate`, `start`) so an agent folder works without
|
|
7
|
+
hand-written composition code.
|
|
8
|
+
|
|
9
|
+
## Category
|
|
10
|
+
|
|
11
|
+
Category: `app`
|
|
12
|
+
|
|
13
|
+
## Responsibility
|
|
14
|
+
|
|
15
|
+
Turn a folder's `mono-agent.config.json` into a running agent host:
|
|
16
|
+
|
|
17
|
+
- Aggregate the adapter-neutral core config and every channel section
|
|
18
|
+
(`telegram`, `slack`, `a2a`, `webhook`, `openaiApi`, `cron`, `whatsapp`).
|
|
19
|
+
- Build the shared runtime/responder through `@mono-agent/agent-host`
|
|
20
|
+
(including `runtime.fallbackModels` backup chains).
|
|
21
|
+
- Drive each channel through a uniform driver contract with per-channel
|
|
22
|
+
`disabled` / `waiting_for_config` / `running` / `failed` status.
|
|
23
|
+
- Start the operator console first and re-apply config writes in-process.
|
|
24
|
+
- Register the host as a traceability source.
|
|
25
|
+
- Scaffold (`mono-agent init`) and validate (`mono-agent validate`) agent
|
|
26
|
+
folders non-destructively.
|
|
27
|
+
|
|
28
|
+
## Install / Usage
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# inside the workspace
|
|
32
|
+
pnpm --filter @mono-agent/agent-app run build
|
|
33
|
+
|
|
34
|
+
# scaffold and run an agent folder
|
|
35
|
+
cd /path/to/agent-folder
|
|
36
|
+
node <workspace>/packages/agent-app/dist/cli.js init --model claude:claude-sonnet-4-6
|
|
37
|
+
node <workspace>/packages/agent-app/dist/cli.js validate
|
|
38
|
+
node <workspace>/packages/agent-app/dist/cli.js start
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Programmatic:
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import { startMonoAgentApp } from "@mono-agent/agent-app";
|
|
45
|
+
|
|
46
|
+
const app = await startMonoAgentApp({ cwd: "/path/to/agent-folder" });
|
|
47
|
+
console.log(app.operatorConsole?.appUrl, app.channelStatuses());
|
|
48
|
+
await app.stop();
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Public API
|
|
52
|
+
|
|
53
|
+
- `startMonoAgentApp(options)` → `MonoAgentApp` (statuses, `applyConfigChange`,
|
|
54
|
+
`startChannelIfConfigured`, `stop`).
|
|
55
|
+
- `defaultChannelDrivers(overrides)` plus per-channel
|
|
56
|
+
`create<Channel>ChannelDriver(overrides)` factories with test seams.
|
|
57
|
+
- `initMonoAgentFolder(options)` / `validateMonoAgentFolder(options)`.
|
|
58
|
+
- `MONO_AGENT_APP_FIELD_GROUPS` and the `resolveApp*` traceability/artifact
|
|
59
|
+
resolvers for operator-console wiring.
|
|
60
|
+
- `runCli(argv)` / `parseCliArgs(argv)` backing the `mono-agent` bin.
|
|
61
|
+
|
|
62
|
+
## Dependency Boundary
|
|
63
|
+
|
|
64
|
+
Depends on `core`, `runtime`, `execution`, `observability`, `communication`,
|
|
65
|
+
and `operator-surface` packages. It is the only publishable package allowed to
|
|
66
|
+
compose communication adapters; adapters never depend on it.
|
|
67
|
+
|
|
68
|
+
## What This Package Does Not Own
|
|
69
|
+
|
|
70
|
+
- Adapter transports, credentials, or allowlists (owned by each
|
|
71
|
+
`*-adapter` package).
|
|
72
|
+
- Core config schema and loading (owned by `@mono-agent/config`).
|
|
73
|
+
- Harness/runtime composition internals (owned by `@mono-agent/agent-host`).
|
|
74
|
+
- Multi-agent orchestration (owned by `@mono-agent/agent-orchestrator`).
|
|
75
|
+
|
|
76
|
+
## Verification
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
pnpm --filter @mono-agent/agent-app run typecheck
|
|
80
|
+
pnpm --filter @mono-agent/agent-app run test
|
|
81
|
+
pnpm run check:architecture
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Smoke path: `mono-agent init` in a temp folder, `mono-agent validate`, then
|
|
85
|
+
`mono-agent start` and a `curl` POST against the printed webhook invoke URL.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { MonoAgentConfigError } from "@mono-agent/config";
|
|
2
|
+
import type { MonoAgentConfig } from "@mono-agent/config";
|
|
3
|
+
import type { FieldGroup } from "@mono-agent/settings";
|
|
4
|
+
/**
|
|
5
|
+
* Every settings group a config-first host edits through the operator console:
|
|
6
|
+
* the adapter-neutral core config plus one group per communication channel.
|
|
7
|
+
*/
|
|
8
|
+
export declare const MONO_AGENT_APP_FIELD_GROUPS: readonly FieldGroup[];
|
|
9
|
+
export interface MonoAgentAppConfigInput {
|
|
10
|
+
readonly env: Record<string, string | undefined>;
|
|
11
|
+
readonly cwd: string;
|
|
12
|
+
readonly configPath: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function loadAppCoreConfig(input: MonoAgentAppConfigInput): Promise<MonoAgentConfig>;
|
|
15
|
+
export declare function isAppCoreConfigError(error: unknown): error is MonoAgentConfigError;
|
|
16
|
+
/**
|
|
17
|
+
* Trace defaults a host can override without touching the user's config file
|
|
18
|
+
* (e.g. the final demo labels its source "Final Agent Demo").
|
|
19
|
+
*/
|
|
20
|
+
export interface AppTraceDefaults {
|
|
21
|
+
readonly sourceIdPrefix?: string;
|
|
22
|
+
readonly sourceLabel?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The resolvers below intentionally tolerate an incomplete or invalid config
|
|
26
|
+
* file: observability and the operator console must stay usable while the
|
|
27
|
+
* user is still fixing their config, so they fall back to defaults instead of
|
|
28
|
+
* throwing on unreadable JSON.
|
|
29
|
+
*/
|
|
30
|
+
export declare function resolveAppArtifactDir(input: MonoAgentAppConfigInput): Promise<string>;
|
|
31
|
+
export declare function resolveAppTraceRegistryDir(input: MonoAgentAppConfigInput): Promise<string>;
|
|
32
|
+
export declare function resolveAppTraceSourceId(input: MonoAgentAppConfigInput, defaults?: AppTraceDefaults): Promise<string>;
|
|
33
|
+
export declare function resolveAppTraceSourceLabel(input: MonoAgentAppConfigInput, defaults?: AppTraceDefaults): Promise<string>;
|
|
34
|
+
export declare function resolveAppTraceHeartbeatMs(input: MonoAgentAppConfigInput): Promise<number>;
|
|
35
|
+
export declare function resolveAppTraceStaleAfterMs(input: MonoAgentAppConfigInput): Promise<number>;
|
|
36
|
+
//# sourceMappingURL=app-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-config.d.ts","sourceRoot":"","sources":["../src/app-config.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,oBAAoB,EAErB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,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KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC,CASjG"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
import { CORE_AGENT_FIELD_GROUPS, loadMonoAgentConfigWithSources, MonoAgentConfigError, readMonoAgentConfigJson, } from "@mono-agent/config";
|
|
5
|
+
import { a2aFieldGroup } from "@mono-agent/a2a-adapter";
|
|
6
|
+
import { cronFieldGroup } from "@mono-agent/cron-adapter";
|
|
7
|
+
import { openAIApiFieldGroup } from "@mono-agent/openai-api-adapter";
|
|
8
|
+
import { slackFieldGroup } from "@mono-agent/slack-adapter";
|
|
9
|
+
import { telegramFieldGroup } from "@mono-agent/telegram-adapter";
|
|
10
|
+
import { webhookFieldGroup } from "@mono-agent/webhook-adapter";
|
|
11
|
+
import { whatsappFieldGroup } from "@mono-agent/whatsapp-adapter";
|
|
12
|
+
/**
|
|
13
|
+
* Every settings group a config-first host edits through the operator console:
|
|
14
|
+
* the adapter-neutral core config plus one group per communication channel.
|
|
15
|
+
*/
|
|
16
|
+
export const MONO_AGENT_APP_FIELD_GROUPS = [
|
|
17
|
+
...CORE_AGENT_FIELD_GROUPS,
|
|
18
|
+
telegramFieldGroup,
|
|
19
|
+
slackFieldGroup,
|
|
20
|
+
a2aFieldGroup,
|
|
21
|
+
webhookFieldGroup,
|
|
22
|
+
openAIApiFieldGroup,
|
|
23
|
+
cronFieldGroup,
|
|
24
|
+
whatsappFieldGroup,
|
|
25
|
+
];
|
|
26
|
+
export async function loadAppCoreConfig(input) {
|
|
27
|
+
return await loadMonoAgentConfigWithSources({
|
|
28
|
+
env: input.env,
|
|
29
|
+
cwd: input.cwd,
|
|
30
|
+
jsonPath: input.configPath,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
export function isAppCoreConfigError(error) {
|
|
34
|
+
return error instanceof MonoAgentConfigError;
|
|
35
|
+
}
|
|
36
|
+
const DEFAULT_TRACE_HEARTBEAT_MS = 10_000;
|
|
37
|
+
const DEFAULT_TRACE_STALE_AFTER_MS = 30_000;
|
|
38
|
+
const DEFAULT_TRACE_SOURCE_ID_PREFIX = "mono-agent";
|
|
39
|
+
const DEFAULT_TRACE_SOURCE_LABEL = "Mono Agent";
|
|
40
|
+
/**
|
|
41
|
+
* The resolvers below intentionally tolerate an incomplete or invalid config
|
|
42
|
+
* file: observability and the operator console must stay usable while the
|
|
43
|
+
* user is still fixing their config, so they fall back to defaults instead of
|
|
44
|
+
* throwing on unreadable JSON.
|
|
45
|
+
*/
|
|
46
|
+
export async function resolveAppArtifactDir(input) {
|
|
47
|
+
const envDir = input.env.MONO_AGENT_ARTIFACT_DIR?.trim();
|
|
48
|
+
if (envDir !== undefined && envDir.length > 0) {
|
|
49
|
+
return resolve(input.cwd, envDir);
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
const { json } = await readMonoAgentConfigJson(input.configPath);
|
|
53
|
+
const configDir = typeof json.artifacts?.dir === "string" ? json.artifacts.dir.trim() : "";
|
|
54
|
+
if (configDir.length > 0) {
|
|
55
|
+
return resolve(input.cwd, configDir);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
// Fall through to the default below.
|
|
60
|
+
}
|
|
61
|
+
return resolve(input.cwd, ".mono-agent", "artifacts");
|
|
62
|
+
}
|
|
63
|
+
export async function resolveAppTraceRegistryDir(input) {
|
|
64
|
+
const envDir = input.env.MONO_AGENT_TRACE_REGISTRY_DIR?.trim();
|
|
65
|
+
if (envDir !== undefined && envDir.length > 0) {
|
|
66
|
+
return resolve(input.cwd, envDir);
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
const { json } = await readMonoAgentConfigJson(input.configPath);
|
|
70
|
+
const registryDir = typeof json.traceability?.registryDir === "string" ? json.traceability.registryDir.trim() : "";
|
|
71
|
+
if (registryDir.length > 0) {
|
|
72
|
+
return resolve(input.cwd, registryDir);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
// Fall through to the default below.
|
|
77
|
+
}
|
|
78
|
+
return resolve(homedir(), ".mono-agent", "trace-sources");
|
|
79
|
+
}
|
|
80
|
+
export async function resolveAppTraceSourceId(input, defaults) {
|
|
81
|
+
const envSourceId = input.env.MONO_AGENT_TRACE_SOURCE_ID?.trim();
|
|
82
|
+
if (envSourceId !== undefined && envSourceId.length > 0) {
|
|
83
|
+
return envSourceId;
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
const { json } = await readMonoAgentConfigJson(input.configPath);
|
|
87
|
+
const sourceId = typeof json.traceability?.sourceId === "string" ? json.traceability.sourceId.trim() : "";
|
|
88
|
+
if (sourceId.length > 0) {
|
|
89
|
+
return sourceId;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
// Use the deterministic cwd/config fallback below.
|
|
94
|
+
}
|
|
95
|
+
const hash = createHash("sha256")
|
|
96
|
+
.update(resolve(input.cwd))
|
|
97
|
+
.update("\0")
|
|
98
|
+
.update(resolve(input.configPath))
|
|
99
|
+
.digest("hex")
|
|
100
|
+
.slice(0, 12);
|
|
101
|
+
return `${defaults?.sourceIdPrefix ?? DEFAULT_TRACE_SOURCE_ID_PREFIX}-${hash}`;
|
|
102
|
+
}
|
|
103
|
+
export async function resolveAppTraceSourceLabel(input, defaults) {
|
|
104
|
+
const envLabel = input.env.MONO_AGENT_TRACE_SOURCE_LABEL?.trim();
|
|
105
|
+
if (envLabel !== undefined && envLabel.length > 0) {
|
|
106
|
+
return envLabel;
|
|
107
|
+
}
|
|
108
|
+
try {
|
|
109
|
+
const { json } = await readMonoAgentConfigJson(input.configPath);
|
|
110
|
+
const label = typeof json.traceability?.sourceLabel === "string" ? json.traceability.sourceLabel.trim() : "";
|
|
111
|
+
if (label.length > 0) {
|
|
112
|
+
return label;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
// Keep the default label below.
|
|
117
|
+
}
|
|
118
|
+
return defaults?.sourceLabel ?? DEFAULT_TRACE_SOURCE_LABEL;
|
|
119
|
+
}
|
|
120
|
+
export async function resolveAppTraceHeartbeatMs(input) {
|
|
121
|
+
return await resolveTraceInteger({
|
|
122
|
+
input,
|
|
123
|
+
envName: "MONO_AGENT_TRACE_HEARTBEAT_MS",
|
|
124
|
+
jsonKey: "heartbeatMs",
|
|
125
|
+
defaultValue: DEFAULT_TRACE_HEARTBEAT_MS,
|
|
126
|
+
min: 250,
|
|
127
|
+
max: 86_400_000,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
export async function resolveAppTraceStaleAfterMs(input) {
|
|
131
|
+
return await resolveTraceInteger({
|
|
132
|
+
input,
|
|
133
|
+
envName: "MONO_AGENT_TRACE_STALE_AFTER_MS",
|
|
134
|
+
jsonKey: "staleAfterMs",
|
|
135
|
+
defaultValue: DEFAULT_TRACE_STALE_AFTER_MS,
|
|
136
|
+
min: 1_000,
|
|
137
|
+
max: 604_800_000,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
async function resolveTraceInteger(options) {
|
|
141
|
+
const envValue = options.input.env[options.envName]?.trim();
|
|
142
|
+
if (envValue !== undefined && envValue.length > 0) {
|
|
143
|
+
return parseTraceInteger(envValue, options.envName, options.min, options.max);
|
|
144
|
+
}
|
|
145
|
+
try {
|
|
146
|
+
const { json } = await readMonoAgentConfigJson(options.input.configPath);
|
|
147
|
+
const value = json.traceability?.[options.jsonKey];
|
|
148
|
+
if (value !== undefined) {
|
|
149
|
+
return parseTraceInteger(value, `traceability.${options.jsonKey}`, options.min, options.max);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
// Use the default while the user fixes an incomplete or invalid config.
|
|
154
|
+
}
|
|
155
|
+
return options.defaultValue;
|
|
156
|
+
}
|
|
157
|
+
function parseTraceInteger(value, name, min, max) {
|
|
158
|
+
const parsed = typeof value === "number" ? value : Number(value);
|
|
159
|
+
if (!Number.isInteger(parsed) || parsed < min || parsed > max) {
|
|
160
|
+
throw new MonoAgentConfigError("invalid_env", `${name} must be an integer between ${min} and ${max}.`, { env: name, reason: "integer_range" });
|
|
161
|
+
}
|
|
162
|
+
return parsed;
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=app-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-config.js","sourceRoot":"","sources":["../src/app-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EACL,uBAAuB,EACvB,8BAA8B,EAC9B,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE;;;GAGG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAA0B;IAChE,GAAG,uBAAuB;IAC1B,kBAAkB;IAClB,eAAe;IACf,aAAa;IACb,iBAAiB;IACjB,mBAAmB;IACnB,cAAc;IACd,kBAAkB;CACnB,CAAC;AAQF,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,KAA8B;IACpE,OAAO,MAAM,8BAA8B,CAAC;QAC1C,GAAG,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KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,OAAO,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;QAC/F,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,wEAAwE;IAC1E,CAAC;IAED,OAAO,OAAO,CAAC,YAAY,CAAC;AAC9B,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAc,EAAE,IAAY,EAAE,GAAW,EAAE,GAAW;IAC/E,MAAM,MAAM,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACjE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,GAAG,IAAI,MAAM,GAAG,GAAG,EAAE,CAAC;QAC9D,MAAM,IAAI,oBAAoB,CAC5B,aAAa,EACb,GAAG,IAAI,+BAA+B,GAAG,QAAQ,GAAG,GAAG,EACvD,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,eAAe,EAAE,CACvC,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/app.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { ConfigApplyResult, OperatorConsoleOptions, OperatorConsoleStartResult } from "@mono-agent/operator-console";
|
|
2
|
+
import type { MonoRuntimeLike } from "@mono-agent/runtime-adapter";
|
|
3
|
+
import type { FieldGroup } from "@mono-agent/settings";
|
|
4
|
+
import type { AppTraceDefaults } from "./app-config.js";
|
|
5
|
+
import type { ChannelDriver, ChannelId, ChannelStatus, MonoAgentAppLogger } from "./channels.js";
|
|
6
|
+
export interface MonoAgentAppOptions {
|
|
7
|
+
readonly env?: Record<string, string | undefined>;
|
|
8
|
+
readonly cwd?: string;
|
|
9
|
+
/** Path to mono-agent.config.json; defaults to <cwd>/mono-agent.config.json. */
|
|
10
|
+
readonly configPath?: string;
|
|
11
|
+
readonly logger?: MonoAgentAppLogger;
|
|
12
|
+
/** Channel drivers to run. Defaults to every built-in channel. */
|
|
13
|
+
readonly drivers?: readonly ChannelDriver[];
|
|
14
|
+
/** Shared runtime override (testing / advanced composition). */
|
|
15
|
+
readonly runtime?: MonoRuntimeLike;
|
|
16
|
+
/** Set false to run headless without the local operator console. */
|
|
17
|
+
readonly operatorConsole?: boolean;
|
|
18
|
+
readonly operatorConsolePort?: number;
|
|
19
|
+
readonly operatorConsoleFactory?: (options: OperatorConsoleOptions) => Promise<OperatorConsoleStartResult>;
|
|
20
|
+
readonly fieldGroups?: readonly FieldGroup[];
|
|
21
|
+
readonly traceDefaults?: AppTraceDefaults;
|
|
22
|
+
}
|
|
23
|
+
export interface MonoAgentAppOperatorConsole {
|
|
24
|
+
/** Base loopback URL for API calls, without the token query string. */
|
|
25
|
+
readonly url: string;
|
|
26
|
+
/** Browser URL that includes the per-boot operator console token. */
|
|
27
|
+
readonly appUrl: string;
|
|
28
|
+
readonly token: string;
|
|
29
|
+
readonly configPath: string;
|
|
30
|
+
}
|
|
31
|
+
export type TraceabilityStatus = {
|
|
32
|
+
readonly kind: "running";
|
|
33
|
+
readonly sourceId: string;
|
|
34
|
+
readonly registryDir: string;
|
|
35
|
+
readonly artifactDir: string;
|
|
36
|
+
} | {
|
|
37
|
+
readonly kind: "disabled";
|
|
38
|
+
readonly reason: string;
|
|
39
|
+
} | {
|
|
40
|
+
readonly kind: "failed";
|
|
41
|
+
readonly reason: string;
|
|
42
|
+
};
|
|
43
|
+
export interface MonoAgentApp {
|
|
44
|
+
readonly operatorConsole: MonoAgentAppOperatorConsole | undefined;
|
|
45
|
+
readonly configPath: string;
|
|
46
|
+
readonly traceabilityStatus: TraceabilityStatus;
|
|
47
|
+
channelStatus(id: ChannelId): ChannelStatus;
|
|
48
|
+
channelStatuses(): ReadonlyMap<ChannelId, ChannelStatus>;
|
|
49
|
+
startChannelIfConfigured(id: ChannelId, reason: string): Promise<ChannelStatus>;
|
|
50
|
+
applyConfigChange(reason: string): Promise<ConfigApplyResult>;
|
|
51
|
+
stop(): Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Starts a config-first mono-agent host in `cwd`: operator console first (so
|
|
55
|
+
* an incomplete config can be fixed in the browser), then traceability, then
|
|
56
|
+
* every configured channel in parallel. Channels with incomplete config report
|
|
57
|
+
* `waiting_for_config` instead of blocking the rest.
|
|
58
|
+
*/
|
|
59
|
+
export declare function startMonoAgentApp(options?: MonoAgentAppOptions): Promise<MonoAgentApp>;
|
|
60
|
+
//# sourceMappingURL=app.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,iBAAiB,EAEjB,sBAAsB,EACtB,0BAA0B,EAC3B,MAAM,8BAA8B,CAAC;AAMtC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAavD,OAAO,KAAK,EAAE,gBAAgB,EAA2B,MAAM,iBAAiB,CAAC;AAEjF,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa,EAAE,kBAAkB,EAAkB,MAAM,eAAe,CAAC;AAEjH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IAClD,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,gFAAgF;IAChF,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,kBAAkB,CAAC;IACrC,kEAAkE;IAClE,QAAQ,CAAC,OAAO,CAAC,EAA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