@cotal-ai/manager 0.171.2 → 0.171.4
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/broker-transport.d.ts +126 -0
- package/dist/broker-transport.d.ts.map +1 -0
- package/dist/broker-transport.js +263 -0
- package/dist/broker-transport.js.map +1 -0
- package/dist/command-dispatch.d.ts +206 -0
- package/dist/command-dispatch.d.ts.map +1 -0
- package/dist/command-dispatch.js +471 -0
- package/dist/command-dispatch.js.map +1 -0
- package/dist/connector-inventory.d.ts +37 -0
- package/dist/connector-inventory.d.ts.map +1 -0
- package/dist/connector-inventory.js +73 -0
- package/dist/connector-inventory.js.map +1 -0
- package/dist/harness-resolution.d.ts +71 -0
- package/dist/harness-resolution.d.ts.map +1 -0
- package/dist/harness-resolution.js +111 -0
- package/dist/harness-resolution.js.map +1 -0
- package/dist/manager.d.ts +91 -375
- package/dist/manager.d.ts.map +1 -1
- package/dist/manager.js +400 -2811
- package/dist/manager.js.map +1 -1
- package/dist/persona-catalog.d.ts +86 -0
- package/dist/persona-catalog.d.ts.map +1 -0
- package/dist/persona-catalog.js +325 -0
- package/dist/persona-catalog.js.map +1 -0
- package/dist/preservation.d.ts +157 -0
- package/dist/preservation.d.ts.map +1 -0
- package/dist/preservation.js +583 -0
- package/dist/preservation.js.map +1 -0
- package/dist/readiness-wait.d.ts +64 -0
- package/dist/readiness-wait.d.ts.map +1 -0
- package/dist/readiness-wait.js +244 -0
- package/dist/readiness-wait.js.map +1 -0
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +22 -0
- package/dist/runtime/index.js.map +1 -1
- package/dist/service-adapter.d.ts.map +1 -1
- package/dist/service-adapter.js +6 -0
- package/dist/service-adapter.js.map +1 -1
- package/dist/spawn-goal.d.ts +77 -0
- package/dist/spawn-goal.d.ts.map +1 -0
- package/dist/spawn-goal.js +357 -0
- package/dist/spawn-goal.js.map +1 -0
- package/dist/start-doors.d.ts +51 -0
- package/dist/start-doors.d.ts.map +1 -0
- package/dist/start-doors.js +187 -0
- package/dist/start-doors.js.map +1 -0
- package/dist/status-and-models.d.ts +155 -0
- package/dist/status-and-models.d.ts.map +1 -0
- package/dist/status-and-models.js +290 -0
- package/dist/status-and-models.js.map +1 -0
- package/dist/terminal-input.d.ts +82 -0
- package/dist/terminal-input.d.ts.map +1 -0
- package/dist/terminal-input.js +266 -0
- package/dist/terminal-input.js.map +1 -0
- package/package.json +12 -12
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { registry, rejectionText } from "@cotal-ai/core";
|
|
2
|
+
import { extensionConnectors, loadExtensionsManifest, OFFICIAL_CONNECTORS } from "@cotal-ai/workspace";
|
|
3
|
+
import { resolveHarness } from "./harness-resolution.js";
|
|
4
|
+
/** The connector inventory taken at boot: which harnesses resolve on this host and the notes for those that do not. */
|
|
5
|
+
export class ConnectorInventory {
|
|
6
|
+
deps;
|
|
7
|
+
constructor(deps) {
|
|
8
|
+
this.deps = deps;
|
|
9
|
+
}
|
|
10
|
+
// The Manager members these bodies read, under their Manager names. Each reads through its dep at
|
|
11
|
+
// use, so a field the Manager assigns later is current and a method a test replaces on the Manager
|
|
12
|
+
// is the one that runs.
|
|
13
|
+
get bootNotes() { return this.deps.bootNotes(); }
|
|
14
|
+
set bootNotes(value) { this.deps.setBootNotes(value); }
|
|
15
|
+
get connectorRequirements() { return this.deps.connectorRequirements(); }
|
|
16
|
+
set connectorRequirements(value) { this.deps.setConnectorRequirements(value); }
|
|
17
|
+
get connectorStatuses() { return this.deps.connectorStatuses(); }
|
|
18
|
+
set connectorStatuses(value) { this.deps.setConnectorStatuses(value); }
|
|
19
|
+
get execution() { return this.deps.execution(); }
|
|
20
|
+
get installedExtensions() { return this.deps.installedExtensions(); }
|
|
21
|
+
get machineSetupCommand() { return this.deps.machineSetupCommand(); }
|
|
22
|
+
classSpawnEnabled(...args) { return this.deps.classSpawnEnabled(...args); }
|
|
23
|
+
prepareClaudeWake(...args) { return this.deps.prepareClaudeWake(...args); }
|
|
24
|
+
/** Resolve every installed/registered connector's declared harness binaries before the manager
|
|
25
|
+
* reports ready. A missing harness degrades only that connector, never unrelated lifecycle work:
|
|
26
|
+
* boot continues, names it once start completes and records it on both manager status surfaces. */
|
|
27
|
+
async inspectConnectorsAtBoot() {
|
|
28
|
+
this.bootNotes = [];
|
|
29
|
+
if (this.execution === "none") {
|
|
30
|
+
this.connectorStatuses = [];
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const rows = [];
|
|
34
|
+
let declared;
|
|
35
|
+
if (this.installedExtensions) {
|
|
36
|
+
try {
|
|
37
|
+
declared = loadExtensionsManifest().extensions.flatMap((ext) => extensionConnectors(ext).map((connector) => ({ ...connector, pkg: ext.pkg })));
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
const reason = rejectionText(error);
|
|
41
|
+
this.bootNotes.push(`! manager boot: connector inventory unavailable - ${reason}`);
|
|
42
|
+
this.connectorStatuses = [{ agent: "(inventory)", state: "unavailable", binaries: {}, eventPlane: false, reason }];
|
|
43
|
+
this.bootNotes.push("! manager: no agent application is available here, so a spawn without --on goes to another manager in this space");
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
declared = registry.all("connector").map((connector) => ({
|
|
49
|
+
name: connector.name,
|
|
50
|
+
requires: connector.requires ?? [],
|
|
51
|
+
eventPlane: connector.eventChannel !== undefined,
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
this.connectorRequirements = new Map(declared.map(({ name, requires, pkg }) => [name, {
|
|
55
|
+
requires, needsClaudeWake: !!this.machineSetupCommand && name === "claude" && pkg === OFFICIAL_CONNECTORS.claude,
|
|
56
|
+
}]));
|
|
57
|
+
for (const { name, requires, eventPlane } of declared) {
|
|
58
|
+
const { binaries, reason: missing } = resolveHarness(name, requires);
|
|
59
|
+
const reason = missing ?? (this.connectorRequirements.get(name)?.needsClaudeWake ? await this.prepareClaudeWake() : undefined);
|
|
60
|
+
if (reason) {
|
|
61
|
+
rows.push({ agent: name, state: "unavailable", binaries, eventPlane, reason });
|
|
62
|
+
this.bootNotes.push(`! manager boot: connector ${name} unavailable - ${reason}`);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
rows.push({ agent: name, state: "available", binaries, eventPlane });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
this.connectorStatuses = rows.sort((a, b) => a.agent.localeCompare(b.agent));
|
|
69
|
+
if (!this.classSpawnEnabled())
|
|
70
|
+
this.bootNotes.push("! manager: no agent application is available here, so a spawn without --on goes to another manager in this space");
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=connector-inventory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connector-inventory.js","sourceRoot":"","sources":["../src/connector-inventory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AACvG,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAoBzD,uHAAuH;AACvH,MAAM,OAAO,kBAAkB;IACA;IAA7B,YAA6B,IAA4B;QAA5B,SAAI,GAAJ,IAAI,CAAwB;IAAG,CAAC;IAE7D,kGAAkG;IAClG,mGAAmG;IACnG,wBAAwB;IACxB,IAAY,SAAS,KAAK,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;IACzD,IAAY,SAAS,CAAC,KAA2B,IAAI,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACrF,IAAY,qBAAqB,KAAK,OAAO,IAAI,CAAC,IAAI,CAAC,qBAAqB,EAAE,CAAC,CAAC,CAAC;IAC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ector's declared harness binaries resolved on PATH now. The refusal sentence is built only
|
|
4
|
+
* here, so the boot row and the check for a connector registered after boot can never word it apart. */
|
|
5
|
+
export declare function resolveHarness(name: string, requires: readonly string[]): {
|
|
6
|
+
binaries: Record<string, string>;
|
|
7
|
+
reason?: string;
|
|
8
|
+
};
|
|
9
|
+
/** What {@link HarnessResolution} reads from the Manager. Every entry is read at use, so a field the Manager
|
|
10
|
+
* assigns after construction is always current, and a Manager method a test replaces is the one that runs. */
|
|
11
|
+
export interface HarnessResolutionDeps {
|
|
12
|
+
connectorStatuses: () => Manager["connectorStatuses"];
|
|
13
|
+
eventPayloadsWithheld: () => Manager["eventPayloadsWithheld"];
|
|
14
|
+
eventsRequired: () => Manager["eventsRequired"];
|
|
15
|
+
expectedConnectorGeneration: () => Manager["expectedConnectorGeneration"];
|
|
16
|
+
installedExtensions: () => Manager["installedExtensions"];
|
|
17
|
+
servers: () => Manager["servers"];
|
|
18
|
+
space: () => Manager["space"];
|
|
19
|
+
workspaceRoot: () => Manager["workspaceRoot"];
|
|
20
|
+
}
|
|
21
|
+
/** Resolving a connector by name and the host fields, harness binaries and capability and events refusals a launch carries. */
|
|
22
|
+
export declare class HarnessResolution {
|
|
23
|
+
private readonly deps;
|
|
24
|
+
constructor(deps: HarnessResolutionDeps);
|
|
25
|
+
private get connectorStatuses();
|
|
26
|
+
private get eventPayloadsWithheld();
|
|
27
|
+
private get eventsRequired();
|
|
28
|
+
private get expectedConnectorGeneration();
|
|
29
|
+
private get installedExtensions();
|
|
30
|
+
private get servers();
|
|
31
|
+
private get space();
|
|
32
|
+
private get workspaceRoot();
|
|
33
|
+
/** Resolve a connector by agent type. Library composition (installedExtensions off) → a registry
|
|
34
|
+
* hit, exactly as before (the composition root imported what it wants). The published binary gates
|
|
35
|
+
* on MANIFEST membership FIRST — so a live `cotal ext remove` is honored even though the registry
|
|
36
|
+
* still holds a connector imported earlier this session — then returns the registry hit or lazily
|
|
37
|
+
* imports the providing package (transactional + single-flight, via the workspace primitive).
|
|
38
|
+
* The captured Manager generation is checked for first-party providers under that lock,
|
|
39
|
+
* including providers already present in the registry.
|
|
40
|
+
* Fail-loud with an install hint; no fallback. */
|
|
41
|
+
resolveConnector(name: string): Promise<Connector>;
|
|
42
|
+
/** The harness binaries a managed launch runs, as boot resolved them, or the refusal naming what is
|
|
43
|
+
* missing. Spawn, resume and the model catalog all take it, so a seat launches from the same files
|
|
44
|
+
* whichever path starts it and the catalog never disagrees with a launch about whether the harness
|
|
45
|
+
* is there. Callers recheck unavailable rows first; available rows retain their resolved files.
|
|
46
|
+
* A connector registered after boot has no inventory row and is checked on PATH now. */
|
|
47
|
+
launchHarness(connector: Connector): {
|
|
48
|
+
binaries?: Readonly<Record<string, string>>;
|
|
49
|
+
} | {
|
|
50
|
+
refusal: string;
|
|
51
|
+
};
|
|
52
|
+
/** The launch fields the host supplies rather than the seat. Spawn and resume both take them from
|
|
53
|
+
* here, so a resumed seat launches under the same host policy, `eventsRequired` included, as the
|
|
54
|
+
* same seat spawned fresh. The caller passes the cotal config it judged the launch by, so the
|
|
55
|
+
* servers and env allowlist come from the contents its checks read. */
|
|
56
|
+
hostLaunchFields(cotalConfig: CotalConfig, agent: string, shareTools: readonly string[] | undefined, harness: {
|
|
57
|
+
binaries?: Readonly<Record<string, string>>;
|
|
58
|
+
}): Pick<LaunchOpts, "space" | "servers" | "mcpServers" | "mcpServersExclusive" | "envAllow" | "resolvedBinaries" | "eventsRequired" | "eventPayloads" | "workspaceRoot">;
|
|
59
|
+
/** The refusal for a launch choice the connector cannot honour. Spawn and resume both ask before
|
|
60
|
+
* a seat's launch is built, so a rule changed here holds on both paths. */
|
|
61
|
+
capabilityRefusal(connector: Connector, launch: {
|
|
62
|
+
variant?: string;
|
|
63
|
+
prompt?: string;
|
|
64
|
+
exact: boolean;
|
|
65
|
+
}): string | undefined;
|
|
66
|
+
/** The refusal for an event-plane choice the registration policy or the connector cannot meet.
|
|
67
|
+
* Spawn and resume both ask before a seat's launch is built, so a seat retained without the
|
|
68
|
+
* plane cannot come back on a space that now requires it. An absent choice arms supported planes. */
|
|
69
|
+
eventsRefusal(connector: Connector, events: boolean | undefined): string | undefined;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=harness-resolution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"harness-resolution.d.ts","sourceRoot":"","sources":["../src/harness-resolution.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEzE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C;yGACyG;AACzG,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAS/H;AAED;+GAC+G;AAC/G,MAAM,WAAW,qBAAqB;IACpC,iBAAiB,EAAE,MAAM,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACtD,qBAAqB,EAAE,MAAM,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAC9D,cAAc,EAAE,MAAM,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAChD,2BAA2B,EAAE,MAAM,OAAO,CAAC,6BAA6B,CAAC,CAAC;IAC1E,mBAAmB,EAAE,MAAM,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAC1D,OAAO,EAAE,MAAM,OAAO,CAAC,SAAS,CAAC,CAAC;IAClC,KAAK,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9B,aAAa,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC;CAC/C;AAED,+HAA+H;AAC/H,qBAAa,iBAAiB;IAChB,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,qBAAqB;IA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AG,MAAM,GAAG,SAAS;CASrF"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { connectorServers, registry, spawnEnvAllow } from "@cotal-ai/core";
|
|
2
|
+
import { connectorInstallHint, manifestExtensionNames, materializeFromManifest, resolveOnPath } from "@cotal-ai/workspace";
|
|
3
|
+
/** One connector's declared harness binaries resolved on PATH now. The refusal sentence is built only
|
|
4
|
+
* here, so the boot row and the check for a connector registered after boot can never word it apart. */
|
|
5
|
+
export function resolveHarness(name, requires) {
|
|
6
|
+
const binaries = {};
|
|
7
|
+
const missing = [];
|
|
8
|
+
for (const bin of requires) {
|
|
9
|
+
const path = resolveOnPath(bin);
|
|
10
|
+
if (path)
|
|
11
|
+
binaries[bin] = path;
|
|
12
|
+
else
|
|
13
|
+
missing.push(bin);
|
|
14
|
+
}
|
|
15
|
+
return missing.length ? { binaries, reason: `${name} harness needs ${missing.join(", ")} on PATH - not found` } : { binaries };
|
|
16
|
+
}
|
|
17
|
+
/** Resolving a connector by name and the host fields, harness binaries and capability and events refusals a launch carries. */
|
|
18
|
+
export class HarnessResolution {
|
|
19
|
+
deps;
|
|
20
|
+
constructor(deps) {
|
|
21
|
+
this.deps = deps;
|
|
22
|
+
}
|
|
23
|
+
// The Manager members these bodies read, under their Manager names. Each reads through its dep at
|
|
24
|
+
// use, so a field the Manager assigns later is current and a method a test replaces on the Manager
|
|
25
|
+
// is the one that runs.
|
|
26
|
+
get connectorStatuses() { return this.deps.connectorStatuses(); }
|
|
27
|
+
get eventPayloadsWithheld() { return this.deps.eventPayloadsWithheld(); }
|
|
28
|
+
get eventsRequired() { return this.deps.eventsRequired(); }
|
|
29
|
+
get expectedConnectorGeneration() { return this.deps.expectedConnectorGeneration(); }
|
|
30
|
+
get installedExtensions() { return this.deps.installedExtensions(); }
|
|
31
|
+
get servers() { return this.deps.servers(); }
|
|
32
|
+
get space() { return this.deps.space(); }
|
|
33
|
+
get workspaceRoot() { return this.deps.workspaceRoot(); }
|
|
34
|
+
/** Resolve a connector by agent type. Library composition (installedExtensions off) → a registry
|
|
35
|
+
* hit, exactly as before (the composition root imported what it wants). The published binary gates
|
|
36
|
+
* on MANIFEST membership FIRST — so a live `cotal ext remove` is honored even though the registry
|
|
37
|
+
* still holds a connector imported earlier this session — then returns the registry hit or lazily
|
|
38
|
+
* imports the providing package (transactional + single-flight, via the workspace primitive).
|
|
39
|
+
* The captured Manager generation is checked for first-party providers under that lock,
|
|
40
|
+
* including providers already present in the registry.
|
|
41
|
+
* Fail-loud with an install hint; no fallback. */
|
|
42
|
+
async resolveConnector(name) {
|
|
43
|
+
if (!this.installedExtensions)
|
|
44
|
+
return registry.resolve("connector", name);
|
|
45
|
+
if (!manifestExtensionNames("connector").includes(name))
|
|
46
|
+
throw new Error(connectorInstallHint(name));
|
|
47
|
+
return materializeFromManifest({ kind: "connector", name }, { hint: (ref) => connectorInstallHint(ref.name), expectedGeneration: this.expectedConnectorGeneration });
|
|
48
|
+
}
|
|
49
|
+
/** The harness binaries a managed launch runs, as boot resolved them, or the refusal naming what is
|
|
50
|
+
* missing. Spawn, resume and the model catalog all take it, so a seat launches from the same files
|
|
51
|
+
* whichever path starts it and the catalog never disagrees with a launch about whether the harness
|
|
52
|
+
* is there. Callers recheck unavailable rows first; available rows retain their resolved files.
|
|
53
|
+
* A connector registered after boot has no inventory row and is checked on PATH now. */
|
|
54
|
+
launchHarness(connector) {
|
|
55
|
+
const row = this.connectorStatuses.find((status) => status.agent === connector.name);
|
|
56
|
+
if (row?.state === "unavailable")
|
|
57
|
+
return { refusal: row.reason ?? `${connector.name} harness is unavailable` };
|
|
58
|
+
if (row)
|
|
59
|
+
return { binaries: row.binaries };
|
|
60
|
+
const { reason } = resolveHarness(connector.name, connector.requires ?? []);
|
|
61
|
+
return reason ? { refusal: reason } : {};
|
|
62
|
+
}
|
|
63
|
+
/** The launch fields the host supplies rather than the seat. Spawn and resume both take them from
|
|
64
|
+
* here, so a resumed seat launches under the same host policy, `eventsRequired` included, as the
|
|
65
|
+
* same seat spawned fresh. The caller passes the cotal config it judged the launch by, so the
|
|
66
|
+
* servers and env allowlist come from the contents its checks read. */
|
|
67
|
+
hostLaunchFields(cotalConfig, agent, shareTools, harness) {
|
|
68
|
+
return {
|
|
69
|
+
space: this.space,
|
|
70
|
+
servers: this.servers,
|
|
71
|
+
// Declared overrides plus the connector's native default, unless this spawn explicitly
|
|
72
|
+
// restricts sharing. An empty selection is deliberate isolation, not the default.
|
|
73
|
+
mcpServers: connectorServers(cotalConfig, agent, shareTools),
|
|
74
|
+
mcpServersExclusive: shareTools !== undefined,
|
|
75
|
+
// The operator's spawn-env policy travels the same route: absent means no extras (the OS
|
|
76
|
+
// allow-list + operator knobs + connector-declared inputs), present means those names too.
|
|
77
|
+
// A connector never reads the config itself.
|
|
78
|
+
envAllow: spawnEnvAllow(cotalConfig),
|
|
79
|
+
resolvedBinaries: harness.binaries,
|
|
80
|
+
eventsRequired: this.eventsRequired,
|
|
81
|
+
...(this.eventPayloadsWithheld ? { eventPayloads: false } : {}),
|
|
82
|
+
// So a connector that keeps per-agent local state can root it at the workspace, not the
|
|
83
|
+
// (possibly per-agent) launch cwd.
|
|
84
|
+
workspaceRoot: this.workspaceRoot,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/** The refusal for a launch choice the connector cannot honour. Spawn and resume both ask before
|
|
88
|
+
* a seat's launch is built, so a rule changed here holds on both paths. */
|
|
89
|
+
capabilityRefusal(connector, launch) {
|
|
90
|
+
if (launch.variant && !connector.supportsModelVariant)
|
|
91
|
+
return `${connector.name} connector does not support model variants (variant)`;
|
|
92
|
+
if (launch.prompt !== undefined && !connector.supportsPrompt)
|
|
93
|
+
return `${connector.name} connector does not support an initial prompt (prompt)`;
|
|
94
|
+
if (launch.exact && (!connector.supportsSessionReopen || !connector.supportsSessionContinuation))
|
|
95
|
+
return `${connector.name} connector does not support exact session continuity (continuity: exact)`;
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
/** The refusal for an event-plane choice the registration policy or the connector cannot meet.
|
|
99
|
+
* Spawn and resume both ask before a seat's launch is built, so a seat retained without the
|
|
100
|
+
* plane cannot come back on a space that now requires it. An absent choice arms supported planes. */
|
|
101
|
+
eventsRefusal(connector, events) {
|
|
102
|
+
if (this.eventsRequired && events === false)
|
|
103
|
+
return `space "${this.space}" requires the event plane by registration policy; --no-events (events: false on the start op) is not allowed`;
|
|
104
|
+
if ((this.eventsRequired || events === true) && !connector.eventChannel)
|
|
105
|
+
return this.eventsRequired
|
|
106
|
+
? `space "${this.space}" requires the event plane by registration policy, but connector "${connector.name}" does not publish one`
|
|
107
|
+
: `connector "${connector.name}" does not publish an AG-UI event plane; omit --events to launch it without one`;
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=harness-resolution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"harness-resolution.js","sourceRoot":"","sources":["../src/harness-resolution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE3E,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAG3H;yGACyG;AACzG,MAAM,UAAU,cAAc,CAAC,IAAY,EAAE,QAA2B;IACtE,MAAM,QAAQ,GAA2B,EAAE,CAAC;IAC5C,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;QAChC,IAAI,IAAI;YAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;;YAC1B,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;IACD,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,QA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