@x12i/memorix-client-api 0.18.0 → 0.20.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.
Files changed (112) hide show
  1. package/HANDOVER.md +13 -2
  2. package/dist/agent-directory.d.ts +25 -0
  3. package/dist/agent-directory.d.ts.map +1 -0
  4. package/dist/agent-directory.js +75 -0
  5. package/dist/agent-directory.js.map +1 -0
  6. package/dist/app.d.ts +31 -6
  7. package/dist/app.d.ts.map +1 -1
  8. package/dist/app.js +285 -61
  9. package/dist/app.js.map +1 -1
  10. package/dist/authix.d.ts +28 -2
  11. package/dist/authix.d.ts.map +1 -1
  12. package/dist/authix.js +55 -4
  13. package/dist/authix.js.map +1 -1
  14. package/dist/catalog.d.ts +33 -1
  15. package/dist/catalog.d.ts.map +1 -1
  16. package/dist/catalog.js +83 -4
  17. package/dist/catalog.js.map +1 -1
  18. package/dist/cli.js +11 -1
  19. package/dist/cli.js.map +1 -1
  20. package/dist/config.d.ts +9 -0
  21. package/dist/config.d.ts.map +1 -1
  22. package/dist/config.js +31 -0
  23. package/dist/config.js.map +1 -1
  24. package/dist/errors.d.ts +16 -2
  25. package/dist/errors.d.ts.map +1 -1
  26. package/dist/errors.js +16 -2
  27. package/dist/errors.js.map +1 -1
  28. package/dist/fetch.d.ts.map +1 -1
  29. package/dist/fetch.js +27 -3
  30. package/dist/fetch.js.map +1 -1
  31. package/dist/peers.d.ts +2 -2
  32. package/dist/peers.d.ts.map +1 -1
  33. package/dist/peers.js +4 -4
  34. package/dist/peers.js.map +1 -1
  35. package/dist/refs.d.ts +7 -1
  36. package/dist/refs.d.ts.map +1 -1
  37. package/dist/refs.js +36 -26
  38. package/dist/refs.js.map +1 -1
  39. package/dist/scope.d.ts +25 -2
  40. package/dist/scope.d.ts.map +1 -1
  41. package/dist/scope.js +71 -4
  42. package/dist/scope.js.map +1 -1
  43. package/dist/scoper-embedded.d.ts +29 -0
  44. package/dist/scoper-embedded.d.ts.map +1 -0
  45. package/dist/scoper-embedded.js +239 -0
  46. package/dist/scoper-embedded.js.map +1 -0
  47. package/dist/scoper.d.ts +19 -27
  48. package/dist/scoper.d.ts.map +1 -1
  49. package/dist/scoper.js +51 -254
  50. package/dist/scoper.js.map +1 -1
  51. package/dist/upstream.d.ts +6 -1
  52. package/dist/upstream.d.ts.map +1 -1
  53. package/dist/upstream.js +22 -4
  54. package/dist/upstream.js.map +1 -1
  55. package/dist/v1/census.d.ts +63 -0
  56. package/dist/v1/census.d.ts.map +1 -0
  57. package/dist/v1/census.js +154 -0
  58. package/dist/v1/census.js.map +1 -0
  59. package/dist/v1/content.d.ts +48 -0
  60. package/dist/v1/content.d.ts.map +1 -0
  61. package/dist/v1/content.js +323 -0
  62. package/dist/v1/content.js.map +1 -0
  63. package/dist/v1/context.d.ts +50 -0
  64. package/dist/v1/context.d.ts.map +1 -0
  65. package/dist/v1/context.js +4 -0
  66. package/dist/v1/context.js.map +1 -0
  67. package/dist/v1/directory.d.ts +26 -0
  68. package/dist/v1/directory.d.ts.map +1 -0
  69. package/dist/v1/directory.js +89 -0
  70. package/dist/v1/directory.js.map +1 -0
  71. package/dist/v1/discovery.d.ts +24 -0
  72. package/dist/v1/discovery.d.ts.map +1 -0
  73. package/dist/v1/discovery.js +166 -0
  74. package/dist/v1/discovery.js.map +1 -0
  75. package/dist/v1/gaps.d.ts +18 -0
  76. package/dist/v1/gaps.d.ts.map +1 -0
  77. package/dist/v1/gaps.js +2 -0
  78. package/dist/v1/gaps.js.map +1 -0
  79. package/dist/v1/http.d.ts +18 -0
  80. package/dist/v1/http.d.ts.map +1 -0
  81. package/dist/v1/http.js +105 -0
  82. package/dist/v1/http.js.map +1 -0
  83. package/dist/v1/mapping.d.ts +161 -0
  84. package/dist/v1/mapping.d.ts.map +1 -0
  85. package/dist/v1/mapping.js +402 -0
  86. package/dist/v1/mapping.js.map +1 -0
  87. package/dist/v1/planning-store.d.ts +74 -0
  88. package/dist/v1/planning-store.d.ts.map +1 -0
  89. package/dist/v1/planning-store.js +192 -0
  90. package/dist/v1/planning-store.js.map +1 -0
  91. package/dist/v1/planning.d.ts +5 -0
  92. package/dist/v1/planning.d.ts.map +1 -0
  93. package/dist/v1/planning.js +297 -0
  94. package/dist/v1/planning.js.map +1 -0
  95. package/dist/v1/records.d.ts +18 -0
  96. package/dist/v1/records.d.ts.map +1 -0
  97. package/dist/v1/records.js +42 -0
  98. package/dist/v1/records.js.map +1 -0
  99. package/dist/v1/relationships.d.ts +72 -0
  100. package/dist/v1/relationships.d.ts.map +1 -0
  101. package/dist/v1/relationships.js +436 -0
  102. package/dist/v1/relationships.js.map +1 -0
  103. package/dist/v1/routes.d.ts +5 -0
  104. package/dist/v1/routes.d.ts.map +1 -0
  105. package/dist/v1/routes.js +16 -0
  106. package/dist/v1/routes.js.map +1 -0
  107. package/dist/v1/sources.d.ts +62 -0
  108. package/dist/v1/sources.d.ts.map +1 -0
  109. package/dist/v1/sources.js +218 -0
  110. package/dist/v1/sources.js.map +1 -0
  111. package/openapi/openapi.json +3616 -480
  112. package/package.json +74 -74
