@cat-factory/kernel 0.243.1 → 0.244.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 (37) hide show
  1. package/dist/domain/agent-capabilities.d.ts +100 -1
  2. package/dist/domain/agent-capabilities.d.ts.map +1 -1
  3. package/dist/domain/agent-capabilities.js +4 -0
  4. package/dist/domain/agent-capabilities.js.map +1 -1
  5. package/dist/domain/audit-log.d.ts +95 -0
  6. package/dist/domain/audit-log.d.ts.map +1 -0
  7. package/dist/domain/audit-log.js +142 -0
  8. package/dist/domain/audit-log.js.map +1 -0
  9. package/dist/domain/tool-call-rollup.d.ts +53 -0
  10. package/dist/domain/tool-call-rollup.d.ts.map +1 -0
  11. package/dist/domain/tool-call-rollup.js +117 -0
  12. package/dist/domain/tool-call-rollup.js.map +1 -0
  13. package/dist/domain/workspace-cascade.d.ts +1 -1
  14. package/dist/domain/workspace-cascade.d.ts.map +1 -1
  15. package/dist/domain/workspace-cascade.js +1 -0
  16. package/dist/domain/workspace-cascade.js.map +1 -1
  17. package/dist/index.d.ts +4 -1
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +3 -1
  20. package/dist/index.js.map +1 -1
  21. package/dist/ports/agent-tool-calls.d.ts +50 -2
  22. package/dist/ports/agent-tool-calls.d.ts.map +1 -1
  23. package/dist/ports/agent-tools.d.ts +63 -1
  24. package/dist/ports/agent-tools.d.ts.map +1 -1
  25. package/dist/ports/audit.d.ts +139 -0
  26. package/dist/ports/audit.d.ts.map +1 -0
  27. package/dist/ports/audit.js +10 -0
  28. package/dist/ports/audit.js.map +1 -0
  29. package/dist/ports/index.d.ts +5 -2
  30. package/dist/ports/index.d.ts.map +1 -1
  31. package/dist/ports/index.js +1 -0
  32. package/dist/ports/index.js.map +1 -1
  33. package/dist/ports/mcp-oauth-repositories.d.ts +58 -0
  34. package/dist/ports/mcp-oauth-repositories.d.ts.map +1 -0
  35. package/dist/ports/mcp-oauth-repositories.js +18 -0
  36. package/dist/ports/mcp-oauth-repositories.js.map +1 -0
  37. package/package.json +2 -2
