@stigmer/mcp-server 3.11.1-dev.20260812192248 → 3.12.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 +4 -22
- package/cli/mcp-server-stigmer.js +11 -11
- package/config.d.ts +1 -5
- package/config.d.ts.map +1 -1
- package/config.js +2 -2
- package/config.js.map +1 -1
- package/domains/resourceuri.d.ts.map +1 -1
- package/domains/resourceuri.js +0 -1
- package/domains/resourceuri.js.map +1 -1
- package/domains/search/tools.d.ts.map +1 -1
- package/domains/search/tools.js +4 -5
- package/domains/search/tools.js.map +1 -1
- package/gen/agent.d.ts +0 -56
- package/gen/agent.d.ts.map +1 -1
- package/gen/agent.js +1 -24
- package/gen/agent.js.map +1 -1
- package/gen/workflow.d.ts +2 -2
- package/index.d.ts +1 -1
- package/index.d.ts.map +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/server.d.ts +6 -18
- package/server.d.ts.map +1 -1
- package/server.js +6 -36
- package/server.js.map +1 -1
- package/src/config.ts +3 -7
- package/src/domains/apply.integration.test.ts +3 -40
- package/src/domains/deletes.integration.test.ts +1 -25
- package/src/domains/reads.integration.test.ts +1 -18
- package/src/domains/resources.integration.test.ts +0 -18
- package/src/domains/resourceuri.test.ts +0 -2
- package/src/domains/resourceuri.ts +0 -1
- package/src/domains/search/search.integration.test.ts +3 -5
- package/src/domains/search/tools.ts +4 -5
- package/src/gen/agent.ts +1 -28
- package/src/http.integration.test.ts +2 -3
- package/src/index.ts +0 -2
- package/src/server.ts +6 -36
- package/domains/datastores/apply.d.ts +0 -4
- package/domains/datastores/apply.d.ts.map +0 -1
- package/domains/datastores/apply.js +0 -28
- package/domains/datastores/apply.js.map +0 -1
- package/domains/datastores/delete.d.ts +0 -3
- package/domains/datastores/delete.d.ts.map +0 -1
- package/domains/datastores/delete.js +0 -38
- package/domains/datastores/delete.js.map +0 -1
- package/domains/datastores/fetch.d.ts +0 -3
- package/domains/datastores/fetch.d.ts.map +0 -1
- package/domains/datastores/fetch.js +0 -23
- package/domains/datastores/fetch.js.map +0 -1
- package/domains/datastores/resources.d.ts +0 -5
- package/domains/datastores/resources.d.ts.map +0 -1
- package/domains/datastores/resources.js +0 -16
- package/domains/datastores/resources.js.map +0 -1
- package/domains/datastores/tools.d.ts +0 -5
- package/domains/datastores/tools.d.ts.map +0 -1
- package/domains/datastores/tools.js +0 -46
- package/domains/datastores/tools.js.map +0 -1
- package/domains/records/calls.d.ts +0 -48
- package/domains/records/calls.d.ts.map +0 -1
- package/domains/records/calls.js +0 -118
- package/domains/records/calls.js.map +0 -1
- package/domains/records/errors.d.ts +0 -24
- package/domains/records/errors.d.ts.map +0 -1
- package/domains/records/errors.js +0 -79
- package/domains/records/errors.js.map +0 -1
- package/domains/records/tools.d.ts +0 -7
- package/domains/records/tools.d.ts.map +0 -1
- package/domains/records/tools.js +0 -139
- package/domains/records/tools.js.map +0 -1
- package/gen/datastore.d.ts +0 -861
- package/gen/datastore.d.ts.map +0 -1
- package/gen/datastore.js +0 -267
- package/gen/datastore.js.map +0 -1
- package/src/domains/datastores/apply.ts +0 -33
- package/src/domains/datastores/delete.ts +0 -47
- package/src/domains/datastores/fetch.ts +0 -32
- package/src/domains/datastores/resources.ts +0 -21
- package/src/domains/datastores/tools.ts +0 -76
- package/src/domains/records/calls.ts +0 -209
- package/src/domains/records/errors.ts +0 -98
- package/src/domains/records/records.integration.test.ts +0 -313
- package/src/domains/records/tools.ts +0 -210
- package/src/gen/datastore.ts +0 -264
package/src/server.ts
CHANGED
|
@@ -25,14 +25,11 @@ import { registerAgentTools } from "./domains/agents/tools.js";
|
|
|
25
25
|
import { registerChannelTools } from "./domains/channels/tools.js";
|
|
26
26
|
import type { BackendTarget } from "./domains/client.js";
|
|
27
27
|
import { registerConversationTools } from "./domains/conversation/tools.js";
|
|
28
|
-
import { registerDatastoreResources } from "./domains/datastores/resources.js";
|
|
29
|
-
import { registerDatastoreTools } from "./domains/datastores/tools.js";
|
|
30
28
|
import { registerEnvironmentResources } from "./domains/environments/resources.js";
|
|
31
29
|
import { registerEnvironmentTools } from "./domains/environments/tools.js";
|
|
32
30
|
import { registerExecutionControlTools } from "./domains/executions/tools.js";
|
|
33
31
|
import { registerMcpServerResources } from "./domains/mcpservers/resources.js";
|
|
34
32
|
import { registerMcpServerTools } from "./domains/mcpservers/tools.js";
|
|
35
|
-
import { registerRecordTools } from "./domains/records/tools.js";
|
|
36
33
|
import { registerSearchTools } from "./domains/search/tools.js";
|
|
37
34
|
import { registerSkillResources } from "./domains/skills/resources.js";
|
|
38
35
|
import { registerSkillTools } from "./domains/skills/tools.js";
|
|
@@ -69,22 +66,6 @@ export function createServer(target: BackendTarget): McpServer {
|
|
|
69
66
|
return server;
|
|
70
67
|
}
|
|
71
68
|
|
|
72
|
-
/**
|
|
73
|
-
* Build a records-only MCP server: the five record tools with the
|
|
74
|
-
* agent-facing argument surface, and nothing else (T05 R1). This is
|
|
75
|
-
* the roster the runner-synthesized datastore attachment connects to —
|
|
76
|
-
* a structural guarantee that an agent session never sees the
|
|
77
|
-
* management tools (apply/delete/…) its empty approval maps would make
|
|
78
|
-
* approval-free. Served on the /records HTTP route and as the stdio
|
|
79
|
-
* roster when STIGMER_MCP_ROSTER=records.
|
|
80
|
-
*/
|
|
81
|
-
export function createRecordsServer(target: BackendTarget): McpServer {
|
|
82
|
-
const server = new McpServer({ name: "mcp-server-stigmer-records", version: SERVER_VERSION });
|
|
83
|
-
const tools = registerRecordTools(server, target, "agent");
|
|
84
|
-
log.info("tools registered (records roster)", { count: tools.length, tools });
|
|
85
|
-
return server;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
69
|
/**
|
|
89
70
|
* Build a channels-only MCP server: send_channel_message with the
|
|
90
71
|
* agent-facing argument surface, and nothing else (proactive-messaging
|
|
@@ -143,11 +124,6 @@ function registerTools(server: McpServer, target: BackendTarget): void {
|
|
|
143
124
|
...registerWorkflowExecutionTools(server, target),
|
|
144
125
|
...registerExecutionControlTools(server, target),
|
|
145
126
|
...registerEnvironmentTools(server, target),
|
|
146
|
-
...registerDatastoreTools(server, target),
|
|
147
|
-
// The record tools also serve external MCP clients — as direct
|
|
148
|
-
// principals with the org argument and honest annotations (the
|
|
149
|
-
// agent-facing variant lives on the records-only roster).
|
|
150
|
-
...registerRecordTools(server, target, "direct"),
|
|
151
127
|
];
|
|
152
128
|
log.info("tools registered", { count: tools.length, tools });
|
|
153
129
|
}
|
|
@@ -164,7 +140,6 @@ function registerResources(server: McpServer, target: BackendTarget): void {
|
|
|
164
140
|
...registerSkillResources(server, target),
|
|
165
141
|
...registerWorkflowResources(server, target),
|
|
166
142
|
...registerEnvironmentResources(server, target),
|
|
167
|
-
...registerDatastoreResources(server, target),
|
|
168
143
|
];
|
|
169
144
|
log.info("resources registered", { count: resources.length, resources });
|
|
170
145
|
}
|
|
@@ -211,9 +186,6 @@ export type RouteServerFactory = (path: string) => McpServer | undefined;
|
|
|
211
186
|
/** HTTP route serving the full roster: the bare origin every published config uses. */
|
|
212
187
|
export const FULL_ROUTE = "/";
|
|
213
188
|
|
|
214
|
-
/** HTTP route serving the records-only roster (T05 R1). */
|
|
215
|
-
export const RECORDS_ROUTE = "/records";
|
|
216
|
-
|
|
217
189
|
/** HTTP route serving the channels-only roster (DD-006 D8). */
|
|
218
190
|
export const CHANNELS_ROUTE = "/channels";
|
|
219
191
|
|
|
@@ -222,9 +194,9 @@ export const CONVERSATION_ROUTE = "/conversation";
|
|
|
222
194
|
|
|
223
195
|
/**
|
|
224
196
|
* The standard HTTP route dispatch: the full roster on {@link FULL_ROUTE},
|
|
225
|
-
* the
|
|
226
|
-
* roster on {@link
|
|
227
|
-
*
|
|
197
|
+
* the channels-only roster on {@link CHANNELS_ROUTE}, the
|
|
198
|
+
* conversation-only roster on {@link CONVERSATION_ROUTE} — and NOTHING
|
|
199
|
+
* anywhere else.
|
|
228
200
|
*
|
|
229
201
|
* The closed route table is load-bearing, not tidiness. This dispatch
|
|
230
202
|
* once fell through to the full roster for any unrecognized path, and a
|
|
@@ -239,7 +211,6 @@ export const CONVERSATION_ROUTE = "/conversation";
|
|
|
239
211
|
export function routedServerFactory(target: BackendTarget): RouteServerFactory {
|
|
240
212
|
return (path) => {
|
|
241
213
|
if (path === FULL_ROUTE) return createServer(target);
|
|
242
|
-
if (path === RECORDS_ROUTE) return createRecordsServer(target);
|
|
243
214
|
if (path === CHANNELS_ROUTE) return createChannelsServer(target);
|
|
244
215
|
if (path === CONVERSATION_ROUTE) return createConversationServer(target);
|
|
245
216
|
return undefined;
|
|
@@ -431,12 +402,11 @@ async function routeRequest(
|
|
|
431
402
|
}
|
|
432
403
|
|
|
433
404
|
/**
|
|
434
|
-
* The stdio server for the configured roster: the
|
|
435
|
-
*
|
|
436
|
-
*
|
|
405
|
+
* The stdio server for the configured roster: the channels-only roster
|
|
406
|
+
* when STIGMER_MCP_ROSTER names it (what the OSS runner-synthesized
|
|
407
|
+
* attachment spawns), the full roster otherwise.
|
|
437
408
|
*/
|
|
438
409
|
export function stdioServer(target: BackendTarget, cfg: Config): McpServer {
|
|
439
|
-
if (cfg.roster === "records") return createRecordsServer(target);
|
|
440
410
|
if (cfg.roster === "channels") return createChannelsServer(target);
|
|
441
411
|
return createServer(target);
|
|
442
412
|
}
|
|
@@ -1,4 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,28 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"apply.js","sourceRoot":"","sources":["../../../src/domains/datastores/apply.ts"],"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uF;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"}
|
|
@@ -1,38 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"delete.js","sourceRoot":"","sources":["../../../src/domains/datastores/delete.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,+EAA+E;AAC/E,+EAA+E;AAC/E,EAAE;AACF,4EAA4E;AAC5E,0CAA0C;AAE1C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,wDAAwD,CAAC;AACzF,OAAO,EAAE,0BAA0B,EAAE,MAAM,4DAA4D,CAAC;AACxG,OAAO,EAAE,wBAAwB,EAAE,MAAM,0DAA0D,CAAC;AACpG,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,uFAAuF;AACvF,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,aAAqB,EACrB,KAAa,EACb,GAAW,EACX,IAAY;IAEZ,MAAM,IAAI,GAAG,cAAc,IAAI,aAAa,GAAG,GAAG,CAAC;IACnD,OAAO,aAAa,CAAC,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,EAAE;QAC1E,MAAM,KAAK,GAAG,YAAY,CAAC,wBAAwB,EAAE,SAAS,CAAC,CAAC;QAChE,IAAI,EAAU,CAAC;QACf,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,MAAM,KAAK,CAAC,cAAc,CAC1C,EAAE,GAAG,EAAE,IAAI,EAAE,eAAe,CAAC,SAAS,EAAE,IAAI,EAAE,EAC9C,WAAW,CACZ,CAAC;YACF,EAAE,GAAG,SAAS,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC;QACpC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC5B,CAAC;QAED,MAAM,OAAO,GAAG,YAAY,CAAC,0BAA0B,EAAE,SAAS,CAAC,CAAC;QACpE,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,WAAW,CAAC,CAAC;YACtE,OAAO,WAAW,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;QAC/C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../src/domains/datastores/fetch.ts"],"names":[],"mappings":"AAaA,oFAAoF;AACpF,wBAAsB,cAAc,CAClC,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,CAAC,CAYjB"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// Datastore-definition read path: the single RPC both the get_datastore tool
|
|
2
|
-
// and the datastore resource template delegate to. This is the *structure*
|
|
3
|
-
// surface (collections, constraints, grants); living records are served by the
|
|
4
|
-
// record tools (records/), whose agent-facing summary is describe_datastore.
|
|
5
|
-
import { DatastoreSchema } from "@stigmer/protos/ai/stigmer/agentic/datastore/v1/api_pb";
|
|
6
|
-
import { DatastoreQueryController } from "@stigmer/protos/ai/stigmer/agentic/datastore/v1/query_pb";
|
|
7
|
-
import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
|
|
8
|
-
import { withClient } from "../client.js";
|
|
9
|
-
import { toProtoJson } from "../marshal.js";
|
|
10
|
-
import { rpcError } from "../rpcerr.js";
|
|
11
|
-
/** Retrieve a datastore by org and slug, returning its protojson representation. */
|
|
12
|
-
export async function fetchDatastore(serverAddress, token, org, slug) {
|
|
13
|
-
return withClient(DatastoreQueryController, serverAddress, token, async (client, callOptions) => {
|
|
14
|
-
try {
|
|
15
|
-
const datastore = await client.getByReference({ org, kind: ApiResourceKind.datastore, slug }, callOptions);
|
|
16
|
-
return toProtoJson(DatastoreSchema, datastore);
|
|
17
|
-
}
|
|
18
|
-
catch (err) {
|
|
19
|
-
throw rpcError(err, `datastore "${slug}" in org "${org}"`);
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=fetch.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../../src/domains/datastores/fetch.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,2EAA2E;AAC3E,+EAA+E;AAC/E,6EAA6E;AAE7E,OAAO,EAAE,eAAe,EAAE,MAAM,wDAAwD,CAAC;AACzF,OAAO,EAAE,wBAAwB,EAAE,MAAM,0DAA0D,CAAC;AACpG,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,oFAAoF;AACpF,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,aAAqB,EACrB,KAAa,EACb,GAAW,EACX,IAAY;IAEZ,OAAO,UAAU,CAAC,wBAAwB,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE;QAC9F,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,cAAc,CAC3C,EAAE,GAAG,EAAE,IAAI,EAAE,eAAe,CAAC,SAAS,EAAE,IAAI,EAAE,EAC9C,WAAW,CACZ,CAAC;YACF,OAAO,WAAW,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;QACjD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,QAAQ,CAAC,GAAG,EAAE,cAAc,IAAI,aAAa,GAAG,GAAG,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import type { BackendTarget } from "../client.js";
|
|
3
|
-
/** Register the datastore resource template; returns the registered resource names. */
|
|
4
|
-
export declare function registerDatastoreResources(server: McpServer, target: BackendTarget): string[];
|
|
5
|
-
//# sourceMappingURL=resources.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../../src/domains/datastores/resources.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAIlD,uFAAuF;AACvF,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,GAAG,MAAM,EAAE,CAW7F"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// Datastore resource template (stigmer://datastores/{org}/{slug}).
|
|
2
|
-
import { registerResource } from "../resourcehandler.js";
|
|
3
|
-
import { fetchDatastore } from "./fetch.js";
|
|
4
|
-
/** Register the datastore resource template; returns the registered resource names. */
|
|
5
|
-
export function registerDatastoreResources(server, target) {
|
|
6
|
-
registerResource(server, target, {
|
|
7
|
-
name: "stigmer_datastore",
|
|
8
|
-
title: "Stigmer Datastore",
|
|
9
|
-
description: "Full definition of a Stigmer datastore (collections, constraints, grants), " +
|
|
10
|
-
"identified by organization and slug.",
|
|
11
|
-
template: "stigmer://datastores/{org}/{slug}",
|
|
12
|
-
fetch: fetchDatastore,
|
|
13
|
-
});
|
|
14
|
-
return ["stigmer_datastore"];
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=resources.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resources.js","sourceRoot":"","sources":["../../../src/domains/datastores/resources.ts"],"names":[],"mappings":"AAAA,mEAAmE;AAKnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,uFAAuF;AACvF,MAAM,UAAU,0BAA0B,CAAC,MAAiB,EAAE,MAAqB;IACjF,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE;QAC/B,IAAI,EAAE,mBAAmB;QACzB,KAAK,EAAE,mBAAmB;QAC1B,WAAW,EACT,6EAA6E;YAC7E,sCAAsC;QACxC,QAAQ,EAAE,mCAAmC;QAC7C,KAAK,EAAE,cAAc;KACtB,CAAC,CAAC;IACH,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import { type BackendTarget } from "../client.js";
|
|
3
|
-
/** Register every Datastore-domain tool; returns the registered tool names. */
|
|
4
|
-
export declare function registerDatastoreTools(server: McpServer, target: BackendTarget): string[];
|
|
5
|
-
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/domains/datastores/tools.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAIzE,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAMhE,+EAA+E;AAC/E,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,GAAG,MAAM,EAAE,CA0DzF"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// MCP tools for the Datastore *definition* domain — the structure surface
|
|
2
|
-
// (collections, fields, constraints, roles, grants). The record tools
|
|
3
|
-
// (records/tools.ts) operate on the living data inside these structures;
|
|
4
|
-
// before this domain existed, an assistant could insert records into a
|
|
5
|
-
// datastore it had no way to create.
|
|
6
|
-
import { z } from "zod";
|
|
7
|
-
import { DatastoreInputShape } from "../../gen/datastore.js";
|
|
8
|
-
import { resolveToken } from "../client.js";
|
|
9
|
-
import { textOrError } from "../toolresult.js";
|
|
10
|
-
import { applyDatastore } from "./apply.js";
|
|
11
|
-
import { deleteDatastore } from "./delete.js";
|
|
12
|
-
import { fetchDatastore } from "./fetch.js";
|
|
13
|
-
/** Register every Datastore-domain tool; returns the registered tool names. */
|
|
14
|
-
export function registerDatastoreTools(server, target) {
|
|
15
|
-
server.registerTool("get_datastore", {
|
|
16
|
-
description: "Get the full definition of a Stigmer datastore by its org and slug: collections, field " +
|
|
17
|
-
"declarations, constraints, roles, and grants. For the record-facing view of the same " +
|
|
18
|
-
"structure (allowed verbs, readable fields), use describe_datastore; for the data " +
|
|
19
|
-
"itself, use the record tools.",
|
|
20
|
-
inputSchema: {
|
|
21
|
-
org: z.string().describe("Organization slug that owns the datastore (e.g. stigmer)."),
|
|
22
|
-
slug: z
|
|
23
|
-
.string()
|
|
24
|
-
.describe("Datastore slug — the unique identifier within the org (e.g. clinic-bookings)."),
|
|
25
|
-
},
|
|
26
|
-
}, (args, extra) => textOrError(() => fetchDatastore(target.serverAddress, resolveToken(extra, target.apiKey), args.org, args.slug)));
|
|
27
|
-
server.registerTool("apply_datastore", {
|
|
28
|
-
description: "Create or update a Stigmer datastore definition (idempotent). The manifest is " +
|
|
29
|
-
"authoritative for structure only — schema changes sync on apply (the server enforces " +
|
|
30
|
-
"its additive-plus change rules), and records are never touched; use the record tools " +
|
|
31
|
-
"to manage data.",
|
|
32
|
-
inputSchema: DatastoreInputShape,
|
|
33
|
-
}, (args, extra) => textOrError(() => applyDatastore(target.serverAddress, resolveToken(extra, target.apiKey), args)));
|
|
34
|
-
server.registerTool("delete_datastore", {
|
|
35
|
-
description: "Delete a Stigmer datastore by its org and slug, destroying its collections and all " +
|
|
36
|
-
"records in them. This is irreversible. Returns the deleted datastore definition.",
|
|
37
|
-
inputSchema: {
|
|
38
|
-
org: z.string().describe("Organization slug that owns the datastore (e.g. stigmer)."),
|
|
39
|
-
slug: z
|
|
40
|
-
.string()
|
|
41
|
-
.describe("Datastore slug — the unique identifier within the org (e.g. clinic-bookings)."),
|
|
42
|
-
},
|
|
43
|
-
}, (args, extra) => textOrError(() => deleteDatastore(target.serverAddress, resolveToken(extra, target.apiKey), args.org, args.slug)));
|
|
44
|
-
return ["get_datastore", "apply_datastore", "delete_datastore"];
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=tools.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../src/domains/datastores/tools.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,sEAAsE;AACtE,yEAAyE;AACzE,uEAAuE;AACvE,qCAAqC;AAGrC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAsB,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAk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CAAC,QAAQ,CAAC,2DAA2D,CAAC;YACrF,IAAI,EAAE,CAAC;iBACJ,MAAM,EAAE;iBACR,QAAQ,CAAC,+EAA+E,CAAC;SAC7F;KACF,EACD,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CACd,WAAW,CAAC,GAAG,EAAE,CACf,eAAe,CAAC,MAAM,CAAC,aAAa,EAAE,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAC/F,CACJ,CAAC;IAEF,OAAO,CAAC,eAAe,EAAE,iBAAiB,EAAE,kBAAkB,CAAC,CAAC;AAClE,CAAC"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A filter condition as the model supplies it. `op` uses the natural
|
|
3
|
-
* spelling "in" (the proto enum's `is_in` exists only because `in` is
|
|
4
|
-
* reserved in Java/Python — a substrate detail the model never sees).
|
|
5
|
-
*/
|
|
6
|
-
export interface ConditionArg {
|
|
7
|
-
field: string;
|
|
8
|
-
op: string;
|
|
9
|
-
value?: string | number | boolean | null;
|
|
10
|
-
values?: (string | number | boolean)[];
|
|
11
|
-
}
|
|
12
|
-
export interface FindArgs {
|
|
13
|
-
datastore: string;
|
|
14
|
-
org?: string;
|
|
15
|
-
collection: string;
|
|
16
|
-
conditions?: ConditionArg[];
|
|
17
|
-
order_by?: {
|
|
18
|
-
field: string;
|
|
19
|
-
direction?: string;
|
|
20
|
-
};
|
|
21
|
-
limit?: number;
|
|
22
|
-
offset?: number;
|
|
23
|
-
}
|
|
24
|
-
export declare function findRecords(serverAddress: string, token: string, args: FindArgs): Promise<string>;
|
|
25
|
-
export declare function insertRecord(serverAddress: string, token: string, args: {
|
|
26
|
-
datastore: string;
|
|
27
|
-
org?: string;
|
|
28
|
-
collection: string;
|
|
29
|
-
record: Record<string, unknown>;
|
|
30
|
-
}): Promise<string>;
|
|
31
|
-
export declare function updateRecord(serverAddress: string, token: string, args: {
|
|
32
|
-
datastore: string;
|
|
33
|
-
org?: string;
|
|
34
|
-
collection: string;
|
|
35
|
-
id: string;
|
|
36
|
-
fields: Record<string, unknown>;
|
|
37
|
-
}): Promise<string>;
|
|
38
|
-
export declare function deleteRecord(serverAddress: string, token: string, args: {
|
|
39
|
-
datastore: string;
|
|
40
|
-
org?: string;
|
|
41
|
-
collection: string;
|
|
42
|
-
id: string;
|
|
43
|
-
}): Promise<string>;
|
|
44
|
-
export declare function describeDatastore(serverAddress: string, token: string, args: {
|
|
45
|
-
datastore: string;
|
|
46
|
-
org?: string;
|
|
47
|
-
}): Promise<string>;
|
|
48
|
-
//# sourceMappingURL=calls.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"calls.d.ts","sourceRoot":"","sources":["../../../src/domains/records/calls.ts"],"names":[],"mappings":"AAyCA;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;IACzC,MAAM,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC;CACxC;AAED,MAAM,WAAW,QAAQ;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,YAAY,EAAE,CAAC;IAC5B,QAAQ,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAgBD,wBAAsB,WAAW,CAC/B,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,QAAQ,GACb,OAAO,CAAC,MAAM,CAAC,CAajB;AAED,wBAAsB,YAAY,CAChC,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GAC7F,OAAO,CAAC,MAAM,CAAC,CAYjB;AAED,wBAAsB,YAAY,CAChC,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE;IACJ,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC,GACA,OAAO,CAAC,MAAM,CAAC,CAWjB;AAED,wBAAsB,YAAY,CAChC,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GACxE,OAAO,CAAC,MAAM,CAAC,CAUjB;AAED,wBAAsB,iBAAiB,CACrC,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GACxC,OAAO,CAAC,MAAM,CAAC,CAQjB"}
|
package/domains/records/calls.js
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
// Record-RPC invocations for the five record tools — 1:1 projections
|
|
2
|
-
// of DatastoreRecordQueryController / DatastoreRecordCommandController
|
|
3
|
-
// (DD-005: the tool layer adds no semantics; validation, grants,
|
|
4
|
-
// scopes, constraints, and messages all live in record-RPC domain
|
|
5
|
-
// logic on the control plane).
|
|
6
|
-
//
|
|
7
|
-
// One file for the five thin calls rather than the resource domains'
|
|
8
|
-
// file-per-verb split: resource verbs each carry orchestration
|
|
9
|
-
// (reference resolution, YAML parsing, two-step deletes); record calls
|
|
10
|
-
// are each "build request, call, marshal" and the shared argument
|
|
11
|
-
// mapping (filter/value building) is the only substance.
|
|
12
|
-
import { create, fromJson } from "@bufbuild/protobuf";
|
|
13
|
-
import { ValueSchema } from "@bufbuild/protobuf/wkt";
|
|
14
|
-
import { DatastoreRecordCommandController, } from "@stigmer/protos/ai/stigmer/agentic/datastore/v1/record_command_pb";
|
|
15
|
-
import { DatastoreRecordQueryController, } from "@stigmer/protos/ai/stigmer/agentic/datastore/v1/record_query_pb";
|
|
16
|
-
import { DatastoreDescriptionSchema, DeleteRecordRequestSchema, DescribeDatastoreRequestSchema, FindRecordsRequestSchema, InsertRecordRequestSchema, RecordConditionOp, RecordConditionSchema, RecordEnvelopeSchema, RecordFilterSchema, RecordListSchema, RecordOrderBySchema, RecordSortDirection, UpdateRecordRequestSchema, } from "@stigmer/protos/ai/stigmer/agentic/datastore/v1/record_io_pb";
|
|
17
|
-
import { withClient } from "../client.js";
|
|
18
|
-
import { toProtoJson } from "../marshal.js";
|
|
19
|
-
/** Model-facing operator spelling → proto enum. */
|
|
20
|
-
const CONDITION_OPS = {
|
|
21
|
-
eq: RecordConditionOp.eq,
|
|
22
|
-
neq: RecordConditionOp.neq,
|
|
23
|
-
gt: RecordConditionOp.gt,
|
|
24
|
-
gte: RecordConditionOp.gte,
|
|
25
|
-
lt: RecordConditionOp.lt,
|
|
26
|
-
lte: RecordConditionOp.lte,
|
|
27
|
-
in: RecordConditionOp.is_in,
|
|
28
|
-
not_in: RecordConditionOp.not_in,
|
|
29
|
-
is_null: RecordConditionOp.is_null,
|
|
30
|
-
not_null: RecordConditionOp.not_null,
|
|
31
|
-
};
|
|
32
|
-
export async function findRecords(serverAddress, token, args) {
|
|
33
|
-
const request = create(FindRecordsRequestSchema, {
|
|
34
|
-
datastore: args.datastore,
|
|
35
|
-
org: args.org ?? "",
|
|
36
|
-
collection: args.collection,
|
|
37
|
-
filter: buildFilter(args.conditions),
|
|
38
|
-
orderBy: buildOrderBy(args.order_by),
|
|
39
|
-
limit: args.limit ?? 0,
|
|
40
|
-
offset: args.offset ?? 0,
|
|
41
|
-
});
|
|
42
|
-
return withClient(DatastoreRecordQueryController, serverAddress, token, async (client, opts) => toProtoJson(RecordListSchema, await client.findRecords(request, opts)));
|
|
43
|
-
}
|
|
44
|
-
export async function insertRecord(serverAddress, token, args) {
|
|
45
|
-
const request = create(InsertRecordRequestSchema, {
|
|
46
|
-
datastore: args.datastore,
|
|
47
|
-
org: args.org ?? "",
|
|
48
|
-
collection: args.collection,
|
|
49
|
-
// google.protobuf.Struct fields are plain JSON objects in
|
|
50
|
-
// protobuf-es v2 — no conversion.
|
|
51
|
-
record: args.record,
|
|
52
|
-
});
|
|
53
|
-
return withClient(DatastoreRecordCommandController, serverAddress, token, async (client, opts) => toProtoJson(RecordEnvelopeSchema, await client.insertRecord(request, opts)));
|
|
54
|
-
}
|
|
55
|
-
export async function updateRecord(serverAddress, token, args) {
|
|
56
|
-
const request = create(UpdateRecordRequestSchema, {
|
|
57
|
-
datastore: args.datastore,
|
|
58
|
-
org: args.org ?? "",
|
|
59
|
-
collection: args.collection,
|
|
60
|
-
id: args.id,
|
|
61
|
-
fields: args.fields,
|
|
62
|
-
});
|
|
63
|
-
return withClient(DatastoreRecordCommandController, serverAddress, token, async (client, opts) => toProtoJson(RecordEnvelopeSchema, await client.updateRecord(request, opts)));
|
|
64
|
-
}
|
|
65
|
-
export async function deleteRecord(serverAddress, token, args) {
|
|
66
|
-
const request = create(DeleteRecordRequestSchema, {
|
|
67
|
-
datastore: args.datastore,
|
|
68
|
-
org: args.org ?? "",
|
|
69
|
-
collection: args.collection,
|
|
70
|
-
id: args.id,
|
|
71
|
-
});
|
|
72
|
-
return withClient(DatastoreRecordCommandController, serverAddress, token, async (client, opts) => toProtoJson(RecordEnvelopeSchema, await client.deleteRecord(request, opts)));
|
|
73
|
-
}
|
|
74
|
-
export async function describeDatastore(serverAddress, token, args) {
|
|
75
|
-
const request = create(DescribeDatastoreRequestSchema, {
|
|
76
|
-
datastore: args.datastore,
|
|
77
|
-
org: args.org ?? "",
|
|
78
|
-
});
|
|
79
|
-
return withClient(DatastoreRecordQueryController, serverAddress, token, async (client, opts) => toProtoJson(DatastoreDescriptionSchema, await client.describeDatastore(request, opts)));
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Build the typed AND-only filter (DD-005 SD-2). An unknown operator is
|
|
83
|
-
* left unspecified for the server to reject with its own domain
|
|
84
|
-
* message — the bridge never fabricates validation of its own.
|
|
85
|
-
*/
|
|
86
|
-
function buildFilter(conditions) {
|
|
87
|
-
if (conditions === undefined || conditions.length === 0) {
|
|
88
|
-
return undefined;
|
|
89
|
-
}
|
|
90
|
-
return create(RecordFilterSchema, {
|
|
91
|
-
conditions: conditions.map(buildCondition),
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
function buildCondition(arg) {
|
|
95
|
-
return create(RecordConditionSchema, {
|
|
96
|
-
field: arg.field,
|
|
97
|
-
op: CONDITION_OPS[arg.op] ?? RecordConditionOp.record_condition_op_unspecified,
|
|
98
|
-
value: arg.value !== undefined ? scalarValue(arg.value) : undefined,
|
|
99
|
-
values: (arg.values ?? []).map(scalarValue),
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
function buildOrderBy(orderBy) {
|
|
103
|
-
if (orderBy === undefined) {
|
|
104
|
-
return undefined;
|
|
105
|
-
}
|
|
106
|
-
return create(RecordOrderBySchema, {
|
|
107
|
-
field: orderBy.field,
|
|
108
|
-
direction: orderBy.direction === "desc"
|
|
109
|
-
? RecordSortDirection.desc
|
|
110
|
-
: orderBy.direction === "asc"
|
|
111
|
-
? RecordSortDirection.asc
|
|
112
|
-
: RecordSortDirection.record_sort_direction_unspecified,
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
function scalarValue(v) {
|
|
116
|
-
return fromJson(ValueSchema, v);
|
|
117
|
-
}
|
|
118
|
-
//# sourceMappingURL=calls.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"calls.js","sourceRoot":"","sources":["../../../src/domains/records/calls.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,uEAAuE;AACvE,iEAAiE;AACjE,kEAAkE;AAClE,+BAA+B;AAC/B,EAAE;AACF,qEAAqE;AACrE,+DAA+D;AAC/D,uEAAuE;AACvE,kEAAkE;AAClE,yDAAyD;AAEzD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAmB,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAE,WAAW,EAAc,MAAM,wBAAwB,CAAC;AACjE,OAAO,EACL,gCAAgC,GACjC,MAAM,mEAAmE,CAAC;AAC3E,OAAO,EACL,8BAA8B,GAC/B,MAAM,iEAAiE,CAAC;AACzE,OAAO,EACL,0BAA0B,EAC1B,yBAAyB,EACzB,8BAA8B,EAC9B,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,yBAAyB,GAI1B,MAAM,8DAA8D,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAwB5C,mDAAmD;AACnD,MAAM,aAAa,GAAgD;IACjE,EAAE,EAAE,iBAAiB,CAAC,EAAE;IACxB,GAAG,EAAE,iBAAiB,CAAC,GAAG;IAC1B,EAAE,EAAE,iBAAiB,CAAC,EAAE;IACxB,GAAG,EAAE,iBAAiB,CAAC,GAAG;IAC1B,EAAE,EAAE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C,CAAC,CAAC;AACL,CAAC;AAED,SAAS,YAAY,CACnB,OAA0D;IAE1D,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,MAAM,CAAC,mBAAmB,EAAE;QACjC,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,SAAS,EAAE,OAAO,CAAC,SAAS,KAAK,MAAM;YACrC,CAAC,CAAC,mBAAmB,CAAC,IAAI;YAC1B,CAAC,CAAC,OAAO,CAAC,SAAS,KAAK,KAAK;gBAC3B,CAAC,CAAC,mBAAmB,CAAC,GAAG;gBACzB,CAAC,CAAC,mBAAmB,CAAC,iCAAiC;KAC5D,CAAC,CAAC;AACL,CAAC;AAED,SAAS,WAAW,CAAC,CAAmC;IACtD,OAAO,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { ConnectError } from "@connectrpc/connect";
|
|
2
|
-
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
-
/** The structured error payload record tools return for domain errors. */
|
|
4
|
-
export interface RecordToolError {
|
|
5
|
-
/** The server's relayable message, byte-for-byte. */
|
|
6
|
-
error: string;
|
|
7
|
-
/** gRPC status name in SCREAMING_SNAKE (e.g. ALREADY_EXISTS). */
|
|
8
|
-
code: string;
|
|
9
|
-
/** ErrorInfo reason (e.g. CONSTRAINT_VIOLATION), when present. */
|
|
10
|
-
reason?: string;
|
|
11
|
-
/** Violated constraint name from ErrorInfo metadata, when present. */
|
|
12
|
-
constraint?: string;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Run a record-tool body: a string payload becomes a text result; a
|
|
16
|
-
* domain error becomes an isError JSON result carrying the verbatim
|
|
17
|
-
* message + ErrorInfo companions; a transport error delegates to the
|
|
18
|
-
* shared classifier. The records analog of ../toolresult.ts
|
|
19
|
-
* textOrError, and the only try/catch in this domain.
|
|
20
|
-
*/
|
|
21
|
-
export declare function recordResult(toolContext: string, produce: () => Promise<string>): Promise<CallToolResult>;
|
|
22
|
-
/** Project a domain ConnectError into the structured tool payload. */
|
|
23
|
-
export declare function domainError(ce: ConnectError): RecordToolError;
|
|
24
|
-
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/domains/records/errors.ts"],"names":[],"mappings":"AAeA,OAAO,EAAQ,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAkBzE,0EAA0E;AAC1E,MAAM,WAAW,eAAe;IAC9B,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,IAAI,EAAE,MAAM,CAAC;IACb,kEAAkE;IAClE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sEAAsE;IACtE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAChC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,GAC7B,OAAO,CAAC,cAAc,CAAC,CAazB;AAED,sEAAsE;AACtE,wBAAgB,WAAW,CAAC,EAAE,EAAE,YAAY,GAAG,eAAe,CAoB7D"}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
// The records-domain error mapper (DD-005 SD-6) — a deliberate,
|
|
2
|
-
// documented divergence from the shared ../rpcerr.ts.
|
|
3
|
-
//
|
|
4
|
-
// Record-RPC domain errors carry agent-relayable messages that are
|
|
5
|
-
// cross-edition contract bytes (DD-002 SD-5): "that slot is already
|
|
6
|
-
// booked", "you are not allowed to insert records in bookings". The
|
|
7
|
-
// shared helper would rewrite them ("Check your API key permissions")
|
|
8
|
-
// and discards google.rpc.ErrorInfo. Here the domain codes pass the
|
|
9
|
-
// server's message through VERBATIM as isError JSON text
|
|
10
|
-
// `{error, code, reason, constraint}` — reason/constraint extracted
|
|
11
|
-
// from ErrorInfo — so the model can self-correct (retry another slot
|
|
12
|
-
// on CONSTRAINT_VIOLATION; stop and relay on PERMISSION_DENIED).
|
|
13
|
-
// Transport codes still delegate to the shared helper, whose advice is
|
|
14
|
-
// right for them.
|
|
15
|
-
import { Code, ConnectError } from "@connectrpc/connect";
|
|
16
|
-
import { ErrorInfoSchema } from "@stigmer/protos/google/rpc/error_details_pb";
|
|
17
|
-
import { rpcError } from "../rpcerr.js";
|
|
18
|
-
import { errorResult, textResult } from "../toolresult.js";
|
|
19
|
-
/**
|
|
20
|
-
* The gRPC codes whose messages are the record-RPC domain contract
|
|
21
|
-
* (DD-005 SD-6): declared constraint messages, fixed denial texts, and
|
|
22
|
-
* domain validation — all written to be relayed to end users verbatim.
|
|
23
|
-
*/
|
|
24
|
-
const DOMAIN_CODES = new Set([
|
|
25
|
-
Code.PermissionDenied,
|
|
26
|
-
Code.AlreadyExists,
|
|
27
|
-
Code.FailedPrecondition,
|
|
28
|
-
Code.InvalidArgument,
|
|
29
|
-
Code.NotFound,
|
|
30
|
-
]);
|
|
31
|
-
/**
|
|
32
|
-
* Run a record-tool body: a string payload becomes a text result; a
|
|
33
|
-
* domain error becomes an isError JSON result carrying the verbatim
|
|
34
|
-
* message + ErrorInfo companions; a transport error delegates to the
|
|
35
|
-
* shared classifier. The records analog of ../toolresult.ts
|
|
36
|
-
* textOrError, and the only try/catch in this domain.
|
|
37
|
-
*/
|
|
38
|
-
export async function recordResult(toolContext, produce) {
|
|
39
|
-
try {
|
|
40
|
-
return textResult(await produce());
|
|
41
|
-
}
|
|
42
|
-
catch (err) {
|
|
43
|
-
const ce = ConnectError.from(err);
|
|
44
|
-
if (DOMAIN_CODES.has(ce.code)) {
|
|
45
|
-
return {
|
|
46
|
-
content: [{ type: "text", text: JSON.stringify(domainError(ce)) }],
|
|
47
|
-
isError: true,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
return errorResult(rpcError(ce, toolContext));
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
/** Project a domain ConnectError into the structured tool payload. */
|
|
54
|
-
export function domainError(ce) {
|
|
55
|
-
const payload = {
|
|
56
|
-
error: ce.rawMessage,
|
|
57
|
-
code: grpcStatusName(ce.code),
|
|
58
|
-
};
|
|
59
|
-
// The record RPCs attach one google.rpc.ErrorInfo per domain error
|
|
60
|
-
// (domain datastore.stigmer.ai); absence means an older server — the
|
|
61
|
-
// message alone still carries the contract.
|
|
62
|
-
const details = ce.findDetails(ErrorInfoSchema);
|
|
63
|
-
if (details.length > 0) {
|
|
64
|
-
const info = details[0];
|
|
65
|
-
if (info.reason !== "") {
|
|
66
|
-
payload.reason = info.reason;
|
|
67
|
-
}
|
|
68
|
-
const constraint = info.metadata["constraint"];
|
|
69
|
-
if (constraint !== undefined && constraint !== "") {
|
|
70
|
-
payload.constraint = constraint;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return payload;
|
|
74
|
-
}
|
|
75
|
-
/** Connect's PascalCase code name → the gRPC SCREAMING_SNAKE status name. */
|
|
76
|
-
function grpcStatusName(code) {
|
|
77
|
-
return Code[code].replace(/([a-z0-9])([A-Z])/g, "$1_$2").toUpperCase();
|
|
78
|
-
}
|
|
79
|
-
//# sourceMappingURL=errors.js.map
|