@aopslab/aops-server 0.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.
Files changed (185) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +6 -0
  3. package/README.md +21 -0
  4. package/aops-server-runtime.json +11 -0
  5. package/build/client/_app/immutable/chunks/2_TffmqH.js +1 -0
  6. package/build/client/_app/immutable/chunks/3DOfIKW0.js +1 -0
  7. package/build/client/_app/immutable/chunks/B2EkC-sy.js +1 -0
  8. package/build/client/_app/immutable/chunks/CMkIcmi1.js +2 -0
  9. package/build/client/_app/immutable/chunks/rqnVXeyB.js +1 -0
  10. package/build/client/_app/immutable/chunks/sZYZbj9W.js +1 -0
  11. package/build/client/_app/immutable/chunks/wbPk3Yxo.js +81 -0
  12. package/build/client/_app/immutable/entry/app.C7STLTX8.js +2 -0
  13. package/build/client/_app/immutable/entry/start.BC94hOaC.js +1 -0
  14. package/build/client/_app/immutable/nodes/0.BYBfjxZ5.js +1 -0
  15. package/build/client/_app/immutable/nodes/1.BNXFXajG.js +1 -0
  16. package/build/client/_app/version.json +1 -0
  17. package/build/env.js +70 -0
  18. package/build/env.js.map +1 -0
  19. package/build/handler.js +16 -0
  20. package/build/handler.js.map +1 -0
  21. package/build/index.js +139 -0
  22. package/build/index.js.map +1 -0
  23. package/build/server/chunks/0-RfB6m2nq.js +7 -0
  24. package/build/server/chunks/0-RfB6m2nq.js.map +1 -0
  25. package/build/server/chunks/1-_gg8Q0UT.js +9 -0
  26. package/build/server/chunks/1-_gg8Q0UT.js.map +1 -0
  27. package/build/server/chunks/_server.ts-6276EQIF.js +44 -0
  28. package/build/server/chunks/_server.ts-6276EQIF.js.map +1 -0
  29. package/build/server/chunks/_server.ts-B59WFQzX.js +174 -0
  30. package/build/server/chunks/_server.ts-B59WFQzX.js.map +1 -0
  31. package/build/server/chunks/_server.ts-BauJsLZI.js +40 -0
  32. package/build/server/chunks/_server.ts-BauJsLZI.js.map +1 -0
  33. package/build/server/chunks/_server.ts-BnGzJw2-.js +81 -0
  34. package/build/server/chunks/_server.ts-BnGzJw2-.js.map +1 -0
  35. package/build/server/chunks/_server.ts-CP7qM24V.js +34 -0
  36. package/build/server/chunks/_server.ts-CP7qM24V.js.map +1 -0
  37. package/build/server/chunks/_server.ts-Cbq_u99d.js +9 -0
  38. package/build/server/chunks/_server.ts-Cbq_u99d.js.map +1 -0
  39. package/build/server/chunks/_server.ts-Ch8fPT-o.js +92 -0
  40. package/build/server/chunks/_server.ts-Ch8fPT-o.js.map +1 -0
  41. package/build/server/chunks/_server.ts-Cv-yaXZI.js +7 -0
  42. package/build/server/chunks/_server.ts-Cv-yaXZI.js.map +1 -0
  43. package/build/server/chunks/_server.ts-D6lBwOON.js +34 -0
  44. package/build/server/chunks/_server.ts-D6lBwOON.js.map +1 -0
  45. package/build/server/chunks/_server.ts-D84K3pp9.js +11 -0
  46. package/build/server/chunks/_server.ts-D84K3pp9.js.map +1 -0
  47. package/build/server/chunks/_server.ts-DNzU1ToA.js +277 -0
  48. package/build/server/chunks/_server.ts-DNzU1ToA.js.map +1 -0
  49. package/build/server/chunks/_server.ts-DQQnw77t.js +17 -0
  50. package/build/server/chunks/_server.ts-DQQnw77t.js.map +1 -0
  51. package/build/server/chunks/_server.ts-DSxr5l15.js +18 -0
  52. package/build/server/chunks/_server.ts-DSxr5l15.js.map +1 -0
  53. package/build/server/chunks/_server.ts-DZYokvuR.js +80 -0
  54. package/build/server/chunks/_server.ts-DZYokvuR.js.map +1 -0
  55. package/build/server/chunks/_server.ts-Dcqwpz2t.js +144 -0
  56. package/build/server/chunks/_server.ts-Dcqwpz2t.js.map +1 -0
  57. package/build/server/chunks/_server.ts-Di9VJnF4.js +81 -0
  58. package/build/server/chunks/_server.ts-Di9VJnF4.js.map +1 -0
  59. package/build/server/chunks/_server.ts-FBEHFT8b.js +33 -0
  60. package/build/server/chunks/_server.ts-FBEHFT8b.js.map +1 -0
  61. package/build/server/chunks/_server.ts-gZytCuiJ.js +10 -0
  62. package/build/server/chunks/_server.ts-gZytCuiJ.js.map +1 -0
  63. package/build/server/chunks/_server.ts-tNULLyEO.js +261 -0
  64. package/build/server/chunks/_server.ts-tNULLyEO.js.map +1 -0
  65. package/build/server/chunks/agent-gateway-runtime-DTZ4SxaC.js +2598 -0
  66. package/build/server/chunks/agent-gateway-runtime-DTZ4SxaC.js.map +1 -0
  67. package/build/server/chunks/aops-runtime-config-wpVmg7T-.js +179 -0
  68. package/build/server/chunks/aops-runtime-config-wpVmg7T-.js.map +1 -0
  69. package/build/server/chunks/discovery-D9JnSgfu.js +894 -0
  70. package/build/server/chunks/discovery-D9JnSgfu.js.map +1 -0
  71. package/build/server/chunks/error.svelte-DgUOqi-L.js +45 -0
  72. package/build/server/chunks/error.svelte-DgUOqi-L.js.map +1 -0
  73. package/build/server/chunks/handler-BN3-p5rP.js +1733 -0
  74. package/build/server/chunks/handler-BN3-p5rP.js.map +1 -0
  75. package/build/server/chunks/hooks.server-C4wxiH5m.js +52 -0
  76. package/build/server/chunks/hooks.server-C4wxiH5m.js.map +1 -0
  77. package/build/server/chunks/index.js-nbqdVuWC.js +10698 -0
  78. package/build/server/chunks/index.js-nbqdVuWC.js.map +1 -0
  79. package/build/server/chunks/manifest.js-_Re-Wj-y.js +167 -0
  80. package/build/server/chunks/manifest.js-_Re-Wj-y.js.map +1 -0
  81. package/build/server/chunks/plugin-error-normalize-Bq14Qbz3.js +297 -0
  82. package/build/server/chunks/plugin-error-normalize-Bq14Qbz3.js.map +1 -0
  83. package/build/server/chunks/project-alias-DqE2v58Q.js +29 -0
  84. package/build/server/chunks/project-alias-DqE2v58Q.js.map +1 -0
  85. package/build/server/chunks/registry-5amIZito.js +289 -0
  86. package/build/server/chunks/registry-5amIZito.js.map +1 -0
  87. package/build/server/chunks/request-base-url-BDdrsaga.js +24 -0
  88. package/build/server/chunks/request-base-url-BDdrsaga.js.map +1 -0
  89. package/build/server/chunks/request-context-tNeFQjgb.js +422 -0
  90. package/build/server/chunks/request-context-tNeFQjgb.js.map +1 -0
  91. package/build/server/chunks/xf-result-BRDjvftr.js +17 -0
  92. package/build/server/chunks/xf-result-BRDjvftr.js.map +1 -0
  93. package/build/shims.js +33 -0
  94. package/build/shims.js.map +1 -0
  95. package/cockpit/.vite/manifest.json +198 -0
  96. package/cockpit/assets/dm-sans-latin-400-normal-BwCSEQnW.woff +0 -0
  97. package/cockpit/assets/dm-sans-latin-400-normal-CW0RaeGs.woff2 +0 -0
  98. package/cockpit/assets/dm-sans-latin-500-normal-B9HHJjqV.woff2 +0 -0
  99. package/cockpit/assets/dm-sans-latin-500-normal-Dr3UlScf.woff +0 -0
  100. package/cockpit/assets/dm-sans-latin-700-normal-CUSSCpQX.woff +0 -0
  101. package/cockpit/assets/dm-sans-latin-700-normal-DvUfVpUG.woff2 +0 -0
  102. package/cockpit/assets/dm-sans-latin-ext-400-normal-BjWJ59Pq.woff +0 -0
  103. package/cockpit/assets/dm-sans-latin-ext-400-normal-BtiwyxMk.woff2 +0 -0
  104. package/cockpit/assets/dm-sans-latin-ext-500-normal-BJfUCQsA.woff2 +0 -0
  105. package/cockpit/assets/dm-sans-latin-ext-500-normal-DR84L5F-.woff +0 -0
  106. package/cockpit/assets/dm-sans-latin-ext-700-normal-BLI3TTWz.woff +0 -0
  107. package/cockpit/assets/dm-sans-latin-ext-700-normal-CJIcxD6K.woff2 +0 -0
  108. package/cockpit/assets/index-DDswO4B1.css +1 -0
  109. package/cockpit/assets/index-bovtnZ98.js +18 -0
  110. package/cockpit/assets/jetbrains-mono-cyrillic-400-normal-BEIGL1Tu.woff2 +0 -0
  111. package/cockpit/assets/jetbrains-mono-cyrillic-400-normal-ugxPyKxw.woff +0 -0
  112. package/cockpit/assets/jetbrains-mono-greek-400-normal-B9oWc5Lo.woff +0 -0
  113. package/cockpit/assets/jetbrains-mono-greek-400-normal-C190GLew.woff2 +0 -0
  114. package/cockpit/assets/jetbrains-mono-latin-400-normal-6-qcROiO.woff +0 -0
  115. package/cockpit/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
  116. package/cockpit/assets/jetbrains-mono-latin-ext-400-normal-Bc8Ftmh3.woff2 +0 -0
  117. package/cockpit/assets/jetbrains-mono-latin-ext-400-normal-fXTG6kC5.woff +0 -0
  118. package/cockpit/assets/jetbrains-mono-vietnamese-400-normal-CqNFfHCs.woff +0 -0
  119. package/cockpit/assets/outfit-latin-400-normal-BGsTXAXT.woff2 +0 -0
  120. package/cockpit/assets/outfit-latin-400-normal-DMwTpYkH.woff +0 -0
  121. package/cockpit/assets/outfit-latin-600-normal-B7SfZ07L.woff2 +0 -0
  122. package/cockpit/assets/outfit-latin-600-normal-BEfTtDA7.woff +0 -0
  123. package/cockpit/assets/outfit-latin-ext-400-normal-5tcqmc2S.woff2 +0 -0
  124. package/cockpit/assets/outfit-latin-ext-400-normal-DHm7mdGe.woff +0 -0
  125. package/cockpit/assets/outfit-latin-ext-600-normal-B85nYjL1.woff2 +0 -0
  126. package/cockpit/assets/outfit-latin-ext-600-normal-CWJcPgd7.woff +0 -0
  127. package/cockpit/assets/unbounded-cyrillic-600-normal-B-s5c2Kn.woff +0 -0
  128. package/cockpit/assets/unbounded-cyrillic-600-normal-DW6uzIMB.woff2 +0 -0
  129. package/cockpit/assets/unbounded-latin-600-normal-BPdB_PEv.woff +0 -0
  130. package/cockpit/assets/unbounded-latin-600-normal-oRSANpZr.woff2 +0 -0
  131. package/cockpit/assets/unbounded-latin-ext-600-normal-0iZLtTDV.woff2 +0 -0
  132. package/cockpit/assets/unbounded-latin-ext-600-normal-ClMPf-bu.woff +0 -0
  133. package/cockpit/assets/unbounded-vietnamese-600-normal-BzfrgZ_C.woff +0 -0
  134. package/cockpit/assets/unbounded-vietnamese-600-normal-Cx2bTSHN.woff2 +0 -0
  135. package/cockpit/community.module-inventory.json +2389 -0
  136. package/cockpit/index.html +14 -0
  137. package/community-postgres.json +13 -0
  138. package/migrations/agentspace/0000_thin_carlie_cooper.sql +764 -0
  139. package/migrations/agentspace/meta/0000_snapshot.json +6885 -0
  140. package/migrations/agentspace/meta/_journal.json +13 -0
  141. package/migrations/chatv3/0000_dry_ego.sql +218 -0
  142. package/migrations/chatv3/0001_nosy_obadiah_stane.sql +35 -0
  143. package/migrations/chatv3/0002_narrow_darkhawk.sql +4 -0
  144. package/migrations/chatv3/0003_damp_zarek.sql +2 -0
  145. package/migrations/chatv3/0004_nervous_martin_li.sql +60 -0
  146. package/migrations/chatv3/0005_chatv3_server_encrypted_mode.sql +1 -0
  147. package/migrations/chatv3/meta/0000_snapshot.json +1887 -0
  148. package/migrations/chatv3/meta/0001_snapshot.json +2175 -0
  149. package/migrations/chatv3/meta/0002_snapshot.json +2229 -0
  150. package/migrations/chatv3/meta/0003_snapshot.json +2241 -0
  151. package/migrations/chatv3/meta/0004_snapshot.json +2746 -0
  152. package/migrations/chatv3/meta/_journal.json +48 -0
  153. package/migrations/docman/0000_curvy_valeria_richards.sql +257 -0
  154. package/migrations/docman/0001_massive_risque.sql +2 -0
  155. package/migrations/docman/0002_simple_logan.sql +50 -0
  156. package/migrations/docman/0003_quick_index.sql +45 -0
  157. package/migrations/docman/0004_known_summary.sql +9 -0
  158. package/migrations/docman/0005_vector_signal.sql +9 -0
  159. package/migrations/docman/0006_document_version_current_invariant.sql +15 -0
  160. package/migrations/docman/meta/_journal.json +55 -0
  161. package/migrations/projectman/0000_smooth_klaw.sql +257 -0
  162. package/migrations/projectman/0001_worthless_zodiak.sql +9 -0
  163. package/migrations/projectman/0002_board_rename.sql +108 -0
  164. package/migrations/projectman/0003_review_request.sql +62 -0
  165. package/migrations/projectman/0004_review_request_idempotency.sql +3 -0
  166. package/migrations/projectman/0005_allow_multi_sprint_per_task.sql +1 -0
  167. package/migrations/projectman/meta/_journal.json +48 -0
  168. package/migrations/sys/0000_loose_praxagora.sql +31 -0
  169. package/migrations/sys/0001_awesome_ronan.sql +2 -0
  170. package/migrations/sys/0002_steady_maximus.sql +2 -0
  171. package/migrations/sys/0003_escalating_rate_limiter.sql +2 -0
  172. package/migrations/sys/0004_rate_limiter_timestamptz.sql +22 -0
  173. package/migrations/sys/0005_sys_counters.sql +21 -0
  174. package/migrations/sys/meta/_journal.json +48 -0
  175. package/npm-shrinkwrap.json +4375 -0
  176. package/package.json +62 -0
  177. package/runtime/agentspace-host-adapter.mjs +64 -0
  178. package/runtime/agentspace-tooling.mjs +389 -0
  179. package/runtime/docman-host-adapter.mjs +177 -0
  180. package/runtime/docman-policy.mjs +450 -0
  181. package/runtime/docman-tooling.mjs +20 -0
  182. package/runtime/projectman-host-adapter.mjs +597 -0
  183. package/runtime/scope-context.mjs +99 -0
  184. package/scripts/community-host.mjs +626 -0
  185. package/scripts/community-migration-policy-v1.json +296 -0
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@aopslab/aops-server",
3
+ "version": "0.1.0",
4
+ "description": "AOPS Community loopback server.",
5
+ "keywords": [
6
+ "aops",
7
+ "ai-operations",
8
+ "server"
9
+ ],
10
+ "license": "Apache-2.0",
11
+ "type": "module",
12
+ "main": "scripts/community-host.mjs",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/eeemzs/aops-community.git",
16
+ "directory": "apps/aops-server"
17
+ },
18
+ "engines": {
19
+ "node": ">=22.9.0"
20
+ },
21
+ "packageManager": "pnpm@11.9.0",
22
+ "aopsSource": {
23
+ "repository": "https://github.com/eeemzs/aops-community",
24
+ "commit": "c04eead7a23aee089eab02942764b0672fc41d71"
25
+ },
26
+ "scripts": {
27
+ "start": "node ./scripts/community-host.mjs"
28
+ },
29
+ "dependencies": {
30
+ "@aopslab/domain-host-plugin-agentspace": "0.1.1",
31
+ "@aopslab/domain-host-plugin-chatv3": "0.1.1",
32
+ "@aopslab/domain-host-plugin-docman": "0.1.4",
33
+ "@aopslab/domain-host-plugin-projectman": "0.0.4",
34
+ "@aopslab/domain-host-plugin-sys": "0.0.6",
35
+ "@aopslab/domain-kit-agentspace": "0.1.1",
36
+ "@aopslab/domain-kit-chatv3": "0.1.1",
37
+ "@aopslab/domain-kit-docman": "0.1.4",
38
+ "@aopslab/domain-kit-projectman": "0.1.5",
39
+ "@aopslab/domain-kit-sys": "0.0.5",
40
+ "@aopslab/domain-pg-bootstrap-chatv3": "0.1.1",
41
+ "@aopslab/domain-pg-bootstrap-docman": "0.1.0",
42
+ "@aopslab/domain-pg-bootstrap-projectman": "0.1.0",
43
+ "@aopslab/domain-pg-bootstrap-sys": "0.1.0",
44
+ "@aopslab/domain-product-docman": "0.1.0",
45
+ "@aopslab/domain-product-projectman": "0.1.1",
46
+ "@aopslab/domain-runtime-config-docman": "0.1.0",
47
+ "@aopslab/domain-runtime-config-projectman": "0.1.0",
48
+ "@aopslab/host-adapter-sveltekit": "0.1.1",
49
+ "@aopslab/host-core": "0.1.1",
50
+ "@aopslab/manifest": "0.1.3",
51
+ "@aopslab/xf-dm-kits": "0.1.14",
52
+ "@aopslab/xf-logger": "0.1.61",
53
+ "ajv": "8.18.0",
54
+ "effect": "3.20.0",
55
+ "pg": "8.20.0",
56
+ "zod": "4.4.3"
57
+ },
58
+ "publishConfig": {
59
+ "access": "public",
60
+ "registry": "https://registry.npmjs.org"
61
+ }
62
+ }
@@ -0,0 +1,64 @@
1
+ // Generated during the public source projection.
2
+ // The base plugin retains input validation/runtime setup; this adapter only narrows its manifest and execution gate.
3
+ import { createAgentspacePlugin as createBaseAgentspacePlugin } from '@aopslab/domain-host-plugin-agentspace';
4
+ import {
5
+ COMMUNITY_AGENTSPACE_ALLOWED_RESOURCE_IDS,
6
+ buildCommunityAgentspaceProjection,
7
+ filterCommunityAgentspaceHostRouteProjection,
8
+ } from './agentspace-tooling.mjs';
9
+
10
+ const normalizeId = (value) => String(value ?? '').trim().toLowerCase();
11
+
12
+ export function createCommunityAgentspacePlugin(options = {}) {
13
+ const projection = buildCommunityAgentspaceProjection({
14
+ refresh: options.refreshProjectionOnCreate === true,
15
+ includeDocs: true,
16
+ });
17
+ const allowedOperationIds = new Set(projection.operationIds);
18
+ const basePlugin = createBaseAgentspacePlugin(options);
19
+ const baseRoutes = Array.isArray(basePlugin?.manifest?.routes) ? basePlugin.manifest.routes : [];
20
+ const routes = filterCommunityAgentspaceHostRouteProjection(baseRoutes, {
21
+ expectedSourceRoutes: projection.sourceRoutes,
22
+ });
23
+ const baseHealth = basePlugin.health;
24
+ const baseExecute = basePlugin.execute;
25
+ if (typeof baseExecute !== 'function') throw new Error('community_agentspace_base_execute_missing');
26
+ return {
27
+ ...basePlugin,
28
+ capabilities: [...COMMUNITY_AGENTSPACE_ALLOWED_RESOURCE_IDS],
29
+ manifest: {
30
+ ...basePlugin.manifest,
31
+ routes,
32
+ meta: {
33
+ ...(basePlugin.manifest?.meta ?? {}),
34
+ adapter: 'aops-community-agentspace-filter-v1',
35
+ capabilityProjection: './agentspace-tooling.mjs#buildCommunityAgentspaceProjection',
36
+ sourceOperationCount: projection.sourceOperationIds.length,
37
+ operationCount: projection.operationIds.length,
38
+ resourceCount: projection.resourceIds.length,
39
+ unclassifiedResourceIds: projection.unclassifiedResourceIds,
40
+ },
41
+ },
42
+ health: typeof baseHealth === "function" ? async () => {
43
+ const result = await baseHealth();
44
+ return {
45
+ ...result,
46
+ details: {
47
+ ...(result?.details ?? {}),
48
+ routesCount: routes.length,
49
+ communitySourceRoutesCount: baseRoutes.length,
50
+ communityResourceCount: projection.resourceIds.length,
51
+ },
52
+ };
53
+ } : baseHealth,
54
+ execute: async (args) => {
55
+ const operationId = normalizeId(args?.match?.route?.operation);
56
+ if (!allowedOperationIds.has(operationId)) {
57
+ throw new Error('operation_route_not_found:agentspace:' + (operationId || 'missing'));
58
+ }
59
+ return baseExecute(args);
60
+ },
61
+ };
62
+ }
63
+
64
+ export const createAgentspacePlugin = createCommunityAgentspacePlugin;
@@ -0,0 +1,389 @@
1
+ // Generated during the public source projection.
2
+ // Community projection: canonical Agentspace DCM remains the source; this module is a fail-closed projection.
3
+ import {
4
+ buildAgentspaceDomainCapabilityManifest as buildBaseAgentspaceDomainCapabilityManifest,
5
+ buildAgentspaceHostRouteProjection as buildBaseAgentspaceHostRouteProjection,
6
+ } from '@aopslab/domain-kit-agentspace';
7
+
8
+ export const COMMUNITY_AGENTSPACE_ALLOWED_RESOURCE_IDS = Object.freeze([
9
+ "activity-item",
10
+ "agent-profile",
11
+ "artifact",
12
+ "artifact-link",
13
+ "chat",
14
+ "chat-binding",
15
+ "chat-member",
16
+ "chat-message",
17
+ "chat-room",
18
+ "discussion-output",
19
+ "discussion-topic",
20
+ "discussion-turn",
21
+ "experience-item",
22
+ "memory-item",
23
+ "mission",
24
+ "official-catalog",
25
+ "playbook",
26
+ "project",
27
+ "prompt",
28
+ "prompt-version",
29
+ "resource",
30
+ "skill",
31
+ "skill-version",
32
+ "tag"
33
+ ]);
34
+ export const COMMUNITY_AGENTSPACE_DENIED_RESOURCE_IDS = Object.freeze([
35
+ "agent-run",
36
+ "agent-run-event",
37
+ "agent-session",
38
+ "codex-chat-message",
39
+ "codex-chat-setting",
40
+ "codex-chat-thread",
41
+ "project-member",
42
+ "project-path",
43
+ "workflow-definition",
44
+ "workflow-instance",
45
+ "workflow-step-run"
46
+ ]);
47
+ export const COMMUNITY_AGENTSPACE_REVIEWED_UNCLASSIFIED_RESOURCE_IDS = Object.freeze([
48
+ "kanban-board",
49
+ "kanban-column",
50
+ "sprint",
51
+ "sprint-item",
52
+ "task",
53
+ "task-comment"
54
+ ]);
55
+ export const COMMUNITY_AGENTSPACE_DENIED_OPERATION_IDS = Object.freeze([
56
+ "project.delete-cascade",
57
+ "skill-version.import-skill-package",
58
+ "skill-version.materialize-skill-package"
59
+ ]);
60
+ export const COMMUNITY_AGENTSPACE_AGENT_ASSET_OPERATION_IDS = Object.freeze([
61
+ "skill.ask",
62
+ "skill.search",
63
+ "skill-version.export-skill-package",
64
+ "official-catalog.inspect",
65
+ "official-catalog.reconcile",
66
+ "official-catalog.rollback"
67
+ ]);
68
+ export const COMMUNITY_AGENTSPACE_ALLOWED_OPERATION_IDS = Object.freeze([
69
+ "activity-item.add-activity-item",
70
+ "activity-item.get-by-id",
71
+ "activity-item.list-activity-items",
72
+ "agent-profile.create",
73
+ "agent-profile.delete",
74
+ "agent-profile.get-by-id",
75
+ "agent-profile.list",
76
+ "agent-profile.update",
77
+ "artifact-link.create",
78
+ "artifact-link.get-by-id",
79
+ "artifact-link.link-artifact",
80
+ "artifact-link.list-artifact-links",
81
+ "artifact.create",
82
+ "artifact.get-artifact",
83
+ "artifact.get-by-id",
84
+ "artifact.link-artifact",
85
+ "artifact.list-artifacts",
86
+ "artifact.list-artifacts-by-ref",
87
+ "artifact.remove-artifact",
88
+ "artifact.store-artifact",
89
+ "chat-binding.add",
90
+ "chat-binding.remove",
91
+ "chat-member.add",
92
+ "chat-member.remove",
93
+ "chat-member.update",
94
+ "chat-message.list",
95
+ "chat-message.send",
96
+ "chat-room.archive",
97
+ "chat-room.create",
98
+ "chat-room.export-manifest",
99
+ "chat-room.get-by-id",
100
+ "chat-room.list",
101
+ "chat-room.open-dm",
102
+ "chat-room.update",
103
+ "chat.catchup",
104
+ "chat.mark-read",
105
+ "discussion-output.set",
106
+ "discussion-topic.abandon",
107
+ "discussion-topic.conclude",
108
+ "discussion-topic.create",
109
+ "discussion-topic.get",
110
+ "discussion-topic.list",
111
+ "discussion-topic.status",
112
+ "discussion-turn.add",
113
+ "experience-item.add-experience-item",
114
+ "experience-item.create",
115
+ "experience-item.get-by-id",
116
+ "experience-item.get-experience-item",
117
+ "experience-item.list-experience-items",
118
+ "experience-item.remove-experience-item",
119
+ "experience-item.update-experience-item",
120
+ "memory-item.add-memory-item",
121
+ "memory-item.build-resume-pack",
122
+ "memory-item.build-synopsis",
123
+ "memory-item.create",
124
+ "memory-item.get-by-id",
125
+ "memory-item.list-memory-items",
126
+ "memory-item.promote-from-experience",
127
+ "memory-item.remove-memory-item",
128
+ "memory-item.search-memory-items",
129
+ "memory-item.set-memory-importance",
130
+ "memory-item.update-memory-item",
131
+ "mission.create",
132
+ "mission.delete",
133
+ "mission.get",
134
+ "mission.list",
135
+ "mission.resume",
136
+ "mission.update",
137
+ "official-catalog.inspect",
138
+ "official-catalog.reconcile",
139
+ "official-catalog.rollback",
140
+ "playbook.list",
141
+ "project.archive-project",
142
+ "project.create",
143
+ "project.get-by-id",
144
+ "project.get-project",
145
+ "project.list-projects",
146
+ "project.remove-project",
147
+ "project.set-project-type",
148
+ "project.set-project-visibility",
149
+ "project.update-project",
150
+ "prompt-version.create",
151
+ "prompt-version.get-by-id",
152
+ "prompt-version.get-prompt-version",
153
+ "prompt-version.list-prompt-versions",
154
+ "prompt-version.publish-prompt-version",
155
+ "prompt-version.remove-prompt-version",
156
+ "prompt-version.update-prompt-version",
157
+ "prompt.create",
158
+ "prompt.get-by-id",
159
+ "prompt.get-prompt",
160
+ "prompt.list-prompts",
161
+ "prompt.remove-prompt",
162
+ "prompt.update-prompt",
163
+ "resource.create",
164
+ "resource.create-resource",
165
+ "resource.get-by-id",
166
+ "resource.get-resource",
167
+ "resource.list-resources",
168
+ "resource.remove-resource",
169
+ "resource.update-resource",
170
+ "skill-version.create",
171
+ "skill-version.export-skill-package",
172
+ "skill-version.get-by-id",
173
+ "skill-version.get-skill-version",
174
+ "skill-version.list-skill-versions",
175
+ "skill-version.publish-skill-version",
176
+ "skill-version.remove-skill-version",
177
+ "skill-version.update-skill-version",
178
+ "skill.ask",
179
+ "skill.create",
180
+ "skill.get-by-id",
181
+ "skill.get-skill",
182
+ "skill.list-skills",
183
+ "skill.remove-skill",
184
+ "skill.search",
185
+ "skill.update-skill",
186
+ "tag.create",
187
+ "tag.ensure-tags",
188
+ "tag.get-by-id",
189
+ "tag.list-tags",
190
+ "tag.search-tags"
191
+ ]);
192
+
193
+ const EXPECTED_SOURCE_OPERATION_COUNT = 178;
194
+ const ALLOWED_RESOURCE_SET = new Set(COMMUNITY_AGENTSPACE_ALLOWED_RESOURCE_IDS);
195
+ const DENIED_RESOURCE_SET = new Set(COMMUNITY_AGENTSPACE_DENIED_RESOURCE_IDS);
196
+ const DENIED_OPERATION_SET = new Set(COMMUNITY_AGENTSPACE_DENIED_OPERATION_IDS);
197
+ const ALLOWED_OPERATION_SET = new Set(COMMUNITY_AGENTSPACE_ALLOWED_OPERATION_IDS);
198
+ const COMMUNITY_DOMAIN_DESCRIPTION = "Community context services for projects, prompts, skills, memory, rooms, discussions, missions, playbooks, experiences, resources, artifacts, profiles, tags, and activity items.";
199
+ const COMMUNITY_DOMAIN_DOCS = Object.freeze({"summary":"Manage the reviewed Community Agentspace surface for projects, reusable context, coordination rooms, discussions, missions, and activity records.","notes":["This Community projection is an exact operation and schema allowlist.","Skill discovery and immutable published-package export are read-only; package import and server filesystem materialization are not exposed.","Project cascade deletion and private runtime/session records are not exposed."]});
200
+ const normalizeId = (value) => String(value ?? '').trim().toLowerCase();
201
+ const codepointCompare = (left, right) => left < right ? -1 : left > right ? 1 : 0;
202
+ const sorted = (values) => [...values].sort(codepointCompare);
203
+ const toRecord = (value) => value && typeof value === 'object' && !Array.isArray(value) ? value : {};
204
+
205
+ function exactSet(label, actual, expected) {
206
+ const left = sorted(actual.map(normalizeId).filter(Boolean));
207
+ const right = sorted(expected.map(normalizeId).filter(Boolean));
208
+ if (new Set(left).size !== left.length || new Set(right).size !== right.length || left.length !== right.length || !left.every((value, index) => value === right[index])) {
209
+ throw new Error('community_agentspace_set_mismatch:' + label + ':expected=' + right.join(',') + ':actual=' + left.join(','));
210
+ }
211
+ }
212
+
213
+ function resolveResourceId(operation) {
214
+ for (const tag of Array.isArray(operation?.tags) ? operation.tags : []) {
215
+ const normalized = normalizeId(tag);
216
+ if (normalized.startsWith('resource:')) return normalizeId(normalized.slice('resource:'.length));
217
+ }
218
+ return normalizeId(operation?.resourceId ?? operation?.serviceEntity);
219
+ }
220
+
221
+ const decodePointerToken = (value) => String(value).replace(/~1/g, '/').replace(/~0/g, '~');
222
+ function resolveTopLevelSchemaRef(value, available) {
223
+ const raw = typeof value === 'string' ? value.trim() : '';
224
+ if (!raw) return null;
225
+ if (available.has(raw)) return raw;
226
+ for (const prefix of ['#/contracts/schemas/', '#/components/schemas/']) {
227
+ if (!raw.startsWith(prefix)) continue;
228
+ const name = decodePointerToken(raw.slice(prefix.length));
229
+ if (!available.has(name)) throw new Error('community_agentspace_schema_ref_missing:' + name);
230
+ return name;
231
+ }
232
+ if (raw.startsWith('#/')) return null;
233
+ throw new Error('community_agentspace_external_schema_ref_forbidden:' + raw);
234
+ }
235
+ function collectSchemaRefs(value, available, output) {
236
+ if (Array.isArray(value)) { for (const item of value) collectSchemaRefs(item, available, output); return; }
237
+ if (!value || typeof value !== 'object') return;
238
+ for (const [key, child] of Object.entries(value)) {
239
+ if (key === '$ref') { const name = resolveTopLevelSchemaRef(child, available); if (name) output.add(name); continue; }
240
+ collectSchemaRefs(child, available, output);
241
+ }
242
+ }
243
+ function projectSchemas(operations, contracts) {
244
+ const sourceSchemas = toRecord(toRecord(contracts).schemas);
245
+ const available = new Set(Object.keys(sourceSchemas));
246
+ const retained = new Set();
247
+ for (const operation of operations) {
248
+ for (const ref of [operation?.inputSchemaRef, operation?.outputSchemaRef]) {
249
+ const name = typeof ref === 'string' ? ref.trim() : '';
250
+ if (!name) continue;
251
+ if (!available.has(name)) throw new Error('community_agentspace_operation_schema_missing:' + operation.operationId + ':' + name);
252
+ retained.add(name);
253
+ }
254
+ }
255
+ const queue = [...retained];
256
+ for (let index = 0; index < queue.length; index += 1) {
257
+ const discovered = new Set();
258
+ collectSchemaRefs(sourceSchemas[queue[index]], available, discovered);
259
+ for (const name of discovered) { if (!retained.has(name)) { retained.add(name); queue.push(name); } }
260
+ }
261
+ const names = sorted(retained);
262
+ return { names, schemas: Object.fromEntries(names.map((name) => [name, sourceSchemas[name]])) };
263
+ }
264
+ function routeList(value) { return Array.isArray(value) ? value : (Array.isArray(value?.routes) ? value.routes : []); }
265
+ function routeSignature(route) {
266
+ const signature = { id: String(route?.id ?? '').trim(), method: String(route?.method ?? '').trim().toUpperCase(), pattern: String(route?.pattern ?? '').trim(), operation: normalizeId(route?.operation) };
267
+ if (Object.values(signature).some((value) => !value)) throw new Error('community_agentspace_route_signature_invalid');
268
+ return signature;
269
+ }
270
+ function exactRoutes(label, actualRoutes, expectedRoutes) {
271
+ const actual = sorted(actualRoutes.map((route) => JSON.stringify(routeSignature(route))));
272
+ const expected = sorted(expectedRoutes.map((route) => JSON.stringify(routeSignature(route))));
273
+ if (new Set(actual).size !== actual.length || new Set(expected).size !== expected.length || actual.length !== expected.length || actual.some((value, index) => value !== expected[index])) throw new Error('community_agentspace_route_signature_mismatch:' + label);
274
+ }
275
+
276
+ export function inspectCommunityAgentspaceProjection(manifest) {
277
+ const operations = Array.isArray(manifest?.capabilities?.operations) ? manifest.capabilities.operations : [];
278
+ const resources = Array.isArray(manifest?.capabilities?.resources) ? manifest.capabilities.resources : [];
279
+ const sourceOperationIds = operations.map((operation) => normalizeId(operation?.operationId));
280
+ if (sourceOperationIds.some((operationId) => !operationId) || new Set(sourceOperationIds).size !== sourceOperationIds.length) throw new Error('community_agentspace_manifest_operation_identity_invalid');
281
+ const declaredResourceIds = resources.map((resource) => normalizeId(resource?.resourceId));
282
+ if (declaredResourceIds.some((resourceId) => !resourceId) || new Set(declaredResourceIds).size !== declaredResourceIds.length) throw new Error('community_agentspace_manifest_resource_identity_invalid');
283
+ const policyOperationIds = Object.keys(toRecord(manifest?.policies?.operations)).map(normalizeId);
284
+ const docsOperationIds = Object.keys(toRecord(manifest?.docs?.operations)).map(normalizeId);
285
+ const docsResourceIds = Object.keys(toRecord(manifest?.docs?.resources)).map(normalizeId);
286
+ const rows = operations.map((operation) => ({ operation, operationId: normalizeId(operation.operationId), resourceId: resolveResourceId(operation) }));
287
+ const projectedRows = rows.filter((row) => ALLOWED_OPERATION_SET.has(row.operationId) && ALLOWED_RESOURCE_SET.has(row.resourceId) && !DENIED_OPERATION_SET.has(row.operationId));
288
+ const projectedOperationIds = sorted(projectedRows.map((row) => row.operationId));
289
+ const projectedResourceIds = sorted(new Set(projectedRows.map((row) => row.resourceId)));
290
+ const missingAllowedOperationIds = sorted(COMMUNITY_AGENTSPACE_ALLOWED_OPERATION_IDS.filter((operationId) => !projectedOperationIds.includes(operationId)));
291
+ const unreviewedOperationIds = sorted(rows.filter((row) => ALLOWED_RESOURCE_SET.has(row.resourceId) && !ALLOWED_OPERATION_SET.has(row.operationId) && !DENIED_OPERATION_SET.has(row.operationId)).map((row) => row.operationId));
292
+ const deniedOperationIds = sorted(rows.filter((row) => DENIED_OPERATION_SET.has(row.operationId)).map((row) => row.operationId));
293
+ const deniedResourceIds = sorted(new Set(rows.filter((row) => DENIED_RESOURCE_SET.has(row.resourceId)).map((row) => row.resourceId)));
294
+ const unclassifiedResourceIds = sorted(new Set(rows.filter((row) => row.resourceId && !ALLOWED_RESOURCE_SET.has(row.resourceId) && !DENIED_RESOURCE_SET.has(row.resourceId)).map((row) => row.resourceId)));
295
+ return {
296
+ sourceOperationIds: sorted(sourceOperationIds),
297
+ sourceResourceIds: sorted(new Set(rows.map((row) => row.resourceId).filter(Boolean))),
298
+ declaredResourceIds: sorted(declaredResourceIds), policyOperationIds: sorted(policyOperationIds), docsOperationIds: sorted(docsOperationIds), docsResourceIds: sorted(docsResourceIds),
299
+ projectedOperationIds, projectedResourceIds, missingAllowedOperationIds, unreviewedOperationIds, deniedOperationIds, deniedResourceIds, unclassifiedResourceIds,
300
+ };
301
+ }
302
+
303
+ function assertReviewedInventory(inventory) {
304
+ if (inventory.sourceOperationIds.length !== EXPECTED_SOURCE_OPERATION_COUNT) throw new Error('community_agentspace_source_operation_count_drift:' + inventory.sourceOperationIds.length);
305
+ exactSet('source_resources', inventory.sourceResourceIds, [...COMMUNITY_AGENTSPACE_ALLOWED_RESOURCE_IDS, ...COMMUNITY_AGENTSPACE_DENIED_RESOURCE_IDS]);
306
+ exactSet('declared_resources', inventory.declaredResourceIds, inventory.sourceResourceIds);
307
+ exactSet('docs_operations', inventory.docsOperationIds, inventory.sourceOperationIds);
308
+ exactSet('docs_resources', inventory.docsResourceIds, inventory.sourceResourceIds);
309
+ const sourceOperationSet = new Set(inventory.sourceOperationIds);
310
+ const unknownPolicyOperationIds = inventory.policyOperationIds.filter((operationId) => !sourceOperationSet.has(operationId));
311
+ if (unknownPolicyOperationIds.length > 0) throw new Error('community_agentspace_unknown_policy_operations:' + unknownPolicyOperationIds.join(','));
312
+ exactSet('projected_operations', inventory.projectedOperationIds, COMMUNITY_AGENTSPACE_ALLOWED_OPERATION_IDS);
313
+ exactSet('projected_resources', inventory.projectedResourceIds, COMMUNITY_AGENTSPACE_ALLOWED_RESOURCE_IDS);
314
+ exactSet('denied_operations', inventory.deniedOperationIds, COMMUNITY_AGENTSPACE_DENIED_OPERATION_IDS);
315
+ exactSet('denied_resources', inventory.deniedResourceIds, COMMUNITY_AGENTSPACE_DENIED_RESOURCE_IDS);
316
+ exactSet('unclassified_resources', inventory.unclassifiedResourceIds, []);
317
+ if (inventory.missingAllowedOperationIds.length > 0) throw new Error('community_agentspace_missing_allowed_operations:' + inventory.missingAllowedOperationIds.join(','));
318
+ if (inventory.unreviewedOperationIds.length > 0) throw new Error('community_agentspace_unreviewed_operations:' + inventory.unreviewedOperationIds.join(','));
319
+ }
320
+
321
+ function filterRecord(value, allowedIds) {
322
+ const allowed = new Set(allowedIds);
323
+ return Object.fromEntries(Object.entries(toRecord(value)).filter(([id]) => allowed.has(normalizeId(id))));
324
+ }
325
+
326
+ export function filterCommunityAgentspaceManifest(manifest) {
327
+ const inventory = inspectCommunityAgentspaceProjection(manifest);
328
+ assertReviewedInventory(inventory);
329
+ const source = toRecord(manifest);
330
+ const capabilities = toRecord(source.capabilities);
331
+ const operations = (Array.isArray(capabilities.operations) ? capabilities.operations : []).filter((operation) => ALLOWED_OPERATION_SET.has(normalizeId(operation?.operationId)));
332
+ const allowedResources = new Set(COMMUNITY_AGENTSPACE_ALLOWED_RESOURCE_IDS);
333
+ const resources = (Array.isArray(capabilities.resources) ? capabilities.resources : []).filter((resource) => allowedResources.has(normalizeId(resource?.resourceId)));
334
+ const policies = toRecord(source.policies);
335
+ const docs = toRecord(source.docs);
336
+ const contracts = toRecord(source.contracts);
337
+ const schemaProjection = projectSchemas(operations, contracts);
338
+ return {
339
+ ...source,
340
+ domain: { ...toRecord(source.domain), displayName: 'Agentspace Community', description: COMMUNITY_DOMAIN_DESCRIPTION },
341
+ capabilities: { ...capabilities, operations, resources },
342
+ contracts: { ...contracts, schemas: schemaProjection.schemas },
343
+ ...(Object.keys(policies).length > 0 ? { policies: { ...policies, operations: filterRecord(policies.operations, COMMUNITY_AGENTSPACE_ALLOWED_OPERATION_IDS) } } : {}),
344
+ ...(Object.keys(docs).length > 0 ? { docs: { ...docs, domain: structuredClone(COMMUNITY_DOMAIN_DOCS), resources: filterRecord(docs.resources, COMMUNITY_AGENTSPACE_ALLOWED_RESOURCE_IDS), operations: filterRecord(docs.operations, COMMUNITY_AGENTSPACE_ALLOWED_OPERATION_IDS) } } : {}),
345
+ };
346
+ }
347
+
348
+ export function filterCommunityAgentspaceHostRouteProjection(routeProjection, { expectedSourceOperationIds, expectedSourceRoutes } = {}) {
349
+ const sourceRoutes = routeList(routeProjection);
350
+ const sourceOperationIds = sourceRoutes.map((route) => normalizeId(route?.operation));
351
+ if (sourceOperationIds.some((operationId) => !operationId) || new Set(sourceOperationIds).size !== sourceOperationIds.length) throw new Error('community_agentspace_route_operation_identity_invalid');
352
+ if (expectedSourceRoutes) exactRoutes('source_routes', sourceRoutes, routeList(expectedSourceRoutes));
353
+ else if (expectedSourceOperationIds) exactSet('route_source_operations', sourceOperationIds, expectedSourceOperationIds);
354
+ else if (sourceOperationIds.length !== EXPECTED_SOURCE_OPERATION_COUNT) throw new Error('community_agentspace_route_source_count_drift:' + sourceOperationIds.length);
355
+ const routes = sourceRoutes.filter((route) => ALLOWED_OPERATION_SET.has(normalizeId(route.operation)));
356
+ exactSet('route_projected_operations', routes.map((route) => route.operation), COMMUNITY_AGENTSPACE_ALLOWED_OPERATION_IDS);
357
+ return Array.isArray(routeProjection) ? routes : { ...toRecord(routeProjection), routes };
358
+ }
359
+
360
+ export function buildCommunityAgentspaceProjection(options = {}) {
361
+ const manifestOptions = { ...options, includeDocs: true };
362
+ const sourceManifest = buildBaseAgentspaceDomainCapabilityManifest(manifestOptions);
363
+ const inventory = inspectCommunityAgentspaceProjection(sourceManifest);
364
+ const manifest = filterCommunityAgentspaceManifest(sourceManifest);
365
+ const sourceRoutes = buildBaseAgentspaceHostRouteProjection({ refresh: options.refresh });
366
+ const routes = filterCommunityAgentspaceHostRouteProjection(
367
+ sourceRoutes,
368
+ { expectedSourceOperationIds: inventory.sourceOperationIds },
369
+ );
370
+ return {
371
+ manifest, routes,
372
+ operationIds: [...COMMUNITY_AGENTSPACE_ALLOWED_OPERATION_IDS],
373
+ resourceIds: [...COMMUNITY_AGENTSPACE_ALLOWED_RESOURCE_IDS],
374
+ sourceOperationIds: [...inventory.sourceOperationIds],
375
+ sourceRoutes,
376
+ unclassifiedResourceIds: [...inventory.unclassifiedResourceIds],
377
+ };
378
+ }
379
+
380
+ export function buildCommunityAgentspaceDomainCapabilityManifest(options = {}) {
381
+ return buildCommunityAgentspaceProjection(options).manifest;
382
+ }
383
+
384
+ export function buildCommunityAgentspaceHostRouteProjection(options = {}) {
385
+ return buildCommunityAgentspaceProjection(options).routes;
386
+ }
387
+
388
+ export const buildAgentspaceDomainCapabilityManifest = buildCommunityAgentspaceDomainCapabilityManifest;
389
+ export const buildAgentspaceHostRouteProjection = buildCommunityAgentspaceHostRouteProjection;