@x12i/memorix-scoper 1.1.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 +29 -0
- package/dist/coordinator.d.ts +12 -0
- package/dist/coordinator.d.ts.map +1 -0
- package/dist/coordinator.js +351 -0
- package/dist/coordinator.js.map +1 -0
- package/dist/create-scoper.d.ts +77 -0
- package/dist/create-scoper.d.ts.map +1 -0
- package/dist/create-scoper.js +58 -0
- package/dist/create-scoper.js.map +1 -0
- package/dist/epistemic.d.ts +4 -0
- package/dist/epistemic.d.ts.map +1 -0
- package/dist/epistemic.js +34 -0
- package/dist/epistemic.js.map +1 -0
- package/dist/guard.d.ts +3 -0
- package/dist/guard.d.ts.map +1 -0
- package/dist/guard.js +15 -0
- package/dist/guard.js.map +1 -0
- package/dist/guard.test.d.ts +2 -0
- package/dist/guard.test.d.ts.map +1 -0
- package/dist/guard.test.js +13 -0
- package/dist/guard.test.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-server.d.ts +58 -0
- package/dist/mcp-server.d.ts.map +1 -0
- package/dist/mcp-server.js +166 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/profiles.d.ts +2 -0
- package/dist/profiles.d.ts.map +1 -0
- package/dist/profiles.js +2 -0
- package/dist/profiles.js.map +1 -0
- package/dist/reasoner/ai-dispatcher.d.ts +24 -0
- package/dist/reasoner/ai-dispatcher.d.ts.map +1 -0
- package/dist/reasoner/ai-dispatcher.js +106 -0
- package/dist/reasoner/ai-dispatcher.js.map +1 -0
- package/dist/reasoner/ai-dispatcher.test.d.ts +2 -0
- package/dist/reasoner/ai-dispatcher.test.d.ts.map +1 -0
- package/dist/reasoner/ai-dispatcher.test.js +70 -0
- package/dist/reasoner/ai-dispatcher.test.js.map +1 -0
- package/dist/reasoner/index.d.ts +4 -0
- package/dist/reasoner/index.d.ts.map +1 -0
- package/dist/reasoner/index.js +3 -0
- package/dist/reasoner/index.js.map +1 -0
- package/dist/reasoner/scripted.d.ts +14 -0
- package/dist/reasoner/scripted.d.ts.map +1 -0
- package/dist/reasoner/scripted.js +22 -0
- package/dist/reasoner/scripted.js.map +1 -0
- package/dist/reasoner/types.d.ts +17 -0
- package/dist/reasoner/types.d.ts.map +1 -0
- package/dist/reasoner/types.js +2 -0
- package/dist/reasoner/types.js.map +1 -0
- package/dist/recursion.d.ts +4 -0
- package/dist/recursion.d.ts.map +1 -0
- package/dist/recursion.js +17 -0
- package/dist/recursion.js.map +1 -0
- package/dist/validation.d.ts +11 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +64 -0
- package/dist/validation.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { describe, expect, it, beforeEach } from "vitest";
|
|
2
|
+
import { enterScopeTrace, __resetScopeTracesForTests } from "./guard.js";
|
|
3
|
+
import { ScoperError } from "@x12i/memorix-scoper-contracts";
|
|
4
|
+
describe("invocation guard", () => {
|
|
5
|
+
beforeEach(() => __resetScopeTracesForTests());
|
|
6
|
+
it("rejects recursive scope entry", () => {
|
|
7
|
+
const exit = enterScopeTrace("t1");
|
|
8
|
+
expect(() => enterScopeTrace("t1")).toThrow(ScoperError);
|
|
9
|
+
exit();
|
|
10
|
+
expect(() => enterScopeTrace("t1")).not.toThrow();
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=guard.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guard.test.js","sourceRoot":"","sources":["../src/guard.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE7D,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,UAAU,CAAC,GAAG,EAAE,CAAC,0BAA0B,EAAE,CAAC,CAAC;IAC/C,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;QACvC,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;QACnC,MAAM,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QACzD,IAAI,EAAE,CAAC;QACP,MAAM,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IACpD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { scope, type ScoperDependencies } from "./coordinator.js";
|
|
2
|
+
export { createScoper, type CreateScoperOptions, type Scoper } from "./create-scoper.js";
|
|
3
|
+
export { createScoperMcpServer, type CreateScoperMcpServerDeps, type ScoperMcpServer, type ScoperMcpTool, } from "./mcp-server.js";
|
|
4
|
+
export type { ScoperReasoner, ReasonerInput } from "./reasoner/types.js";
|
|
5
|
+
export { ScriptedReasoner, type ScriptedReasonerOptions } from "./reasoner/scripted.js";
|
|
6
|
+
export { AiDispatcherReasoner, dispatcherOptionsFromEnv, type AiDispatcherReasonerOptions, } from "./reasoner/ai-dispatcher.js";
|
|
7
|
+
export { enterScopeTrace, resetScopeTraces } from "./recursion.js";
|
|
8
|
+
export { validatePlanAgainstCatalog, validateEpistemicConsistency, assertNotPromotingPolicyToReachable, } from "./validation.js";
|
|
9
|
+
export * from "./profiles.js";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACzF,OAAO,EACL,qBAAqB,EACrB,KAAK,yBAAyB,EAC9B,KAAK,eAAe,EACpB,KAAK,aAAa,GACnB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,KAAK,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACxF,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,KAAK,2BAA2B,GACjC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,EAC5B,mCAAmC,GACpC,MAAM,iBAAiB,CAAC;AACzB,cAAc,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { scope } from "./coordinator.js";
|
|
2
|
+
export { createScoper } from "./create-scoper.js";
|
|
3
|
+
export { createScoperMcpServer, } from "./mcp-server.js";
|
|
4
|
+
export { ScriptedReasoner } from "./reasoner/scripted.js";
|
|
5
|
+
export { AiDispatcherReasoner, dispatcherOptionsFromEnv, } from "./reasoner/ai-dispatcher.js";
|
|
6
|
+
export { enterScopeTrace, resetScopeTraces } from "./recursion.js";
|
|
7
|
+
export { validatePlanAgainstCatalog, validateEpistemicConsistency, assertNotPromotingPolicyToReachable, } from "./validation.js";
|
|
8
|
+
export * from "./profiles.js";
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAA2B,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAyC,MAAM,oBAAoB,CAAC;AACzF,OAAO,EACL,qBAAqB,GAItB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,gBAAgB,EAAgC,MAAM,wBAAwB,CAAC;AACxF,OAAO,EACL,oBAAoB,EACpB,wBAAwB,GAEzB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,EAC5B,mCAAmC,GACpC,MAAM,iBAAiB,CAAC;AACzB,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FR-SC — Scoper as an ai-dispatcher MCP server.
|
|
3
|
+
*
|
|
4
|
+
* Hosts bind TrustedExecutionContext + SDK at create time. Tool args never
|
|
5
|
+
* carry org/credentials (same model as scoper-service HTTP).
|
|
6
|
+
*
|
|
7
|
+
* Attach:
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { createAiDispatcher } from "@x12i/ai-dispatcher";
|
|
10
|
+
* import { createScoper, createScoperMcpServer } from "@x12i/memorix-scoper";
|
|
11
|
+
*
|
|
12
|
+
* const scoper = createScoper({ sdkConfig: { memorixBaseUrls: [...] } });
|
|
13
|
+
* const dispatcher = createAiDispatcher({
|
|
14
|
+
* // providers…
|
|
15
|
+
* mcp: {
|
|
16
|
+
* servers: [
|
|
17
|
+
* createScoperMcpServer({
|
|
18
|
+
* scoper,
|
|
19
|
+
* context: { orgId, agentIds, caller, traceId },
|
|
20
|
+
* }),
|
|
21
|
+
* ],
|
|
22
|
+
* },
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* Exposed tools: `scoper__scope`, `scoper__subject_data`.
|
|
27
|
+
*/
|
|
28
|
+
import { type TrustedExecutionContext } from "@x12i/memorix-scoper-contracts";
|
|
29
|
+
import type { Scoper } from "./create-scoper.js";
|
|
30
|
+
import { type CreateScoperOptions } from "./create-scoper.js";
|
|
31
|
+
/** Shape compatible with `@x12i/ai-dispatcher` DispatcherMcpServer (1.4+). */
|
|
32
|
+
export type ScoperMcpTool = {
|
|
33
|
+
name: string;
|
|
34
|
+
description?: string;
|
|
35
|
+
inputSchema?: Record<string, unknown>;
|
|
36
|
+
};
|
|
37
|
+
export type ScoperMcpServer = {
|
|
38
|
+
id: string;
|
|
39
|
+
tools: ScoperMcpTool[];
|
|
40
|
+
callTool: (name: string, args: Record<string, unknown>, context?: unknown) => Promise<unknown> | unknown;
|
|
41
|
+
listTools?: () => Promise<ScoperMcpTool[]>;
|
|
42
|
+
};
|
|
43
|
+
export type CreateScoperMcpServerDeps = {
|
|
44
|
+
/** Pre-built scoper (preferred when sharing with HTTP host). */
|
|
45
|
+
scoper?: Scoper;
|
|
46
|
+
/** Used when `scoper` is omitted. */
|
|
47
|
+
createOptions?: CreateScoperOptions;
|
|
48
|
+
/** Trusted host context — never taken from tool args. */
|
|
49
|
+
context: TrustedExecutionContext;
|
|
50
|
+
/** MCP server id (default `scoper`). Must match `^[A-Za-z0-9_-]+$`. */
|
|
51
|
+
id?: string;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Build an ai-dispatcher MCP server for Scoper tools.
|
|
55
|
+
* Tool set is static — `listTools` returns the same schemas; `refreshMcp` is a no-op refresh.
|
|
56
|
+
*/
|
|
57
|
+
export declare function createScoperMcpServer(deps: CreateScoperMcpServerDeps): ScoperMcpServer;
|
|
58
|
+
//# sourceMappingURL=mcp-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAKL,KAAK,uBAAuB,EAC7B,MAAM,gCAAgC,CAAC;AAExC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAgB,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAI5E,8EAA8E;AAC9E,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,QAAQ,EAAE,CACR,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,CAAC,EAAE,OAAO,KACd,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,gEAAgE;IAChE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qCAAqC;IACrC,aAAa,CAAC,EAAE,mBAAmB,CAAC;IACpC,yDAAyD;IACzD,OAAO,EAAE,uBAAuB,CAAC;IACjC,uEAAuE;IACvE,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AA8GF;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,yBAAyB,GAAG,eAAe,CAkCtF"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FR-SC — Scoper as an ai-dispatcher MCP server.
|
|
3
|
+
*
|
|
4
|
+
* Hosts bind TrustedExecutionContext + SDK at create time. Tool args never
|
|
5
|
+
* carry org/credentials (same model as scoper-service HTTP).
|
|
6
|
+
*
|
|
7
|
+
* Attach:
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { createAiDispatcher } from "@x12i/ai-dispatcher";
|
|
10
|
+
* import { createScoper, createScoperMcpServer } from "@x12i/memorix-scoper";
|
|
11
|
+
*
|
|
12
|
+
* const scoper = createScoper({ sdkConfig: { memorixBaseUrls: [...] } });
|
|
13
|
+
* const dispatcher = createAiDispatcher({
|
|
14
|
+
* // providers…
|
|
15
|
+
* mcp: {
|
|
16
|
+
* servers: [
|
|
17
|
+
* createScoperMcpServer({
|
|
18
|
+
* scoper,
|
|
19
|
+
* context: { orgId, agentIds, caller, traceId },
|
|
20
|
+
* }),
|
|
21
|
+
* ],
|
|
22
|
+
* },
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* Exposed tools: `scoper__scope`, `scoper__subject_data`.
|
|
27
|
+
*/
|
|
28
|
+
import { ScopeRequestSchema, SubjectDataRequestSchema, isScoperError, ScoperError, } from "@x12i/memorix-scoper-contracts";
|
|
29
|
+
import { readSubjectData } from "@x12i/memorix-scoper-sdk";
|
|
30
|
+
import { createScoper } from "./create-scoper.js";
|
|
31
|
+
const UNTRUSTED_KEYS = ["orgId", "credentials", "token", "memorixBaseUrl", "agentIds", "caller"];
|
|
32
|
+
const SCOPE_INPUT_SCHEMA = {
|
|
33
|
+
type: "object",
|
|
34
|
+
required: ["profileId", "question"],
|
|
35
|
+
additionalProperties: false,
|
|
36
|
+
properties: {
|
|
37
|
+
profileId: { type: "string", minLength: 1 },
|
|
38
|
+
question: { type: "string", minLength: 1, maxLength: 16000 },
|
|
39
|
+
focus: {
|
|
40
|
+
type: "object",
|
|
41
|
+
additionalProperties: false,
|
|
42
|
+
properties: {
|
|
43
|
+
subjectIds: { type: "array", items: { type: "string" } },
|
|
44
|
+
objectTypes: { type: "array", items: { type: "string" } },
|
|
45
|
+
contentTypes: { type: "array", items: { type: "string" } },
|
|
46
|
+
tags: { type: "array", items: { type: "string" } },
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
budgets: { type: "object", additionalProperties: true },
|
|
50
|
+
options: {
|
|
51
|
+
type: "object",
|
|
52
|
+
additionalProperties: false,
|
|
53
|
+
properties: {
|
|
54
|
+
allowExplore: { type: "boolean" },
|
|
55
|
+
dryRun: { type: "boolean" },
|
|
56
|
+
includeUnknowns: { type: "boolean" },
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
hints: { type: "object", additionalProperties: true },
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
const SUBJECT_DATA_INPUT_SCHEMA = {
|
|
63
|
+
type: "object",
|
|
64
|
+
required: ["recordId", "objectType", "contentType"],
|
|
65
|
+
additionalProperties: false,
|
|
66
|
+
properties: {
|
|
67
|
+
recordId: { type: "string", minLength: 1 },
|
|
68
|
+
objectType: { type: "string", minLength: 1 },
|
|
69
|
+
contentType: { type: "string", minLength: 1 },
|
|
70
|
+
alsoContentTypes: {
|
|
71
|
+
type: "array",
|
|
72
|
+
maxItems: 16,
|
|
73
|
+
items: { type: "string", minLength: 1 },
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
const TOOLS = [
|
|
78
|
+
{
|
|
79
|
+
name: "scope",
|
|
80
|
+
description: "Run Scoper against Memorix with a ScopeRequest body. Trusted org/agent/caller come from the host — do not pass credentials.",
|
|
81
|
+
inputSchema: SCOPE_INPUT_SCHEMA,
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: "subject_data",
|
|
85
|
+
description: "Read stored Memorix subject pieces for one recordId + objectType + contentType (optional alsoContentTypes).",
|
|
86
|
+
inputSchema: SUBJECT_DATA_INPUT_SCHEMA,
|
|
87
|
+
},
|
|
88
|
+
];
|
|
89
|
+
function stripUntrusted(args) {
|
|
90
|
+
const out = { ...args };
|
|
91
|
+
for (const key of UNTRUSTED_KEYS) {
|
|
92
|
+
delete out[key];
|
|
93
|
+
}
|
|
94
|
+
return out;
|
|
95
|
+
}
|
|
96
|
+
function mcpOk(payload) {
|
|
97
|
+
return {
|
|
98
|
+
content: [{ type: "text", text: JSON.stringify(payload) }],
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function mcpErr(err) {
|
|
102
|
+
if (isScoperError(err) || err instanceof ScoperError) {
|
|
103
|
+
return {
|
|
104
|
+
isError: true,
|
|
105
|
+
content: [{ type: "text", text: JSON.stringify(err.toJSON()) }],
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
if (err && typeof err === "object" && "issues" in err) {
|
|
109
|
+
return {
|
|
110
|
+
isError: true,
|
|
111
|
+
content: [
|
|
112
|
+
{
|
|
113
|
+
type: "text",
|
|
114
|
+
text: JSON.stringify({
|
|
115
|
+
code: "INVALID_REQUEST",
|
|
116
|
+
message: "tool args failed schema validation",
|
|
117
|
+
details: err,
|
|
118
|
+
}),
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
124
|
+
return {
|
|
125
|
+
isError: true,
|
|
126
|
+
content: [{ type: "text", text: JSON.stringify({ code: "INTERNAL", message }) }],
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Build an ai-dispatcher MCP server for Scoper tools.
|
|
131
|
+
* Tool set is static — `listTools` returns the same schemas; `refreshMcp` is a no-op refresh.
|
|
132
|
+
*/
|
|
133
|
+
export function createScoperMcpServer(deps) {
|
|
134
|
+
const id = deps.id ?? "scoper";
|
|
135
|
+
if (!/^[A-Za-z0-9_-]+$/.test(id)) {
|
|
136
|
+
throw new Error(`createScoperMcpServer: id "${id}" must match ^[A-Za-z0-9_-]+$`);
|
|
137
|
+
}
|
|
138
|
+
const scoper = deps.scoper ?? createScoper(deps.createOptions ?? {});
|
|
139
|
+
const context = deps.context;
|
|
140
|
+
async function callTool(name, args) {
|
|
141
|
+
try {
|
|
142
|
+
const body = stripUntrusted(args ?? {});
|
|
143
|
+
if (name === "scope") {
|
|
144
|
+
const request = ScopeRequestSchema.parse(body);
|
|
145
|
+
const bundle = await scoper.scope(request, context);
|
|
146
|
+
return mcpOk(bundle);
|
|
147
|
+
}
|
|
148
|
+
if (name === "subject_data") {
|
|
149
|
+
const request = SubjectDataRequestSchema.parse(body);
|
|
150
|
+
const data = await readSubjectData(scoper.deps.sdk.forContext(context), request);
|
|
151
|
+
return mcpOk(data);
|
|
152
|
+
}
|
|
153
|
+
return mcpErr(new ScoperError("INVALID_REQUEST", `Unknown Scoper MCP tool: ${name}`));
|
|
154
|
+
}
|
|
155
|
+
catch (err) {
|
|
156
|
+
return mcpErr(err);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
id,
|
|
161
|
+
tools: TOOLS,
|
|
162
|
+
callTool,
|
|
163
|
+
listTools: async () => TOOLS,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=mcp-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-server.js","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,aAAa,EACb,WAAW,GAEZ,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,EAAE,YAAY,EAA4B,MAAM,oBAAoB,CAAC;AAE5E,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,QAAQ,CAAU,CAAC;AA+B1G,MAAM,kBAAkB,GAA4B;IAClD,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC;IACnC,oBAAoB,EAAE,KAAK;IAC3B,UAAU,EAAE;QACV,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE;QAC3C,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AAE,CAAC;gBACrB,MAAM,OAAO,GAAG,kBAAkB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAC/C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;gBACpD,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC;YACvB,CAAC;YACD,IAAI,IAAI,KAAK,cAAc,EAAE,CAAC;gBAC5B,MAAM,OAAO,GAAG,wBAAwB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBACrD,MAAM,IAAI,GAAG,MAAM,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;gBACjF,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC;YACrB,CAAC;YACD,OAAO,MAAM,CAAC,IAAI,WAAW,CAAC,iBAAiB,EAAE,4BAA4B,IAAI,EAAE,CAAC,CAAC,CAAC;QACxF,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;QACrB,CAAC;IACH,CAAC;IAED,OAAO;QACL,EAAE;QACF,KAAK,EAAE,KAAK;QACZ,QAAQ;QACR,SAAS,EAAE,KAAK,IAAI,EAAE,CAAC,KAAK;KAC7B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { PROFILES, getProfile, listProfiles, generalProfile, entityInventoryProfile, vulnerabilityProfile, alertLiveProfile, exposureReachabilityProfile, investigationProfile, knowledgeSnapshotProfile, } from "@x12i/memorix-scoper-profiles";
|
|
2
|
+
//# sourceMappingURL=profiles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiles.d.ts","sourceRoot":"","sources":["../src/profiles.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,cAAc,EACd,sBAAsB,EACtB,oBAAoB,EACpB,gBAAgB,EAChB,2BAA2B,EAC3B,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,+BAA+B,CAAC"}
|
package/dist/profiles.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { PROFILES, getProfile, listProfiles, generalProfile, entityInventoryProfile, vulnerabilityProfile, alertLiveProfile, exposureReachabilityProfile, investigationProfile, knowledgeSnapshotProfile, } from "@x12i/memorix-scoper-profiles";
|
|
2
|
+
//# sourceMappingURL=profiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiles.js","sourceRoot":"","sources":["../src/profiles.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,cAAc,EACd,sBAAsB,EACtB,oBAAoB,EACpB,gBAAgB,EAChB,2BAA2B,EAC3B,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type AiDispatcher, type AiDispatcherOptions, type AiProviderId } from "@x12i/ai-dispatcher";
|
|
2
|
+
import { type RetrievalPlan } from "@x12i/memorix-scoper-contracts";
|
|
3
|
+
import type { ReasonerInput, ScoperReasoner } from "./types.js";
|
|
4
|
+
export interface AiDispatcherReasonerOptions {
|
|
5
|
+
dispatcher?: AiDispatcher;
|
|
6
|
+
dispatcherOptions?: AiDispatcherOptions;
|
|
7
|
+
/** Default provider for run(); omit to use dispatcher default (openrouter). */
|
|
8
|
+
provider?: AiProviderId;
|
|
9
|
+
model?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* AI reasoner via @x12i/ai-dispatcher (gateway only — OpenRouter / Bedrock / OpenAI).
|
|
13
|
+
* Uses run() only — no tools. One repair attempt is owned by the coordinator.
|
|
14
|
+
*/
|
|
15
|
+
export declare class AiDispatcherReasoner implements ScoperReasoner {
|
|
16
|
+
private readonly dispatcher;
|
|
17
|
+
private readonly model;
|
|
18
|
+
private readonly provider;
|
|
19
|
+
constructor(options?: AiDispatcherReasonerOptions);
|
|
20
|
+
proposePlan(input: ReasonerInput): Promise<RetrievalPlan>;
|
|
21
|
+
}
|
|
22
|
+
/** Build dispatcher options from common host env vars (no secrets in request body). */
|
|
23
|
+
export declare function dispatcherOptionsFromEnv(env?: NodeJS.ProcessEnv): AiDispatcherOptions;
|
|
24
|
+
//# sourceMappingURL=ai-dispatcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-dispatcher.d.ts","sourceRoot":"","sources":["../../src/reasoner/ai-dispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EAClB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAkChE,MAAM,WAAW,2BAA2B;IAC1C,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B,iBAAiB,CAAC,EAAE,mBAAmB,CAAC;IACxC,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,qBAAa,oBAAqB,YAAW,cAAc;IACzD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAe;IAC1C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA2B;gBAExC,OAAO,GAAE,2BAAgC;IAM/C,WAAW,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;CAwBhE;AAED,uFAAuF;AACvF,wBAAgB,wBAAwB,CACtC,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,mBAAmB,CA8BrB"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { createAiDispatcher, AiDispatcherError, } from "@x12i/ai-dispatcher";
|
|
2
|
+
import { RetrievalPlanSchema, ScoperError, normalizeUpstreamError, } from "@x12i/memorix-scoper-contracts";
|
|
3
|
+
function extractJsonObject(text) {
|
|
4
|
+
const trimmed = text.trim();
|
|
5
|
+
try {
|
|
6
|
+
return JSON.parse(trimmed);
|
|
7
|
+
}
|
|
8
|
+
catch {
|
|
9
|
+
const start = trimmed.indexOf("{");
|
|
10
|
+
const end = trimmed.lastIndexOf("}");
|
|
11
|
+
if (start >= 0 && end > start) {
|
|
12
|
+
return JSON.parse(trimmed.slice(start, end + 1));
|
|
13
|
+
}
|
|
14
|
+
throw new Error("no JSON object in model response");
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function buildPrompt(input) {
|
|
18
|
+
const catalogIds = input.catalog.entries.map((e) => e.id).join(", ");
|
|
19
|
+
const repair = input.repairOf
|
|
20
|
+
? `\nPrevious plan was invalid: ${input.repairOf.error}\nPrevious plan: ${JSON.stringify(input.repairOf.previousPlan)}\nFix the plan.`
|
|
21
|
+
: "";
|
|
22
|
+
return [
|
|
23
|
+
`Profile: ${input.profile.id}`,
|
|
24
|
+
`Question: ${input.request.question}`,
|
|
25
|
+
`Allowed catalog entry ids: ${catalogIds}`,
|
|
26
|
+
`Budgets (immutable — do not attempt to change): ${JSON.stringify(input.budgets)}`,
|
|
27
|
+
`Epistemic rules: ${input.profile.epistemicRules.join(" | ")}`,
|
|
28
|
+
"Return ONLY a JSON RetrievalPlan with fields: planId, rationale, steps[], selections[], optional answerDraft.",
|
|
29
|
+
"Each step needs id, capability, catalogEntryId, args, optional parallelGroup, required.",
|
|
30
|
+
"No tools. No markdown. JSON only.",
|
|
31
|
+
repair,
|
|
32
|
+
].join("\n");
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* AI reasoner via @x12i/ai-dispatcher (gateway only — OpenRouter / Bedrock / OpenAI).
|
|
36
|
+
* Uses run() only — no tools. One repair attempt is owned by the coordinator.
|
|
37
|
+
*/
|
|
38
|
+
export class AiDispatcherReasoner {
|
|
39
|
+
dispatcher;
|
|
40
|
+
model;
|
|
41
|
+
provider;
|
|
42
|
+
constructor(options = {}) {
|
|
43
|
+
this.dispatcher = options.dispatcher ?? createAiDispatcher(options.dispatcherOptions ?? {});
|
|
44
|
+
this.provider = options.provider ?? options.dispatcherOptions?.provider;
|
|
45
|
+
this.model = options.model ?? "openai/gpt-4o-mini";
|
|
46
|
+
}
|
|
47
|
+
async proposePlan(input) {
|
|
48
|
+
try {
|
|
49
|
+
const response = await this.dispatcher.run({
|
|
50
|
+
...(this.provider ? { provider: this.provider } : {}),
|
|
51
|
+
model: this.model,
|
|
52
|
+
system: [input.profile.systemPrompt, "Return JSON only. No tools."].filter(Boolean).join("\n"),
|
|
53
|
+
prompt: buildPrompt(input),
|
|
54
|
+
});
|
|
55
|
+
const text = response.text?.trim() ? response.text : "";
|
|
56
|
+
if (!text) {
|
|
57
|
+
throw new ScoperError("REASONER_INVALID_PLAN", "AI dispatcher returned empty text", {
|
|
58
|
+
details: { status: response.status, model: response.model },
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
const raw = extractJsonObject(text);
|
|
62
|
+
return RetrievalPlanSchema.parse(raw);
|
|
63
|
+
}
|
|
64
|
+
catch (err) {
|
|
65
|
+
if (err instanceof AiDispatcherError && err.code === "PROVIDER_NOT_IMPLEMENTED") {
|
|
66
|
+
throw new ScoperError("PROVIDER_NOT_IMPLEMENTED", err.message, { details: err.details });
|
|
67
|
+
}
|
|
68
|
+
if (err instanceof ScoperError)
|
|
69
|
+
throw err;
|
|
70
|
+
throw normalizeUpstreamError(err);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/** Build dispatcher options from common host env vars (no secrets in request body). */
|
|
75
|
+
export function dispatcherOptionsFromEnv(env = process.env) {
|
|
76
|
+
const provider = (env.SCOPER_AI_PROVIDER ?? "openrouter");
|
|
77
|
+
const options = { provider };
|
|
78
|
+
if (env.OPENROUTER_API_KEY) {
|
|
79
|
+
options.openrouter = {
|
|
80
|
+
apiKey: env.OPENROUTER_API_KEY,
|
|
81
|
+
...(env.SCOPER_AI_MODEL && provider === "openrouter"
|
|
82
|
+
? { defaultModel: env.SCOPER_AI_MODEL }
|
|
83
|
+
: {}),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
if (env.AWS_REGION || env.BEDROCK_REGION) {
|
|
87
|
+
options.bedrock = {
|
|
88
|
+
region: env.BEDROCK_REGION ?? env.AWS_REGION,
|
|
89
|
+
...(env.SCOPER_AI_MODEL && provider === "bedrock"
|
|
90
|
+
? { defaultModel: env.SCOPER_AI_MODEL }
|
|
91
|
+
: {}),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
if (env.OPENAI_API_KEY) {
|
|
95
|
+
options.openai = {
|
|
96
|
+
apiKey: env.OPENAI_API_KEY,
|
|
97
|
+
...(env.OPENAI_ORG_ID ? { organization: env.OPENAI_ORG_ID } : {}),
|
|
98
|
+
...(env.OPENAI_PROJECT_ID ? { project: env.OPENAI_PROJECT_ID } : {}),
|
|
99
|
+
...(env.SCOPER_AI_MODEL && provider === "openai"
|
|
100
|
+
? { defaultModel: env.SCOPER_AI_MODEL }
|
|
101
|
+
: {}),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
return options;
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=ai-dispatcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-dispatcher.js","sourceRoot":"","sources":["../../src/reasoner/ai-dispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,iBAAiB,GAIlB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,sBAAsB,GAEvB,MAAM,gCAAgC,CAAC;AAGxC,SAAS,iBAAiB,CAAC,IAAY;IACrC,MAA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,GAAG,CAAC,cAAc,IAAI,GAAG,CAAC,UAAW;YAC7C,GAAG,CAAC,GAAG,CAAC,eAAe,IAAI,QAAQ,KAAK,SAAS;gBAC/C,CAAC,CAAC,EAAE,YAAY,EAAE,GAAG,CAAC,eAAe,EAAE;gBACvC,CAAC,CAAC,EAAE,CAAC;SACR,CAAC;IACJ,CAAC;IACD,IAAI,GAAG,CAAC,cAAc,EAAE,CAAC;QACvB,OAAO,CAAC,MAAM,GAAG;YACf,MAAM,EAAE,GAAG,CAAC,cAAc;YAC1B,GAAG,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,GAAG,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACjE,GAAG,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACpE,GAAG,CAAC,GAAG,CAAC,eAAe,IAAI,QAAQ,KAAK,QAAQ;gBAC9C,CAAC,CAAC,EAAE,YAAY,EAAE,GAAG,CAAC,eAAe,EAAE;gBACvC,CAAC,CAAC,EAAE,CAAC;SACR,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-dispatcher.test.d.ts","sourceRoot":"","sources":["../../src/reasoner/ai-dispatcher.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { AiDispatcherReasoner } from "./ai-dispatcher.js";
|
|
3
|
+
import { ScoperError } from "@x12i/memorix-scoper-contracts";
|
|
4
|
+
function planningInput() {
|
|
5
|
+
return {
|
|
6
|
+
request: { objective: "x" },
|
|
7
|
+
context: {
|
|
8
|
+
orgId: "o",
|
|
9
|
+
agentIds: ["a"],
|
|
10
|
+
callerId: "c",
|
|
11
|
+
permissions: ["*"],
|
|
12
|
+
classificationCeiling: "*",
|
|
13
|
+
traceId: "t",
|
|
14
|
+
deadlineAt: new Date().toISOString(),
|
|
15
|
+
budgets: {
|
|
16
|
+
maxWallTimeMs: 1,
|
|
17
|
+
maxSdkCalls: 1,
|
|
18
|
+
maxPages: 1,
|
|
19
|
+
maxRecords: 1,
|
|
20
|
+
maxBytes: 1,
|
|
21
|
+
maxEvidenceItems: 1,
|
|
22
|
+
maxRelationshipDepth: 0,
|
|
23
|
+
maxReasoningRounds: 1,
|
|
24
|
+
maxParallelCalls: 1,
|
|
25
|
+
},
|
|
26
|
+
flags: { bagsOnly: true, nexumExploreEnabled: false },
|
|
27
|
+
},
|
|
28
|
+
catalog: [{
|
|
29
|
+
id: "subjects.list",
|
|
30
|
+
version: "1",
|
|
31
|
+
description: "d",
|
|
32
|
+
surface: "subject",
|
|
33
|
+
operation: "subjects.list",
|
|
34
|
+
physicalContractVersion: "memorix-record/2",
|
|
35
|
+
identifiers: [],
|
|
36
|
+
relationships: [],
|
|
37
|
+
epistemicPlanes: [],
|
|
38
|
+
limits: {},
|
|
39
|
+
classification: "internal",
|
|
40
|
+
requiredPermissions: [],
|
|
41
|
+
mayBeMissing: true,
|
|
42
|
+
limitations: [],
|
|
43
|
+
prohibitedInferences: [],
|
|
44
|
+
owner: "t",
|
|
45
|
+
}],
|
|
46
|
+
profiles: [],
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
describe("AiDispatcherReasoner", () => {
|
|
50
|
+
it("repairs once then fails on invalid output", async () => {
|
|
51
|
+
const run = vi.fn()
|
|
52
|
+
.mockResolvedValueOnce({ text: "not-json" })
|
|
53
|
+
.mockResolvedValueOnce({ text: "{\"planId\":1}" });
|
|
54
|
+
const reasoner = new AiDispatcherReasoner({ provider: "openrouter", openrouter: { apiKey: "test" } }, { provider: "openrouter", run, executeStreamingChat: async function* () { }, compile: () => ({}) });
|
|
55
|
+
await expect(reasoner.createPlan(planningInput())).rejects.toBeInstanceOf(ScoperError);
|
|
56
|
+
expect(run).toHaveBeenCalledTimes(2);
|
|
57
|
+
});
|
|
58
|
+
it("parses a valid plan from dispatcher.run", async () => {
|
|
59
|
+
const plan = {
|
|
60
|
+
planId: "p1",
|
|
61
|
+
objective: "x",
|
|
62
|
+
profiles: ["general"],
|
|
63
|
+
steps: [],
|
|
64
|
+
};
|
|
65
|
+
const run = vi.fn().mockResolvedValue({ text: JSON.stringify(plan) });
|
|
66
|
+
const reasoner = new AiDispatcherReasoner({ provider: "openrouter", openrouter: { apiKey: "test" } }, { provider: "openrouter", run, executeStreamingChat: async function* () { }, compile: () => ({}) });
|
|
67
|
+
await expect(reasoner.createPlan(planningInput())).resolves.toEqual(plan);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
//# sourceMappingURL=ai-dispatcher.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-dispatcher.test.js","sourceRoot":"","sources":["../../src/reasoner/ai-dispatcher.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAG7D,SAAS,aAAa;IACpB,OAAO;QACL,OAAO,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE;QAC3B,OAAO,EAAE;YACP,KAAK,EAAE,GAAG;YACV,QAAQ,EAAE,CAAC,GAAG,CAAC;YACf,QAAQ,EAAE,GAAG;YACb,WAAW,EAAE,CAAC,GAAG,CAAC;YAClB,qBAAqB,EAAE,GAAG;YAC1B,OAAO,EAAE,GAAG;YACZ,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACpC,OAAO,EAAE;gBACP,aAAa,EAAE,CAAC;gBAChB,WAAW,EAAE,CAAC;g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
3
|
+
export { AiDispatcherReasoner, dispatcherOptionsFromEnv, type AiDispatcherReasonerOptions } from "./ai-dispatcher.js";
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reasoner/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,KAAK,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,KAAK,2BAA2B,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/reasoner/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAgC,MAAM,eAAe,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAoC,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type RetrievalPlan } from "@x12i/memorix-scoper-contracts";
|
|
2
|
+
import type { ReasonerInput, ScoperReasoner } from "./types.js";
|
|
3
|
+
export interface ScriptedReasonerOptions {
|
|
4
|
+
plans?: RetrievalPlan[];
|
|
5
|
+
factory?: (input: ReasonerInput) => RetrievalPlan | Promise<RetrievalPlan>;
|
|
6
|
+
}
|
|
7
|
+
/** Deterministic reasoner for tests and offline evaluation. */
|
|
8
|
+
export declare class ScriptedReasoner implements ScoperReasoner {
|
|
9
|
+
private readonly options;
|
|
10
|
+
private index;
|
|
11
|
+
constructor(options?: ScriptedReasonerOptions);
|
|
12
|
+
proposePlan(input: ReasonerInput): Promise<RetrievalPlan>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=scripted.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scripted.d.ts","sourceRoot":"","sources":["../../src/reasoner/scripted.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEhE,MAAM,WAAW,uBAAuB;IACtC,KAAK,CAAC,EAAE,aAAa,EAAE,CAAC;IACxB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CAC5E;AAED,+DAA+D;AAC/D,qBAAa,gBAAiB,YAAW,cAAc;IAEzC,OAAO,CAAC,QAAQ,CAAC,OAAO;IADpC,OAAO,CAAC,KAAK,CAAK;gBACW,OAAO,GAAE,uBAA4B;IAE5D,WAAW,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;CAYhE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { RetrievalPlanSchema, ScoperError, } from "@x12i/memorix-scoper-contracts";
|
|
2
|
+
/** Deterministic reasoner for tests and offline evaluation. */
|
|
3
|
+
export class ScriptedReasoner {
|
|
4
|
+
options;
|
|
5
|
+
index = 0;
|
|
6
|
+
constructor(options = {}) {
|
|
7
|
+
this.options = options;
|
|
8
|
+
}
|
|
9
|
+
async proposePlan(input) {
|
|
10
|
+
if (this.options.factory) {
|
|
11
|
+
return RetrievalPlanSchema.parse(await this.options.factory(input));
|
|
12
|
+
}
|
|
13
|
+
const plans = this.options.plans ?? [];
|
|
14
|
+
const plan = plans[Math.min(this.index, plans.length - 1)];
|
|
15
|
+
this.index += 1;
|
|
16
|
+
if (!plan) {
|
|
17
|
+
throw new ScoperError("REASONER_INVALID_PLAN", "ScriptedReasoner has no plans");
|
|
18
|
+
}
|
|
19
|
+
return RetrievalPlanSchema.parse(plan);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=scripted.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scripted.js","sourceRoot":"","sources":["../../src/reasoner/scripted.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,WAAW,GAEZ,MAAM,gCAAgC,CAAC;AAQxC,+DAA+D;AAC/D,MAAM,OAAO,gBAAgB;IAEE;IADrB,KAAK,GAAG,CAAC,CAAC;IAClB,YAA6B,UAAmC,EAAE;QAArC,YAAO,GAAP,OAAO,CAA8B;IAAG,CAAC;IAEtE,KAAK,CAAC,WAAW,CAAC,KAAoB;QACpC,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YACzB,OAAO,mBAAmB,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;QACtE,CAAC;QACD,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC;QACvC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;QAC3D,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;QAChB,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,WAAW,CAAC,uBAAuB,EAAE,+BAA+B,CAAC,CAAC;QAClF,CAAC;QACD,OAAO,mBAAmB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;CACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ScopeRequest, TrustedExecutionContext, ScoperProfile, RetrievalPlan, ScoperBudgets } from "@x12i/memorix-scoper-contracts";
|
|
2
|
+
import type { ContextualSdk } from "@x12i/memorix-scoper-sdk";
|
|
3
|
+
export interface ReasonerInput {
|
|
4
|
+
request: ScopeRequest;
|
|
5
|
+
context: TrustedExecutionContext;
|
|
6
|
+
profile: ScoperProfile;
|
|
7
|
+
budgets: ScoperBudgets;
|
|
8
|
+
catalog: ReturnType<ContextualSdk["catalog"]["describe"]>;
|
|
9
|
+
repairOf?: {
|
|
10
|
+
previousPlan: unknown;
|
|
11
|
+
error: string;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface ScoperReasoner {
|
|
15
|
+
proposePlan(input: ReasonerInput): Promise<RetrievalPlan>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/reasoner/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,uBAAuB,EACvB,aAAa,EACb,aAAa,EACb,aAAa,EACd,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE9D,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,YAAY,CAAC;IACtB,OAAO,EAAE,uBAAuB,CAAC;IACjC,OAAO,EAAE,aAAa,CAAC;IACvB,OAAO,EAAE,aAAa,CAAC;IACvB,OAAO,EAAE,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;IAC1D,QAAQ,CAAC,EAAE;QAAE,YAAY,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CACrD;AAED,MAAM,WAAW,cAAc;IAC7B,WAAW,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CAC3D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/reasoner/types.ts"],"names":[],"mappings":""}
|