@@ -0,0 +1,58 @@
1
+ /** One workspace's sealed OAuth grant for one tool server. */
2
+ export interface McpOAuthGrantRecord {
3
+ workspaceId: string;
4
+ /** The tool server id the grant authorises (`McpServerDefinition.id`). */
5
+ serverId: string;
6
+ /**
7
+ * Sealed JSON of the token set: the access token, the refresh token when one was issued, the
8
+ * absolute expiry and the granted scope. Opaque to everything but `McpOAuthService`, which
9
+ * decrypts it to answer a dispatch and re-seals it after a refresh.
10
+ */
11
+ tokens: string;
12
+ /**
13
+ * Non-secret display summary as JSON (`McpOAuthGrantSummary`), so the operator surface can say
14
+ * what a board is connected to, when, by whom, and whether the last token exchange failed —
15
+ * without decrypting anything.
16
+ */
17
+ summary: string;
18
+ /**
19
+ * Optimistic-concurrency revision, bumped on every write. Two dispatches can reach an expired
20
+ * access token at the same instant and both try to refresh it; the rev is what makes one of them
21
+ * the writer and lets the other adopt the winner's tokens instead of overwriting them with a
22
+ * token set minted from a refresh token the server has already rotated away.
23
+ */
24
+ rev: number;
25
+ createdAt: number;
26
+ updatedAt: number;
27
+ }
28
+ export interface McpOAuthGrantRepository {
29
+ get(workspaceId: string, serverId: string): Promise<McpOAuthGrantRecord | null>;
30
+ /**
31
+ * Every grant a workspace holds.
32
+ *
33
+ * The read the operator surface uses, and the reason it exists rather than a `get` per row: the
34
+ * tool-server inventory renders one row per DECLARED server and each needs its connection state,
35
+ * so a per-server read there is an N+1 over a list whose length is the deployment's whole
36
+ * registry.
37
+ */
38
+ listByWorkspace(workspaceId: string): Promise<McpOAuthGrantRecord[]>;
39
+ /**
40
+ * Blind write, for the two paths whose semantics ARE last-writer-wins: completing an
41
+ * authorization (a human just granted, and what they granted supersedes whatever was stored) and
42
+ * the first mint of a client-credentials token. Inserts with the record's `rev`; on conflict the
43
+ * STORED rev is bumped in SQL, so it stays monotonic and a concurrent `compareAndSwap` whose
44
+ * base predates this write reliably loses.
45
+ */
46
+ upsert(record: McpOAuthGrantRecord): Promise<void>;
47
+ /**
48
+ * Rev-guarded conditional write, for the REFRESH path: persists `record` only if the stored row
49
+ * still carries `expectedRev`. `expectedRev: null` means "expect NO row" (a conflict-do-nothing
50
+ * insert). False ⇒ another writer refreshed first, and the caller re-reads and uses THEIR tokens
51
+ * rather than re-applying its own — a rotated refresh token makes the loser's token set the
52
+ * stale one, so "reload and re-apply" would replace a working grant with a dead one.
53
+ */
54
+ compareAndSwap(record: McpOAuthGrantRecord, expectedRev: number | null): Promise<boolean>;
55
+ /** Disconnect: drop the grant. The next dispatch reports the server as `oauth_not_connected`. */
56
+ delete(workspaceId: string, serverId: string): Promise<void>;
57
+ }
58
+ //# sourceMappingURL=mcp-oauth-repositories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-oauth-repositories.d.ts","sourceRoot":"","sources":["../../src/ports/mcp-oauth-repositories.ts"],"names":[],"mappings":"AAiBA,8DAA8D;AAC9D,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,MAAM,CAAA;IACnB,0EAA0E;IAC1E,QAAQ,EAAE,MAAM,CAAA;IAChB;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;;;;OAKG;IACH,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,uBAAuB;IACtC,GAAG,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAA;IAC/E;;;;;;;OAOG;IACH,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAAA;IACpE;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAClD;;;;;;OAMG;IACH,cAAc,CAAC,MAAM,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IACzF,iGAAiG;IACjG,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC7D"}
@@ -0,0 +1,18 @@
1
+ // Persistence port for the PER-WORKSPACE OAuth grants a remote (`http`) tool server needs — the
2
+ // tokens a board holds against a vendor's MCP server, and the machine tokens a client-credentials
3
+ // declaration mints on demand.
4
+ //
5
+ // Mirrors across the D1 (Cloudflare) and Drizzle/Postgres (Node) facades; runtime parity is
6
+ // mandatory. Values are sealed at rest by the facade's `SecretCipher` (info tag
7
+ // `cat-factory:mcp-oauth`), so the record carries the sealed blob and never a token — which is
8
+ // what lets it ride the mothership's persistence RPC, exactly like `CapabilityCredentialRepository`.
9
+ //
10
+ // ONE ROW PER (workspace, server), unlike the capability-credential store's one-blob-per-workspace.
11
+ // The shapes differ because the WRITES do: a credential row is edited by a human filling in a
12
+ // checklist, while a grant row is rewritten by a REFRESH on the dispatch path, and two dispatches
13
+ // refreshing two different servers at the same moment are the ordinary case rather than the
14
+ // pathological one. Per-server rows make those two writes touch different rows instead of
15
+ // contending on one; the rev then only has to settle a race between two refreshes of the SAME
16
+ // grant, which is what it is for.
17
+ export {};
18
+ //# sourceMappingURL=mcp-oauth-repositories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-oauth-repositories.js","sourceRoot":"","sources":["../../src/ports/mcp-oauth-repositories.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,kGAAkG;AAClG,+BAA+B;AAC/B,EAAE;AACF,4FAA4F;AAC5F,gFAAgF;AAChF,+FAA+F;AAC/F,qGAAqG;AACrG,EAAE;AACF,oGAAoG;AACpG,8FAA8F;AAC9F,kGAAkG;AAClG,4FAA4F;AAC5F,0FAA0F;AAC1F,8FAA8F;AAC9F,kCAAkC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cat-factory/kernel",
3
- "version": "0.243.1",
3
+ "version": "0.244.0",
4
4
  "description": "Shared vocabulary, pure logic, and port interfaces for the Agent Architecture Board.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,7 +26,7 @@
26
26
  "dependencies": {
27
27
  "ai": "^7.0.51",
28
28
  "yaml": "^2.9.0",
29
- "@cat-factory/contracts": "0.245.0"
29
+ "@cat-factory/contracts": "0.246.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@vitest/coverage-v8": "^4.1.10",