@stigmer/mcp-server 3.0.8-dev.20260612122433
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 +190 -0
- package/README.md +157 -0
- package/cli/mcp-server-stigmer.d.ts +3 -0
- package/cli/mcp-server-stigmer.d.ts.map +1 -0
- package/cli/mcp-server-stigmer.js +201 -0
- package/cli/mcp-server-stigmer.js.map +1 -0
- package/config.d.ts +44 -0
- package/config.d.ts.map +1 -0
- package/config.js +92 -0
- package/config.js.map +1 -0
- package/domains/agents/apply.d.ts +4 -0
- package/domains/agents/apply.d.ts.map +1 -0
- package/domains/agents/apply.js +25 -0
- package/domains/agents/apply.js.map +1 -0
- package/domains/agents/delete.d.ts +3 -0
- package/domains/agents/delete.d.ts.map +1 -0
- package/domains/agents/delete.js +35 -0
- package/domains/agents/delete.js.map +1 -0
- package/domains/agents/fetch.d.ts +6 -0
- package/domains/agents/fetch.d.ts.map +1 -0
- package/domains/agents/fetch.js +24 -0
- package/domains/agents/fetch.js.map +1 -0
- package/domains/agents/resources.d.ts +5 -0
- package/domains/agents/resources.d.ts.map +1 -0
- package/domains/agents/resources.js +16 -0
- package/domains/agents/resources.js.map +1 -0
- package/domains/agents/tools.d.ts +5 -0
- package/domains/agents/tools.d.ts.map +1 -0
- package/domains/agents/tools.js +41 -0
- package/domains/agents/tools.js.map +1 -0
- package/domains/client.d.ts +53 -0
- package/domains/client.d.ts.map +1 -0
- package/domains/client.js +62 -0
- package/domains/client.js.map +1 -0
- package/domains/marshal.d.ts +8 -0
- package/domains/marshal.d.ts.map +1 -0
- package/domains/marshal.js +17 -0
- package/domains/marshal.js.map +1 -0
- package/domains/mcpservers/apply.d.ts +4 -0
- package/domains/mcpservers/apply.d.ts.map +1 -0
- package/domains/mcpservers/apply.js +26 -0
- package/domains/mcpservers/apply.js.map +1 -0
- package/domains/mcpservers/delete.d.ts +6 -0
- package/domains/mcpservers/delete.d.ts.map +1 -0
- package/domains/mcpservers/delete.js +42 -0
- package/domains/mcpservers/delete.js.map +1 -0
- package/domains/mcpservers/fetch.d.ts +7 -0
- package/domains/mcpservers/fetch.d.ts.map +1 -0
- package/domains/mcpservers/fetch.js +26 -0
- package/domains/mcpservers/fetch.js.map +1 -0
- package/domains/mcpservers/resources.d.ts +5 -0
- package/domains/mcpservers/resources.d.ts.map +1 -0
- package/domains/mcpservers/resources.js +16 -0
- package/domains/mcpservers/resources.js.map +1 -0
- package/domains/mcpservers/tools.d.ts +5 -0
- package/domains/mcpservers/tools.d.ts.map +1 -0
- package/domains/mcpservers/tools.js +39 -0
- package/domains/mcpservers/tools.js.map +1 -0
- package/domains/resourcehandler.d.ts +27 -0
- package/domains/resourcehandler.d.ts.map +1 -0
- package/domains/resourcehandler.js +32 -0
- package/domains/resourcehandler.js.map +1 -0
- package/domains/resourceuri.d.ts +34 -0
- package/domains/resourceuri.d.ts.map +1 -0
- package/domains/resourceuri.js +100 -0
- package/domains/resourceuri.js.map +1 -0
- package/domains/rpcerr.d.ts +8 -0
- package/domains/rpcerr.d.ts.map +1 -0
- package/domains/rpcerr.js +42 -0
- package/domains/rpcerr.js.map +1 -0
- package/domains/search/tools.d.ts +5 -0
- package/domains/search/tools.d.ts.map +1 -0
- package/domains/search/tools.js +125 -0
- package/domains/search/tools.js.map +1 -0
- package/domains/skills/delete.d.ts +6 -0
- package/domains/skills/delete.d.ts.map +1 -0
- package/domains/skills/delete.js +38 -0
- package/domains/skills/delete.js.map +1 -0
- package/domains/skills/fetch.d.ts +6 -0
- package/domains/skills/fetch.d.ts.map +1 -0
- package/domains/skills/fetch.js +28 -0
- package/domains/skills/fetch.js.map +1 -0
- package/domains/skills/resources.d.ts +5 -0
- package/domains/skills/resources.d.ts.map +1 -0
- package/domains/skills/resources.js +25 -0
- package/domains/skills/resources.js.map +1 -0
- package/domains/skills/tools.d.ts +5 -0
- package/domains/skills/tools.d.ts.map +1 -0
- package/domains/skills/tools.js +39 -0
- package/domains/skills/tools.js.map +1 -0
- package/domains/toolresult.d.ts +12 -0
- package/domains/toolresult.d.ts.map +1 -0
- package/domains/toolresult.js +30 -0
- package/domains/toolresult.js.map +1 -0
- package/domains/workflowexecutions/tools.d.ts +5 -0
- package/domains/workflowexecutions/tools.d.ts.map +1 -0
- package/domains/workflowexecutions/tools.js +80 -0
- package/domains/workflowexecutions/tools.js.map +1 -0
- package/domains/workflows/apply.d.ts +4 -0
- package/domains/workflows/apply.d.ts.map +1 -0
- package/domains/workflows/apply.js +30 -0
- package/domains/workflows/apply.js.map +1 -0
- package/domains/workflows/delete.d.ts +3 -0
- package/domains/workflows/delete.d.ts.map +1 -0
- package/domains/workflows/delete.js +35 -0
- package/domains/workflows/delete.js.map +1 -0
- package/domains/workflows/fetch.d.ts +6 -0
- package/domains/workflows/fetch.d.ts.map +1 -0
- package/domains/workflows/fetch.js +25 -0
- package/domains/workflows/fetch.js.map +1 -0
- package/domains/workflows/resources.d.ts +5 -0
- package/domains/workflows/resources.d.ts.map +1 -0
- package/domains/workflows/resources.js +16 -0
- package/domains/workflows/resources.js.map +1 -0
- package/domains/workflows/taskkinds.d.ts +5 -0
- package/domains/workflows/taskkinds.d.ts.map +1 -0
- package/domains/workflows/taskkinds.js +66 -0
- package/domains/workflows/taskkinds.js.map +1 -0
- package/domains/workflows/tools.d.ts +5 -0
- package/domains/workflows/tools.d.ts.map +1 -0
- package/domains/workflows/tools.js +35 -0
- package/domains/workflows/tools.js.map +1 -0
- package/domains/workflows/validate.d.ts +5 -0
- package/domains/workflows/validate.d.ts.map +1 -0
- package/domains/workflows/validate.js +113 -0
- package/domains/workflows/validate.js.map +1 -0
- package/gen/agent.d.ts +385 -0
- package/gen/agent.d.ts.map +1 -0
- package/gen/agent.js +170 -0
- package/gen/agent.js.map +1 -0
- package/gen/apply-runtime.d.ts +18 -0
- package/gen/apply-runtime.d.ts.map +1 -0
- package/gen/apply-runtime.js +50 -0
- package/gen/apply-runtime.js.map +1 -0
- package/gen/mcpserver.d.ts +289 -0
- package/gen/mcpserver.d.ts.map +1 -0
- package/gen/mcpserver.js +166 -0
- package/gen/mcpserver.js.map +1 -0
- package/gen/workflow.d.ts +805 -0
- package/gen/workflow.d.ts.map +1 -0
- package/gen/workflow.js +842 -0
- package/gen/workflow.js.map +1 -0
- package/index.d.ts +20 -0
- package/index.d.ts.map +1 -0
- package/index.js +58 -0
- package/index.js.map +1 -0
- package/logger.d.ts +20 -0
- package/logger.d.ts.map +1 -0
- package/logger.js +41 -0
- package/logger.js.map +1 -0
- package/package.json +43 -0
- package/server.d.ts +60 -0
- package/server.d.ts.map +1 -0
- package/server.js +366 -0
- package/server.js.map +1 -0
- package/src/cli/mcp-server-stigmer.ts +42 -0
- package/src/config.test.ts +88 -0
- package/src/config.ts +151 -0
- package/src/domains/agents/apply.ts +30 -0
- package/src/domains/agents/delete.ts +41 -0
- package/src/domains/agents/fetch.ts +33 -0
- package/src/domains/agents/resources.ts +20 -0
- package/src/domains/agents/tools.ts +68 -0
- package/src/domains/apply.integration.test.ts +220 -0
- package/src/domains/client.ts +95 -0
- package/src/domains/deletes.integration.test.ts +124 -0
- package/src/domains/marshal.ts +21 -0
- package/src/domains/mcpservers/apply.ts +36 -0
- package/src/domains/mcpservers/delete.ts +51 -0
- package/src/domains/mcpservers/fetch.ts +35 -0
- package/src/domains/mcpservers/resources.ts +20 -0
- package/src/domains/mcpservers/tools.ts +74 -0
- package/src/domains/reads.integration.test.ts +134 -0
- package/src/domains/resourcehandler.ts +90 -0
- package/src/domains/resources.integration.test.ts +139 -0
- package/src/domains/resourceuri.test.ts +97 -0
- package/src/domains/resourceuri.ts +124 -0
- package/src/domains/rpcerr.test.ts +62 -0
- package/src/domains/rpcerr.ts +46 -0
- package/src/domains/search/search.integration.test.ts +127 -0
- package/src/domains/search/tools.ts +160 -0
- package/src/domains/skills/delete.ts +44 -0
- package/src/domains/skills/fetch.ts +38 -0
- package/src/domains/skills/resources.ts +33 -0
- package/src/domains/skills/tools.ts +67 -0
- package/src/domains/toolresult.ts +33 -0
- package/src/domains/workflowexecutions/tools.ts +133 -0
- package/src/domains/workflows/apply.ts +40 -0
- package/src/domains/workflows/delete.ts +44 -0
- package/src/domains/workflows/fetch.ts +34 -0
- package/src/domains/workflows/resources.ts +20 -0
- package/src/domains/workflows/taskkinds.ts +103 -0
- package/src/domains/workflows/tools.ts +68 -0
- package/src/domains/workflows/validate.integration.test.ts +117 -0
- package/src/domains/workflows/validate.ts +144 -0
- package/src/domains/workflows/workflow-tools.integration.test.ts +148 -0
- package/src/gen/agent.ts +173 -0
- package/src/gen/apply-runtime.ts +52 -0
- package/src/gen/mcpserver.ts +163 -0
- package/src/gen/workflow.ts +858 -0
- package/src/http.integration.test.ts +140 -0
- package/src/index.ts +66 -0
- package/src/logger.ts +49 -0
- package/src/server.integration.test.ts +82 -0
- package/src/server.ts +414 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-server-stigmer.js","sourceRoot":"","sources":["../../src/cli/mcp-server-stigmer.ts"],"names":[],"mappings":";AACA,yEAAyE;AACzE,uDAAuD;AACvD,EAAE;AACF,SAAS;AACT,uFAAuF;AACvF,wDAAwD;AACxD,kDAAkD;AAClD,iEAAiE;AACjE,EAAE;AACF,4EAA4E;AAC5E,qCAAqC;AAErC,OAAO,EAAE,aAAa,EAAE,GAAG,EAAkB,MAAM,aAAa,CAAC;AAEjE,MAAM,gBAAgB,GAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAEtE,KAAK,UAAU,IAAI;IACjB,IAAI,GAAG,GAAG,aAAa,EAAE,CAAC;IAE1B,iEAAiE;IACjE,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC5B,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtB,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACpC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,uBAAuB,GAAG,qCAAqC,CAAC,CAAC;YACtF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,GAAG,GAAG,EAAE,GAAG,GAAG,EAAE,SAAS,EAAE,GAAgB,EAAE,CAAC;IAChD,CAAC;IAED,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;IACzC,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IAC1C,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACjC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAElC,MAAM,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;IAC5B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACrF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/config.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type LogFormat, type LogLevel } from "./logger.js";
|
|
2
|
+
/** Communication mode between MCP clients and the server. */
|
|
3
|
+
export type Transport = "stdio" | "http" | "both";
|
|
4
|
+
/**
|
|
5
|
+
* OAuth 2.0 Protected Resource Metadata (RFC 9728) discovery settings.
|
|
6
|
+
*
|
|
7
|
+
* Purely additive: the server stays a stateless Bearer passthrough that never
|
|
8
|
+
* validates tokens. Issuer values come from deployment config, never code, so
|
|
9
|
+
* the OSS server is issuer-agnostic. (HTTP discovery wiring itself lands in T02.)
|
|
10
|
+
*/
|
|
11
|
+
export interface OAuthConfig {
|
|
12
|
+
readonly enabled: boolean;
|
|
13
|
+
readonly resource: string;
|
|
14
|
+
readonly authorizationServers: string[];
|
|
15
|
+
readonly scopesSupported: string[];
|
|
16
|
+
}
|
|
17
|
+
/** Runtime configuration for the MCP server. */
|
|
18
|
+
export interface Config {
|
|
19
|
+
/** gRPC dial target for stigmer-server (e.g. "localhost:7234"). */
|
|
20
|
+
readonly stigmerServerAddress: string;
|
|
21
|
+
/**
|
|
22
|
+
* API key for stigmer-server. Used for stdio/both; in http mode every
|
|
23
|
+
* request carries its own Bearer token. Empty when targeting an
|
|
24
|
+
* unauthenticated local backend.
|
|
25
|
+
*/
|
|
26
|
+
readonly apiKey: string;
|
|
27
|
+
readonly transport: Transport;
|
|
28
|
+
readonly httpPort: string;
|
|
29
|
+
/** Whether HTTP requests require an Authorization: Bearer header. */
|
|
30
|
+
readonly httpAuthEnabled: boolean;
|
|
31
|
+
readonly oauth: OAuthConfig;
|
|
32
|
+
readonly logFormat: LogFormat;
|
|
33
|
+
readonly logLevel: LogLevel;
|
|
34
|
+
}
|
|
35
|
+
/** Reads configuration from the process environment, applying defaults. */
|
|
36
|
+
export declare function loadConfigFromEnv(env?: NodeJS.ProcessEnv): Config;
|
|
37
|
+
/**
|
|
38
|
+
* Validates invariants that must hold before the server starts. Throws on hard
|
|
39
|
+
* errors; emits warnings (via the configured logger) for the soft cases the Go
|
|
40
|
+
* server warns about. Configure the logger before calling this so warnings are
|
|
41
|
+
* formatted consistently.
|
|
42
|
+
*/
|
|
43
|
+
export declare function validateConfig(cfg: Config): void;
|
|
44
|
+
//# sourceMappingURL=config.d.ts.map
|
package/config.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAQA,OAAO,EAAO,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEjE,6DAA6D;AAC7D,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAElD;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,oBAAoB,EAAE,MAAM,EAAE,CAAC;IACxC,QAAQ,CAAC,eAAe,EAAE,MAAM,EAAE,CAAC;CACpC;AAED,gDAAgD;AAChD,MAAM,WAAW,MAAM;IACrB,mEAAmE;IACnE,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACtC;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,qEAAqE;IACrE,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;CAC7B;AAMD,2EAA2E;AAC3E,wBAAgB,iBAAiB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAiB9E;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CA8ChD"}
|
package/config.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// Environment-variable configuration for mcp-server-stigmer.
|
|
2
|
+
//
|
|
3
|
+
// Every value is read from a STIGMER_-prefixed environment variable with a
|
|
4
|
+
// development-friendly default. This is the embeddable configuration surface
|
|
5
|
+
// (plain types, no internal coupling) and the parity mirror of the Go server's
|
|
6
|
+
// internal/config + pkg/mcpserver Config (inventory §4.4) — the validation
|
|
7
|
+
// reproduces Go's hard-errors AND warnings, not just the defaults.
|
|
8
|
+
import { log } from "./logger.js";
|
|
9
|
+
const VALID_TRANSPORTS = ["stdio", "http", "both"];
|
|
10
|
+
const VALID_LOG_FORMATS = ["text", "json"];
|
|
11
|
+
const VALID_LOG_LEVELS = ["debug", "info", "warn", "error"];
|
|
12
|
+
/** Reads configuration from the process environment, applying defaults. */
|
|
13
|
+
export function loadConfigFromEnv(env = process.env) {
|
|
14
|
+
return {
|
|
15
|
+
stigmerServerAddress: envOr(env, "STIGMER_SERVER_ADDRESS", "localhost:7234"),
|
|
16
|
+
apiKey: env.STIGMER_API_KEY ?? "",
|
|
17
|
+
transport: envOr(env, "STIGMER_MCP_TRANSPORT", "stdio").toLowerCase(),
|
|
18
|
+
httpPort: envOr(env, "STIGMER_MCP_HTTP_PORT", "8080"),
|
|
19
|
+
// Go semantics: only the exact string "true" enables auth.
|
|
20
|
+
httpAuthEnabled: envOr(env, "STIGMER_MCP_HTTP_AUTH_ENABLED", "true") === "true",
|
|
21
|
+
oauth: {
|
|
22
|
+
enabled: env.STIGMER_MCP_OAUTH_ENABLED === "true",
|
|
23
|
+
resource: (env.STIGMER_MCP_OAUTH_RESOURCE ?? "").trim(),
|
|
24
|
+
authorizationServers: splitList(env.STIGMER_MCP_OAUTH_AUTHORIZATION_SERVERS),
|
|
25
|
+
scopesSupported: splitList(env.STIGMER_MCP_OAUTH_SCOPES_SUPPORTED),
|
|
26
|
+
},
|
|
27
|
+
logFormat: envOr(env, "STIGMER_MCP_LOG_FORMAT", "text").toLowerCase(),
|
|
28
|
+
logLevel: envOr(env, "STIGMER_MCP_LOG_LEVEL", "info").toLowerCase(),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Validates invariants that must hold before the server starts. Throws on hard
|
|
33
|
+
* errors; emits warnings (via the configured logger) for the soft cases the Go
|
|
34
|
+
* server warns about. Configure the logger before calling this so warnings are
|
|
35
|
+
* formatted consistently.
|
|
36
|
+
*/
|
|
37
|
+
export function validateConfig(cfg) {
|
|
38
|
+
if (!VALID_TRANSPORTS.includes(cfg.transport)) {
|
|
39
|
+
throw new Error(`invalid STIGMER_MCP_TRANSPORT "${cfg.transport}": must be stdio, http, or both`);
|
|
40
|
+
}
|
|
41
|
+
if (cfg.stigmerServerAddress === "") {
|
|
42
|
+
throw new Error("STIGMER_SERVER_ADDRESS must not be empty");
|
|
43
|
+
}
|
|
44
|
+
if (cfg.stigmerServerAddress.includes("://")) {
|
|
45
|
+
log.warn("STIGMER_SERVER_ADDRESS contains a URL scheme; gRPC targets are host:port — " +
|
|
46
|
+
"the scheme is informational and TLS is derived from the port", { value: cfg.stigmerServerAddress });
|
|
47
|
+
}
|
|
48
|
+
else if (!hasExplicitPort(cfg.stigmerServerAddress)) {
|
|
49
|
+
log.warn("STIGMER_SERVER_ADDRESS has no explicit port; :443 with TLS is assumed for non-loopback addresses", { value: cfg.stigmerServerAddress });
|
|
50
|
+
}
|
|
51
|
+
if (!VALID_LOG_FORMATS.includes(cfg.logFormat)) {
|
|
52
|
+
throw new Error(`invalid STIGMER_MCP_LOG_FORMAT "${cfg.logFormat}": must be text or json`);
|
|
53
|
+
}
|
|
54
|
+
if (!VALID_LOG_LEVELS.includes(cfg.logLevel)) {
|
|
55
|
+
throw new Error(`invalid STIGMER_MCP_LOG_LEVEL "${cfg.logLevel}": must be debug, info, warn, or error`);
|
|
56
|
+
}
|
|
57
|
+
if (cfg.oauth.enabled) {
|
|
58
|
+
if (cfg.oauth.resource === "") {
|
|
59
|
+
throw new Error("STIGMER_MCP_OAUTH_RESOURCE must be set when STIGMER_MCP_OAUTH_ENABLED is true");
|
|
60
|
+
}
|
|
61
|
+
if (cfg.oauth.authorizationServers.length === 0) {
|
|
62
|
+
throw new Error("STIGMER_MCP_OAUTH_AUTHORIZATION_SERVERS must list at least one issuer when STIGMER_MCP_OAUTH_ENABLED is true");
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function envOr(env, key, fallback) {
|
|
67
|
+
const v = env[key];
|
|
68
|
+
return v !== undefined && v !== "" ? v : fallback;
|
|
69
|
+
}
|
|
70
|
+
/** Parses a comma-separated value into trimmed, non-empty entries. */
|
|
71
|
+
function splitList(raw) {
|
|
72
|
+
if (!raw || raw.trim() === "")
|
|
73
|
+
return [];
|
|
74
|
+
return raw
|
|
75
|
+
.split(",")
|
|
76
|
+
.map((p) => p.trim())
|
|
77
|
+
.filter((p) => p !== "");
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Reports whether an authority carries an explicit port. Tolerates bracketed
|
|
81
|
+
* IPv6 (`[::1]:443`) and treats bare IPv6 (`::1`) as port-less, matching the
|
|
82
|
+
* intent of Go's net.SplitHostPort in the config warning path.
|
|
83
|
+
*/
|
|
84
|
+
function hasExplicitPort(authority) {
|
|
85
|
+
if (authority.startsWith("[")) {
|
|
86
|
+
const close = authority.indexOf("]");
|
|
87
|
+
return close !== -1 && authority.slice(close + 1).startsWith(":");
|
|
88
|
+
}
|
|
89
|
+
const lastColon = authority.lastIndexOf(":");
|
|
90
|
+
return lastColon !== -1 && authority.indexOf(":") === lastColon;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=config.js.map
|
package/config.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,EAAE;AACF,2EAA2E;AAC3E,6EAA6E;AAC7E,+EAA+E;AAC/E,2EAA2E;AAC3E,mEAAmE;AAEnE,OAAO,EAAE,GAAG,EAAiC,MAAM,aAAa,CAAC;AAsCjE,MAAM,gBAAgB,GAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AACtE,MAAM,iBAAiB,GAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC9D,MAAM,gBAAgB,GAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAE/E,2EAA2E;AAC3E,MAAM,U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AC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;AACpD,CAAC;AAED,sEAAsE;AACtE,SAAS,SAAS,CAAC,GAAuB;IACxC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,OAAO,EAAE,CAAC;IACzC,OAAO,GAAG;SACP,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SACpB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;AAC7B,CAAC;AAED;;;;GAIG;AACH,SAAS,eAAe,CAAC,SAAiB;IACxC,IAAI,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC9B,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACrC,OAAO,KAAK,KAAK,CAAC,CAAC,IAAI,SAAS,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IACpE,CAAC;IACD,MAAM,SAAS,GAAG,SAAS,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC7C,OAAO,SAAS,KAAK,CAAC,CAAC,IAAI,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type AgentInput } from "../../gen/agent.js";
|
|
2
|
+
/** Create or update an agent, returning the persisted agent as protojson. */
|
|
3
|
+
export declare function applyAgent(serverAddress: string, token: string, input: AgentInput): Promise<string>;
|
|
4
|
+
//# sourceMappingURL=apply.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../../src/domains/agents/apply.ts"],"names":[],"mappings":"AAQA,OAAO,EAAqB,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAKxE,6EAA6E;AAC7E,wBAAsB,UAAU,CAC9B,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,UAAU,GAChB,OAAO,CAAC,MAAM,CAAC,CAWjB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Agent apply path: create-or-update via the AgentCommandController.apply RPC.
|
|
2
|
+
// The flat MCP input is projected into a fully-formed Agent proto by the
|
|
3
|
+
// generated agentInputToProto bridge (codegen, src/gen/agent.ts) before the call.
|
|
4
|
+
// Go parity: mcp-server/internal/domains/agents/apply.go.
|
|
5
|
+
import { AgentSchema } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/api_pb";
|
|
6
|
+
import { AgentCommandController } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/command_pb";
|
|
7
|
+
import { agentInputToProto } from "../../gen/agent.js";
|
|
8
|
+
import { withClient } from "../client.js";
|
|
9
|
+
import { toProtoJson } from "../marshal.js";
|
|
10
|
+
import { rpcError } from "../rpcerr.js";
|
|
11
|
+
/** Create or update an agent, returning the persisted agent as protojson. */
|
|
12
|
+
export async function applyAgent(serverAddress, token, input) {
|
|
13
|
+
const agent = agentInputToProto(input);
|
|
14
|
+
const desc = `agent "${agent.metadata?.slug ?? ""}" in org "${agent.metadata?.org ?? ""}"`;
|
|
15
|
+
return withClient(AgentCommandController, serverAddress, token, async (client, callOptions) => {
|
|
16
|
+
try {
|
|
17
|
+
const result = await client.apply(agent, callOptions);
|
|
18
|
+
return toProtoJson(AgentSchema, result);
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
throw rpcError(err, desc);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=apply.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply.js","sourceRoot":"","sources":["../../../src/domains/agents/apply.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,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,CAAC,CAoBjB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Agent delete path: resolve org/slug → id via the Query controller, then
|
|
2
|
+
// delete via the Command controller, both over a single shared transport.
|
|
3
|
+
// Go parity: mcp-server/internal/domains/agents/delete.go.
|
|
4
|
+
import { createClient } from "@connectrpc/connect";
|
|
5
|
+
import { AgentSchema } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/api_pb";
|
|
6
|
+
import { AgentCommandController } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/command_pb";
|
|
7
|
+
import { AgentQueryController } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/query_pb";
|
|
8
|
+
import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
|
|
9
|
+
import { withTransport } from "../client.js";
|
|
10
|
+
import { toProtoJson } from "../marshal.js";
|
|
11
|
+
import { rpcError } from "../rpcerr.js";
|
|
12
|
+
/** Delete an agent by org and slug, returning the deleted agent as protojson. */
|
|
13
|
+
export async function deleteAgent(serverAddress, token, org, slug) {
|
|
14
|
+
const desc = `agent "${slug}" in org "${org}"`;
|
|
15
|
+
return withTransport(serverAddress, token, async (transport, callOptions) => {
|
|
16
|
+
const query = createClient(AgentQueryController, transport);
|
|
17
|
+
let id;
|
|
18
|
+
try {
|
|
19
|
+
const agent = await query.getByReference({ org, kind: ApiResourceKind.agent, slug }, callOptions);
|
|
20
|
+
id = agent.metadata?.id ?? "";
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
throw rpcError(err, desc);
|
|
24
|
+
}
|
|
25
|
+
const command = createClient(AgentCommandController, transport);
|
|
26
|
+
try {
|
|
27
|
+
const deleted = await command.delete({ value: id }, callOptions);
|
|
28
|
+
return toProtoJson(AgentSchema, deleted);
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
throw rpcError(err, desc);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=delete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete.js","sourceRoot":"","sources":["../../../src/domains/agents/delete.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,0EAA0E;AAC1E,2DAA2D;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,oDAAoD,CAAC;AACjF,OAAO,EAAE,sBAAsB,EAAE,MAAM,wDAAwD,CAAC;AAChG,OAAO,EAAE,oBAAoB,EAAE,MAAM,sDAAsD,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,qFAAqF,CAAC;AAEtH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,iFAAiF;AACjF,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,aAAqB,EACrB,KAAa,EACb,GAAW,EACX,IAAY;IAEZ,MAAM,IAAI,GAAG,UAAU,IAAI,aAAa,GAAG,GAAG,CAAC;IAC/C,OAAO,aAAa,CAAC,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,EAAE;QAC1E,MAAM,KAAK,GAAG,YAAY,CAAC,oBAAoB,EAAE,SAAS,CAAC,CAAC;QAC5D,IAAI,EAAU,CAAC;QACf,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,MAAM,KAAK,CAAC,cAAc,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,eAAe,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,WAAW,CAAC,CAAC;YAClG,EAAE,GAAG,KAAK,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC;QAChC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC5B,CAAC;QAED,MAAM,OAAO,GAAG,YAAY,CAAC,sBAAsB,EAAE,SAAS,CAAC,CAAC;QAChE,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,WAAW,CAAC,CAAC;YACjE,OAAO,WAAW,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QAC3C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retrieve an agent by org and slug, returning its protojson representation.
|
|
3
|
+
* Errors are classified into user-facing messages via {@link rpcError}.
|
|
4
|
+
*/
|
|
5
|
+
export declare function fetchAgent(serverAddress: string, token: string, org: string, slug: string): Promise<string>;
|
|
6
|
+
//# sourceMappingURL=fetch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../src/domains/agents/fetch.ts"],"names":[],"mappings":"AAWA;;;GAGG;AACH,wBAAsB,UAAU,CAC9B,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,CAAC,CAYjB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Agent read path: the single RPC both the get_agent tool and the agent
|
|
2
|
+
// resource template delegate to. Mirrors Go internal/domains/agents/fetch.go.
|
|
3
|
+
import { AgentSchema } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/api_pb";
|
|
4
|
+
import { AgentQueryController } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/query_pb";
|
|
5
|
+
import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
|
|
6
|
+
import { withClient } from "../client.js";
|
|
7
|
+
import { toProtoJson } from "../marshal.js";
|
|
8
|
+
import { rpcError } from "../rpcerr.js";
|
|
9
|
+
/**
|
|
10
|
+
* Retrieve an agent by org and slug, returning its protojson representation.
|
|
11
|
+
* Errors are classified into user-facing messages via {@link rpcError}.
|
|
12
|
+
*/
|
|
13
|
+
export async function fetchAgent(serverAddress, token, org, slug) {
|
|
14
|
+
return withClient(AgentQueryController, serverAddress, token, async (client, callOptions) => {
|
|
15
|
+
try {
|
|
16
|
+
const agent = await client.getByReference({ org, kind: ApiResourceKind.agent, slug }, callOptions);
|
|
17
|
+
return toProtoJson(AgentSchema, agent);
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
throw rpcError(err, `agent "${slug}" in org "${org}"`);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=fetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../../src/domains/agents/fetch.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,8EAA8E;AAE9E,OAAO,EAAE,WAAW,EAAE,MAAM,oDAAoD,CAAC;AACjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,sDAAsD,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,qFAAqF,CAAC;AAEtH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,aAAqB,EACrB,KAAa,EACb,GAAW,EACX,IAAY;IAEZ,OAAO,UAAU,CAAC,oBAAoB,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE;QAC1F,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,cAAc,CACvC,EAAE,GAAG,EAAE,IAAI,EAAE,eAAe,CAAC,KAAK,EAAE,IAAI,EAAE,EAC1C,WAAW,CACZ,CAAC;YACF,OAAO,WAAW,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QACzC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,QAAQ,CAAC,GAAG,EAAE,UAAU,IAAI,aAAa,GAAG,GAAG,CAAC,CAAC;QACzD,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import type { BackendTarget } from "../client.js";
|
|
3
|
+
/** Register the agent resource template; returns the registered resource names. */
|
|
4
|
+
export declare function registerAgentResources(server: McpServer, target: BackendTarget): string[];
|
|
5
|
+
//# sourceMappingURL=resources.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../../src/domains/agents/resources.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAIlD,mFAAmF;AACnF,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,GAAG,MAAM,EAAE,CASzF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Agent resource template (stigmer://agents/{org}/{slug}).
|
|
2
|
+
// Go parity: mcp-server/internal/domains/agents/resources.go.
|
|
3
|
+
import { registerResource } from "../resourcehandler.js";
|
|
4
|
+
import { fetchAgent } from "./fetch.js";
|
|
5
|
+
/** Register the agent resource template; returns the registered resource names. */
|
|
6
|
+
export function registerAgentResources(server, target) {
|
|
7
|
+
registerResource(server, target, {
|
|
8
|
+
name: "stigmer_agent",
|
|
9
|
+
title: "Stigmer Agent",
|
|
10
|
+
description: "Full definition of a Stigmer agent, identified by organization and slug.",
|
|
11
|
+
template: "stigmer://agents/{org}/{slug}",
|
|
12
|
+
fetch: fetchAgent,
|
|
13
|
+
});
|
|
14
|
+
return ["stigmer_agent"];
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=resources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resources.js","sourceRoot":"","sources":["../../../src/domains/agents/resources.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,8DAA8D;AAK9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,mFAAmF;AACnF,MAAM,UAAU,sBAAsB,CAAC,MAAiB,EAAE,MAAqB;IAC7E,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE;QAC/B,IAAI,EAAE,eAAe;QACrB,KAAK,EAAE,eAAe;QACtB,WAAW,EAAE,0EAA0E;QACvF,QAAQ,EAAE,+BAA+B;QACzC,KAAK,EAAE,UAAU;KAClB,CAAC,CAAC;IACH,OAAO,CAAC,eAAe,CAAC,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { type BackendTarget } from "../client.js";
|
|
3
|
+
/** Register every Agent-domain tool; returns the registered tool names. */
|
|
4
|
+
export declare function registerAgentTools(server: McpServer, target: BackendTarget): string[];
|
|
5
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/domains/agents/tools.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAIzE,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAMhE,2EAA2E;AAC3E,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,GAAG,MAAM,EAAE,CAgDrF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// MCP tools for the Agent domain. Mirrors Go internal/domains/agents/tools.go.
|
|
2
|
+
//
|
|
3
|
+
// The tool name, description, and per-field input descriptions are part of the
|
|
4
|
+
// parity contract (MCP clients surface them to the model verbatim), so they are
|
|
5
|
+
// copied exactly from the Go definitions. This file is the canonical pattern the
|
|
6
|
+
// remaining domains follow in T02: define the tool, resolve the per-request
|
|
7
|
+
// credential, delegate to the domain fetch, and shape the result.
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
import { AgentInputShape } from "../../gen/agent.js";
|
|
10
|
+
import { resolveToken } from "../client.js";
|
|
11
|
+
import { textOrError } from "../toolresult.js";
|
|
12
|
+
import { applyAgent } from "./apply.js";
|
|
13
|
+
import { deleteAgent } from "./delete.js";
|
|
14
|
+
import { fetchAgent } from "./fetch.js";
|
|
15
|
+
/** Register every Agent-domain tool; returns the registered tool names. */
|
|
16
|
+
export function registerAgentTools(server, target) {
|
|
17
|
+
server.registerTool("get_agent", {
|
|
18
|
+
description: "Get full details of a Stigmer agent by its org and slug (e.g. org=stigmer slug=code-reviewer).",
|
|
19
|
+
inputSchema: {
|
|
20
|
+
org: z.string().describe("Organization slug that owns the agent (e.g. stigmer)."),
|
|
21
|
+
slug: z
|
|
22
|
+
.string()
|
|
23
|
+
.describe("Agent slug — the unique identifier within the org (e.g. code-reviewer)."),
|
|
24
|
+
},
|
|
25
|
+
}, (args, extra) => textOrError(() => fetchAgent(target.serverAddress, resolveToken(extra, target.apiKey), args.org, args.slug)));
|
|
26
|
+
server.registerTool("apply_agent", {
|
|
27
|
+
description: "Create or update a Stigmer agent (idempotent). Provide identity fields (name, org) and agent configuration (instructions, skills, MCP servers, etc.).",
|
|
28
|
+
inputSchema: AgentInputShape,
|
|
29
|
+
}, (args, extra) => textOrError(() => applyAgent(target.serverAddress, resolveToken(extra, target.apiKey), args)));
|
|
30
|
+
server.registerTool("delete_agent", {
|
|
31
|
+
description: "Delete a Stigmer agent by its org and slug. Returns the deleted agent.",
|
|
32
|
+
inputSchema: {
|
|
33
|
+
org: z.string().describe("Organization slug that owns the agent (e.g. stigmer)."),
|
|
34
|
+
slug: z
|
|
35
|
+
.string()
|
|
36
|
+
.describe("Agent slug — the unique identifier within the org (e.g. code-reviewer)."),
|
|
37
|
+
},
|
|
38
|
+
}, (args, extra) => textOrError(() => deleteAgent(target.serverAddress, resolveToken(extra, target.apiKey), args.org, args.slug)));
|
|
39
|
+
return ["get_agent", "apply_agent", "delete_agent"];
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../src/domains/agents/tools.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,EAAE;AACF,+EAA+E;AAC/E,gFAAgF;AAChF,iFAAiF;AACjF,4EAA4E;AAC5E,kEAAkE;AAGlE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAsB,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,2EAA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AC,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAC3F,CACJ,CAAC;IAEF,OAAO,CAAC,WAAW,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type Client, type CallOptions, type Transport } from "@connectrpc/connect";
|
|
2
|
+
import type { DescService } from "@bufbuild/protobuf";
|
|
3
|
+
/**
|
|
4
|
+
* Per-call RPC timeout. Mirrors Go's DefaultRPCTimeout: generous for both
|
|
5
|
+
* localhost (milliseconds) and remote endpoints (low seconds), while still
|
|
6
|
+
* failing fast against a misconfigured or unreachable address.
|
|
7
|
+
*/
|
|
8
|
+
export declare const DEFAULT_RPC_TIMEOUT_MS = 30000;
|
|
9
|
+
/**
|
|
10
|
+
* The stigmer-server endpoint and startup credential captured at registration
|
|
11
|
+
* time and shared by every tool handler. Mirrors the `serverAddress` closure +
|
|
12
|
+
* startup API key that the Go handlers capture.
|
|
13
|
+
*/
|
|
14
|
+
export interface BackendTarget {
|
|
15
|
+
readonly serverAddress: string;
|
|
16
|
+
/** stdio startup API key; "" when targeting an unauthenticated backend. */
|
|
17
|
+
readonly apiKey: string;
|
|
18
|
+
}
|
|
19
|
+
/** The subset of the MCP request `extra` this layer reads to resolve a token. */
|
|
20
|
+
export interface RequestAuth {
|
|
21
|
+
readonly authInfo?: {
|
|
22
|
+
readonly token?: string;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Resolve the credential for an inbound tool call: the per-request Bearer token
|
|
27
|
+
* (http) when present, otherwise the startup API key (stdio). Returns "" when
|
|
28
|
+
* targeting an unauthenticated backend, in which case no credential is attached.
|
|
29
|
+
*/
|
|
30
|
+
export declare function resolveToken(extra: RequestAuth | undefined, fallback: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* Build an authenticated transport to stigmer-server for a single credential.
|
|
33
|
+
* The address is normalized (scheme/TLS rules) before the transport is built;
|
|
34
|
+
* an empty token attaches no Authorization header.
|
|
35
|
+
*/
|
|
36
|
+
export declare function transportForToken(serverAddress: string, token: string): Transport;
|
|
37
|
+
/**
|
|
38
|
+
* Open a short-lived authenticated transport and invoke `fn` with it and the
|
|
39
|
+
* standard call options (RPC timeout pre-applied). Mirrors Go's WithConnection:
|
|
40
|
+
* the single place that owns transport construction and the timeout. Use this
|
|
41
|
+
* when an operation needs more than one controller over the SAME connection —
|
|
42
|
+
* e.g. the two-step deletes that resolve via the Query controller and delete via
|
|
43
|
+
* the Command controller.
|
|
44
|
+
*/
|
|
45
|
+
export declare function withTransport<T>(serverAddress: string, token: string, fn: (transport: Transport, callOptions: CallOptions) => Promise<T>): Promise<T>;
|
|
46
|
+
/**
|
|
47
|
+
* Open a short-lived raw controller client and invoke `fn` with it and the
|
|
48
|
+
* standard call options. The single-controller convenience over
|
|
49
|
+
* {@link withTransport}; call sites that only touch one service stay a
|
|
50
|
+
* one-liner.
|
|
51
|
+
*/
|
|
52
|
+
export declare function withClient<S extends DescService, T>(service: S, serverAddress: string, token: string, fn: (client: Client<S>, callOptions: CallOptions) => Promise<T>): Promise<T>;
|
|
53
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/domains/client.ts"],"names":[],"mappings":"AAcA,OAAO,EAAgB,KAAK,MAAM,EAAE,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAClG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGtD;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,QAAS,CAAC;AAE7C;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,2EAA2E;IAC3E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,iFAAiF;AACjF,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE;QAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACjD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGrF;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,CAKjF;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,CAAC,EACnC,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,EACb,EAAE,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,GACjE,OAAO,CAAC,CAAC,CAAC,CAEZ;AAED;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,CAAC,SAAS,WAAW,EAAE,CAAC,EACvD,OAAO,EAAE,CAAC,EACV,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,EACb,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,GAC9D,OAAO,CAAC,CAAC,CAAC,CAIZ"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// Per-request gRPC client construction for tool handlers.
|
|
2
|
+
//
|
|
3
|
+
// Parity contract (mirrors Go internal/domains/conn.go WithConnection + the
|
|
4
|
+
// auth/grpc layer): each tool call resolves its credential, opens a short-lived
|
|
5
|
+
// authenticated client to stigmer-server with a fixed RPC timeout, runs the
|
|
6
|
+
// call, and discards the client. This is intentionally simple — the MCP server
|
|
7
|
+
// handles a low volume of calls and transport setup is cheap. Pooling can be
|
|
8
|
+
// introduced later without touching call sites.
|
|
9
|
+
//
|
|
10
|
+
// Credential source mirrors Go precisely:
|
|
11
|
+
// - stdio: the API key is captured once at startup (constant per process).
|
|
12
|
+
// - http: every request carries its own Bearer token via authInfo, which the
|
|
13
|
+
// transport injected from the Authorization header.
|
|
14
|
+
import { createClient } from "@connectrpc/connect";
|
|
15
|
+
import { createNodeTransport, normalizeEndpoint } from "@stigmer/sdk/node";
|
|
16
|
+
/**
|
|
17
|
+
* Per-call RPC timeout. Mirrors Go's DefaultRPCTimeout: generous for both
|
|
18
|
+
* localhost (milliseconds) and remote endpoints (low seconds), while still
|
|
19
|
+
* failing fast against a misconfigured or unreachable address.
|
|
20
|
+
*/
|
|
21
|
+
export const DEFAULT_RPC_TIMEOUT_MS = 30_000;
|
|
22
|
+
/**
|
|
23
|
+
* Resolve the credential for an inbound tool call: the per-request Bearer token
|
|
24
|
+
* (http) when present, otherwise the startup API key (stdio). Returns "" when
|
|
25
|
+
* targeting an unauthenticated backend, in which case no credential is attached.
|
|
26
|
+
*/
|
|
27
|
+
export function resolveToken(extra, fallback) {
|
|
28
|
+
const token = extra?.authInfo?.token;
|
|
29
|
+
return token !== undefined && token !== "" ? token : fallback;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Build an authenticated transport to stigmer-server for a single credential.
|
|
33
|
+
* The address is normalized (scheme/TLS rules) before the transport is built;
|
|
34
|
+
* an empty token attaches no Authorization header.
|
|
35
|
+
*/
|
|
36
|
+
export function transportForToken(serverAddress, token) {
|
|
37
|
+
return createNodeTransport({
|
|
38
|
+
baseUrl: normalizeEndpoint(serverAddress),
|
|
39
|
+
apiKey: token === "" ? undefined : token,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Open a short-lived authenticated transport and invoke `fn` with it and the
|
|
44
|
+
* standard call options (RPC timeout pre-applied). Mirrors Go's WithConnection:
|
|
45
|
+
* the single place that owns transport construction and the timeout. Use this
|
|
46
|
+
* when an operation needs more than one controller over the SAME connection —
|
|
47
|
+
* e.g. the two-step deletes that resolve via the Query controller and delete via
|
|
48
|
+
* the Command controller.
|
|
49
|
+
*/
|
|
50
|
+
export async function withTransport(serverAddress, token, fn) {
|
|
51
|
+
return fn(transportForToken(serverAddress, token), { timeoutMs: DEFAULT_RPC_TIMEOUT_MS });
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Open a short-lived raw controller client and invoke `fn` with it and the
|
|
55
|
+
* standard call options. The single-controller convenience over
|
|
56
|
+
* {@link withTransport}; call sites that only touch one service stay a
|
|
57
|
+
* one-liner.
|
|
58
|
+
*/
|
|
59
|
+
export async function withClient(service, serverAddress, token, fn) {
|
|
60
|
+
return withTransport(serverAddress, token, (transport, callOptions) => fn(createClient(service, transport), callOptions));
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/domains/client.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,EAAE;AACF,4EAA4E;AAC5E,gFAAgF;AAChF,4EAA4E;AAC5E,+EAA+E;AAC/E,6EAA6E;AAC7E,gDAAgD;AAChD,EAAE;AACF,0CAA0C;AAC1C,6EAA6E;AAC7E,+EAA+E;AAC/E,wDAAwD;AAExD,OAAO,EAAE,YAAY,EAAiD,MAAM,qBAAqB,CAAC;AAElG,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE3E;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC;AAkB7C;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,KAA8B,EAAE,QAAgB;IAC3E,MAAM,KAAK,GAAG,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC;IACrC,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC;AAChE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,aAAqB,EAAE,KAAa;IACpE,OAAO,mBAAmB,CAAC;QACzB,OAAO,EAAE,iBAAiB,CAAC,aAAa,CAAC;QACzC,MAAM,EAAE,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK;KACzC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,aAAqB,EACrB,KAAa,EACb,EAAkE;IAElE,OAAO,EAAE,CAAC,iBAAiB,CAAC,aAAa,EAAE,KAAK,CAAC,EAAE,EAAE,SAAS,EAAE,sBAAsB,EAAE,CAAC,CAAC;AAC5F,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,OAAU,EACV,aAAqB,EACrB,KAAa,EACb,EAA+D;IAE/D,OAAO,aAAa,CAAC,aAAa,EAAE,KAAK,EAAE,CAAC,SAAS,EAAE,WAAW,EAAE,EAAE,CACpE,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,WAAW,CAAC,CAClD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type DescMessage, type MessageShape } from "@bufbuild/protobuf";
|
|
2
|
+
/**
|
|
3
|
+
* Serialize a protobuf message to the human-friendly JSON string returned in
|
|
4
|
+
* MCP tool output. Field names use the proto (snake_case) names so the payload
|
|
5
|
+
* is byte-comparable, after parsing, with the Go server's protojson.
|
|
6
|
+
*/
|
|
7
|
+
export declare function toProtoJson<Desc extends DescMessage>(schema: Desc, message: MessageShape<Desc>): string;
|
|
8
|
+
//# sourceMappingURL=marshal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marshal.d.ts","sourceRoot":"","sources":["../../src/domains/marshal.ts"],"names":[],"mappings":"AAQA,OAAO,EAAU,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEjF;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,SAAS,WAAW,EAClD,MAAM,EAAE,IAAI,EACZ,OAAO,EAAE,YAAY,CAAC,IAAI,CAAC,GAC1B,MAAM,CAER"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Canonical protobuf → JSON serialization shared by every tool response.
|
|
2
|
+
//
|
|
3
|
+
// Parity contract (mirrors Go internal/domains/marshal.go): the Go server emits
|
|
4
|
+
// protojson with UseProtoNames=true and EmitUnpopulated=false, 2-space indented.
|
|
5
|
+
// protobuf-es `toJson` with { useProtoFieldName: true } reproduces this exactly —
|
|
6
|
+
// snake_case field names, omitted defaults, base64 bytes, string enums, and
|
|
7
|
+
// RFC-3339 timestamps — and JSON.stringify(..., 2) applies the same indentation.
|
|
8
|
+
import { toJson } from "@bufbuild/protobuf";
|
|
9
|
+
/**
|
|
10
|
+
* Serialize a protobuf message to the human-friendly JSON string returned in
|
|
11
|
+
* MCP tool output. Field names use the proto (snake_case) names so the payload
|
|
12
|
+
* is byte-comparable, after parsing, with the Go server's protojson.
|
|
13
|
+
*/
|
|
14
|
+
export function toProtoJson(schema, message) {
|
|
15
|
+
return JSON.stringify(toJson(schema, message, { useProtoFieldName: true }), null, 2);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=marshal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marshal.js","sourceRoot":"","sources":["../../src/domains/marshal.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,EAAE;AACF,gFAAgF;AAChF,iFAAiF;AACjF,kFAAkF;AAClF,4EAA4E;AAC5E,iFAAiF;AAEjF,OAAO,EAAE,MAAM,EAAuC,MAAM,oBAAoB,CAAC;AAEjF;;;;GAIG;AACH,MAAM,UAAU,WAAW,CACzB,MAAY,EACZ,OAA2B;IAE3B,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACvF,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type McpServerInput } from "../../gen/mcpserver.js";
|
|
2
|
+
/** Create or update an MCP server, returning the persisted server as protojson. */
|
|
3
|
+
export declare function applyMcpServer(serverAddress: string, token: string, input: McpServerInput): Promise<string>;
|
|
4
|
+
//# sourceMappingURL=apply.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../../src/domains/mcpservers/apply.ts"],"names":[],"mappings":"AASA,OAAO,EAAyB,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAKpF,mFAAmF;AACnF,wBAAsB,cAAc,CAClC,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,cAAc,GACpB,OAAO,CAAC,MAAM,CAAC,CAgBjB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// McpServer apply path: create-or-update via the McpServerCommandController.apply
|
|
2
|
+
// RPC. The flat MCP input is projected into a fully-formed McpServer proto by the
|
|
3
|
+
// generated mcpServerInputToProto bridge (codegen, src/gen/mcpserver.ts), which
|
|
4
|
+
// also rebuilds the stdio/http oneof, before the call.
|
|
5
|
+
// Go parity: mcp-server/internal/domains/mcpservers/apply.go.
|
|
6
|
+
import { McpServerSchema } from "@stigmer/protos/ai/stigmer/agentic/mcpserver/v1/api_pb";
|
|
7
|
+
import { McpServerCommandController } from "@stigmer/protos/ai/stigmer/agentic/mcpserver/v1/command_pb";
|
|
8
|
+
import { mcpServerInputToProto } from "../../gen/mcpserver.js";
|
|
9
|
+
import { withClient } from "../client.js";
|
|
10
|
+
import { toProtoJson } from "../marshal.js";
|
|
11
|
+
import { rpcError } from "../rpcerr.js";
|
|
12
|
+
/** Create or update an MCP server, returning the persisted server as protojson. */
|
|
13
|
+
export async function applyMcpServer(serverAddress, token, input) {
|
|
14
|
+
const server = mcpServerInputToProto(input);
|
|
15
|
+
const desc = `mcp server "${server.metadata?.slug ?? ""}" in org "${server.metadata?.org ?? ""}"`;
|
|
16
|
+
return withClient(McpServerCommandController, serverAddress, token, async (client, callOptions) => {
|
|
17
|
+
try {
|
|
18
|
+
const result = await client.apply(server, callOptions);
|
|
19
|
+
return toProtoJson(McpServerSchema, result);
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
throw rpcError(err, desc);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=apply.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply.js","sourceRoot":"","sources":["../../../src/domains/mcpservers/apply.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,kFAAkF;AAClF,gFAAgF;AAChF,uDAAuD;AACvD,8DAA8D;AAE9D,OAAO,EAAE,eAAe,EAAE,MAAM,wDAAwD,CAAC;AACzF,OAAO,EAAE,0BAA0B,EAAE,MAAM,4DAA4D,CAAC;AAExG,OAAO,EAAE,qBAAqB,EAAuB,MAAM,wBAAwB,CAAC;AACpF,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,mFAAmF;AACnF,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,aAAqB,EACrB,KAAa,EACb,KAAqB;IAErB,MAAM,MAAM,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,IAAI,GAAG,eAAe,MAAM,CAAC,QAAQ,EAAE,IAAI,IAAI,EAAE,aAAa,MAAM,CAAC,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,CAAC;IAClG,OAAO,UAAU,CACf,0BAA0B,EAC1B,aAAa,EACb,KAAK,EACL,KA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