@stigmer/mcp-server 3.2.3 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -13
- package/cli/mcp-server-stigmer.js +13 -9
- package/config.d.ts +12 -0
- package/config.d.ts.map +1 -1
- package/config.js +5 -0
- package/config.js.map +1 -1
- package/domains/agentexecutions/approve.d.ts +9 -0
- package/domains/agentexecutions/approve.d.ts.map +1 -0
- package/domains/agentexecutions/approve.js +46 -0
- package/domains/agentexecutions/approve.js.map +1 -0
- package/domains/agentexecutions/fetch.d.ts +28 -0
- package/domains/agentexecutions/fetch.d.ts.map +1 -0
- package/domains/agentexecutions/fetch.js +82 -0
- package/domains/agentexecutions/fetch.js.map +1 -0
- package/domains/agentexecutions/run.d.ts +27 -0
- package/domains/agentexecutions/run.d.ts.map +1 -0
- package/domains/agentexecutions/run.js +87 -0
- package/domains/agentexecutions/run.js.map +1 -0
- package/domains/agentexecutions/tools.d.ts +5 -0
- package/domains/agentexecutions/tools.d.ts.map +1 -0
- package/domains/agentexecutions/tools.js +97 -0
- package/domains/agentexecutions/tools.js.map +1 -0
- package/domains/datastores/apply.d.ts +4 -0
- package/domains/datastores/apply.d.ts.map +1 -0
- package/domains/datastores/apply.js +28 -0
- package/domains/datastores/apply.js.map +1 -0
- package/domains/datastores/delete.d.ts +3 -0
- package/domains/datastores/delete.d.ts.map +1 -0
- package/domains/datastores/delete.js +38 -0
- package/domains/datastores/delete.js.map +1 -0
- package/domains/datastores/fetch.d.ts +3 -0
- package/domains/datastores/fetch.d.ts.map +1 -0
- package/domains/datastores/fetch.js +23 -0
- package/domains/datastores/fetch.js.map +1 -0
- package/domains/datastores/resources.d.ts +5 -0
- package/domains/datastores/resources.d.ts.map +1 -0
- package/domains/datastores/resources.js +16 -0
- package/domains/datastores/resources.js.map +1 -0
- package/domains/datastores/tools.d.ts +5 -0
- package/domains/datastores/tools.d.ts.map +1 -0
- package/domains/datastores/tools.js +46 -0
- package/domains/datastores/tools.js.map +1 -0
- package/domains/environments/apply.d.ts +4 -0
- package/domains/environments/apply.d.ts.map +1 -0
- package/domains/environments/apply.js +30 -0
- package/domains/environments/apply.js.map +1 -0
- package/domains/environments/delete.d.ts +3 -0
- package/domains/environments/delete.d.ts.map +1 -0
- package/domains/environments/delete.js +36 -0
- package/domains/environments/delete.js.map +1 -0
- package/domains/environments/fetch.d.ts +6 -0
- package/domains/environments/fetch.d.ts.map +1 -0
- package/domains/environments/fetch.js +30 -0
- package/domains/environments/fetch.js.map +1 -0
- package/domains/environments/resources.d.ts +5 -0
- package/domains/environments/resources.d.ts.map +1 -0
- package/domains/environments/resources.js +16 -0
- package/domains/environments/resources.js.map +1 -0
- package/domains/environments/tools.d.ts +5 -0
- package/domains/environments/tools.d.ts.map +1 -0
- package/domains/environments/tools.js +51 -0
- package/domains/environments/tools.js.map +1 -0
- package/domains/executions/cancel.d.ts +9 -0
- package/domains/executions/cancel.d.ts.map +1 -0
- package/domains/executions/cancel.js +114 -0
- package/domains/executions/cancel.js.map +1 -0
- package/domains/executions/tools.d.ts +5 -0
- package/domains/executions/tools.d.ts.map +1 -0
- package/domains/executions/tools.js +28 -0
- package/domains/executions/tools.js.map +1 -0
- package/domains/records/calls.d.ts +48 -0
- package/domains/records/calls.d.ts.map +1 -0
- package/domains/records/calls.js +118 -0
- package/domains/records/calls.js.map +1 -0
- package/domains/records/errors.d.ts +24 -0
- package/domains/records/errors.d.ts.map +1 -0
- package/domains/records/errors.js +79 -0
- package/domains/records/errors.js.map +1 -0
- package/domains/records/tools.d.ts +7 -0
- package/domains/records/tools.d.ts.map +1 -0
- package/domains/records/tools.js +139 -0
- package/domains/records/tools.js.map +1 -0
- package/domains/resourceuri.d.ts.map +1 -1
- package/domains/resourceuri.js +2 -0
- package/domains/resourceuri.js.map +1 -1
- package/domains/search/tools.d.ts.map +1 -1
- package/domains/search/tools.js +10 -7
- package/domains/search/tools.js.map +1 -1
- package/domains/skills/tools.d.ts.map +1 -1
- package/domains/skills/tools.js +25 -1
- package/domains/skills/tools.js.map +1 -1
- package/domains/skills/versions.d.ts +9 -0
- package/domains/skills/versions.d.ts.map +1 -0
- package/domains/skills/versions.js +31 -0
- package/domains/skills/versions.js.map +1 -0
- package/domains/workflowexecutions/approvals.d.ts +17 -0
- package/domains/workflowexecutions/approvals.d.ts.map +1 -0
- package/domains/workflowexecutions/approvals.js +61 -0
- package/domains/workflowexecutions/approvals.js.map +1 -0
- package/domains/workflowexecutions/run.d.ts +12 -0
- package/domains/workflowexecutions/run.d.ts.map +1 -0
- package/domains/workflowexecutions/run.js +69 -0
- package/domains/workflowexecutions/run.js.map +1 -0
- package/domains/workflowexecutions/tools.d.ts.map +1 -1
- package/domains/workflowexecutions/tools.js +89 -6
- package/domains/workflowexecutions/tools.js.map +1 -1
- package/domains/workflows/tools.d.ts.map +1 -1
- package/domains/workflows/tools.js +69 -5
- package/domains/workflows/tools.js.map +1 -1
- package/domains/workflows/versions.d.ts +29 -0
- package/domains/workflows/versions.d.ts.map +1 -0
- package/domains/workflows/versions.js +99 -0
- package/domains/workflows/versions.js.map +1 -0
- package/gen/agent.d.ts +56 -0
- package/gen/agent.d.ts.map +1 -1
- package/gen/agent.js +24 -1
- package/gen/agent.js.map +1 -1
- package/gen/datastore.d.ts +861 -0
- package/gen/datastore.d.ts.map +1 -0
- package/gen/datastore.js +267 -0
- package/gen/datastore.js.map +1 -0
- package/gen/environment.d.ts +77 -0
- package/gen/environment.d.ts.map +1 -0
- package/gen/environment.js +62 -0
- package/gen/environment.js.map +1 -0
- package/gen/workflow.d.ts +4 -4
- package/index.d.ts +2 -2
- package/index.d.ts.map +1 -1
- package/index.js +4 -4
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/server.d.ts +31 -1
- package/server.d.ts.map +1 -1
- package/server.js +53 -3
- package/server.js.map +1 -1
- package/src/config.ts +19 -0
- package/src/domains/agentexecutions/approve.ts +67 -0
- package/src/domains/agentexecutions/fetch.ts +112 -0
- package/src/domains/agentexecutions/run.ts +112 -0
- package/src/domains/agentexecutions/tools.ts +139 -0
- package/src/domains/apply.integration.test.ts +82 -6
- package/src/domains/datastores/apply.ts +33 -0
- package/src/domains/datastores/delete.ts +47 -0
- package/src/domains/datastores/fetch.ts +32 -0
- package/src/domains/datastores/resources.ts +21 -0
- package/src/domains/datastores/tools.ts +76 -0
- package/src/domains/deletes.integration.test.ts +49 -2
- package/src/domains/environments/apply.ts +40 -0
- package/src/domains/environments/delete.ts +45 -0
- package/src/domains/environments/fetch.ts +39 -0
- package/src/domains/environments/resources.ts +21 -0
- package/src/domains/environments/tools.ts +81 -0
- package/src/domains/executions/cancel.ts +148 -0
- package/src/domains/executions/tools.ts +45 -0
- package/src/domains/executions.integration.test.ts +376 -0
- package/src/domains/reads.integration.test.ts +51 -5
- package/src/domains/records/calls.ts +209 -0
- package/src/domains/records/errors.ts +98 -0
- package/src/domains/records/records.integration.test.ts +313 -0
- package/src/domains/records/tools.ts +210 -0
- package/src/domains/resources.integration.test.ts +38 -2
- package/src/domains/resourceuri.test.ts +11 -2
- package/src/domains/resourceuri.ts +2 -0
- package/src/domains/search/search.integration.test.ts +18 -2
- package/src/domains/search/tools.ts +12 -7
- package/src/domains/skills/tools.ts +34 -1
- package/src/domains/skills/versions.ts +47 -0
- package/src/domains/versions.integration.test.ts +212 -0
- package/src/domains/workflowexecutions/approvals.ts +102 -0
- package/src/domains/workflowexecutions/run.ts +87 -0
- package/src/domains/workflowexecutions/tools.ts +120 -6
- package/src/domains/workflows/tools.ts +90 -7
- package/src/domains/workflows/versions.ts +147 -0
- package/src/gen/agent.ts +28 -1
- package/src/gen/datastore.ts +264 -0
- package/src/gen/environment.ts +66 -0
- package/src/http.integration.test.ts +1 -0
- package/src/index.ts +12 -5
- package/src/server.ts +71 -5
package/config.d.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { type LogFormat, type LogLevel } from "./logger.js";
|
|
2
2
|
/** Communication mode between MCP clients and the server. */
|
|
3
3
|
export type Transport = "stdio" | "http" | "both";
|
|
4
|
+
/**
|
|
5
|
+
* Which tool roster the server exposes.
|
|
6
|
+
*
|
|
7
|
+
* - "full": every domain (the default — external MCP clients).
|
|
8
|
+
* - "records": only the five record tools (DD-005) with the agent-facing
|
|
9
|
+
* argument surface. This is what the runner-synthesized datastore
|
|
10
|
+
* attachment spawns over stdio (T05 R1); over HTTP the same roster is
|
|
11
|
+
* served on the /records route regardless of this setting.
|
|
12
|
+
*/
|
|
13
|
+
export type Roster = "full" | "records";
|
|
4
14
|
/**
|
|
5
15
|
* OAuth 2.0 Protected Resource Metadata (RFC 9728) discovery settings.
|
|
6
16
|
*
|
|
@@ -25,6 +35,8 @@ export interface Config {
|
|
|
25
35
|
*/
|
|
26
36
|
readonly apiKey: string;
|
|
27
37
|
readonly transport: Transport;
|
|
38
|
+
/** Tool roster for stdio/both stdio-side; HTTP routes by path. */
|
|
39
|
+
readonly roster: Roster;
|
|
28
40
|
readonly httpPort: string;
|
|
29
41
|
/** Whether HTTP requests require an Authorization: Bearer header. */
|
|
30
42
|
readonly httpAuthEnabled: boolean;
|
package/config.d.ts.map
CHANGED
|
@@ -1 +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,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,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;AAOD,2EAA2E;AAC3E,wBAAgB,iBAAiB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAkB9E;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAkDhD"}
|
package/config.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
// reproduces Go's hard-errors AND warnings, not just the defaults.
|
|
8
8
|
import { log } from "./logger.js";
|
|
9
9
|
const VALID_TRANSPORTS = ["stdio", "http", "both"];
|
|
10
|
+
const VALID_ROSTERS = ["full", "records"];
|
|
10
11
|
const VALID_LOG_FORMATS = ["text", "json"];
|
|
11
12
|
const VALID_LOG_LEVELS = ["debug", "info", "warn", "error"];
|
|
12
13
|
/** Reads configuration from the process environment, applying defaults. */
|
|
@@ -15,6 +16,7 @@ export function loadConfigFromEnv(env = process.env) {
|
|
|
15
16
|
stigmerServerAddress: envOr(env, "STIGMER_SERVER_ADDRESS", "localhost:7234"),
|
|
16
17
|
apiKey: env.STIGMER_API_KEY ?? "",
|
|
17
18
|
transport: envOr(env, "STIGMER_MCP_TRANSPORT", "stdio").toLowerCase(),
|
|
19
|
+
roster: envOr(env, "STIGMER_MCP_ROSTER", "full").toLowerCase(),
|
|
18
20
|
httpPort: envOr(env, "STIGMER_MCP_HTTP_PORT", "8080"),
|
|
19
21
|
// Go semantics: only the exact string "true" enables auth.
|
|
20
22
|
httpAuthEnabled: envOr(env, "STIGMER_MCP_HTTP_AUTH_ENABLED", "true") === "true",
|
|
@@ -38,6 +40,9 @@ export function validateConfig(cfg) {
|
|
|
38
40
|
if (!VALID_TRANSPORTS.includes(cfg.transport)) {
|
|
39
41
|
throw new Error(`invalid STIGMER_MCP_TRANSPORT "${cfg.transport}": must be stdio, http, or both`);
|
|
40
42
|
}
|
|
43
|
+
if (!VALID_ROSTERS.includes(cfg.roster)) {
|
|
44
|
+
throw new Error(`invalid STIGMER_MCP_ROSTER "${cfg.roster}": must be full or records`);
|
|
45
|
+
}
|
|
41
46
|
if (cfg.stigmerServerAddress === "") {
|
|
42
47
|
throw new Error("STIGMER_SERVER_ADDRESS must not be empty");
|
|
43
48
|
}
|
package/config.js.map
CHANGED
|
@@ -1 +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;
|
|
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;AAmDjE,MAAM,gBAAgB,GAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AACtE,MAAM,aAAa,GAAsB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAC7D,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,UAAU,iBAAiB,CAAC,MAAyB,OAAO,CAAC,GAAG;IACpE,OAAO;QACL,oBAAoB,EAA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;
|
|
5
|
+
readonly comment?: string;
|
|
6
|
+
}
|
|
7
|
+
/** Submit an approval decision; returns the execution in the compact view. */
|
|
8
|
+
export declare function submitAgentApproval(serverAddress: string, token: string, args: SubmitAgentApprovalArgs): Promise<string>;
|
|
9
|
+
//# sourceMappingURL=approve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"approve.d.ts","sourceRoot":"","sources":["../../../src/domains/agentexecutions/approve.ts"],"names":[],"mappings":"AA4BA,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,8EAA8E;AAC9E,wBAAsB,mBAAmB,CACvC,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,uBAAuB,GAC5B,OAAO,CAAC,MAAM,CAAC,CA0BjB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Agent-execution approval path: submit a decision for a tool call the
|
|
2
|
+
// execution is waiting on (AgentExecutionCommandController.submitApproval).
|
|
3
|
+
//
|
|
4
|
+
// Pending approvals surface in get_agent_execution's
|
|
5
|
+
// status.pending_approvals[] — there is no org-wide inbox for agent
|
|
6
|
+
// executions (that exists only for workflow human_input tasks, see
|
|
7
|
+
// workflowexecutions/approvals.ts). The response reuses the compact
|
|
8
|
+
// projection: the returned AgentExecution embeds the full message history,
|
|
9
|
+
// which the approval loop doesn't need.
|
|
10
|
+
import { ApprovalAction } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
|
|
11
|
+
import { AgentExecutionCommandController } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/command_pb";
|
|
12
|
+
import { withClient } from "../client.js";
|
|
13
|
+
import { rpcError } from "../rpcerr.js";
|
|
14
|
+
import { compactExecutionJson, DEFAULT_MESSAGE_LIMIT } from "./fetch.js";
|
|
15
|
+
/**
|
|
16
|
+
* Model-facing action spelling → proto enum. APPROVE_ALL is deliberately not
|
|
17
|
+
* exposed: blanket auto-approval is a run-configuration concern, not a
|
|
18
|
+
* per-decision one.
|
|
19
|
+
*/
|
|
20
|
+
const APPROVAL_ACTIONS = {
|
|
21
|
+
approve: ApprovalAction.APPROVE,
|
|
22
|
+
skip: ApprovalAction.SKIP,
|
|
23
|
+
reject: ApprovalAction.REJECT,
|
|
24
|
+
};
|
|
25
|
+
/** Submit an approval decision; returns the execution in the compact view. */
|
|
26
|
+
export async function submitAgentApproval(serverAddress, token, args) {
|
|
27
|
+
const action = APPROVAL_ACTIONS[args.action];
|
|
28
|
+
if (action === undefined) {
|
|
29
|
+
throw new Error(`unknown action "${args.action}"; valid actions: approve, skip, reject`);
|
|
30
|
+
}
|
|
31
|
+
return withClient(AgentExecutionCommandController, serverAddress, token, async (client, callOptions) => {
|
|
32
|
+
try {
|
|
33
|
+
const execution = await client.submitApproval({
|
|
34
|
+
agentExecutionId: args.executionId,
|
|
35
|
+
toolCallId: args.toolCallId,
|
|
36
|
+
action,
|
|
37
|
+
comment: args.comment ?? "",
|
|
38
|
+
}, callOptions);
|
|
39
|
+
return compactExecutionJson(execution, DEFAULT_MESSAGE_LIMIT);
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
throw rpcError(err, `approval for agent execution "${args.executionId}"`);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=approve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"approve.js","sourceRoot":"","sources":["../../../src/domains/agentexecutions/approve.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,4EAA4E;AAC5E,EAAE;AACF,qDAAqD;AACrD,oEAAoE;AACpE,mEAAmE;AACnE,oEAAoE;AACpE,2EAA2E;AA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I,CAAC,WAAW,GAAG,CAAC,CAAC;QAC5E,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type AgentExecution } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/api_pb";
|
|
2
|
+
export type ExecutionView = "compact" | "full";
|
|
3
|
+
/** Message-tail size when the caller doesn't specify one. */
|
|
4
|
+
export declare const DEFAULT_MESSAGE_LIMIT = 5;
|
|
5
|
+
/** Fetch a single agent execution by ID and shape it for the requested view. */
|
|
6
|
+
export declare function fetchAgentExecution(serverAddress: string, token: string, executionId: string, view: ExecutionView, messageLimit: number): Promise<string>;
|
|
7
|
+
/** The compact projection plus the pre-truncation message count. */
|
|
8
|
+
export interface CompactExecution {
|
|
9
|
+
readonly totalMessages: number;
|
|
10
|
+
readonly data: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Build the compact projection: full protojson minus the pruned status
|
|
14
|
+
* fields, with status.messages sliced to the last `messageLimit` entries.
|
|
15
|
+
* Exposed at the data level so wrappers (cancel_execution's already_terminal
|
|
16
|
+
* envelope) can compose it without double-nesting.
|
|
17
|
+
*
|
|
18
|
+
* Shared by the write tools that return an AgentExecution (approve, cancel):
|
|
19
|
+
* their responses embed the same potentially-huge status.
|
|
20
|
+
*/
|
|
21
|
+
export declare function compactExecution(execution: AgentExecution, messageLimit: number): CompactExecution;
|
|
22
|
+
/**
|
|
23
|
+
* The compact view as returned by tools: a wrapper carrying total_messages so
|
|
24
|
+
* the model can tell when the message tail is a window (and re-request with a
|
|
25
|
+
* larger message_limit or view=full).
|
|
26
|
+
*/
|
|
27
|
+
export declare function compactExecutionJson(execution: AgentExecution, messageLimit: number): string;
|
|
28
|
+
//# sourceMappingURL=fetch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../src/domains/agentexecutions/fetch.ts"],"names":[],"mappings":"AAWA,OAAO,EAAwB,KAAK,cAAc,EAAE,MAAM,6DAA6D,CAAC;AAOxH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,MAAM,CAAC;AAE/C,6DAA6D;AAC7D,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAevC,gFAAgF;AAChF,wBAAsB,mBAAmB,CACvC,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,aAAa,EACnB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,MAAM,CAAC,CAoBjB;AAED,oEAAoE;AACpE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACxC;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,GAAG,gBAAgB,CAiBlG;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAO5F"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// Agent-execution read path: the polling primitive behind get_agent_execution.
|
|
2
|
+
//
|
|
3
|
+
// Agent executions have no event-log RPC (unlike workflow executions) — the
|
|
4
|
+
// platform's contract is: poll get and read status.phase, status.messages[],
|
|
5
|
+
// and status.pending_approvals[]. That makes the response shape critical for
|
|
6
|
+
// MCP: a long conversation's full protojson (every message, the resolved
|
|
7
|
+
// context snapshot, the approval ledger, sub-agent transcripts) can dwarf the
|
|
8
|
+
// model's context. The default "compact" view therefore returns a bounded
|
|
9
|
+
// message tail and drops the bulky server-side bookkeeping fields; "full" is
|
|
10
|
+
// the verbatim protojson for when the model genuinely needs everything.
|
|
11
|
+
import { AgentExecutionSchema } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/api_pb";
|
|
12
|
+
import { AgentExecutionQueryController } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/query_pb";
|
|
13
|
+
import { withClient } from "../client.js";
|
|
14
|
+
import { toProtoJson } from "../marshal.js";
|
|
15
|
+
import { rpcError } from "../rpcerr.js";
|
|
16
|
+
/** Message-tail size when the caller doesn't specify one. */
|
|
17
|
+
export const DEFAULT_MESSAGE_LIMIT = 5;
|
|
18
|
+
/**
|
|
19
|
+
* Bulky status fields pruned from the compact view. These are server-side
|
|
20
|
+
* bookkeeping (resolved-resource snapshot, append-only approval ledger,
|
|
21
|
+
* Temporal callback token) and sub-agent transcripts — none of which the
|
|
22
|
+
* poll loop (phase? messages? approvals?) needs.
|
|
23
|
+
*/
|
|
24
|
+
const COMPACT_PRUNED_STATUS_FIELDS = [
|
|
25
|
+
"resolved_context",
|
|
26
|
+
"approval_events",
|
|
27
|
+
"callback_token",
|
|
28
|
+
"sub_agent_executions",
|
|
29
|
+
];
|
|
30
|
+
/** Fetch a single agent execution by ID and shape it for the requested view. */
|
|
31
|
+
export async function fetchAgentExecution(serverAddress, token, executionId, view, messageLimit) {
|
|
32
|
+
if (executionId === "") {
|
|
33
|
+
throw new Error("execution_id is required");
|
|
34
|
+
}
|
|
35
|
+
return withClient(AgentExecutionQueryController, serverAddress, token, async (client, callOptions) => {
|
|
36
|
+
let execution;
|
|
37
|
+
try {
|
|
38
|
+
execution = await client.get({ value: executionId }, callOptions);
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
throw rpcError(err, `agent execution "${executionId}"`);
|
|
42
|
+
}
|
|
43
|
+
return view === "full"
|
|
44
|
+
? toProtoJson(AgentExecutionSchema, execution)
|
|
45
|
+
: compactExecutionJson(execution, messageLimit);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Build the compact projection: full protojson minus the pruned status
|
|
50
|
+
* fields, with status.messages sliced to the last `messageLimit` entries.
|
|
51
|
+
* Exposed at the data level so wrappers (cancel_execution's already_terminal
|
|
52
|
+
* envelope) can compose it without double-nesting.
|
|
53
|
+
*
|
|
54
|
+
* Shared by the write tools that return an AgentExecution (approve, cancel):
|
|
55
|
+
* their responses embed the same potentially-huge status.
|
|
56
|
+
*/
|
|
57
|
+
export function compactExecution(execution, messageLimit) {
|
|
58
|
+
const data = JSON.parse(toProtoJson(AgentExecutionSchema, execution));
|
|
59
|
+
let totalMessages = 0;
|
|
60
|
+
const status = data.status;
|
|
61
|
+
if (status !== undefined) {
|
|
62
|
+
const messages = Array.isArray(status.messages) ? status.messages : [];
|
|
63
|
+
totalMessages = messages.length;
|
|
64
|
+
if (messages.length > messageLimit) {
|
|
65
|
+
status.messages = messages.slice(-messageLimit);
|
|
66
|
+
}
|
|
67
|
+
for (const field of COMPACT_PRUNED_STATUS_FIELDS) {
|
|
68
|
+
delete status[field];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return { totalMessages, data };
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The compact view as returned by tools: a wrapper carrying total_messages so
|
|
75
|
+
* the model can tell when the message tail is a window (and re-request with a
|
|
76
|
+
* larger message_limit or view=full).
|
|
77
|
+
*/
|
|
78
|
+
export function compactExecutionJson(execution, messageLimit) {
|
|
79
|
+
const { totalMessages, data } = compactExecution(execution, messageLimit);
|
|
80
|
+
return JSON.stringify({ view: "compact", total_messages: totalMessages, execution: data }, null, 2);
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=fetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../../src/domains/agentexecutions/fetch.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,EAAE;AACF,4EAA4E;AAC5E,6EAA6E;AAC7E,6EAA6E;AAC7E,yEAAyE;AACzE,8EAA8E;AAC9E,0EAA0E;AAC1E,6EAA6E;AAC7E,wEAAwE;AAExE,OAAO,EA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3
|
+
readonly org: string;
|
|
4
|
+
readonly agent: string;
|
|
5
|
+
readonly message: string;
|
|
6
|
+
readonly sessionId?: string;
|
|
7
|
+
readonly runtimeEnv?: Record<string, string>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Start an agent execution: resolve org/slug → agent ID, then create the
|
|
11
|
+
* execution. Returns the created execution as protojson (small at creation
|
|
12
|
+
* time — status is empty until the runner picks it up).
|
|
13
|
+
*/
|
|
14
|
+
export declare function runAgent(serverAddress: string, token: string, args: RunAgentArgs): Promise<string>;
|
|
15
|
+
/**
|
|
16
|
+
* Convert the tool's plain string map to the proto ExecutionValue map. Values
|
|
17
|
+
* arriving through an MCP tool call have already passed through the model's
|
|
18
|
+
* context, so they are never secrets by definition — secrets reach executions
|
|
19
|
+
* through Environments, not through this tool.
|
|
20
|
+
*/
|
|
21
|
+
export declare function toExecutionValues(env: Record<string, string> | undefined): Record<string, ExecutionValue>;
|
|
22
|
+
/**
|
|
23
|
+
* Unique-enough placeholder name; the backend owns final identity. Mirrors the
|
|
24
|
+
* CLI's executionName (Go's fmt.Sprintf("execution-%d", UnixMicro())).
|
|
25
|
+
*/
|
|
26
|
+
export declare function executionName(): string;
|
|
27
|
+
//# sourceMappingURL=run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/domains/agentexecutions/run.ts"],"names":[],"mappings":"AAoBA,OAAO,EAEL,KAAK,cAAc,EACpB,MAAM,gEAAgE,CAAC;AAWxE,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9C;AAED;;;;GAIG;AACH,wBAAsB,QAAQ,CAC5B,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,YAAY,GACjB,OAAO,CAAC,MAAM,CAAC,CAoCjB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,GACtC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAMhC;AAED;;;GAGG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// Agent-execution start path for the run_agent tool.
|
|
2
|
+
//
|
|
3
|
+
// Mirrors the CLI's run stack (client-apps/cli/src/resources/run/create.ts):
|
|
4
|
+
// starting an agent is a single AgentExecutionCommandController.create call —
|
|
5
|
+
// the server bootstraps the session, resolves the agent's default instance
|
|
6
|
+
// (auto-creating if missing), and dispatches the message. The MCP layer only
|
|
7
|
+
// resolves the org/slug reference to the agent ID first, over the same
|
|
8
|
+
// transport (the two-step pattern the delete tools use).
|
|
9
|
+
//
|
|
10
|
+
// The tool is deliberately asynchronous: it returns the created execution
|
|
11
|
+
// (with its aex_* ID) immediately and the run continues in the background.
|
|
12
|
+
// Observation happens through get_agent_execution polling — MCP tools are
|
|
13
|
+
// request/response, so there is no streaming path here by design.
|
|
14
|
+
import { createClient } from "@connectrpc/connect";
|
|
15
|
+
import { create as createMessage } from "@bufbuild/protobuf";
|
|
16
|
+
import { AgentQueryController } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/query_pb";
|
|
17
|
+
import { AgentExecutionSchema } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/api_pb";
|
|
18
|
+
import { AgentExecutionCommandController } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/command_pb";
|
|
19
|
+
import { AgentExecutionSpecSchema } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/spec_pb";
|
|
20
|
+
import { ExecutionValueSchema, } from "@stigmer/protos/ai/stigmer/agentic/executioncontext/v1/spec_pb";
|
|
21
|
+
import { ApiResourceMetadataSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/metadata_pb";
|
|
22
|
+
import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
|
|
23
|
+
import { withTransport } from "../client.js";
|
|
24
|
+
import { toProtoJson } from "../marshal.js";
|
|
25
|
+
import { rpcError } from "../rpcerr.js";
|
|
26
|
+
/** apiVersion stamped on created executions; mirrors the CLI's run stack. */
|
|
27
|
+
const API_VERSION = "agentic.stigmer.ai/v1";
|
|
28
|
+
/**
|
|
29
|
+
* Start an agent execution: resolve org/slug → agent ID, then create the
|
|
30
|
+
* execution. Returns the created execution as protojson (small at creation
|
|
31
|
+
* time — status is empty until the runner picks it up).
|
|
32
|
+
*/
|
|
33
|
+
export async function runAgent(serverAddress, token, args) {
|
|
34
|
+
const desc = `agent "${args.agent}" in org "${args.org}"`;
|
|
35
|
+
return withTransport(serverAddress, token, async (transport, callOptions) => {
|
|
36
|
+
const query = createClient(AgentQueryController, transport);
|
|
37
|
+
let agentId;
|
|
38
|
+
try {
|
|
39
|
+
const agent = await query.getByReference({ org: args.org, kind: ApiResourceKind.agent, slug: args.agent }, callOptions);
|
|
40
|
+
agentId = agent.metadata?.id ?? "";
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
throw rpcError(err, desc);
|
|
44
|
+
}
|
|
45
|
+
const execution = createMessage(AgentExecutionSchema, {
|
|
46
|
+
apiVersion: API_VERSION,
|
|
47
|
+
kind: "AgentExecution",
|
|
48
|
+
metadata: createMessage(ApiResourceMetadataSchema, { name: executionName(), org: args.org }),
|
|
49
|
+
spec: createMessage(AgentExecutionSpecSchema, {
|
|
50
|
+
// Empty message means "just run" — the CLI applies the same default.
|
|
51
|
+
message: args.message === "" ? "execute" : args.message,
|
|
52
|
+
runtimeEnv: toExecutionValues(args.runtimeEnv),
|
|
53
|
+
sessionId: args.sessionId ?? "",
|
|
54
|
+
agentId,
|
|
55
|
+
}),
|
|
56
|
+
});
|
|
57
|
+
const command = createClient(AgentExecutionCommandController, transport);
|
|
58
|
+
try {
|
|
59
|
+
const created = await command.create(execution, callOptions);
|
|
60
|
+
return toProtoJson(AgentExecutionSchema, created);
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
throw rpcError(err, `execution of ${desc}`);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Convert the tool's plain string map to the proto ExecutionValue map. Values
|
|
69
|
+
* arriving through an MCP tool call have already passed through the model's
|
|
70
|
+
* context, so they are never secrets by definition — secrets reach executions
|
|
71
|
+
* through Environments, not through this tool.
|
|
72
|
+
*/
|
|
73
|
+
export function toExecutionValues(env) {
|
|
74
|
+
const out = {};
|
|
75
|
+
for (const [key, value] of Object.entries(env ?? {})) {
|
|
76
|
+
out[key] = createMessage(ExecutionValueSchema, { value, isSecret: false });
|
|
77
|
+
}
|
|
78
|
+
return out;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Unique-enough placeholder name; the backend owns final identity. Mirrors the
|
|
82
|
+
* CLI's executionName (Go's fmt.Sprintf("execution-%d", UnixMicro())).
|
|
83
|
+
*/
|
|
84
|
+
export function executionName() {
|
|
85
|
+
return `execution-${Date.now() * 1000}`;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=run.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../../src/domains/agentexecutions/run.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,EAAE;AACF,6EAA6E;AAC7E,8EAA8E;AAC9E,2EAA2E;AAC3E,6EAA6E;AAC7E,uEAAuE;AACvE,yDAAyD;AACzD,EAAE;AACF,0EAA0E;AAC1E,2EAA2E;AAC3E,0EAA0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EAAE,CAAC;IAC/C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,CAAC;QACrD,GAAG,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,oBAAoB,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,aAAa,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;AAC1C,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 AgentExecution-domain tool; returns the registered tool names. */
|
|
4
|
+
export declare function registerAgentExecutionTools(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/agentexecutions/tools.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAMhE,oFAAoF;AACpF,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,GAAG,MAAM,EAAE,CAqH9F"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// MCP tools for the AgentExecution domain: start a run, poll it, and answer
|
|
2
|
+
// its approval requests. Together with cancel_execution (executions domain)
|
|
3
|
+
// these close the agent iteration loop: author with apply_agent, run with
|
|
4
|
+
// run_agent, observe with get_agent_execution, steer with
|
|
5
|
+
// submit_agent_execution_approval.
|
|
6
|
+
//
|
|
7
|
+
// The execution model is asynchronous by design: run_agent returns as soon as
|
|
8
|
+
// the backend accepts the execution; progress is observed by polling. Agent
|
|
9
|
+
// executions have no event-log RPC, so get_agent_execution IS the poll loop —
|
|
10
|
+
// which is why it defaults to the compact view (see fetch.ts).
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
import { resolveToken } from "../client.js";
|
|
13
|
+
import { textOrError } from "../toolresult.js";
|
|
14
|
+
import { submitAgentApproval } from "./approve.js";
|
|
15
|
+
import { DEFAULT_MESSAGE_LIMIT, fetchAgentExecution } from "./fetch.js";
|
|
16
|
+
import { runAgent } from "./run.js";
|
|
17
|
+
/** Register every AgentExecution-domain tool; returns the registered tool names. */
|
|
18
|
+
export function registerAgentExecutionTools(server, target) {
|
|
19
|
+
server.registerTool("run_agent", {
|
|
20
|
+
description: "Start an agent execution (asynchronous). Returns immediately with the created execution " +
|
|
21
|
+
"(aex_* ID) while the run continues in the background — poll get_agent_execution to observe " +
|
|
22
|
+
"progress, pending approvals, and the final result. Omit session_id to start a fresh " +
|
|
23
|
+
"conversation; pass one to send a follow-up message into an existing session.",
|
|
24
|
+
inputSchema: {
|
|
25
|
+
org: z.string().describe("Organization slug that owns the agent (e.g. stigmer)."),
|
|
26
|
+
agent: z
|
|
27
|
+
.string()
|
|
28
|
+
.describe("Agent slug — the unique identifier within the org (e.g. code-reviewer)."),
|
|
29
|
+
message: z.string().describe("The instruction or message for the agent to act on."),
|
|
30
|
+
session_id: z
|
|
31
|
+
.string()
|
|
32
|
+
.optional()
|
|
33
|
+
.describe("Existing session ID to continue a conversation (from a previous execution's " +
|
|
34
|
+
"spec.session_id). Omit to start a new session."),
|
|
35
|
+
runtime_env: z
|
|
36
|
+
.record(z.string())
|
|
37
|
+
.optional()
|
|
38
|
+
.describe("Non-secret runtime environment values (name → value) injected into the run. " +
|
|
39
|
+
"Secrets must come from Environments attached to the agent, never through this tool."),
|
|
40
|
+
},
|
|
41
|
+
}, (args, extra) => textOrError(() => runAgent(target.serverAddress, resolveToken(extra, target.apiKey), {
|
|
42
|
+
org: args.org,
|
|
43
|
+
agent: args.agent,
|
|
44
|
+
message: args.message,
|
|
45
|
+
sessionId: args.session_id,
|
|
46
|
+
runtimeEnv: args.runtime_env,
|
|
47
|
+
})));
|
|
48
|
+
server.registerTool("get_agent_execution", {
|
|
49
|
+
description: "Get an agent execution's status: phase, messages, pending approvals, errors, timing. " +
|
|
50
|
+
"Agent executions have no event log — poll this tool to track a run started with run_agent " +
|
|
51
|
+
"(terminal phases: completed, failed, cancelled, terminated). The default compact view " +
|
|
52
|
+
"returns the last few messages and omits bulky bookkeeping fields (resolved context, " +
|
|
53
|
+
"approval ledger, sub-agent transcripts); total_messages tells you when the tail is a " +
|
|
54
|
+
"window. Use view=full for the complete record.",
|
|
55
|
+
inputSchema: {
|
|
56
|
+
execution_id: z.string().describe("Agent execution ID (aex_* format)."),
|
|
57
|
+
view: z
|
|
58
|
+
.enum(["compact", "full"])
|
|
59
|
+
.optional()
|
|
60
|
+
.describe("Response shape: compact (default, bounded message tail) or full protojson."),
|
|
61
|
+
message_limit: z
|
|
62
|
+
.number()
|
|
63
|
+
.int()
|
|
64
|
+
.min(1)
|
|
65
|
+
.optional()
|
|
66
|
+
.describe(`Compact view only: number of trailing messages to return (default ${DEFAULT_MESSAGE_LIMIT}).`),
|
|
67
|
+
},
|
|
68
|
+
}, (args, extra) => textOrError(() => fetchAgentExecution(target.serverAddress, resolveToken(extra, target.apiKey), args.execution_id, args.view ?? "compact", args.message_limit ?? DEFAULT_MESSAGE_LIMIT)));
|
|
69
|
+
server.registerTool("submit_agent_execution_approval", {
|
|
70
|
+
description: "Approve, skip, or reject a tool call an agent execution is waiting on (phase " +
|
|
71
|
+
"waiting-for-approval). Find pending requests in get_agent_execution's " +
|
|
72
|
+
"status.pending_approvals — tool_call_id must match exactly. reject denies the single " +
|
|
73
|
+
"tool call and feeds your comment back to the agent, which then continues; to stop the " +
|
|
74
|
+
"whole run use cancel_execution instead.",
|
|
75
|
+
inputSchema: {
|
|
76
|
+
execution_id: z.string().describe("Agent execution ID (aex_* format)."),
|
|
77
|
+
tool_call_id: z
|
|
78
|
+
.string()
|
|
79
|
+
.describe("Tool call awaiting the decision (status.pending_approvals[].tool_call_id)."),
|
|
80
|
+
action: z
|
|
81
|
+
.enum(["approve", "skip", "reject"])
|
|
82
|
+
.describe("approve: execute the tool. skip: don't execute, agent proceeds without it. " +
|
|
83
|
+
"reject: don't execute, agent is told why (see comment) and adapts."),
|
|
84
|
+
comment: z
|
|
85
|
+
.string()
|
|
86
|
+
.optional()
|
|
87
|
+
.describe("Reason for the decision; on reject it is fed back to the agent."),
|
|
88
|
+
},
|
|
89
|
+
}, (args, extra) => textOrError(() => submitAgentApproval(target.serverAddress, resolveToken(extra, target.apiKey), {
|
|
90
|
+
executionId: args.execution_id,
|
|
91
|
+
toolCallId: args.tool_call_id,
|
|
92
|
+
action: args.action,
|
|
93
|
+
comment: args.comment,
|
|
94
|
+
})));
|
|
95
|
+
return ["run_agent", "get_agent_execution", "submit_agent_execution_approval"];
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../src/domains/agentexecutions/tools.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,4EAA4E;AAC5E,0EAA0E;AAC1E,0DAA0D;AAC1D,mCAAmC;AACnC,EAAE;AACF,8EAA8E;AAC9E,4EAA4E;AAC5E,8EAA8E;AAC9E,+DAA+D;AAG/D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAsB,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CA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,CAAC;SAC/E;KACF,EACD,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CACd,WAAW,CAAC,GAAG,EAAE,CACf,mBAAmB,CAAC,MAAM,CAAC,aAAa,EAAE,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE;QAC5E,WAAW,EAAE,IAAI,CAAC,YAAY;QAC9B,UAAU,EAAE,IAAI,CAAC,YAAY;QAC7B,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,OAAO,EAAE,IAAI,CAAC,OAAO;KACtB,CAAC,CACH,CACJ,CAAC;IAEF,OAAO,CAAC,WAAW,EAAE,qBAAqB,EAAE,iCAAiC,CAAC,CAAC;AACjF,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type DatastoreInput } from "../../gen/datastore.js";
|
|
2
|
+
/** Create or update a datastore, returning the persisted resource as protojson. */
|
|
3
|
+
export declare function applyDatastore(serverAddress: string, token: string, input: DatastoreInput): Promise<string>;
|
|
4
|
+
//# sourceMappingURL=apply.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../../src/domains/datastores/apply.ts"],"names":[],"mappings":"AAWA,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,CAWjB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Datastore apply path: create-or-update via DatastoreCommandController.apply.
|
|
2
|
+
// The flat MCP input is projected into a fully-formed Datastore proto by the
|
|
3
|
+
// generated datastoreInputToProto bridge (codegen, src/gen/datastore.ts).
|
|
4
|
+
//
|
|
5
|
+
// The manifest is authoritative for structure, never for data: schema changes
|
|
6
|
+
// sync on apply (the server enforces its additive-plus change matrix), and
|
|
7
|
+
// records enter exclusively through the record tools.
|
|
8
|
+
import { DatastoreSchema } from "@stigmer/protos/ai/stigmer/agentic/datastore/v1/api_pb";
|
|
9
|
+
import { DatastoreCommandController } from "@stigmer/protos/ai/stigmer/agentic/datastore/v1/command_pb";
|
|
10
|
+
import { datastoreInputToProto } from "../../gen/datastore.js";
|
|
11
|
+
import { withClient } from "../client.js";
|
|
12
|
+
import { toProtoJson } from "../marshal.js";
|
|
13
|
+
import { rpcError } from "../rpcerr.js";
|
|
14
|
+
/** Create or update a datastore, returning the persisted resource as protojson. */
|
|
15
|
+
export async function applyDatastore(serverAddress, token, input) {
|
|
16
|
+
const datastore = datastoreInputToProto(input);
|
|
17
|
+
const desc = `datastore "${datastore.metadata?.slug ?? ""}" in org "${datastore.metadata?.org ?? ""}"`;
|
|
18
|
+
return withClient(DatastoreCommandController, serverAddress, token, async (client, callOptions) => {
|
|
19
|
+
try {
|
|
20
|
+
const result = await client.apply(datastore, callOptions);
|
|
21
|
+
return toProtoJson(DatastoreSchema, result);
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
throw rpcError(err, desc);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=apply.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply.js","sourceRoot":"","sources":["../../../src/domains/datastores/apply.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,6EAA6E;AAC7E,0EAA0E;AAC1E,EAAE;AACF,8EAA8E;AAC9E,2EAA2E;AAC3E,sDAAsD;AAEtD,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,SAAS,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAC/C,MAAM,IAAI,GAAG,cAAc,SAAS,CAAC,QAAQ,EAAE,IAAI,IAAI,EAAE,aAAa,SAAS,CAAC,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,CAAC;IACvG,OAAO,UAAU,CAAC,0BAA0B,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE;QAChG,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;YAC1D,OAAO,WAAW,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;QAC9C,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 @@
|
|
|
1
|
+
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../src/domains/datastores/delete.ts"],"names":[],"mappings":"AAiBA,uFAAuF;AACvF,wBAAsB,eAAe,CACnC,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,CAAC,CAuBjB"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Datastore delete path: resolve org/slug → id via the Query controller, then
|
|
2
|
+
// delete via the Command controller, both over a single shared transport. Like
|
|
3
|
+
// McpServer, the command controller takes ApiResourceDeleteInput{resource_id}.
|
|
4
|
+
//
|
|
5
|
+
// This is the only path that destroys collections — record tools can delete
|
|
6
|
+
// individual records but never structure.
|
|
7
|
+
import { createClient } from "@connectrpc/connect";
|
|
8
|
+
import { DatastoreSchema } from "@stigmer/protos/ai/stigmer/agentic/datastore/v1/api_pb";
|
|
9
|
+
import { DatastoreCommandController } from "@stigmer/protos/ai/stigmer/agentic/datastore/v1/command_pb";
|
|
10
|
+
import { DatastoreQueryController } from "@stigmer/protos/ai/stigmer/agentic/datastore/v1/query_pb";
|
|
11
|
+
import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
|
|
12
|
+
import { withTransport } from "../client.js";
|
|
13
|
+
import { toProtoJson } from "../marshal.js";
|
|
14
|
+
import { rpcError } from "../rpcerr.js";
|
|
15
|
+
/** Delete a datastore by org and slug, returning the deleted resource as protojson. */
|
|
16
|
+
export async function deleteDatastore(serverAddress, token, org, slug) {
|
|
17
|
+
const desc = `datastore "${slug}" in org "${org}"`;
|
|
18
|
+
return withTransport(serverAddress, token, async (transport, callOptions) => {
|
|
19
|
+
const query = createClient(DatastoreQueryController, transport);
|
|
20
|
+
let id;
|
|
21
|
+
try {
|
|
22
|
+
const datastore = await query.getByReference({ org, kind: ApiResourceKind.datastore, slug }, callOptions);
|
|
23
|
+
id = datastore.metadata?.id ?? "";
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
throw rpcError(err, desc);
|
|
27
|
+
}
|
|
28
|
+
const command = createClient(DatastoreCommandController, transport);
|
|
29
|
+
try {
|
|
30
|
+
const deleted = await command.delete({ resourceId: id }, callOptions);
|
|
31
|
+
return toProtoJson(DatastoreSchema, deleted);
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
throw rpcError(err, desc);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=delete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete.js","sourceRoot":"","sources":["../../../src/dom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