@agimon-ai/po-domain 0.0.0-alpha.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/LICENSE +21 -0
- package/README.md +71 -0
- package/dist/apiContracts.cjs +17 -0
- package/dist/apiContracts.cjs.map +1 -0
- package/dist/apiContracts.d.mts +53 -0
- package/dist/apiContracts.d.mts.map +1 -0
- package/dist/apiContracts.mjs +13 -0
- package/dist/apiContracts.mjs.map +1 -0
- package/dist/apply.cjs +76 -0
- package/dist/apply.cjs.map +1 -0
- package/dist/apply.d.mts +23 -0
- package/dist/apply.d.mts.map +1 -0
- package/dist/apply.mjs +72 -0
- package/dist/apply.mjs.map +1 -0
- package/dist/domainText-Dm8k7p4z.mjs +97 -0
- package/dist/domainText-Dm8k7p4z.mjs.map +1 -0
- package/dist/domainText-UIRIz6-_.cjs +204 -0
- package/dist/domainText-UIRIz6-_.cjs.map +1 -0
- package/dist/extensions/mcp.cjs +26 -0
- package/dist/extensions/mcp.cjs.map +1 -0
- package/dist/extensions/mcp.d.mts +5 -0
- package/dist/extensions/mcp.d.mts.map +1 -0
- package/dist/extensions/mcp.mjs +21 -0
- package/dist/extensions/mcp.mjs.map +1 -0
- package/dist/extensions/server.cjs +229 -0
- package/dist/extensions/server.cjs.map +1 -0
- package/dist/extensions/server.d.mts +5 -0
- package/dist/extensions/server.d.mts.map +1 -0
- package/dist/extensions/server.mjs +221 -0
- package/dist/extensions/server.mjs.map +1 -0
- package/dist/extensions/web.mjs +26 -0
- package/dist/extensions/web.mjs.map +1 -0
- package/dist/index.cjs +19 -0
- package/dist/index.d.mts +84 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +3 -0
- package/dist/mcp.cjs +32 -0
- package/dist/mcp.cjs.map +1 -0
- package/dist/mcp.d.mts +52 -0
- package/dist/mcp.d.mts.map +1 -0
- package/dist/mcp.mjs +19 -0
- package/dist/mcp.mjs.map +1 -0
- package/dist/mcpFilter-CZNmU_VF.cjs +189 -0
- package/dist/mcpFilter-CZNmU_VF.cjs.map +1 -0
- package/dist/mcpFilter-Cf-czy8O.mjs +151 -0
- package/dist/mcpFilter-Cf-czy8O.mjs.map +1 -0
- package/dist/pluginMaterializer-C8IZ1PSY.cjs +267 -0
- package/dist/pluginMaterializer-C8IZ1PSY.cjs.map +1 -0
- package/dist/pluginMaterializer-D9-oDF-b.mjs +259 -0
- package/dist/pluginMaterializer-D9-oDF-b.mjs.map +1 -0
- package/dist/plugins.cjs +3 -0
- package/dist/plugins.d.mts +14 -0
- package/dist/plugins.d.mts.map +1 -0
- package/dist/plugins.mjs +2 -0
- package/dist/resourceCollector-CRY5cmeY.mjs +773 -0
- package/dist/resourceCollector-CRY5cmeY.mjs.map +1 -0
- package/dist/resourceCollector-Cu-lp5hJ.cjs +837 -0
- package/dist/resourceCollector-Cu-lp5hJ.cjs.map +1 -0
- package/dist/resources-BEjxE3Zn.d.mts +66 -0
- package/dist/resources-BEjxE3Zn.d.mts.map +1 -0
- package/dist/resources.cjs +12 -0
- package/dist/resources.d.mts +43 -0
- package/dist/resources.d.mts.map +1 -0
- package/dist/resources.mjs +2 -0
- package/dist/rolldown-runtime-VH7oDXx4.cjs +28 -0
- package/dist/toolNames-Ckp5VLMD.mjs +43 -0
- package/dist/toolNames-Ckp5VLMD.mjs.map +1 -0
- package/dist/toolNames-Cuu-u8r1.cjs +48 -0
- package/dist/toolNames-Cuu-u8r1.cjs.map +1 -0
- package/llms.txt +12 -0
- package/package.json +158 -0
- package/src/prompts/po-author-domain/SKILL.md +18 -0
- package/src/prompts/po-author-domain/references/domains-contract.md +165 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Vuong Ngo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# @agimon-ai/po-domain
|
|
2
|
+
|
|
3
|
+
Domain selection for [Po](https://www.npmjs.com/package/@agimon-ai/po) sessions.
|
|
4
|
+
|
|
5
|
+
**Domains** are one of the four axes of a Po selection, alongside the major mode, the profile,
|
|
6
|
+
and the minor modes. Unlike a major mode, domains compose: a session selects a set of them, and
|
|
7
|
+
the union of what they contribute is what the model sees.
|
|
8
|
+
|
|
9
|
+
```yaml
|
|
10
|
+
# .po/domains.yaml
|
|
11
|
+
plugins:
|
|
12
|
+
entries:
|
|
13
|
+
frontend: plugins/frontend
|
|
14
|
+
infra: plugins/infra
|
|
15
|
+
domains:
|
|
16
|
+
development:
|
|
17
|
+
description: Application code, tests, and review tooling.
|
|
18
|
+
plugins: [frontend]
|
|
19
|
+
mcp:
|
|
20
|
+
servers: [code-intel]
|
|
21
|
+
platform:
|
|
22
|
+
description: Deployment, infrastructure, and incident tooling.
|
|
23
|
+
plugins: [infra]
|
|
24
|
+
aliases:
|
|
25
|
+
everything: [development, platform]
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## What it registers
|
|
29
|
+
|
|
30
|
+
| Surface | Behavior |
|
|
31
|
+
| ---------- | ----------------------------------------------------- |
|
|
32
|
+
| `/domains` | prints the selection, or switches to `name[,name...]` |
|
|
33
|
+
|
|
34
|
+
When the `@agimon-ai/po-help` minor mode is active, this package contributes the
|
|
35
|
+
`po-author-domain` skill. It provides package-owned guidance for plugin catalogs, domain
|
|
36
|
+
filters, aliases, defaults, shared skills, and MCP scopes in `domains.yaml`. The contribution is
|
|
37
|
+
registered through the session's `doom/help` Cordis service and is withdrawn with this package's
|
|
38
|
+
plugin fiber.
|
|
39
|
+
|
|
40
|
+
## What a switch stages
|
|
41
|
+
|
|
42
|
+
A domain switch is not just a config write, which is why it does not live in
|
|
43
|
+
`@agimon-ai/po-config/selectionSwitch` with the major-mode and profile switches. Applying a
|
|
44
|
+
selection:
|
|
45
|
+
|
|
46
|
+
- materializes any remote (Git or npm) plugins the selected domains name into a content-addressed
|
|
47
|
+
cache guarded by an install marker;
|
|
48
|
+
- discovers the exact `SKILL.md` files behind the selection, through a manifest cache keyed by
|
|
49
|
+
worktree so a second session does not rescan the tree;
|
|
50
|
+
- adapts each plugin's Claude-authored agent definitions into the form Pi loads, and stages them
|
|
51
|
+
privately (`0600`) beside a dispatcher agent;
|
|
52
|
+
- merges the repository and legacy plugin `.mcp.json` layers, and validates root `mcp.json` for
|
|
53
|
+
schema-gated Agent Plugins v1 (including plugin-relative commands, data directories, and transport
|
|
54
|
+
normalization);
|
|
55
|
+
- applies the selected domains' MCP allowlists and rewrites the proxy's upstream list into a
|
|
56
|
+
private per-run config; and
|
|
57
|
+
- atomically stores an immutable MCP projection in harness state. Config publishes that snapshot through the session Cordis registry for Po MCP to
|
|
58
|
+
consume; Domain never reaches into the live MCP runtime.
|
|
59
|
+
|
|
60
|
+
An allowlist only takes effect once **every** selected domain declares one. Mixing a scoped domain
|
|
61
|
+
with a domain that has not opted in leaves the session unfiltered, so an unmigrated domain cannot
|
|
62
|
+
silently lose its tools.
|
|
63
|
+
|
|
64
|
+
## Installation
|
|
65
|
+
|
|
66
|
+
Po depends on this package and activates it as fixed host core, so a Po install already has
|
|
67
|
+
it. It is not selectable from `.po/modes.yaml`; it reads `.po/domains.yaml`.
|
|
68
|
+
|
|
69
|
+
## License
|
|
70
|
+
|
|
71
|
+
MIT
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
5
|
+
//#region src/schemas/apiContracts.ts
|
|
6
|
+
/** This facet contributes agent tools, commands or lifecycle only, with no separate HTTP or socket surface. */
|
|
7
|
+
const apiContracts = (0, require("@agimon-ai/po-core/apiContracts").defineApiContract)({
|
|
8
|
+
version: 1,
|
|
9
|
+
http: [],
|
|
10
|
+
sockets: [],
|
|
11
|
+
dynamic: []
|
|
12
|
+
});
|
|
13
|
+
//#endregion
|
|
14
|
+
exports.apiContracts = apiContracts;
|
|
15
|
+
exports.default = apiContracts;
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=apiContracts.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiContracts.cjs","names":["defineApiContract"],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract } from '@agimon-ai/po-core/apiContracts';\n\n/** This facet contributes agent tools, commands or lifecycle only, with no separate HTTP or socket surface. */\nexport const apiContracts = defineApiContract({ version: 1, http: [], sockets: [], dynamic: [] });\nexport default apiContracts;\n"],"mappings":";;;;;;AAGA,MAAa,gBAAA,4CAAeA,CAAAA,CAAAA,kBAAAA,CAAkB;CAAE,SAAS;CAAG,MAAM,CAAC;CAAG,SAAS,CAAC;CAAG,SAAS,CAAC;AAAE,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
//#region src/schemas/apiContracts.d.ts
|
|
2
|
+
/** This facet contributes agent tools, commands or lifecycle only, with no separate HTTP or socket surface. */
|
|
3
|
+
export declare const apiContracts: {
|
|
4
|
+
version: 1;
|
|
5
|
+
protocols?: Record<string, string> | undefined;
|
|
6
|
+
schemas?: Record<string, boolean | object> | undefined;
|
|
7
|
+
http: {
|
|
8
|
+
id: string;
|
|
9
|
+
scope: "global" | "session" | "workspace";
|
|
10
|
+
basePath?: string | undefined;
|
|
11
|
+
path: string;
|
|
12
|
+
method: "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT";
|
|
13
|
+
description: string;
|
|
14
|
+
availability?: string | undefined;
|
|
15
|
+
authentication: "device" | "none" | "owner";
|
|
16
|
+
parameters?: {
|
|
17
|
+
name: string;
|
|
18
|
+
in: "header" | "path" | "query";
|
|
19
|
+
required: boolean;
|
|
20
|
+
schema: boolean | object;
|
|
21
|
+
}[] | undefined;
|
|
22
|
+
body?: {
|
|
23
|
+
contentType: string;
|
|
24
|
+
contentTypes?: string[] | undefined;
|
|
25
|
+
required: boolean;
|
|
26
|
+
schema: boolean | object;
|
|
27
|
+
} | undefined;
|
|
28
|
+
responses: Record<string, {
|
|
29
|
+
description: string;
|
|
30
|
+
contentType?: string | undefined;
|
|
31
|
+
schema?: boolean | object | undefined;
|
|
32
|
+
events?: Record<string, boolean | object> | undefined;
|
|
33
|
+
}>;
|
|
34
|
+
}[];
|
|
35
|
+
sockets: {
|
|
36
|
+
id: string;
|
|
37
|
+
scope: "global" | "session" | "workspace";
|
|
38
|
+
description: string;
|
|
39
|
+
availability?: string | undefined;
|
|
40
|
+
service: string;
|
|
41
|
+
member: string;
|
|
42
|
+
direction: "client-to-server" | "server-to-client";
|
|
43
|
+
kind: "channel" | "method" | "state";
|
|
44
|
+
input: boolean | object;
|
|
45
|
+
output?: boolean | object | undefined;
|
|
46
|
+
errors?: boolean | object | undefined;
|
|
47
|
+
}[];
|
|
48
|
+
dynamic: string[];
|
|
49
|
+
gaps?: string[] | undefined;
|
|
50
|
+
};
|
|
51
|
+
//#endregion
|
|
52
|
+
export { apiContracts as default };
|
|
53
|
+
//# sourceMappingURL=apiContracts.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiContracts.d.mts","names":[],"sources":["../src/schemas/apiContracts.ts"],"mappings":";;qBAGa"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defineApiContract } from "@agimon-ai/po-core/apiContracts";
|
|
2
|
+
//#region src/schemas/apiContracts.ts
|
|
3
|
+
/** This facet contributes agent tools, commands or lifecycle only, with no separate HTTP or socket surface. */
|
|
4
|
+
const apiContracts = defineApiContract({
|
|
5
|
+
version: 1,
|
|
6
|
+
http: [],
|
|
7
|
+
sockets: [],
|
|
8
|
+
dynamic: []
|
|
9
|
+
});
|
|
10
|
+
//#endregion
|
|
11
|
+
export { apiContracts, apiContracts as default };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=apiContracts.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiContracts.mjs","names":[],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract } from '@agimon-ai/po-core/apiContracts';\n\n/** This facet contributes agent tools, commands or lifecycle only, with no separate HTTP or socket surface. */\nexport const apiContracts = defineApiContract({ version: 1, http: [], sockets: [], dynamic: [] });\nexport default apiContracts;\n"],"mappings":";;;AAGA,MAAa,eAAe,kBAAkB;CAAE,SAAS;CAAG,MAAM,CAAC;CAAG,SAAS,CAAC;CAAG,SAAS,CAAC;AAAE,CAAC"}
|
package/dist/apply.cjs
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_rolldown_runtime = require("./rolldown-runtime-VH7oDXx4.cjs");
|
|
3
|
+
const require_mcpFilter = require("./mcpFilter-CZNmU_VF.cjs");
|
|
4
|
+
const require_pluginMaterializer = require("./pluginMaterializer-C8IZ1PSY.cjs");
|
|
5
|
+
const require_resourceCollector = require("./resourceCollector-Cu-lp5hJ.cjs");
|
|
6
|
+
let node_fs = require("node:fs");
|
|
7
|
+
node_fs = require_rolldown_runtime.__toESM(node_fs, 1);
|
|
8
|
+
let node_path = require("node:path");
|
|
9
|
+
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
10
|
+
let _agimon_ai_po_config_domains = require("@agimon-ai/po-config/domains");
|
|
11
|
+
let _agimon_ai_po_config_harnessStore = require("@agimon-ai/po-config/harnessStore");
|
|
12
|
+
//#region src/services/applyDomains/index.ts
|
|
13
|
+
/**
|
|
14
|
+
* Live domain switching: skills, plugin hooks, MCP config and subagent directories.
|
|
15
|
+
*
|
|
16
|
+
* Writes through the harness state module and relies on Pi's reload
|
|
17
|
+
* re-executing extension modules. The replacement Config factory publishes the
|
|
18
|
+
* persisted MCP projection on the new session's Cordis root.
|
|
19
|
+
*
|
|
20
|
+
* What reload cannot do is change the SET of loaded extensions: Pi freezes the
|
|
21
|
+
* CLI --extension list at construction and re-resolves that same array on every
|
|
22
|
+
* reload. Callers report those parts as needing a relaunch instead of pretending
|
|
23
|
+
* they applied.
|
|
24
|
+
*
|
|
25
|
+
* The major-mode and profile switches live in
|
|
26
|
+
* @agimon-ai/po-config/selectionSwitch: they are config writes with no
|
|
27
|
+
* resource staging, and the synced startup path applies them before any command
|
|
28
|
+
* exists to run. Domains stays here because it stages plugins, skills and MCP
|
|
29
|
+
* config.
|
|
30
|
+
*/
|
|
31
|
+
async function applyDomains(domainNames, state) {
|
|
32
|
+
const { root, temporaryDirectory } = (0, _agimon_ai_po_config_harnessStore.requireHarnessPaths)(state);
|
|
33
|
+
const pluginEntries = await require_pluginMaterializer.materializePluginEntries((0, _agimon_ai_po_config_domains.resolvePluginEntries)(root, domainNames, [...state.pluginDirectories]));
|
|
34
|
+
const mcpAllowlist = require_mcpFilter.resolveMcpAllowlist(root, domainNames);
|
|
35
|
+
const candidateDirectory = await node_fs.default.promises.mkdtemp(node_path.default.join(temporaryDirectory, "domains-"));
|
|
36
|
+
let resources;
|
|
37
|
+
try {
|
|
38
|
+
resources = await require_resourceCollector.collectResources(root, pluginEntries, {
|
|
39
|
+
agents: state.agents,
|
|
40
|
+
mcp: state.mcp,
|
|
41
|
+
temporaryDirectory: candidateDirectory,
|
|
42
|
+
sharedSkills: (0, _agimon_ai_po_config_domains.resolveSharedSkills)(root, domainNames),
|
|
43
|
+
mcpAllowlist
|
|
44
|
+
});
|
|
45
|
+
} catch (error) {
|
|
46
|
+
await node_fs.default.promises.rm(candidateDirectory, {
|
|
47
|
+
recursive: true,
|
|
48
|
+
force: true
|
|
49
|
+
});
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
let updated;
|
|
53
|
+
try {
|
|
54
|
+
updated = (0, _agimon_ai_po_config_harnessStore.updateHarnessState)({
|
|
55
|
+
domains: domainNames,
|
|
56
|
+
skillDirectories: resources.skillDirectories,
|
|
57
|
+
agentDirectories: resources.agentDirectories,
|
|
58
|
+
pluginHooks: resources.pluginHooks,
|
|
59
|
+
mcpConfigPath: resources.mcpConfigPath,
|
|
60
|
+
mcpProjection: resources.mcpProjection
|
|
61
|
+
});
|
|
62
|
+
} catch (error) {
|
|
63
|
+
await node_fs.default.promises.rm(candidateDirectory, {
|
|
64
|
+
recursive: true,
|
|
65
|
+
force: true
|
|
66
|
+
});
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
process.env.PI_SUBAGENT_EXTRA_AGENT_DIRS = resources.agentDirectories.join(node_path.default.delimiter);
|
|
70
|
+
process.env.PI_SUBAGENT_EXTRA_SKILL_DIRS = resources.skillDirectories.join(node_path.default.delimiter);
|
|
71
|
+
return updated;
|
|
72
|
+
}
|
|
73
|
+
//#endregion
|
|
74
|
+
exports.applyDomains = applyDomains;
|
|
75
|
+
|
|
76
|
+
//# sourceMappingURL=apply.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply.cjs","names":["requireHarnessPaths","materializePluginEntries","resolvePluginEntries","resolveMcpAllowlist","fs","path","collectResources","resolveSharedSkills","updateHarnessState"],"sources":["../src/services/applyDomains/index.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport { resolvePluginEntries, resolveSharedSkills } from '@agimon-ai/po-config/domains';\nimport { requireHarnessPaths, updateHarnessState } from '@agimon-ai/po-config/harnessStore';\nimport type { DoomHarnessContext, HarnessState } from '@agimon-ai/po-config/types';\n\nimport { resolveMcpAllowlist } from '../mcpFilter';\nimport { materializePluginEntries } from '../pluginMaterializer';\nimport { collectResources } from '../resourceCollector';\n\n/**\n * Live domain switching: skills, plugin hooks, MCP config and subagent directories.\n *\n * Writes through the harness state module and relies on Pi's reload\n * re-executing extension modules. The replacement Config factory publishes the\n * persisted MCP projection on the new session's Cordis root.\n *\n * What reload cannot do is change the SET of loaded extensions: Pi freezes the\n * CLI --extension list at construction and re-resolves that same array on every\n * reload. Callers report those parts as needing a relaunch instead of pretending\n * they applied.\n *\n * The major-mode and profile switches live in\n * @agimon-ai/po-config/selectionSwitch: they are config writes with no\n * resource staging, and the synced startup path applies them before any command\n * exists to run. Domains stays here because it stages plugins, skills and MCP\n * config.\n */\nexport async function applyDomains(domainNames: string[], state: DoomHarnessContext): Promise<HarnessState> {\n const { root, temporaryDirectory } = requireHarnessPaths(state);\n\n const pluginEntries = await materializePluginEntries(\n resolvePluginEntries(root, domainNames, [...state.pluginDirectories]),\n );\n const mcpAllowlist = resolveMcpAllowlist(root, domainNames);\n // Keep the active generation untouched while the candidate is parsed and\n // normalized. Pi's reload later removes the whole process-owned run root, so\n // retired generations need no eager destructive cleanup here.\n const candidateDirectory = await fs.promises.mkdtemp(path.join(temporaryDirectory, 'domains-'));\n let resources: Awaited<ReturnType<typeof collectResources>>;\n try {\n resources = await collectResources(root, pluginEntries, {\n agents: state.agents,\n mcp: state.mcp,\n temporaryDirectory: candidateDirectory,\n sharedSkills: resolveSharedSkills(root, domainNames),\n mcpAllowlist,\n });\n } catch (error) {\n await fs.promises.rm(candidateDirectory, { recursive: true, force: true });\n throw error;\n }\n\n let updated: HarnessState;\n try {\n updated = updateHarnessState({\n domains: domainNames,\n skillDirectories: resources.skillDirectories,\n agentDirectories: resources.agentDirectories,\n pluginHooks: resources.pluginHooks,\n mcpConfigPath: resources.mcpConfigPath,\n mcpProjection: resources.mcpProjection,\n });\n } catch (error) {\n await fs.promises.rm(candidateDirectory, { recursive: true, force: true });\n throw error;\n }\n process.env.PI_SUBAGENT_EXTRA_AGENT_DIRS = resources.agentDirectories.join(path.delimiter);\n process.env.PI_SUBAGENT_EXTRA_SKILL_DIRS = resources.skillDirectories.join(path.delimiter);\n return updated;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,eAAsB,aAAa,aAAuB,OAAkD;CAC1G,MAAM,EAAE,MAAM,wBAAA,GAAuBA,kCAAAA,oBAAAA,CAAoB,KAAK;CAE9D,MAAM,gBAAgB,MAAMC,2BAAAA,0BAAAA,GAC1BC,6BAAAA,qBAAAA,CAAqB,MAAM,aAAa,CAAC,GAAG,MAAM,iBAAiB,CAAC,CACtE;CACA,MAAM,eAAeC,kBAAAA,oBAAoB,MAAM,WAAW;CAI1D,MAAM,qBAAqB,MAAMC,QAAAA,QAAG,SAAS,QAAQC,UAAAA,QAAK,KAAK,oBAAoB,UAAU,CAAC;CAC9F,IAAI;CACJ,IAAI;EACF,YAAY,MAAMC,0BAAAA,iBAAiB,MAAM,eAAe;GACtD,QAAQ,MAAM;GACd,KAAK,MAAM;GACX,oBAAoB;GACpB,eAAA,GAAcC,6BAAAA,oBAAAA,CAAoB,MAAM,WAAW;GACnD;EACF,CAAC;CACH,SAAS,OAAO;EACd,MAAMH,QAAAA,QAAG,SAAS,GAAG,oBAAoB;GAAE,WAAW;GAAM,OAAO;EAAK,CAAC;EACzE,MAAM;CACR;CAEA,IAAI;CACJ,IAAI;EACF,WAAA,GAAUI,kCAAAA,mBAAAA,CAAmB;GAC3B,SAAS;GACT,kBAAkB,UAAU;GAC5B,kBAAkB,UAAU;GAC5B,aAAa,UAAU;GACvB,eAAe,UAAU;GACzB,eAAe,UAAU;EAC3B,CAAC;CACH,SAAS,OAAO;EACd,MAAMJ,QAAAA,QAAG,SAAS,GAAG,oBAAoB;GAAE,WAAW;GAAM,OAAO;EAAK,CAAC;EACzE,MAAM;CACR;CACA,QAAQ,IAAI,+BAA+B,UAAU,iBAAiB,KAAKC,UAAAA,QAAK,SAAS;CACzF,QAAQ,IAAI,+BAA+B,UAAU,iBAAiB,KAAKA,UAAAA,QAAK,SAAS;CACzF,OAAO;AACT"}
|
package/dist/apply.d.mts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { DoomHarnessContext, HarnessState } from "@agimon-ai/po-config/types";
|
|
2
|
+
//#region src/services/applyDomains/index.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Live domain switching: skills, plugin hooks, MCP config and subagent directories.
|
|
5
|
+
*
|
|
6
|
+
* Writes through the harness state module and relies on Pi's reload
|
|
7
|
+
* re-executing extension modules. The replacement Config factory publishes the
|
|
8
|
+
* persisted MCP projection on the new session's Cordis root.
|
|
9
|
+
*
|
|
10
|
+
* What reload cannot do is change the SET of loaded extensions: Pi freezes the
|
|
11
|
+
* CLI --extension list at construction and re-resolves that same array on every
|
|
12
|
+
* reload. Callers report those parts as needing a relaunch instead of pretending
|
|
13
|
+
* they applied.
|
|
14
|
+
*
|
|
15
|
+
* The major-mode and profile switches live in
|
|
16
|
+
* @agimon-ai/po-config/selectionSwitch: they are config writes with no
|
|
17
|
+
* resource staging, and the synced startup path applies them before any command
|
|
18
|
+
* exists to run. Domains stays here because it stages plugins, skills and MCP
|
|
19
|
+
* config.
|
|
20
|
+
*/
|
|
21
|
+
export declare function applyDomains(domainNames: string[], state: DoomHarnessContext): Promise<HarnessState>;
|
|
22
|
+
//#endregion
|
|
23
|
+
//# sourceMappingURL=apply.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply.d.mts","names":[],"sources":["../src/services/applyDomains/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;wBA6BsB,aAAa,uBAAuB,OAAO,qBAAqB,QAAQ"}
|
package/dist/apply.mjs
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { o as resolveMcpAllowlist } from "./mcpFilter-Cf-czy8O.mjs";
|
|
2
|
+
import { t as materializePluginEntries } from "./pluginMaterializer-D9-oDF-b.mjs";
|
|
3
|
+
import { r as collectResources } from "./resourceCollector-CRY5cmeY.mjs";
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { resolvePluginEntries, resolveSharedSkills } from "@agimon-ai/po-config/domains";
|
|
7
|
+
import { requireHarnessPaths, updateHarnessState } from "@agimon-ai/po-config/harnessStore";
|
|
8
|
+
//#region src/services/applyDomains/index.ts
|
|
9
|
+
/**
|
|
10
|
+
* Live domain switching: skills, plugin hooks, MCP config and subagent directories.
|
|
11
|
+
*
|
|
12
|
+
* Writes through the harness state module and relies on Pi's reload
|
|
13
|
+
* re-executing extension modules. The replacement Config factory publishes the
|
|
14
|
+
* persisted MCP projection on the new session's Cordis root.
|
|
15
|
+
*
|
|
16
|
+
* What reload cannot do is change the SET of loaded extensions: Pi freezes the
|
|
17
|
+
* CLI --extension list at construction and re-resolves that same array on every
|
|
18
|
+
* reload. Callers report those parts as needing a relaunch instead of pretending
|
|
19
|
+
* they applied.
|
|
20
|
+
*
|
|
21
|
+
* The major-mode and profile switches live in
|
|
22
|
+
* @agimon-ai/po-config/selectionSwitch: they are config writes with no
|
|
23
|
+
* resource staging, and the synced startup path applies them before any command
|
|
24
|
+
* exists to run. Domains stays here because it stages plugins, skills and MCP
|
|
25
|
+
* config.
|
|
26
|
+
*/
|
|
27
|
+
async function applyDomains(domainNames, state) {
|
|
28
|
+
const { root, temporaryDirectory } = requireHarnessPaths(state);
|
|
29
|
+
const pluginEntries = await materializePluginEntries(resolvePluginEntries(root, domainNames, [...state.pluginDirectories]));
|
|
30
|
+
const mcpAllowlist = resolveMcpAllowlist(root, domainNames);
|
|
31
|
+
const candidateDirectory = await fs.promises.mkdtemp(path.join(temporaryDirectory, "domains-"));
|
|
32
|
+
let resources;
|
|
33
|
+
try {
|
|
34
|
+
resources = await collectResources(root, pluginEntries, {
|
|
35
|
+
agents: state.agents,
|
|
36
|
+
mcp: state.mcp,
|
|
37
|
+
temporaryDirectory: candidateDirectory,
|
|
38
|
+
sharedSkills: resolveSharedSkills(root, domainNames),
|
|
39
|
+
mcpAllowlist
|
|
40
|
+
});
|
|
41
|
+
} catch (error) {
|
|
42
|
+
await fs.promises.rm(candidateDirectory, {
|
|
43
|
+
recursive: true,
|
|
44
|
+
force: true
|
|
45
|
+
});
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
let updated;
|
|
49
|
+
try {
|
|
50
|
+
updated = updateHarnessState({
|
|
51
|
+
domains: domainNames,
|
|
52
|
+
skillDirectories: resources.skillDirectories,
|
|
53
|
+
agentDirectories: resources.agentDirectories,
|
|
54
|
+
pluginHooks: resources.pluginHooks,
|
|
55
|
+
mcpConfigPath: resources.mcpConfigPath,
|
|
56
|
+
mcpProjection: resources.mcpProjection
|
|
57
|
+
});
|
|
58
|
+
} catch (error) {
|
|
59
|
+
await fs.promises.rm(candidateDirectory, {
|
|
60
|
+
recursive: true,
|
|
61
|
+
force: true
|
|
62
|
+
});
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
process.env.PI_SUBAGENT_EXTRA_AGENT_DIRS = resources.agentDirectories.join(path.delimiter);
|
|
66
|
+
process.env.PI_SUBAGENT_EXTRA_SKILL_DIRS = resources.skillDirectories.join(path.delimiter);
|
|
67
|
+
return updated;
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
export { applyDomains };
|
|
71
|
+
|
|
72
|
+
//# sourceMappingURL=apply.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply.mjs","names":[],"sources":["../src/services/applyDomains/index.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport { resolvePluginEntries, resolveSharedSkills } from '@agimon-ai/po-config/domains';\nimport { requireHarnessPaths, updateHarnessState } from '@agimon-ai/po-config/harnessStore';\nimport type { DoomHarnessContext, HarnessState } from '@agimon-ai/po-config/types';\n\nimport { resolveMcpAllowlist } from '../mcpFilter';\nimport { materializePluginEntries } from '../pluginMaterializer';\nimport { collectResources } from '../resourceCollector';\n\n/**\n * Live domain switching: skills, plugin hooks, MCP config and subagent directories.\n *\n * Writes through the harness state module and relies on Pi's reload\n * re-executing extension modules. The replacement Config factory publishes the\n * persisted MCP projection on the new session's Cordis root.\n *\n * What reload cannot do is change the SET of loaded extensions: Pi freezes the\n * CLI --extension list at construction and re-resolves that same array on every\n * reload. Callers report those parts as needing a relaunch instead of pretending\n * they applied.\n *\n * The major-mode and profile switches live in\n * @agimon-ai/po-config/selectionSwitch: they are config writes with no\n * resource staging, and the synced startup path applies them before any command\n * exists to run. Domains stays here because it stages plugins, skills and MCP\n * config.\n */\nexport async function applyDomains(domainNames: string[], state: DoomHarnessContext): Promise<HarnessState> {\n const { root, temporaryDirectory } = requireHarnessPaths(state);\n\n const pluginEntries = await materializePluginEntries(\n resolvePluginEntries(root, domainNames, [...state.pluginDirectories]),\n );\n const mcpAllowlist = resolveMcpAllowlist(root, domainNames);\n // Keep the active generation untouched while the candidate is parsed and\n // normalized. Pi's reload later removes the whole process-owned run root, so\n // retired generations need no eager destructive cleanup here.\n const candidateDirectory = await fs.promises.mkdtemp(path.join(temporaryDirectory, 'domains-'));\n let resources: Awaited<ReturnType<typeof collectResources>>;\n try {\n resources = await collectResources(root, pluginEntries, {\n agents: state.agents,\n mcp: state.mcp,\n temporaryDirectory: candidateDirectory,\n sharedSkills: resolveSharedSkills(root, domainNames),\n mcpAllowlist,\n });\n } catch (error) {\n await fs.promises.rm(candidateDirectory, { recursive: true, force: true });\n throw error;\n }\n\n let updated: HarnessState;\n try {\n updated = updateHarnessState({\n domains: domainNames,\n skillDirectories: resources.skillDirectories,\n agentDirectories: resources.agentDirectories,\n pluginHooks: resources.pluginHooks,\n mcpConfigPath: resources.mcpConfigPath,\n mcpProjection: resources.mcpProjection,\n });\n } catch (error) {\n await fs.promises.rm(candidateDirectory, { recursive: true, force: true });\n throw error;\n }\n process.env.PI_SUBAGENT_EXTRA_AGENT_DIRS = resources.agentDirectories.join(path.delimiter);\n process.env.PI_SUBAGENT_EXTRA_SKILL_DIRS = resources.skillDirectories.join(path.delimiter);\n return updated;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,eAAsB,aAAa,aAAuB,OAAkD;CAC1G,MAAM,EAAE,MAAM,uBAAuB,oBAAoB,KAAK;CAE9D,MAAM,gBAAgB,MAAM,yBAC1B,qBAAqB,MAAM,aAAa,CAAC,GAAG,MAAM,iBAAiB,CAAC,CACtE;CACA,MAAM,eAAe,oBAAoB,MAAM,WAAW;CAI1D,MAAM,qBAAqB,MAAM,GAAG,SAAS,QAAQ,KAAK,KAAK,oBAAoB,UAAU,CAAC;CAC9F,IAAI;CACJ,IAAI;EACF,YAAY,MAAM,iBAAiB,MAAM,eAAe;GACtD,QAAQ,MAAM;GACd,KAAK,MAAM;GACX,oBAAoB;GACpB,cAAc,oBAAoB,MAAM,WAAW;GACnD;EACF,CAAC;CACH,SAAS,OAAO;EACd,MAAM,GAAG,SAAS,GAAG,oBAAoB;GAAE,WAAW;GAAM,OAAO;EAAK,CAAC;EACzE,MAAM;CACR;CAEA,IAAI;CACJ,IAAI;EACF,UAAU,mBAAmB;GAC3B,SAAS;GACT,kBAAkB,UAAU;GAC5B,kBAAkB,UAAU;GAC5B,aAAa,UAAU;GACvB,eAAe,UAAU;GACzB,eAAe,UAAU;EAC3B,CAAC;CACH,SAAS,OAAO;EACd,MAAM,GAAG,SAAS,GAAG,oBAAoB;GAAE,WAAW;GAAM,OAAO;EAAK,CAAC;EACzE,MAAM;CACR;CACA,QAAQ,IAAI,+BAA+B,UAAU,iBAAiB,KAAK,KAAK,SAAS;CACzF,QAAQ,IAAI,+BAA+B,UAAU,iBAAiB,KAAK,KAAK,SAAS;CACzF,OAAO;AACT"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { VOICE_TOOL_MAX_DOMAIN_COUNT, VOICE_TOOL_MAX_IDENTIFIER_LENGTH } from "@agimon-ai/po-core/voiceTools";
|
|
2
|
+
//#region src/types/domains.ts
|
|
3
|
+
/** The npm name this package registers its voice tools and contributions under. */
|
|
4
|
+
const DOMAIN_SOURCE = "@agimon-ai/po-domain";
|
|
5
|
+
/**
|
|
6
|
+
* The only names a domain, an operation or a handoff token may carry.
|
|
7
|
+
*
|
|
8
|
+
* Selections arrive from the model and from the command line, and every one of
|
|
9
|
+
* them ends up in a filesystem path or a process environment variable, so the
|
|
10
|
+
* shape is constrained once here and reused by the schema and the validator.
|
|
11
|
+
*/
|
|
12
|
+
const SAFE_DOMAIN_NAME = /^[A-Za-z0-9@][A-Za-z0-9@/._:-]*$/u;
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/services/domainText/index.ts
|
|
15
|
+
const DOMAIN_SEPARATOR = ",";
|
|
16
|
+
const DOMAIN_COMMAND = "domains";
|
|
17
|
+
/** Footer status key the cockpit's domains axis reads. */
|
|
18
|
+
const DOMAIN_STATUS_KEY = "doom-domain";
|
|
19
|
+
/** What an empty selection reads as, which is a real state rather than an error. */
|
|
20
|
+
const NONE = "(none)";
|
|
21
|
+
/** Splits the comma-separated argument the command and the autocomplete share. */
|
|
22
|
+
function splitDomains(value) {
|
|
23
|
+
return value.split(DOMAIN_SEPARATOR).map((item) => item.trim()).filter(Boolean);
|
|
24
|
+
}
|
|
25
|
+
/** The published axis content: the active domains in the same comma-separated shape splitDomains reads. */
|
|
26
|
+
function domainStatus(domains) {
|
|
27
|
+
return domains.join(DOMAIN_SEPARATOR);
|
|
28
|
+
}
|
|
29
|
+
/** Picker rows for the domain multi-select. */
|
|
30
|
+
function domainItems(names, descriptions = {}) {
|
|
31
|
+
return names.map((name) => ({
|
|
32
|
+
value: name,
|
|
33
|
+
label: name,
|
|
34
|
+
...descriptions[name] ? { description: descriptions[name] } : {}
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
function domainSummary(listing) {
|
|
38
|
+
return `Active domains: ${listing.effective.join(", ") || "(none)"}\nAvailable domains: ${listing.available.join(", ")}\nUse /${DOMAIN_COMMAND} <name[,name...]> to switch.`;
|
|
39
|
+
}
|
|
40
|
+
function switchedSummary(domains) {
|
|
41
|
+
return `Switched domains to: ${domains.join(", ") || "(none)"}`;
|
|
42
|
+
}
|
|
43
|
+
function unchangedSummary(domains) {
|
|
44
|
+
return `Domains already active: ${domains.join(", ") || "(none)"}`;
|
|
45
|
+
}
|
|
46
|
+
function pickerTitle(listing) {
|
|
47
|
+
return `Domains (active: ${listing.effective.join(", ") || "(none)"})`;
|
|
48
|
+
}
|
|
49
|
+
const MARK_ON = "[x]";
|
|
50
|
+
const MARK_OFF = "[ ]";
|
|
51
|
+
const OPTION_PREFIX = /^\[[ x]\] /;
|
|
52
|
+
/**
|
|
53
|
+
* Rows for a single-pick select where domains compose: each row shows the
|
|
54
|
+
* membership it would flip, so a client without a multi-select still reaches
|
|
55
|
+
* every set one toggle at a time.
|
|
56
|
+
*/
|
|
57
|
+
function domainToggleOptions(listing) {
|
|
58
|
+
const active = new Set(listing.effective);
|
|
59
|
+
return listing.available.map((name) => `${active.has(name) ? MARK_ON : MARK_OFF} ${name}`);
|
|
60
|
+
}
|
|
61
|
+
/** The domain a toggle row names. */
|
|
62
|
+
function toggleOptionDomain(option) {
|
|
63
|
+
return option.replace(OPTION_PREFIX, "").trim();
|
|
64
|
+
}
|
|
65
|
+
/** The effective set with one domain flipped, order preserved for the rest. */
|
|
66
|
+
function toggledDomains(effective, name) {
|
|
67
|
+
return effective.includes(name) ? effective.filter((domain) => domain !== name) : [...effective, name];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Deduplicates a requested selection and rejects anything unsafe.
|
|
71
|
+
*
|
|
72
|
+
* Bounded before the manifest is read, because a selection large enough to
|
|
73
|
+
* matter comes from the model rather than from a person typing the command.
|
|
74
|
+
*/
|
|
75
|
+
function normalizeDomainNames(values) {
|
|
76
|
+
if (values.length > VOICE_TOOL_MAX_DOMAIN_COUNT) throw new Error(`A maximum of ${VOICE_TOOL_MAX_DOMAIN_COUNT} domains may be selected.`);
|
|
77
|
+
const result = [];
|
|
78
|
+
const seen = /* @__PURE__ */ new Set();
|
|
79
|
+
for (const value of values) {
|
|
80
|
+
const name = value.trim();
|
|
81
|
+
if (!name || name.length > VOICE_TOOL_MAX_IDENTIFIER_LENGTH || !SAFE_DOMAIN_NAME.test(name)) throw new Error(`Invalid domain name: ${value}`);
|
|
82
|
+
if (seen.has(name)) continue;
|
|
83
|
+
seen.add(name);
|
|
84
|
+
result.push(name);
|
|
85
|
+
}
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
function errorMessage(error) {
|
|
89
|
+
return error instanceof Error ? error.message : String(error);
|
|
90
|
+
}
|
|
91
|
+
function transitionError(result) {
|
|
92
|
+
return /* @__PURE__ */ new Error(`Domain transition was ${result.outcome}: ${result.diagnostics.join(", ")}`);
|
|
93
|
+
}
|
|
94
|
+
//#endregion
|
|
95
|
+
export { DOMAIN_SOURCE as _, domainStatus as a, errorMessage as c, splitDomains as d, switchedSummary as f, unchangedSummary as g, transitionError as h, domainItems as i, normalizeDomainNames as l, toggledDomains as m, DOMAIN_STATUS_KEY as n, domainSummary as o, toggleOptionDomain as p, NONE as r, domainToggleOptions as s, DOMAIN_COMMAND as t, pickerTitle as u, SAFE_DOMAIN_NAME as v };
|
|
96
|
+
|
|
97
|
+
//# sourceMappingURL=domainText-Dm8k7p4z.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domainText-Dm8k7p4z.mjs","names":[],"sources":["../src/types/domains.ts","../src/services/domainText/index.ts"],"sourcesContent":["/** The npm name this package registers its voice tools and contributions under. */\nexport const DOMAIN_SOURCE = '@agimon-ai/po-domain';\n\n/**\n * The only names a domain, an operation or a handoff token may carry.\n *\n * Selections arrive from the model and from the command line, and every one of\n * them ends up in a filesystem path or a process environment variable, so the\n * shape is constrained once here and reused by the schema and the validator.\n */\nexport const SAFE_DOMAIN_NAME = /^[A-Za-z0-9@][A-Za-z0-9@/._:-]*$/u;\n\n/**\n * The selection as the command, the picker and the voice tool all need to see it.\n *\n * `active` is what the session persisted and `effective` is what it is running\n * with, which differ while a major mode contributes its default domains.\n */\nexport interface DomainListing {\n readonly active: string[];\n readonly effective: string[];\n readonly available: string[];\n}\n\n/** One comma-triggered autocomplete response for the `/domains` argument. */\nexport interface DomainCompletion {\n readonly prefix: string;\n readonly items: Array<{ value: string; label: string }>;\n}\n","import type { DoomTransitionResult } from '@agimon-ai/po-core/transition';\nimport { VOICE_TOOL_MAX_DOMAIN_COUNT, VOICE_TOOL_MAX_IDENTIFIER_LENGTH } from '@agimon-ai/po-core/voiceTools';\n\nimport { type DomainListing, SAFE_DOMAIN_NAME } from '../../types/domains';\n\ninterface SelectItem {\n value: string;\n label: string;\n description?: string;\n}\n\nconst DOMAIN_SEPARATOR = ',';\nexport const DOMAIN_COMMAND = 'domains';\n/** Footer status key the cockpit's domains axis reads. */\nexport const DOMAIN_STATUS_KEY = 'doom-domain';\n/** What an empty selection reads as, which is a real state rather than an error. */\nexport const NONE = '(none)';\n\n/** Splits the comma-separated argument the command and the autocomplete share. */\nexport function splitDomains(value: string): string[] {\n return value\n .split(DOMAIN_SEPARATOR)\n .map((item) => item.trim())\n .filter(Boolean);\n}\n\n/** The published axis content: the active domains in the same comma-separated shape splitDomains reads. */\nexport function domainStatus(domains: readonly string[]): string {\n return domains.join(DOMAIN_SEPARATOR);\n}\n\n/** Picker rows for the domain multi-select. */\nexport function domainItems(\n names: string[],\n descriptions: Readonly<Record<string, string | undefined>> = {},\n): SelectItem[] {\n return names.map((name) => ({\n value: name,\n label: name,\n ...(descriptions[name] ? { description: descriptions[name] } : {}),\n }));\n}\n\nexport function domainSummary(listing: DomainListing): string {\n const active = listing.effective.join(', ') || NONE;\n return `Active domains: ${active}\\nAvailable domains: ${listing.available.join(', ')}\\nUse /${DOMAIN_COMMAND} <name[,name...]> to switch.`;\n}\n\nexport function switchedSummary(domains: readonly string[]): string {\n return `Switched domains to: ${domains.join(', ') || NONE}`;\n}\n\nexport function unchangedSummary(domains: readonly string[]): string {\n return `Domains already active: ${domains.join(', ') || NONE}`;\n}\n\nexport function pickerTitle(listing: DomainListing): string {\n return `Domains (active: ${listing.effective.join(', ') || NONE})`;\n}\n\nconst MARK_ON = '[x]';\nconst MARK_OFF = '[ ]';\nconst OPTION_PREFIX = /^\\[[ x]\\] /;\n\n/**\n * Rows for a single-pick select where domains compose: each row shows the\n * membership it would flip, so a client without a multi-select still reaches\n * every set one toggle at a time.\n */\nexport function domainToggleOptions(listing: DomainListing): string[] {\n const active = new Set(listing.effective);\n return listing.available.map((name) => `${active.has(name) ? MARK_ON : MARK_OFF} ${name}`);\n}\n\n/** The domain a toggle row names. */\nexport function toggleOptionDomain(option: string): string {\n return option.replace(OPTION_PREFIX, '').trim();\n}\n\n/** The effective set with one domain flipped, order preserved for the rest. */\nexport function toggledDomains(effective: readonly string[], name: string): string[] {\n return effective.includes(name) ? effective.filter((domain) => domain !== name) : [...effective, name];\n}\n\n/**\n * Deduplicates a requested selection and rejects anything unsafe.\n *\n * Bounded before the manifest is read, because a selection large enough to\n * matter comes from the model rather than from a person typing the command.\n */\nexport function normalizeDomainNames(values: readonly string[]): string[] {\n if (values.length > VOICE_TOOL_MAX_DOMAIN_COUNT) {\n throw new Error(`A maximum of ${VOICE_TOOL_MAX_DOMAIN_COUNT} domains may be selected.`);\n }\n const result: string[] = [];\n const seen = new Set<string>();\n for (const value of values) {\n const name = value.trim();\n if (!name || name.length > VOICE_TOOL_MAX_IDENTIFIER_LENGTH || !SAFE_DOMAIN_NAME.test(name)) {\n throw new Error(`Invalid domain name: ${value}`);\n }\n if (seen.has(name)) continue;\n seen.add(name);\n result.push(name);\n }\n return result;\n}\n\nexport function errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nexport function transitionError(result: DoomTransitionResult): Error {\n return new Error(`Domain transition was ${result.outcome}: ${result.diagnostics.join(', ')}`);\n}\n"],"mappings":";;;AACA,MAAa,gBAAgB;;;;;;;;AAS7B,MAAa,mBAAmB;;;ACChC,MAAM,mBAAmB;AACzB,MAAa,iBAAiB;;AAE9B,MAAa,oBAAoB;;AAEjC,MAAa,OAAO;;AAGpB,SAAgB,aAAa,OAAyB;CACpD,OAAO,MACJ,MAAM,gBAAgB,CAAC,CACvB,KAAK,SAAS,KAAK,KAAK,CAAC,CAAC,CAC1B,OAAO,OAAO;AACnB;;AAGA,SAAgB,aAAa,SAAoC;CAC/D,OAAO,QAAQ,KAAK,gBAAgB;AACtC;;AAGA,SAAgB,YACd,OACA,eAA6D,CAAC,GAChD;CACd,OAAO,MAAM,KAAK,UAAU;EAC1B,OAAO;EACP,OAAO;EACP,GAAI,aAAa,QAAQ,EAAE,aAAa,aAAa,MAAM,IAAI,CAAC;CAClE,EAAE;AACJ;AAEA,SAAgB,cAAc,SAAgC;CAE5D,OAAO,mBADQ,QAAQ,UAAU,KAAK,IAAI,KAAA,SACT,uBAAuB,QAAQ,UAAU,KAAK,IAAI,EAAE,SAAS,eAAe;AAC/G;AAEA,SAAgB,gBAAgB,SAAoC;CAClE,OAAO,wBAAwB,QAAQ,KAAK,IAAI,KAAA;AAClD;AAEA,SAAgB,iBAAiB,SAAoC;CACnE,OAAO,2BAA2B,QAAQ,KAAK,IAAI,KAAA;AACrD;AAEA,SAAgB,YAAY,SAAgC;CAC1D,OAAO,oBAAoB,QAAQ,UAAU,KAAK,IAAI,KAAA,SAAU;AAClE;AAEA,MAAM,UAAU;AAChB,MAAM,WAAW;AACjB,MAAM,gBAAgB;;;;;;AAOtB,SAAgB,oBAAoB,SAAkC;CACpE,MAAM,SAAS,IAAI,IAAI,QAAQ,SAAS;CACxC,OAAO,QAAQ,UAAU,KAAK,SAAS,GAAG,OAAO,IAAI,IAAI,IAAI,UAAU,SAAS,GAAG,MAAM;AAC3F;;AAGA,SAAgB,mBAAmB,QAAwB;CACzD,OAAO,OAAO,QAAQ,eAAe,EAAE,CAAC,CAAC,KAAK;AAChD;;AAGA,SAAgB,eAAe,WAA8B,MAAwB;CACnF,OAAO,UAAU,SAAS,IAAI,IAAI,UAAU,QAAQ,WAAW,WAAW,IAAI,IAAI,CAAC,GAAG,WAAW,IAAI;AACvG;;;;;;;AAQA,SAAgB,qBAAqB,QAAqC;CACxE,IAAI,OAAO,SAAS,6BAClB,MAAM,IAAI,MAAM,gBAAgB,4BAA4B,0BAA0B;CAExF,MAAM,SAAmB,CAAC;CAC1B,MAAM,uBAAO,IAAI,IAAY;CAC7B,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,OAAO,MAAM,KAAK;EACxB,IAAI,CAAC,QAAQ,KAAK,SAAS,oCAAoC,CAAC,iBAAiB,KAAK,IAAI,GACxF,MAAM,IAAI,MAAM,wBAAwB,OAAO;EAEjD,IAAI,KAAK,IAAI,IAAI,GAAG;EACpB,KAAK,IAAI,IAAI;EACb,OAAO,KAAK,IAAI;CAClB;CACA,OAAO;AACT;AAEA,SAAgB,aAAa,OAAwB;CACnD,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC9D;AAEA,SAAgB,gBAAgB,QAAqC;CACnE,uBAAO,IAAI,MAAM,yBAAyB,OAAO,QAAQ,IAAI,OAAO,YAAY,KAAK,IAAI,GAAG;AAC9F"}
|