neotoma 0.22.2 → 0.23.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/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +49 -50
- package/dist/actions.js.map +1 -1
- package/dist/config.d.ts +19 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +79 -3
- package/dist/config.js.map +1 -1
- package/dist/docs/developer/mcp/compact_instructions.md +2 -0
- package/dist/docs/developer/mcp/instructions.md +30 -3
- package/dist/docs/developer/mcp/proxy.md +6 -4
- package/dist/docs/operations/configuration.md +54 -42
- package/dist/docs/specs/MCP_SPEC.md +1 -1
- package/dist/docs/subsystems/conflict_resolution.md +11 -6
- package/dist/docs/subsystems/observation_architecture.md +2 -2
- package/dist/docs/subsystems/reducer.md +29 -3
- package/dist/docs/subsystems/schema_registry.md +11 -0
- package/dist/docs/testing/automated_test_catalog.md +13 -6
- package/dist/mcp_http_session.d.ts +51 -0
- package/dist/mcp_http_session.d.ts.map +1 -0
- package/dist/mcp_http_session.js +173 -0
- package/dist/mcp_http_session.js.map +1 -0
- package/dist/reducers/observation_reducer.d.ts.map +1 -1
- package/dist/reducers/observation_reducer.js +24 -6
- package/dist/reducers/observation_reducer.js.map +1 -1
- package/dist/server.d.ts +7 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +117 -10
- package/dist/server.js.map +1 -1
- package/dist/services/field_canonicalization.d.ts +1 -0
- package/dist/services/field_canonicalization.d.ts.map +1 -1
- package/dist/services/field_canonicalization.js +15 -9
- package/dist/services/field_canonicalization.js.map +1 -1
- package/dist/services/interpretation.d.ts +2 -0
- package/dist/services/interpretation.d.ts.map +1 -1
- package/dist/services/interpretation.js +2 -1
- package/dist/services/interpretation.js.map +1 -1
- package/dist/services/schema_definitions.d.ts.map +1 -1
- package/dist/services/schema_definitions.js +108 -0
- package/dist/services/schema_definitions.js.map +1 -1
- package/dist/services/schema_registry.d.ts +1 -0
- package/dist/services/schema_registry.d.ts.map +1 -1
- package/dist/services/schema_registry.js.map +1 -1
- package/dist/services/skills/instance_skills.d.ts +137 -0
- package/dist/services/skills/instance_skills.d.ts.map +1 -0
- package/dist/services/skills/instance_skills.js +381 -0
- package/dist/services/skills/instance_skills.js.map +1 -0
- package/dist/tool_definitions.js +1 -1
- package/dist/tool_definitions.js.map +1 -1
- package/docs/developer/mcp/instructions.md +30 -3
- package/package.json +2 -2
package/dist/actions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AA2C9B,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,6BAA6B,CAAC;AAarC,OAAO,EAGL,KAAK,aAAa,EAGnB,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AA2C9B,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,6BAA6B,CAAC;AAarC,OAAO,EAGL,KAAK,aAAa,EAGnB,MAAM,4BAA4B,CAAC;AAyCpC,OAAO,EAQL,KAAK,sBAAsB,EAC5B,MAAM,4BAA4B,CAAC;AAkDpC,OAAO,EAGL,oBAAoB,EACrB,MAAM,8BAA8B,CAAC;AAWtC,OAAO,EAiCL,KAAK,wBAAwB,EAE9B,MAAM,4BAA4B,CAAC;AA8CpC,6FAA6F;AAC7F,wBAAgB,qBAAqB,IAAI,sBAAsB,GAAG,IAAI,CAErE;AAED,eAAO,MAAM,GAAG,6CAAY,CAAC;AA2zB7B,kFAAkF;AAClF,eAAO,MAAM,4BAA4B,QAAS,CAAC;AAEnD;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAMtE;AAoBD,uFAAuF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,OAAO,CAAC;;;cAnC3B,MAAM;gBACJ,MAAM;2BACK,MAAM;qBACZ,MAAM;mBACR,MAAM;wBACD,MAAM;uBACP,MAAM;;;;;mBAhSV,MAAM;qBACJ,MAAM;wBACH,MAAM,GAAG,IAAI;2BACV,MAAM;;wBAET,MAAM;uBACP,MAAM,EAAE;wBACP,MAAM;uBACP,MAAM;;kBAxYX,MAAM;oBACJ,MAAM;yBACD,MAAM;4BACH,MAAM;2BACP,MAAM;;;kBAQf,MAAM;yBACC,MAAM;iCACE,MAAM;sCACD,MAAM;;+BA4Xb,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;;;2BAwMlC,MAAM;0BACP,MAAM;0BACN,MAAM;;;;;;;;GA4e3B;AAklHD,wBAAsB,eAAe;;;eA+QpC"}
|
package/dist/actions.js
CHANGED
|
@@ -38,9 +38,8 @@ import { initServerKeys } from "./services/encryption_service.js";
|
|
|
38
38
|
import { storeRawContent, downloadRawContent, resolveLocalSourceFilePath, SourceFileNotFoundError, } from "./services/raw_storage.js";
|
|
39
39
|
import { attachSourceLabelsToObservations } from "./services/observation_source_label.js";
|
|
40
40
|
import { isFilesystemLocalToCaller, buildFilePathServerLocalError, decodeFileContent, FileInputError, } from "./services/file_input_diagnostics.js";
|
|
41
|
-
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
42
41
|
import { isInitializeRequest } from "@modelcontextprotocol/sdk/types.js";
|
|
43
|
-
import {
|
|
42
|
+
import { adoptRecoveredSessionId, completeSyntheticMcpHandshake, mintMcpHttpSession, unknownSessionJsonRpcBody, } from "./mcp_http_session.js";
|
|
44
43
|
import { logger } from "./utils/logger.js";
|
|
45
44
|
import { formatRequestLogLine } from "./utils/safe_request_log_format.js";
|
|
46
45
|
import { emitEntitySnapshotChange, emitObservationCreated, shallowFieldsChanged, } from "./events/substrate_store_emit.js";
|
|
@@ -1703,59 +1702,59 @@ app.all("/mcp", async (req, res) => {
|
|
|
1703
1702
|
let serverInstance = sessionId
|
|
1704
1703
|
? mcpServerInstances.get(sessionId)
|
|
1705
1704
|
: undefined;
|
|
1705
|
+
const mcpSessionMaps = {
|
|
1706
|
+
transports: mcpTransports,
|
|
1707
|
+
servers: mcpServerInstances,
|
|
1708
|
+
};
|
|
1709
|
+
const rpcIdForUnknownSession = req.body &&
|
|
1710
|
+
typeof req.body === "object" &&
|
|
1711
|
+
!Array.isArray(req.body) &&
|
|
1712
|
+
"id" in req.body &&
|
|
1713
|
+
(typeof req.body.id === "string" ||
|
|
1714
|
+
typeof req.body.id === "number")
|
|
1715
|
+
? req.body.id
|
|
1716
|
+
: null;
|
|
1706
1717
|
if (!transport && req.method === "POST" && isInitializeRequest(req.body)) {
|
|
1707
|
-
//
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
if (transport?.sessionId) {
|
|
1731
|
-
mcpTransports.delete(transport.sessionId);
|
|
1732
|
-
mcpServerInstances.delete(transport.sessionId);
|
|
1733
|
-
logger.error(`[MCP HTTP] Session closed: ${transport.sessionId}`);
|
|
1718
|
+
// Client-driven initialize: mint a fresh session (ignores any stale session id).
|
|
1719
|
+
const minted = await mintMcpHttpSession(req, mcpSessionMaps, resolvePublicAppOriginFromRequest);
|
|
1720
|
+
transport = minted.transport;
|
|
1721
|
+
serverInstance = minted.serverInstance;
|
|
1722
|
+
}
|
|
1723
|
+
else if (!transport &&
|
|
1724
|
+
req.method === "POST" &&
|
|
1725
|
+
typeof sessionId === "string" &&
|
|
1726
|
+
sessionId.length > 0 &&
|
|
1727
|
+
req.body &&
|
|
1728
|
+
typeof req.body === "object" &&
|
|
1729
|
+
!isInitializeRequest(req.body)) {
|
|
1730
|
+
// Recover-in-place (neotoma#2100): authenticated POST with an unknown session
|
|
1731
|
+
// id and a non-initialize body mints a new transport, completes a server-side
|
|
1732
|
+
// initialize handshake, then serves the original call under the new session id.
|
|
1733
|
+
// Auth already passed above — do not mint on 401 paths.
|
|
1734
|
+
try {
|
|
1735
|
+
const minted = await mintMcpHttpSession(req, mcpSessionMaps, resolvePublicAppOriginFromRequest);
|
|
1736
|
+
const handshakeOk = await completeSyntheticMcpHandshake(minted.transport);
|
|
1737
|
+
const recoveredSessionId = minted.transport.sessionId;
|
|
1738
|
+
if (!handshakeOk || !recoveredSessionId) {
|
|
1739
|
+
logger.warn(`[MCP HTTP] Recover-in-place handshake failed for stale Mcp-Session-Id (first 8 chars): ${sessionId.slice(0, 8)}...`);
|
|
1740
|
+
return res.status(404).json(unknownSessionJsonRpcBody(rpcIdForUnknownSession));
|
|
1734
1741
|
}
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1742
|
+
transport = minted.transport;
|
|
1743
|
+
serverInstance = minted.serverInstance;
|
|
1744
|
+
adoptRecoveredSessionId(req, recoveredSessionId);
|
|
1745
|
+
logger.info(`[MCP HTTP] Recovered unknown/expired session (stale first 8: ${sessionId.slice(0, 8)}...) → new session ${recoveredSessionId.slice(0, 8)}...`);
|
|
1746
|
+
}
|
|
1747
|
+
catch (recoverError) {
|
|
1748
|
+
logger.warn(`[MCP HTTP] Recover-in-place failed for stale Mcp-Session-Id (first 8 chars): ${sessionId.slice(0, 8)}...`, recoverError);
|
|
1749
|
+
return res.status(404).json(unknownSessionJsonRpcBody(rpcIdForUnknownSession));
|
|
1750
|
+
}
|
|
1738
1751
|
}
|
|
1739
1752
|
else if (!transport) {
|
|
1740
|
-
const rpcId = req.body &&
|
|
1741
|
-
typeof req.body === "object" &&
|
|
1742
|
-
!Array.isArray(req.body) &&
|
|
1743
|
-
"id" in req.body &&
|
|
1744
|
-
(typeof req.body.id === "string" ||
|
|
1745
|
-
typeof req.body.id === "number")
|
|
1746
|
-
? req.body.id
|
|
1747
|
-
: null;
|
|
1748
1753
|
const hadSessionHeader = typeof sessionId === "string" && sessionId.length > 0;
|
|
1749
1754
|
if (hadSessionHeader) {
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
error: {
|
|
1754
|
-
code: -32001,
|
|
1755
|
-
message: "Not Found: MCP session is unknown or expired on this API instance. The client should re-initialize by sending a new InitializeRequest without a session ID. If you run multiple replicas, enable sticky sessions for POST /mcp (or route /mcp to a single instance).",
|
|
1756
|
-
},
|
|
1757
|
-
id: rpcId,
|
|
1758
|
-
});
|
|
1755
|
+
// GET/DELETE unknown session, or POST only after mint/handshake failure above.
|
|
1756
|
+
logger.warn(`[MCP HTTP] Unknown or expired Mcp-Session-Id (first 8 chars): ${sessionId.slice(0, 8)}... server restart or stale client state`);
|
|
1757
|
+
return res.status(404).json(unknownSessionJsonRpcBody(rpcIdForUnknownSession));
|
|
1759
1758
|
}
|
|
1760
1759
|
return res.status(400).json({
|
|
1761
1760
|
jsonrpc: "2.0",
|
|
@@ -1763,7 +1762,7 @@ app.all("/mcp", async (req, res) => {
|
|
|
1763
1762
|
code: -32000,
|
|
1764
1763
|
message: "Bad Request: No MCP session on this request. Send an initialize JSON-RPC message first, then include the mcp-session-id response header on every subsequent POST.",
|
|
1765
1764
|
},
|
|
1766
|
-
id:
|
|
1765
|
+
id: rpcIdForUnknownSession,
|
|
1767
1766
|
});
|
|
1768
1767
|
}
|
|
1769
1768
|
// Thread AAuth / clientInfo fallback attribution into the server for
|