package/HANDOVER.md CHANGED
@@ -43,14 +43,15 @@ The listen port comes from `attachCoreFastify` (`MEMORIX_CLIENT_API_PORT`, defau
43
43
  | `SCOPER_FUNCTIONS_DIR` | | Pagx directory of saved query and scope functions, passed to `createScoper({ functions })`. |
44
44
  | `SCOPER_FUNCTIONS_PACKAGE` | | Parent package name for that directory. |
45
45
  | `SCOPER_FUNCTIONS_LEARN` | off | `true` asks the coder to write a function on a miss. Needs `@x12i/coder-dispatcher`. |
46
- | `SCOPER_MODE` | `auto` | `auto` hosts Scoper here unless `SCOPER_URL` is healthy and `3.0.x`. `external` requires that peer. `embedded` does not probe. |
46
+ | `SCOPER_MODE` | `auto` | `auto` hosts Scoper here unless `SCOPER_URL` is healthy and `3.x`. `external` requires that peer and does not load the Scoper packages. `embedded` does not probe. See `docs/scoper-downstream.md`. |
47
47
  | `SCOPER_URL` | | Base URL of a Scoper peer. Proxied for the process lifetime when selected. |
48
48
  | `SKILLS_MODE` | `auto` | `auto` probes skill-api and hosts agent functions here when that probe fails. `external` requires the peer. `embedded` does not probe. |
49
49
  | `SKILL_API_URL` | `http://127.0.0.1:7180` in `auto` | Skill-api base. A selected peer answers list, run, save, and delete. |
50
50
  | `SKILLS_PACK_DIR` | | Pack directory with `functions/catalog.json` and `functions/run.mjs`. Used when functions are hosted here. |
51
51
  | `AGENTS_DIR` | | Agents root. A folder named for the agent, or the first pack with functions, is the catalog. |
52
52
  | `MEMORIX_AGENT_IDS` | | Content agents that use the process pack. `PROCESS_AGENT_ID` is the fallback. |
53
- | `ASSISTANT_MONGO_URI` or `MONGO_URI` | | Assistants database for function overrides. Unset: pack functions run, save returns `503`. Not opened when skill-api is the peer. |
53
+ | `ASSISTANT_MONGO_URI` or `MONGO_URI` | | Assistants database `{orgId}-memorix-assistants`: function overrides (only while functions are hosted here) and planning items (collection `planning_items`). Unset: pack functions run, save returns `503`, and planning routes are `501 CAPABILITY_UNAVAILABLE`. |
54
+ | `PLANNING_ASSIGNEES` | | JSON object of org id to `[{ "id", "name", "kind"? }]`. Planning assignee options. Unset: only unassigned. |
54
55
  | `AUTHIX_APP_ID` | | Required with `MEMORIX_AUTH=authix`. |
55
56
  | `AUTHIX_APP_SECRET_KEY` | | Required with `MEMORIX_AUTH=authix`. |
56
57
  | `AUTHIX_INTROSPECT_URL` | | Optional revocation check, for example `http://127.0.0.1:3100/v1/tokens/introspect`. |
@@ -63,6 +64,16 @@ npm run typecheck
63
64
  npm run build && npm start
64
65
  ```
65
66
 
67
+ The `visualizer` contract (`docs/visualizer-api.md`) is served from `src/v1/`. Every `/api/v1` route checks the requested agents against `GET /api/metadata/agents?scope=org` (reused for 30 seconds): `*` is the org's deployed agents, and an agent the org has not deployed is `403 AGENT_NOT_DEPLOYED`. Against a Memorix without the org agent record, agent ids pass through unchanged.
68
+
69
+ ## Release
70
+
71
+ 1. Bump `package.json` and `package-lock.json` (`npm version <v> --no-git-tag-version`), `openapi/openapi.json` `info.version`, and the version lines in the root `README.md`. The read client also bumps `clientInfo.version` in `src/index.ts`. `memorix-client` adds a `CHANGELOG.md` entry.
72
+ 2. In each package: `npm test`, `npm run typecheck`, `npm run build`. Check that `npm view <package>@<version>` is a 404, then `npm pack --dry-run`.
73
+ 3. Publish `memorix-client` first, then this server (which depends on it), then the read client: `npm publish --access public`.
74
+ 4. Commit and push.
75
+ 5. On the host, stop the listener on 5120 and start `npm run dev` in this folder again. Check `/health`, `/ready`, `/api/openapi.json` (`info.version`), and `/api/v1/capabilities` (401 without a token).
76
+
66
77
  ## What must already be on the Memorix host
67
78
 
68
79
  These stay in the Memorix repo. This API calls them over HTTP.
@@ -0,0 +1,25 @@
1
+ import { type Upstream } from "./upstream.js";
2
+ export type AgentEntry = {
3
+ id: string;
4
+ ok: boolean;
5
+ error: string | null;
6
+ objectTypes: Array<{
7
+ id: string;
8
+ name?: string;
9
+ contentTypes: string[];
10
+ }>;
11
+ };
12
+ export type AgentDirectory = {
13
+ /**
14
+ * Agents recorded for the org (`GET /api/metadata/agents?scope=org`).
15
+ * `null` means Memorix has no org agent record (service older than 3.18.0).
16
+ */
17
+ deployed(orgId: string, caller: string): Promise<AgentEntry[] | null>;
18
+ /** Every pack installed on the platform. */
19
+ installed(orgId: string, caller: string): Promise<AgentEntry[]>;
20
+ };
21
+ export declare function agentsFromListing(body: unknown): AgentEntry[];
22
+ /** A Memorix without an org agent record: agent ids are sent as requested and `*` is not expanded. */
23
+ export declare const NO_ORG_AGENT_RECORD: AgentDirectory;
24
+ export declare function createAgentDirectory(upstream: Upstream, ttlMs?: number): AgentDirectory;
25
+ //# sourceMappingURL=agent-directory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-directory.d.ts","sourceRoot":"","sources":["../src/agent-directory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAExD,MAAM,MAAM,UAAU,GAAG;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,OAAO,CAAC;IACZ,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,WAAW,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;CAC3E,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,GAAG,IAAI,CAAC,CAAC;IACtE,4CAA4C;IAC5C,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;CACjE,CAAC;AAIF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,UAAU,EAAE,CA2B7D;AAED,sGAAsG;AACtG,eAAO,MAAM,mBAAmB,EAAE,cAGjC,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,SAAiB,GAAG,cAAc,CAoC/F"}
@@ -0,0 +1,75 @@
1
+ import { UpstreamError } from "./errors.js";
2
+ import { asRecord } from "./upstream.js";
3
+ const DEFAULT_TTL_MS = 30_000;
4
+ export function agentsFromListing(body) {
5
+ const agents = asRecord(body)?.agents;
6
+ if (!Array.isArray(agents))
7
+ return [];
8
+ const out = [];
9
+ for (const item of agents) {
10
+ const row = asRecord(item);
11
+ if (!row || typeof row.id !== "string" || !row.id)
12
+ continue;
13
+ const objectTypes = Array.isArray(row.objectTypes)
14
+ ? row.objectTypes
15
+ .map((entry) => asRecord(entry))
16
+ .filter((entry) => entry !== null && typeof entry.id === "string")
17
+ .map((entry) => ({
18
+ id: entry.id,
19
+ ...(typeof entry.name === "string" ? { name: entry.name } : {}),
20
+ contentTypes: Array.isArray(entry.contentTypes)
21
+ ? entry.contentTypes.filter((ct) => typeof ct === "string")
22
+ : [],
23
+ }))
24
+ : [];
25
+ out.push({
26
+ id: row.id,
27
+ ok: row.ok !== false,
28
+ error: typeof row.error === "string" ? row.error : null,
29
+ objectTypes,
30
+ });
31
+ }
32
+ return out.sort((a, b) => a.id.localeCompare(b.id));
33
+ }
34
+ /** A Memorix without an org agent record: agent ids are sent as requested and `*` is not expanded. */
35
+ export const NO_ORG_AGENT_RECORD = {
36
+ deployed: async () => null,
37
+ installed: async () => [],
38
+ };
39
+ export function createAgentDirectory(upstream, ttlMs = DEFAULT_TTL_MS) {
40
+ const cache = new Map();
41
+ function cached(key, load) {
42
+ const hit = cache.get(key);
43
+ if (hit && Date.now() - hit.at < ttlMs)
44
+ return hit.value;
45
+ const value = load();
46
+ cache.set(key, { at: Date.now(), value });
47
+ value.catch(() => cache.delete(key));
48
+ return value;
49
+ }
50
+ function listingScope(orgId, caller) {
51
+ return { orgId, agentIds: ["*"], caller };
52
+ }
53
+ return {
54
+ deployed(orgId, caller) {
55
+ return cached(`org:${orgId}`, async () => {
56
+ try {
57
+ const body = await upstream.get("/api/metadata/agents?scope=org", listingScope(orgId, caller));
58
+ if (!Array.isArray(asRecord(body)?.agents))
59
+ return null;
60
+ return agentsFromListing(body);
61
+ }
62
+ catch (err) {
63
+ if (err instanceof UpstreamError && (err.statusCode === 404 || err.statusCode === 501))
64
+ return null;
65
+ throw err;
66
+ }
67
+ });
68
+ },
69
+ async installed(orgId, caller) {
70
+ const value = await cached("platform", async () => agentsFromListing(await upstream.get("/api/metadata/agents", listingScope(orgId, caller))));
71
+ return value ?? [];
72
+ },
73
+ };
74
+ }
75
+ //# sourceMappingURL=agent-directory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-directory.js","sourceRoot":"","sources":["../src/agent-directory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,QAA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+1,45 @@
1
1
  import { type FastifyInstance } from "fastify";
2
2
  import { type ScoperReasonerKind } from "./config.js";
3
3
  import type { PeerChoice } from "./peers.js";
4
- import { createScoperHost, type ScoperHost } from "./scoper.js";
4
+ import { type ScoperHost } from "./scoper.js";
5
+ import type { createScoperHost } from "./scoper-embedded.js";
5
6
  import { type EmbeddedSkillsOptions, type SkillsHost } from "./skills.js";
7
+ import { type AgentDirectory } from "./agent-directory.js";
8
+ import type { TokenClaims } from "./authix.js";
9
+ import { type PlanningStore } from "./v1/planning-store.js";
6
10
  export type ClientApiAuth = {
7
11
  mode: "header";
8
12
  } | {
9
13
  mode: "authix";
10
- verify: (token: string) => Promise<{
11
- organizationIds: string[];
12
- }>;
14
+ verify: (token: string) => Promise<TokenClaims>;
13
15
  };
14
16
  export type ClientApiOptions = {
15
17
  memorixUrl: string;
16
18
  fetchImpl?: typeof fetch;
17
19
  /** Default `header`: org comes from `x-memorix-org-id`. */
18
20
  auth?: ClientApiAuth;
21
+ /** Upstream timeout. Default 30000 ms. */
22
+ upstreamTimeoutMs?: number;
23
+ /** How long the org's deployed agent list is reused. Default 30000 ms. */
24
+ agentCacheMs?: number;
25
+ /** Deployed and installed agents. Default reads `GET /api/metadata/agents` on Memorix. */
26
+ agentDirectory?: AgentDirectory;
27
+ /** How long a census is reused per org and agent set. Default 60000 ms. */
28
+ censusCacheMs?: number;
29
+ /**
30
+ * Planning items. `store` is a test double. `mongoUri` keeps items in `{orgId}-memorix-assistants.planning_items`.
31
+ * Neither means planning routes are `501 CAPABILITY_UNAVAILABLE`.
32
+ */
33
+ planning?: {
34
+ store?: PlanningStore;
35
+ mongoUri?: string;
36
+ /** Assignee options per org. Absent means only unassigned is valid. */
37
+ assignees?: Record<string, Array<{
38
+ id: string;
39
+ name: string;
40
+ kind?: string;
41
+ }>>;
42
+ };
19
43
  /** Listen port. Default `MEMORIX_CLIENT_API_PORT` or 5120. */
20
44
  port?: number;
21
45
  /**
@@ -24,8 +48,9 @@ export type ClientApiOptions = {
24
48
  */
25
49
  mgcMcpUrl?: string | null;
26
50
  /**
27
- * Scoper 3.0.0 hosted in this process. The library default is the scripted reasoner
28
- * and no saved functions. The CLI passes the process env.
51
+ * Scoper 3.0.0 hosted in this process, or a peer chosen at startup. The library default is the
52
+ * scripted reasoner and no saved functions. The CLI passes the process env.
53
+ * The Scoper packages are loaded only when this process hosts Scoper.
29
54
  */
30
55
  scoper?: {
31
56
  reasoner?: ScoperReasonerKind;
package/dist/app.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAGA,OAAgB,EAAE,KAAK,eAAe,EAAuB,MAAM,SAAS,CAAC;AAW7E,OAAO,EAAkB,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAStE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAkD,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAChH,OAAO,EAIL,KAAK,qBAAqB,EAC1B,KAAK,UAAU,EAChB,MAAM,aAAa,CAAC;AAQrB,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC;AAE1F,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IACzB,2DAA2D;IAC3D,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,8DAA8D;IAC9D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B;;;OAGG;IACH,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