@elliotding/ai-agent-mcp 0.2.21 → 0.2.22
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/client-adapters/codex-adapter.d.ts +48 -0
- package/dist/client-adapters/codex-adapter.d.ts.map +1 -0
- package/dist/client-adapters/codex-adapter.js +69 -0
- package/dist/client-adapters/codex-adapter.js.map +1 -0
- package/dist/client-adapters/cursor-adapter.d.ts +36 -0
- package/dist/client-adapters/cursor-adapter.d.ts.map +1 -0
- package/dist/client-adapters/cursor-adapter.js +65 -0
- package/dist/client-adapters/cursor-adapter.js.map +1 -0
- package/dist/client-adapters/index.d.ts +89 -0
- package/dist/client-adapters/index.d.ts.map +1 -0
- package/dist/client-adapters/index.js +49 -0
- package/dist/client-adapters/index.js.map +1 -0
- package/dist/config/index.d.ts +19 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +12 -2
- package/dist/config/index.js.map +1 -1
- package/dist/prompts/manager.d.ts +18 -0
- package/dist/prompts/manager.d.ts.map +1 -1
- package/dist/prompts/manager.js +51 -5
- package/dist/prompts/manager.js.map +1 -1
- package/dist/server/http.d.ts +10 -6
- package/dist/server/http.d.ts.map +1 -1
- package/dist/server/http.js +83 -89
- package/dist/server/http.js.map +1 -1
- package/dist/server/streamable-http.d.ts +28 -0
- package/dist/server/streamable-http.d.ts.map +1 -0
- package/dist/server/streamable-http.js +126 -0
- package/dist/server/streamable-http.js.map +1 -0
- package/dist/server.d.ts +8 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +60 -96
- package/dist/server.js.map +1 -1
- package/dist/telemetry/manager.d.ts +5 -0
- package/dist/telemetry/manager.d.ts.map +1 -1
- package/dist/telemetry/manager.js +5 -0
- package/dist/telemetry/manager.js.map +1 -1
- package/dist/tools/manage-subscription.d.ts.map +1 -1
- package/dist/tools/manage-subscription.js +33 -2
- package/dist/tools/manage-subscription.js.map +1 -1
- package/dist/tools/policy-generator.d.ts +31 -0
- package/dist/tools/policy-generator.d.ts.map +1 -0
- package/dist/tools/policy-generator.js +53 -0
- package/dist/tools/policy-generator.js.map +1 -0
- package/dist/tools/resolve-prompt-content.d.ts.map +1 -1
- package/dist/tools/resolve-prompt-content.js +14 -1
- package/dist/tools/resolve-prompt-content.js.map +1 -1
- package/dist/tools/search-resources.d.ts.map +1 -1
- package/dist/tools/search-resources.js +24 -0
- package/dist/tools/search-resources.js.map +1 -1
- package/dist/tools/sync-resources.d.ts.map +1 -1
- package/dist/tools/sync-resources.js +134 -39
- package/dist/tools/sync-resources.js.map +1 -1
- package/dist/tools/uninstall-resource.d.ts.map +1 -1
- package/dist/tools/uninstall-resource.js +21 -3
- package/dist/tools/uninstall-resource.js.map +1 -1
- package/dist/types/tools.d.ts +78 -1
- package/dist/types/tools.d.ts.map +1 -1
- package/dist/utils/codex-paths.d.ts +35 -0
- package/dist/utils/codex-paths.d.ts.map +1 -0
- package/dist/utils/codex-paths.js +49 -0
- package/dist/utils/codex-paths.js.map +1 -0
- package/package.json +1 -1
- package/dist/transport/sse.d.ts +0 -29
- package/dist/transport/sse.d.ts.map +0 -1
- package/dist/transport/sse.js +0 -271
- package/dist/transport/sse.js.map +0 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Codex Client Adapter
|
|
3
|
+
*
|
|
4
|
+
* Implements the ClientAdapter interface for the OpenAI Codex CLI client.
|
|
5
|
+
*
|
|
6
|
+
* Key differences from CursorAdapter:
|
|
7
|
+
* - Complex skills → ~/.csp-ai-agent/codex/skills/<name>/
|
|
8
|
+
* - Commands → transformed into Codex skill bundles (same path as skills)
|
|
9
|
+
* - Rules → aggregated into csp-routing-policy.md (no .mdc files written)
|
|
10
|
+
* - MCP config → ~/.codex/config.toml (merge_toml action, not mcp.json)
|
|
11
|
+
* - Policy delivery → developer_instructions in ~/.codex/config.toml
|
|
12
|
+
*/
|
|
13
|
+
import type { ClientAdapter, AgentProfile, PolicyStrategy } from './index.js';
|
|
14
|
+
export declare class CodexAdapter implements ClientAdapter {
|
|
15
|
+
readonly profile: AgentProfile;
|
|
16
|
+
/** Complex skills are cached in the Codex-specific sub-tree. */
|
|
17
|
+
getSkillDir(skillName: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Codex has no native "commands" concept. Commands are transformed into
|
|
20
|
+
* Codex skill bundles so they are placed in the skills directory under a
|
|
21
|
+
* namespaced sub-folder.
|
|
22
|
+
*/
|
|
23
|
+
getCommandDir(commandName: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Codex does not use per-file `.mdc` rules. Rules are instead aggregated
|
|
26
|
+
* into a single policy markdown file and injected via `developer_instructions`.
|
|
27
|
+
* This method returns an empty array to signal that no individual rule files
|
|
28
|
+
* should be written; the calling code in sync-resources must route rules to
|
|
29
|
+
* the policy aggregator instead.
|
|
30
|
+
*/
|
|
31
|
+
getRuleTargetDirs(_scope: string): string[];
|
|
32
|
+
/**
|
|
33
|
+
* Codex reads MCP server configurations from its native config.toml rather
|
|
34
|
+
* than a JSON mcp.json file.
|
|
35
|
+
*/
|
|
36
|
+
getMcpConfigPath(): string;
|
|
37
|
+
/**
|
|
38
|
+
* Policy is delivered by materialising a policy markdown file and injecting
|
|
39
|
+
* its file path into the `developer_instructions` key in config.toml.
|
|
40
|
+
*
|
|
41
|
+
* The MCP server emits a `merge_toml` LocalAction carrying the policy content
|
|
42
|
+
* and a `restart_required: true` field so the Agent can prompt the user to
|
|
43
|
+
* restart Codex for the policy to take effect.
|
|
44
|
+
*/
|
|
45
|
+
getPolicyStrategy(): PolicyStrategy;
|
|
46
|
+
getTelemetryTags(): Record<string, string>;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=codex-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex-adapter.d.ts","sourceRoot":"","sources":["../../src/client-adapters/codex-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAO9E,qBAAa,YAAa,YAAW,aAAa;IAChD,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAW;IAEzC,gEAAgE;IAChE,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAItC;;;;OAIG;IACH,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM;IAI1C;;;;;;OAMG;IACH,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE;IAI3C;;;OAGG;IACH,gBAAgB,IAAI,MAAM;IAI1B;;;;;;;OAOG;IACH,iBAAiB,IAAI,cAAc;IASnC,gBAAgB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAG3C"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Codex Client Adapter
|
|
4
|
+
*
|
|
5
|
+
* Implements the ClientAdapter interface for the OpenAI Codex CLI client.
|
|
6
|
+
*
|
|
7
|
+
* Key differences from CursorAdapter:
|
|
8
|
+
* - Complex skills → ~/.csp-ai-agent/codex/skills/<name>/
|
|
9
|
+
* - Commands → transformed into Codex skill bundles (same path as skills)
|
|
10
|
+
* - Rules → aggregated into csp-routing-policy.md (no .mdc files written)
|
|
11
|
+
* - MCP config → ~/.codex/config.toml (merge_toml action, not mcp.json)
|
|
12
|
+
* - Policy delivery → developer_instructions in ~/.codex/config.toml
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.CodexAdapter = void 0;
|
|
16
|
+
const codex_paths_js_1 = require("../utils/codex-paths.js");
|
|
17
|
+
class CodexAdapter {
|
|
18
|
+
profile = 'codex';
|
|
19
|
+
/** Complex skills are cached in the Codex-specific sub-tree. */
|
|
20
|
+
getSkillDir(skillName) {
|
|
21
|
+
return (0, codex_paths_js_1.getCodexSkillDirForClient)(skillName);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Codex has no native "commands" concept. Commands are transformed into
|
|
25
|
+
* Codex skill bundles so they are placed in the skills directory under a
|
|
26
|
+
* namespaced sub-folder.
|
|
27
|
+
*/
|
|
28
|
+
getCommandDir(commandName) {
|
|
29
|
+
return (0, codex_paths_js_1.getCodexSkillDirForClient)(`__cmd__${commandName}`);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Codex does not use per-file `.mdc` rules. Rules are instead aggregated
|
|
33
|
+
* into a single policy markdown file and injected via `developer_instructions`.
|
|
34
|
+
* This method returns an empty array to signal that no individual rule files
|
|
35
|
+
* should be written; the calling code in sync-resources must route rules to
|
|
36
|
+
* the policy aggregator instead.
|
|
37
|
+
*/
|
|
38
|
+
getRuleTargetDirs(_scope) {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Codex reads MCP server configurations from its native config.toml rather
|
|
43
|
+
* than a JSON mcp.json file.
|
|
44
|
+
*/
|
|
45
|
+
getMcpConfigPath() {
|
|
46
|
+
return (0, codex_paths_js_1.getCodexConfigTomlPathForClient)();
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Policy is delivered by materialising a policy markdown file and injecting
|
|
50
|
+
* its file path into the `developer_instructions` key in config.toml.
|
|
51
|
+
*
|
|
52
|
+
* The MCP server emits a `merge_toml` LocalAction carrying the policy content
|
|
53
|
+
* and a `restart_required: true` field so the Agent can prompt the user to
|
|
54
|
+
* restart Codex for the policy to take effect.
|
|
55
|
+
*/
|
|
56
|
+
getPolicyStrategy() {
|
|
57
|
+
return {
|
|
58
|
+
type: 'policy_inject',
|
|
59
|
+
policyFile: (0, codex_paths_js_1.getCodexPolicyPathForClient)(),
|
|
60
|
+
configTomlKey: 'developer_instructions',
|
|
61
|
+
configTomlPath: (0, codex_paths_js_1.getCodexConfigTomlPathForClient)(),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
getTelemetryTags() {
|
|
65
|
+
return { agent_profile: 'codex' };
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.CodexAdapter = CodexAdapter;
|
|
69
|
+
//# sourceMappingURL=codex-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex-adapter.js","sourceRoot":"","sources":["../../src/client-adapters/codex-adapter.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAGH,4DAIiC;AAEjC,MAAa,YAAY;IACd,OAAO,GAAiB,OAAO,CAAC;IAEzC,gEAAgE;IAChE,WAAW,CAAC,SAAiB;QAC3B,OAAO,IAAA,0CAAyB,EAAC,SAAS,CAAC,CAAC;IAC9C,CAAC;IAED;;;;OAIG;IACH,aAAa,CAAC,WAAmB;QAC/B,OAAO,IAAA,0CAAyB,EAAC,UAAU,WAAW,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED;;;;;;OAMG;IACH,iBAAiB,CAAC,MAAc;QAC9B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED;;;OAGG;IACH,gBAAgB;QACd,OAAO,IAAA,gDAA+B,GAAE,CAAC;IAC3C,CAAC;IAED;;;;;;;OAOG;IACH,iBAAiB;QACf,OAAO;YACL,IAAI,EAAE,eAAe;YACrB,UAAU,EAAE,IAAA,4CAA2B,GAAE;YACzC,aAAa,EAAE,wBAAwB;YACvC,cAAc,EAAE,IAAA,gDAA+B,GAAE;SAClD,CAAC;IACJ,CAAC;IAED,gBAAgB;QACd,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC;IACpC,CAAC;CACF;AAxDD,oCAwDC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cursor Client Adapter
|
|
3
|
+
*
|
|
4
|
+
* Wraps the existing cursor-paths.ts behaviour so that all current code paths
|
|
5
|
+
* continue to work unchanged. This adapter must produce identical output to
|
|
6
|
+
* what the pre-adapter code produced for every method.
|
|
7
|
+
*/
|
|
8
|
+
import type { ClientAdapter, AgentProfile, PolicyStrategy } from './index.js';
|
|
9
|
+
export declare class CursorAdapter implements ClientAdapter {
|
|
10
|
+
readonly profile: AgentProfile;
|
|
11
|
+
/**
|
|
12
|
+
* Complex skills are cached in ~/.csp-ai-agent/skills/<name>/ (path-isolated
|
|
13
|
+
* from Cursor's own ~/.cursor/skills/ to keep Cursor from auto-discovering them).
|
|
14
|
+
*/
|
|
15
|
+
getSkillDir(skillName: string): string;
|
|
16
|
+
/** Cursor slash commands → ~/.cursor/commands/<name>/ */
|
|
17
|
+
getCommandDir(commandName: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Resolves the target directories for a rule depending on its scope.
|
|
20
|
+
*
|
|
21
|
+
* - `global` → ~/.cursor/rules/ (applies to every workspace)
|
|
22
|
+
* - `workspace` → (the calling tool will inject the workspace path; returned
|
|
23
|
+
* here as a sentinel that callers can detect and replace)
|
|
24
|
+
* - `all` → both global and workspace targets
|
|
25
|
+
*/
|
|
26
|
+
getRuleTargetDirs(scope: string): string[];
|
|
27
|
+
/** Cursor reads MCP server configs from ~/.cursor/mcp.json */
|
|
28
|
+
getMcpConfigPath(): string;
|
|
29
|
+
/**
|
|
30
|
+
* Cursor uses `.mdc` files placed in `~/.cursor/rules/` to deliver
|
|
31
|
+
* routing policies. No TOML injection needed.
|
|
32
|
+
*/
|
|
33
|
+
getPolicyStrategy(): PolicyStrategy;
|
|
34
|
+
getTelemetryTags(): Record<string, string>;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=cursor-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor-adapter.d.ts","sourceRoot":"","sources":["../../src/client-adapters/cursor-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAM9E,qBAAa,aAAc,YAAW,aAAa;IACjD,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAY;IAE1C;;;OAGG;IACH,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAItC,yDAAyD;IACzD,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM;IAI1C;;;;;;;OAOG;IACH,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAc1C,8DAA8D;IAC9D,gBAAgB,IAAI,MAAM;IAI1B;;;OAGG;IACH,iBAAiB,IAAI,cAAc;IAOnC,gBAAgB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAG3C"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Cursor Client Adapter
|
|
4
|
+
*
|
|
5
|
+
* Wraps the existing cursor-paths.ts behaviour so that all current code paths
|
|
6
|
+
* continue to work unchanged. This adapter must produce identical output to
|
|
7
|
+
* what the pre-adapter code produced for every method.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.CursorAdapter = void 0;
|
|
11
|
+
const cursor_paths_js_1 = require("../utils/cursor-paths.js");
|
|
12
|
+
class CursorAdapter {
|
|
13
|
+
profile = 'cursor';
|
|
14
|
+
/**
|
|
15
|
+
* Complex skills are cached in ~/.csp-ai-agent/skills/<name>/ (path-isolated
|
|
16
|
+
* from Cursor's own ~/.cursor/skills/ to keep Cursor from auto-discovering them).
|
|
17
|
+
*/
|
|
18
|
+
getSkillDir(skillName) {
|
|
19
|
+
return `${(0, cursor_paths_js_1.getCspAgentDirForClient)('skills')}/${skillName}`;
|
|
20
|
+
}
|
|
21
|
+
/** Cursor slash commands → ~/.cursor/commands/<name>/ */
|
|
22
|
+
getCommandDir(commandName) {
|
|
23
|
+
return `${(0, cursor_paths_js_1.getCursorRootDirForClient)()}/commands/${commandName}`;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Resolves the target directories for a rule depending on its scope.
|
|
27
|
+
*
|
|
28
|
+
* - `global` → ~/.cursor/rules/ (applies to every workspace)
|
|
29
|
+
* - `workspace` → (the calling tool will inject the workspace path; returned
|
|
30
|
+
* here as a sentinel that callers can detect and replace)
|
|
31
|
+
* - `all` → both global and workspace targets
|
|
32
|
+
*/
|
|
33
|
+
getRuleTargetDirs(scope) {
|
|
34
|
+
const globalDir = `${(0, cursor_paths_js_1.getCursorRootDirForClient)()}/rules`;
|
|
35
|
+
switch (scope) {
|
|
36
|
+
case 'global':
|
|
37
|
+
return [globalDir];
|
|
38
|
+
case 'workspace':
|
|
39
|
+
return ['__WORKSPACE_RULES_DIR__'];
|
|
40
|
+
case 'all':
|
|
41
|
+
return [globalDir, '__WORKSPACE_RULES_DIR__'];
|
|
42
|
+
default:
|
|
43
|
+
return [globalDir];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/** Cursor reads MCP server configs from ~/.cursor/mcp.json */
|
|
47
|
+
getMcpConfigPath() {
|
|
48
|
+
return `${(0, cursor_paths_js_1.getCursorRootDirForClient)()}/mcp.json`;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Cursor uses `.mdc` files placed in `~/.cursor/rules/` to deliver
|
|
52
|
+
* routing policies. No TOML injection needed.
|
|
53
|
+
*/
|
|
54
|
+
getPolicyStrategy() {
|
|
55
|
+
return {
|
|
56
|
+
type: 'mdc',
|
|
57
|
+
targetDir: `${(0, cursor_paths_js_1.getCursorRootDirForClient)()}/rules`,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
getTelemetryTags() {
|
|
61
|
+
return { agent_profile: 'cursor' };
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.CursorAdapter = CursorAdapter;
|
|
65
|
+
//# sourceMappingURL=cursor-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor-adapter.js","sourceRoot":"","sources":["../../src/client-adapters/cursor-adapter.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAGH,8DAGkC;AAElC,MAAa,aAAa;IACf,OAAO,GAAiB,QAAQ,CAAC;IAE1C;;;OAGG;IACH,WAAW,CAAC,SAAiB;QAC3B,OAAO,GAAG,IAAA,yCAAuB,EAAC,QAAQ,CAAC,IAAI,SAAS,EAAE,CAAC;IAC7D,CAAC;IAED,yDAAyD;IACzD,aAAa,CAAC,WAAmB;QAC/B,OAAO,GAAG,IAAA,2CAAyB,GAAE,aAAa,WAAW,EAAE,CAAC;IAClE,CAAC;IAED;;;;;;;OAOG;IACH,iBAAiB,CAAC,KAAa;QAC7B,MAAM,SAAS,GAAG,GAAG,IAAA,2CAAyB,GAAE,QAAQ,CAAC;QACzD,QAAQ,KAAK,EAAE,CAAC;YACd,KAAK,QAAQ;gBACX,OAAO,CAAC,SAAS,CAAC,CAAC;YACrB,KAAK,WAAW;gBACd,OAAO,CAAC,yBAAyB,CAAC,CAAC;YACrC,KAAK,KAAK;gBACR,OAAO,CAAC,SAAS,EAAE,yBAAyB,CAAC,CAAC;YAChD;gBACE,OAAO,CAAC,SAAS,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAED,8DAA8D;IAC9D,gBAAgB;QACd,OAAO,GAAG,IAAA,2CAAyB,GAAE,WAAW,CAAC;IACnD,CAAC;IAED;;;OAGG;IACH,iBAAiB;QACf,OAAO;YACL,IAAI,EAAE,KAAK;YACX,SAAS,EAAE,GAAG,IAAA,2CAAyB,GAAE,QAAQ;SAClD,CAAC;IACJ,CAAC;IAED,gBAAgB;QACd,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC;IACrC,CAAC;CACF;AAzDD,sCAyDC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client Adapter Framework
|
|
3
|
+
*
|
|
4
|
+
* Provides an abstraction layer so that all client-specific logic (path
|
|
5
|
+
* resolution, distribution strategy, policy injection) is routed through
|
|
6
|
+
* a pluggable adapter rather than scattered `if (profile === 'codex')` checks
|
|
7
|
+
* throughout shared tools.
|
|
8
|
+
*
|
|
9
|
+
* Two built-in adapters:
|
|
10
|
+
* CursorAdapter – behaviour identical to the existing Cursor-only code paths
|
|
11
|
+
* CodexAdapter – new Codex-specific paths and policy injection strategy
|
|
12
|
+
*/
|
|
13
|
+
export type AgentProfile = 'cursor' | 'codex';
|
|
14
|
+
/**
|
|
15
|
+
* Describes where a resource should be materialised on the client machine
|
|
16
|
+
* and which LocalAction type should be used to write it.
|
|
17
|
+
*/
|
|
18
|
+
export interface MaterializationPath {
|
|
19
|
+
/** Destination path on the user's local machine (may start with ~). */
|
|
20
|
+
localPath: string;
|
|
21
|
+
/** Which LocalAction type the server should emit for this file. */
|
|
22
|
+
actionType: 'write_file' | 'merge_mcp_json' | 'merge_toml' | 'skip';
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Describes how global routing policies (CSP prompt-routing rules) are
|
|
26
|
+
* delivered to the client agent.
|
|
27
|
+
*
|
|
28
|
+
* - `mdc` – write a `.mdc` file into `~/.cursor/rules/`
|
|
29
|
+
* - `policy_inject` – materialise a policy markdown file and inject its path
|
|
30
|
+
* into the Codex `developer_instructions` config key
|
|
31
|
+
*/
|
|
32
|
+
export interface PolicyStrategy {
|
|
33
|
+
type: 'mdc' | 'policy_inject';
|
|
34
|
+
/** For `mdc` – target directory for the generated `.mdc` file. */
|
|
35
|
+
targetDir?: string;
|
|
36
|
+
/** For `policy_inject` – path of the materialised policy markdown file. */
|
|
37
|
+
policyFile?: string;
|
|
38
|
+
/**
|
|
39
|
+
* For `policy_inject` – TOML config key to update.
|
|
40
|
+
* Typically `developer_instructions`.
|
|
41
|
+
*/
|
|
42
|
+
configTomlKey?: string;
|
|
43
|
+
/**
|
|
44
|
+
* For `policy_inject` – absolute path to the client config TOML file.
|
|
45
|
+
* Typically `~/.codex/config.toml`.
|
|
46
|
+
*/
|
|
47
|
+
configTomlPath?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Interface that every client adapter must satisfy.
|
|
51
|
+
*
|
|
52
|
+
* Each method returns a path or descriptor; it is the caller's
|
|
53
|
+
* responsibility to translate that into a concrete LocalAction.
|
|
54
|
+
*/
|
|
55
|
+
export interface ClientAdapter {
|
|
56
|
+
readonly profile: AgentProfile;
|
|
57
|
+
/** Directory where complex skills are cached for this client. */
|
|
58
|
+
getSkillDir(skillName: string): string;
|
|
59
|
+
/** Directory where commands are cached for this client. */
|
|
60
|
+
getCommandDir(commandName: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* Returns all local directories that a rule with the given scope should be
|
|
63
|
+
* written to. May return an empty array when rules are aggregated into a
|
|
64
|
+
* policy file instead (Codex).
|
|
65
|
+
*/
|
|
66
|
+
getRuleTargetDirs(scope: string): string[];
|
|
67
|
+
/** Absolute path to the MCP server config file for this client. */
|
|
68
|
+
getMcpConfigPath(): string;
|
|
69
|
+
/** Policy delivery strategy for this client. */
|
|
70
|
+
getPolicyStrategy(): PolicyStrategy;
|
|
71
|
+
/** Additional telemetry tags to attach for this client (e.g. agent_profile). */
|
|
72
|
+
getTelemetryTags(): Record<string, string>;
|
|
73
|
+
}
|
|
74
|
+
export declare class ClientAdapterRegistry {
|
|
75
|
+
private readonly adapters;
|
|
76
|
+
register(adapter: ClientAdapter): void;
|
|
77
|
+
/**
|
|
78
|
+
* Returns the adapter for the requested profile.
|
|
79
|
+
* Falls back to the `cursor` adapter when the requested profile has not
|
|
80
|
+
* been registered, ensuring backward-compatible behaviour for all existing
|
|
81
|
+
* callers.
|
|
82
|
+
*/
|
|
83
|
+
get(profile: AgentProfile): ClientAdapter;
|
|
84
|
+
/** Returns true when an adapter for the given profile has been registered. */
|
|
85
|
+
has(profile: AgentProfile): boolean;
|
|
86
|
+
}
|
|
87
|
+
/** Shared singleton registry. Adapters are registered at module load time. */
|
|
88
|
+
export declare const adapterRegistry: ClientAdapterRegistry;
|
|
89
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1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AI;IAItC;;;;;OAKG;IACH,GAAG,CAAC,OAAO,EAAE,YAAY,GAAG,aAAa;IAYzC,8EAA8E;IAC9E,GAAG,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO;CAGpC;AAED,8EAA8E;AAC9E,eAAO,MAAM,eAAe,uBAA8B,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Client Adapter Framework
|
|
4
|
+
*
|
|
5
|
+
* Provides an abstraction layer so that all client-specific logic (path
|
|
6
|
+
* resolution, distribution strategy, policy injection) is routed through
|
|
7
|
+
* a pluggable adapter rather than scattered `if (profile === 'codex')` checks
|
|
8
|
+
* throughout shared tools.
|
|
9
|
+
*
|
|
10
|
+
* Two built-in adapters:
|
|
11
|
+
* CursorAdapter – behaviour identical to the existing Cursor-only code paths
|
|
12
|
+
* CodexAdapter – new Codex-specific paths and policy injection strategy
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.adapterRegistry = exports.ClientAdapterRegistry = void 0;
|
|
16
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
17
|
+
// Registry
|
|
18
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
19
|
+
class ClientAdapterRegistry {
|
|
20
|
+
adapters = new Map();
|
|
21
|
+
register(adapter) {
|
|
22
|
+
this.adapters.set(adapter.profile, adapter);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Returns the adapter for the requested profile.
|
|
26
|
+
* Falls back to the `cursor` adapter when the requested profile has not
|
|
27
|
+
* been registered, ensuring backward-compatible behaviour for all existing
|
|
28
|
+
* callers.
|
|
29
|
+
*/
|
|
30
|
+
get(profile) {
|
|
31
|
+
const adapter = this.adapters.get(profile);
|
|
32
|
+
if (adapter) {
|
|
33
|
+
return adapter;
|
|
34
|
+
}
|
|
35
|
+
const fallback = this.adapters.get('cursor');
|
|
36
|
+
if (fallback) {
|
|
37
|
+
return fallback;
|
|
38
|
+
}
|
|
39
|
+
throw new Error(`ClientAdapterRegistry: no adapter registered for profile '${profile}' and no cursor fallback available`);
|
|
40
|
+
}
|
|
41
|
+
/** Returns true when an adapter for the given profile has been registered. */
|
|
42
|
+
has(profile) {
|
|
43
|
+
return this.adapters.has(profile);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.ClientAdapterRegistry = ClientAdapterRegistry;
|
|
47
|
+
/** Shared singleton registry. Adapters are registered at module load time. */
|
|
48
|
+
exports.adapterRegistry = new ClientAdapterRegistry();
|
|
49
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client-adapters/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AA6EH,gFAAgF;AAChF,WAAW;AACX,gFAAgF;AAEhF,MAAa,qBAAqB;IACf,QAAQ,GAAG,IAAI,GAAG,EAA+B,CAAC;IAEnE,QAAQ,CAAC,OAAsB;QAC7B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAC,OAAqB;QACvB,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC3C,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC7C,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,6DAA6D,OAAO,oCAAoC,CAAC,CAAC;IAC5H,CAAC;IAED,8EAA8E;IAC9E,GAAG,CAAC,OAAqB;QACvB,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;CACF;AA7BD,sDA6BC;AAED,8EAA8E;AACjE,QAAA,eAAe,GAAG,IAAI,qBAAqB,EAAE,CAAC"}
|
package/dist/config/index.d.ts
CHANGED
|
@@ -2,13 +2,26 @@
|
|
|
2
2
|
* Configuration Management Module
|
|
3
3
|
* Loads and validates configuration from environment variables
|
|
4
4
|
*/
|
|
5
|
+
import type { AgentProfile } from '../client-adapters/index.js';
|
|
5
6
|
export interface Config {
|
|
6
7
|
nodeEnv: 'development' | 'production' | 'test';
|
|
7
8
|
port: number;
|
|
8
9
|
logLevel: 'debug' | 'info' | 'warn' | 'error';
|
|
9
10
|
transport: {
|
|
10
|
-
|
|
11
|
+
/**
|
|
12
|
+
* 'stdio' — local stdio (Cursor local MCP)
|
|
13
|
+
* 'sse' — legacy SSE only (Cursor remote MCP)
|
|
14
|
+
* 'streamable_http' — Streamable HTTP only (Codex CLI)
|
|
15
|
+
* 'dual' — SSE + Streamable HTTP simultaneously (both clients)
|
|
16
|
+
*/
|
|
17
|
+
mode: 'stdio' | 'sse' | 'streamable_http' | 'dual';
|
|
11
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* Identifies which AI client this server instance is serving.
|
|
21
|
+
* Set via the CSP_AGENT_PROFILE environment variable.
|
|
22
|
+
* Defaults to 'cursor' for backward compatibility.
|
|
23
|
+
*/
|
|
24
|
+
agentProfile: AgentProfile;
|
|
12
25
|
http?: {
|
|
13
26
|
host: string;
|
|
14
27
|
port: number;
|
|
@@ -31,6 +44,11 @@ export interface Config {
|
|
|
31
44
|
*/
|
|
32
45
|
publicOrigin: string;
|
|
33
46
|
};
|
|
47
|
+
streamableHttp?: {
|
|
48
|
+
host: string;
|
|
49
|
+
port: number;
|
|
50
|
+
basePath: string;
|
|
51
|
+
};
|
|
34
52
|
session?: {
|
|
35
53
|
timeout: number;
|
|
36
54
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAwBhE,MAAM,WAAW,MAAM;IAErB,OAAO,EAAE,aAAa,GAAG,YAAY,GAAG,MAAM,CAAC;IAG/C,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IAG9C,SAAS,EAAE;QACT;;;;;WAKG;QACH,IAAI,EAAE,OAAO,GAAG,KAAK,GAAG,iBAAiB,GAAG,MAAM,CAAC;KACpD,CAAC;IAEF;;;;OAIG;IACH,YAAY,EAAE,YAAY,CAAC;IAG3B,IAAI,CAAC,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb;;;;WAIG;QACH,QAAQ,EAAE,MAAM,CAAC;QACjB;;;;;;;;;;WAUG;QACH,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;IAKF,cAAc,CAAC,EAAE;QACf,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;IAGF,OAAO,CAAC,EAAE;QACR,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IAGF,GAAG,EAAE;QACH,UAAU,EAAE,MAAM,CAAC;QAKnB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IAGF,GAAG,EAAE;QACH,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IAKF,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAGhC,KAAK,EAAE;QACL,OAAO,EAAE,OAAO,CAAC;QACjB,KAAK,CAAC,EAAE;YACN,GAAG,EAAE,MAAM,CAAC;YACZ,GAAG,EAAE,MAAM,CAAC;SACb,CAAC;QACF,MAAM,EAAE;YACN,OAAO,EAAE,MAAM,CAAC;SACjB,CAAC;KACH,CAAC;IAGF,QAAQ,CAAC,EAAE;QACT,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;IAGF,OAAO,EAAE;QACP,OAAO,EAAE,OAAO,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;IAGF,OAAO,EAAE;QACP,GAAG,EAAE,MAAM,CAAC;QACZ,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAoCD,wBAAgB,UAAU,IAAI,MAAM,CAmGnC;AAGD,QAAA,IAAI,MAAM,EAAE,MAAM,CAAC;AAqBnB,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
package/dist/config/index.js
CHANGED
|
@@ -96,14 +96,19 @@ function loadConfig() {
|
|
|
96
96
|
const nodeEnv = (process.env.NODE_ENV || 'development');
|
|
97
97
|
const logLevel = (process.env.LOG_LEVEL || 'info');
|
|
98
98
|
const transportMode = (process.env.TRANSPORT_MODE || 'stdio');
|
|
99
|
+
// In dual mode the server serves both Cursor (SSE) and Codex (Streamable HTTP),
|
|
100
|
+
// so agentProfile defaults to 'cursor' for backward-compatible SSE behaviour;
|
|
101
|
+
// the Streamable HTTP path sets it per-request via the adapter registry.
|
|
102
|
+
const agentProfile = (process.env.CSP_AGENT_PROFILE === 'codex' ? 'codex' : 'cursor');
|
|
99
103
|
return {
|
|
100
104
|
nodeEnv,
|
|
101
105
|
port: getEnvNumber('PORT', 5090),
|
|
102
106
|
logLevel,
|
|
107
|
+
agentProfile,
|
|
103
108
|
transport: {
|
|
104
109
|
mode: transportMode,
|
|
105
110
|
},
|
|
106
|
-
http: transportMode === 'sse' ? (() => {
|
|
111
|
+
http: (transportMode === 'sse' || transportMode === 'dual') ? (() => {
|
|
107
112
|
const host = getEnv('HTTP_HOST', '0.0.0.0');
|
|
108
113
|
const port = getEnvNumber('HTTP_PORT', 3000);
|
|
109
114
|
const basePath = getEnv('HTTP_BASE_PATH', '');
|
|
@@ -132,7 +137,12 @@ function loadConfig() {
|
|
|
132
137
|
}
|
|
133
138
|
return { host, port, basePath, publicOrigin };
|
|
134
139
|
})() : undefined,
|
|
135
|
-
|
|
140
|
+
streamableHttp: (transportMode === 'streamable_http' || transportMode === 'dual') ? {
|
|
141
|
+
host: getEnv('STREAMABLE_HTTP_HOST', '0.0.0.0'),
|
|
142
|
+
port: getEnvNumber('STREAMABLE_HTTP_PORT', 3001),
|
|
143
|
+
basePath: getEnv('HTTP_BASE_PATH', ''), // share the same base path prefix
|
|
144
|
+
} : undefined,
|
|
145
|
+
session: (transportMode === 'sse' || transportMode === 'dual') ? {
|
|
136
146
|
timeout: getEnvNumber('SESSION_TIMEOUT', 3600),
|
|
137
147
|
} : undefined,
|
|
138
148
|
csp: {
|
package/dist/config/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkLH,gCAmGC;AAnRD,+CAAiC;AACjC,2CAA6B;AAC7B,uCAAyB;AAGzB,2BAA2B;AAC3B,uCAAuC;AACvC,MAAM,gBAAgB,GAAG;IACvB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,EAAqB,4BAA4B;IACpF,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,YAAY,CAAC,EAAmB,oCAAoC;IAC5F,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,eAAe,CAAC,EAAgB,mCAAmC;C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,aAAa,EAAE,YAAY,CAAC,oBAAoB,EAAE,CAAC,CAAC;SACrD;KACF,CAAC;AACJ,CAAC;AAED,iCAAiC;AACjC,IAAI,MAAc,CAAC;AAEnB,IAAI,CAAC;IACH,iBAAA,MAAM,GAAG,UAAU,EAAE,CAAC;AACxB,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IACf,4CAA4C;IAC5C,sJAAsJ;IACtJ,MAAM,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC,MAAM,CAAC;IACjD,yGAAyG;IACzG,MAAM,CAAC,KAAK,CACV;QACE,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE,aAAa;QACxB,KAAK,EAAG,KAAe,CAAC,OAAO;QAC/B,KAAK,EAAG,KAAe,CAAC,KAAK;KAC9B,EACD,8BAA8B,CAC/B,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -87,6 +87,12 @@ export declare class PromptManager {
|
|
|
87
87
|
* GetPrompt calls.
|
|
88
88
|
*/
|
|
89
89
|
private readonly userSyncActions;
|
|
90
|
+
/**
|
|
91
|
+
* Per-user cache of restart hints from Codex policy injection.
|
|
92
|
+
* Populated after a sync that emitted merge_toml actions requiring a restart.
|
|
93
|
+
* Consumed and cleared when the setup prompt is fetched.
|
|
94
|
+
*/
|
|
95
|
+
private readonly userRestartHints;
|
|
90
96
|
/**
|
|
91
97
|
* Tracks which Server instances already have handlers installed.
|
|
92
98
|
* Each SSE connection creates a new Server instance, so we track per-instance
|
|
@@ -116,6 +122,18 @@ export declare class PromptManager {
|
|
|
116
122
|
* @param actions The list of local file-system actions to execute.
|
|
117
123
|
*/
|
|
118
124
|
storeSyncActions(userToken: string, actions: LocalAction[]): void;
|
|
125
|
+
/**
|
|
126
|
+
* Store a restart hint for the given user.
|
|
127
|
+
* Called when sync_resources produces merge_toml actions that require a
|
|
128
|
+
* Codex session restart to take effect.
|
|
129
|
+
*/
|
|
130
|
+
storeRestartHint(userToken: string, hint: string): void;
|
|
131
|
+
/**
|
|
132
|
+
* Consume and return the cached restart hint for a user.
|
|
133
|
+
* Returns undefined if no hint is cached.
|
|
134
|
+
* The cache is cleared after retrieval.
|
|
135
|
+
*/
|
|
136
|
+
consumeRestartHint(userToken: string): string | undefined;
|
|
119
137
|
/**
|
|
120
138
|
* Consume and return the cached sync actions for a user.
|
|
121
139
|
* Returns undefined if no actions are cached (nothing to do).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/prompts/manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAMH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAKxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAOrD,KAAK,eAAe,GAAG,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAE7D,MAAM,WAAW,kBAAkB;IACjC,+EAA+E;IAC/E,WAAW,EAAE,MAAM,CAAC;IACpB,0BAA0B;IAC1B,aAAa,EAAE,SAAS,GAAG,OAAO,CAAC;IACnC,oCAAoC;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,0DAA0D;IAC1D,WAAW,EAAE,MAAM,CAAC;IACpB,gEAAgE;IAChE,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,gBAAgB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,kBAAkB,CAAC;CAC1B;AAED,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,kBAAkB,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,OAAO,GAAG,WAAW,G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