@aopslabs/aops-server 0.2.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 (150) hide show
  1. package/LICENSE +19 -0
  2. package/NOTICE +7 -0
  3. package/README.md +28 -0
  4. package/THIRD_PARTY_NOTICES +13409 -0
  5. package/THIRD_PARTY_NOTICES.inventory.json +2768 -0
  6. package/build/client/_app/immutable/chunks/2_TffmqH.js +1 -0
  7. package/build/client/_app/immutable/chunks/3DOfIKW0.js +1 -0
  8. package/build/client/_app/immutable/chunks/B2EkC-sy.js +1 -0
  9. package/build/client/_app/immutable/chunks/BlANKL2r.js +1 -0
  10. package/build/client/_app/immutable/chunks/CMkIcmi1.js +2 -0
  11. package/build/client/_app/immutable/chunks/rqnVXeyB.js +1 -0
  12. package/build/client/_app/immutable/chunks/wbPk3Yxo.js +81 -0
  13. package/build/client/_app/immutable/entry/app.a0iGCm6X.js +2 -0
  14. package/build/client/_app/immutable/entry/start.Df7u6fQ1.js +1 -0
  15. package/build/client/_app/immutable/nodes/0.BYBfjxZ5.js +1 -0
  16. package/build/client/_app/immutable/nodes/1.BtbjYUHR.js +1 -0
  17. package/build/client/_app/version.json +1 -0
  18. package/build/env.js +69 -0
  19. package/build/handler.js +15 -0
  20. package/build/index.js +138 -0
  21. package/build/server/chunks/0-RfB6m2nq.js +6 -0
  22. package/build/server/chunks/1-UJuUicIe.js +8 -0
  23. package/build/server/chunks/_server.ts-6bdzoHJH.js +83 -0
  24. package/build/server/chunks/_server.ts-AwMeEYiZ.js +9 -0
  25. package/build/server/chunks/_server.ts-B9gjXi95.js +260 -0
  26. package/build/server/chunks/_server.ts-BX4X0tW0.js +16 -0
  27. package/build/server/chunks/_server.ts-BkxSxdd0.js +172 -0
  28. package/build/server/chunks/_server.ts-Bly8fCZa.js +90 -0
  29. package/build/server/chunks/_server.ts-Bz-Erv-1.js +43 -0
  30. package/build/server/chunks/_server.ts-CRKd0KAC.js +43 -0
  31. package/build/server/chunks/_server.ts-CjzSQgpk.js +95 -0
  32. package/build/server/chunks/_server.ts-Cv-yaXZI.js +6 -0
  33. package/build/server/chunks/_server.ts-DQWRrk5C.js +14 -0
  34. package/build/server/chunks/_server.ts-DQzYSH_C.js +125 -0
  35. package/build/server/chunks/_server.ts-DaIr3NkR.js +10 -0
  36. package/build/server/chunks/_server.ts-DbdAfdYo.js +8 -0
  37. package/build/server/chunks/_server.ts-De9ZrSV0.js +84 -0
  38. package/build/server/chunks/_server.ts-DsTeOL2P.js +17 -0
  39. package/build/server/chunks/_server.ts-N61POKjl.js +84 -0
  40. package/build/server/chunks/_server.ts-Ua5Ieisy.js +37 -0
  41. package/build/server/chunks/_server.ts-XmKDT59M.js +37 -0
  42. package/build/server/chunks/_server.ts-o9pJceJP.js +54 -0
  43. package/build/server/chunks/_server.ts-u2UWBqNN.js +276 -0
  44. package/build/server/chunks/admission-snapshot-C2wGfTWE.js +1034 -0
  45. package/build/server/chunks/agent-gateway-runtime-C7Kvvy0H.js +2614 -0
  46. package/build/server/chunks/aops-runtime-config-CHpDUCdE.js +185 -0
  47. package/build/server/chunks/auth-provider-C07OUlnz.js +18 -0
  48. package/build/server/chunks/canonical-text-order-DbXJJnFD.js +5 -0
  49. package/build/server/chunks/commercial-admission-loader-V_vXHdVa.js +2077 -0
  50. package/build/server/chunks/discovery-BvDEgiqC.js +897 -0
  51. package/build/server/chunks/error.svelte-B9R6O_Hn.js +44 -0
  52. package/build/server/chunks/handler-DurXhqww.js +1472 -0
  53. package/build/server/chunks/hooks.server-DYGrWbgh.js +62 -0
  54. package/build/server/chunks/index.js-BQnOaW3H.js +11573 -0
  55. package/build/server/chunks/manifest.js-CCJDdahY.js +180 -0
  56. package/build/server/chunks/plugin-error-normalize-DNeRsopQ.js +309 -0
  57. package/build/server/chunks/project-alias-BdnRxWft.js +28 -0
  58. package/build/server/chunks/registry-DO8ob5o1.js +660 -0
  59. package/build/server/chunks/request-base-url-zKJpVUv5.js +35 -0
  60. package/build/server/chunks/request-context-9wzBoKrz.js +421 -0
  61. package/build/server/chunks/xf-result-BRDjvftr.js +16 -0
  62. package/build/shims.js +32 -0
  63. package/cockpit/.vite/manifest.json +198 -0
  64. package/cockpit/assets/dm-sans-latin-400-normal-BwCSEQnW.woff +0 -0
  65. package/cockpit/assets/dm-sans-latin-400-normal-CW0RaeGs.woff2 +0 -0
  66. package/cockpit/assets/dm-sans-latin-500-normal-B9HHJjqV.woff2 +0 -0
  67. package/cockpit/assets/dm-sans-latin-500-normal-Dr3UlScf.woff +0 -0
  68. package/cockpit/assets/dm-sans-latin-700-normal-CUSSCpQX.woff +0 -0
  69. package/cockpit/assets/dm-sans-latin-700-normal-DvUfVpUG.woff2 +0 -0
  70. package/cockpit/assets/dm-sans-latin-ext-400-normal-BjWJ59Pq.woff +0 -0
  71. package/cockpit/assets/dm-sans-latin-ext-400-normal-BtiwyxMk.woff2 +0 -0
  72. package/cockpit/assets/dm-sans-latin-ext-500-normal-BJfUCQsA.woff2 +0 -0
  73. package/cockpit/assets/dm-sans-latin-ext-500-normal-DR84L5F-.woff +0 -0
  74. package/cockpit/assets/dm-sans-latin-ext-700-normal-BLI3TTWz.woff +0 -0
  75. package/cockpit/assets/dm-sans-latin-ext-700-normal-CJIcxD6K.woff2 +0 -0
  76. package/cockpit/assets/index-CkhZWZ2f.js +18 -0
  77. package/cockpit/assets/index-TSfC5rf2.css +1 -0
  78. package/cockpit/assets/jetbrains-mono-cyrillic-400-normal-BEIGL1Tu.woff2 +0 -0
  79. package/cockpit/assets/jetbrains-mono-cyrillic-400-normal-ugxPyKxw.woff +0 -0
  80. package/cockpit/assets/jetbrains-mono-greek-400-normal-B9oWc5Lo.woff +0 -0
  81. package/cockpit/assets/jetbrains-mono-greek-400-normal-C190GLew.woff2 +0 -0
  82. package/cockpit/assets/jetbrains-mono-latin-400-normal-6-qcROiO.woff +0 -0
  83. package/cockpit/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
  84. package/cockpit/assets/jetbrains-mono-latin-ext-400-normal-Bc8Ftmh3.woff2 +0 -0
  85. package/cockpit/assets/jetbrains-mono-latin-ext-400-normal-fXTG6kC5.woff +0 -0
  86. package/cockpit/assets/jetbrains-mono-vietnamese-400-normal-CqNFfHCs.woff +0 -0
  87. package/cockpit/assets/outfit-latin-400-normal-BGsTXAXT.woff2 +0 -0
  88. package/cockpit/assets/outfit-latin-400-normal-DMwTpYkH.woff +0 -0
  89. package/cockpit/assets/outfit-latin-600-normal-B7SfZ07L.woff2 +0 -0
  90. package/cockpit/assets/outfit-latin-600-normal-BEfTtDA7.woff +0 -0
  91. package/cockpit/assets/outfit-latin-ext-400-normal-5tcqmc2S.woff2 +0 -0
  92. package/cockpit/assets/outfit-latin-ext-400-normal-DHm7mdGe.woff +0 -0
  93. package/cockpit/assets/outfit-latin-ext-600-normal-B85nYjL1.woff2 +0 -0
  94. package/cockpit/assets/outfit-latin-ext-600-normal-CWJcPgd7.woff +0 -0
  95. package/cockpit/assets/unbounded-cyrillic-600-normal-B-s5c2Kn.woff +0 -0
  96. package/cockpit/assets/unbounded-cyrillic-600-normal-DW6uzIMB.woff2 +0 -0
  97. package/cockpit/assets/unbounded-latin-600-normal-BPdB_PEv.woff +0 -0
  98. package/cockpit/assets/unbounded-latin-600-normal-oRSANpZr.woff2 +0 -0
  99. package/cockpit/assets/unbounded-latin-ext-600-normal-0iZLtTDV.woff2 +0 -0
  100. package/cockpit/assets/unbounded-latin-ext-600-normal-ClMPf-bu.woff +0 -0
  101. package/cockpit/assets/unbounded-vietnamese-600-normal-BzfrgZ_C.woff +0 -0
  102. package/cockpit/assets/unbounded-vietnamese-600-normal-Cx2bTSHN.woff2 +0 -0
  103. package/cockpit/community.module-inventory.json +2439 -0
  104. package/cockpit/index.html +14 -0
  105. package/community-postgres.json +13 -0
  106. package/migrations/agentspace/0000_thin_carlie_cooper.sql +764 -0
  107. package/migrations/agentspace/meta/_journal.json +13 -0
  108. package/migrations/chatv3/0000_dry_ego.sql +218 -0
  109. package/migrations/chatv3/0001_nosy_obadiah_stane.sql +35 -0
  110. package/migrations/chatv3/0002_narrow_darkhawk.sql +4 -0
  111. package/migrations/chatv3/0003_damp_zarek.sql +2 -0
  112. package/migrations/chatv3/0004_nervous_martin_li.sql +60 -0
  113. package/migrations/chatv3/0005_chatv3_server_encrypted_mode.sql +1 -0
  114. package/migrations/chatv3/0006_chatv3_database_server_keyring.sql +21 -0
  115. package/migrations/chatv3/meta/_journal.json +55 -0
  116. package/migrations/docman/0000_curvy_valeria_richards.sql +257 -0
  117. package/migrations/docman/0001_massive_risque.sql +2 -0
  118. package/migrations/docman/0002_simple_logan.sql +50 -0
  119. package/migrations/docman/0003_quick_index.sql +45 -0
  120. package/migrations/docman/0004_known_summary.sql +9 -0
  121. package/migrations/docman/0005_vector_signal.sql +9 -0
  122. package/migrations/docman/0006_document_version_current_invariant.sql +15 -0
  123. package/migrations/docman/meta/_journal.json +55 -0
  124. package/migrations/projectman/0000_smooth_klaw.sql +257 -0
  125. package/migrations/projectman/0001_worthless_zodiak.sql +9 -0
  126. package/migrations/projectman/0002_board_rename.sql +108 -0
  127. package/migrations/projectman/0003_review_request.sql +62 -0
  128. package/migrations/projectman/0004_review_request_idempotency.sql +3 -0
  129. package/migrations/projectman/0005_allow_multi_sprint_per_task.sql +1 -0
  130. package/migrations/projectman/meta/_journal.json +48 -0
  131. package/migrations/sys/0000_loose_praxagora.sql +31 -0
  132. package/migrations/sys/0001_awesome_ronan.sql +2 -0
  133. package/migrations/sys/0002_steady_maximus.sql +2 -0
  134. package/migrations/sys/0003_escalating_rate_limiter.sql +2 -0
  135. package/migrations/sys/0004_rate_limiter_timestamptz.sql +22 -0
  136. package/migrations/sys/0005_sys_counters.sql +21 -0
  137. package/migrations/sys/meta/_journal.json +48 -0
  138. package/npm-shrinkwrap.json +5069 -0
  139. package/package.json +88 -0
  140. package/runtime/agentspace-host-adapter.mjs +64 -0
  141. package/runtime/agentspace-tooling.mjs +389 -0
  142. package/runtime/commercial-integrity-worker.mjs +1643 -0
  143. package/runtime/docman-host-adapter.mjs +177 -0
  144. package/runtime/docman-policy.mjs +450 -0
  145. package/runtime/docman-tooling.mjs +20 -0
  146. package/runtime/projectman-host-adapter.mjs +597 -0
  147. package/runtime/scope-context.mjs +99 -0
  148. package/runtime-closure.package.json +376 -0
  149. package/scripts/community-host.mjs +919 -0
  150. package/scripts/community-migration-policy-package-v1.json +11854 -0
@@ -0,0 +1,185 @@
1
+ import { lstatSync, realpathSync, readFileSync } from 'node:fs';
2
+ import path from 'node:path';
3
+ import { Pool } from 'pg';
4
+
5
+ const COMMUNITY_PG_ENV_KEY = "AOPS_PG_URL";
6
+ const COMMUNITY_PG_SCHEMA_TABLES = ["projects", "docman_documents", "projectman_kanban_boards", "chatv3-rooms", "sys_event_stores"];
7
+ const codepointCompare = (left, right) => left < right ? -1 : left > right ? 1 : 0;
8
+ function nonEmpty(value) {
9
+ return typeof value === "string" ? value.trim() : "";
10
+ }
11
+ function assertNoAmbientPgEnv(processEnv) {
12
+ const forbidden = Object.keys(processEnv).filter((key) => /^PG[A-Z0-9_]+$/i.test(key) && nonEmpty(processEnv[key])).sort();
13
+ if (forbidden.length > 0) {
14
+ throw new Error(`community_pg_ambient_env_forbidden:${forbidden.join(",")}`);
15
+ }
16
+ }
17
+ function decodeUrlComponent(value) {
18
+ try {
19
+ return decodeURIComponent(value);
20
+ } catch {
21
+ throw new Error("community_pg_url_invalid");
22
+ }
23
+ }
24
+ function isLoopbackPgHost(value) {
25
+ const host = value.trim().toLowerCase();
26
+ if (host === "localhost" || host === "::1") return true;
27
+ const match = /^127\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(host);
28
+ return Boolean(match && match.slice(1).every((octet) => Number(octet) <= 255));
29
+ }
30
+ function parsePgTarget(value) {
31
+ const normalized = typeof value === "string" ? value.trim() : "";
32
+ if (!normalized) throw new Error("aops_pg_url_required");
33
+ let parsed;
34
+ try {
35
+ parsed = new URL(normalized);
36
+ } catch {
37
+ throw new Error("community_pg_url_invalid");
38
+ }
39
+ if (parsed.protocol !== "postgres:" && parsed.protocol !== "postgresql:" || parsed.hash) {
40
+ throw new Error("community_pg_url_invalid");
41
+ }
42
+ const host = parsed.hostname.startsWith("[") && parsed.hostname.endsWith("]") ? parsed.hostname.slice(1, -1) : parsed.hostname;
43
+ const port = parsed.port ? Number(parsed.port) : 5432;
44
+ const user = decodeUrlComponent(parsed.username);
45
+ const password = decodeUrlComponent(parsed.password);
46
+ const database = decodeUrlComponent(parsed.pathname.startsWith("/") ? parsed.pathname.slice(1) : parsed.pathname);
47
+ const entries = [...parsed.searchParams.entries()];
48
+ const uniqueQueryKeys = new Set(entries.map(([key]) => key));
49
+ const exactQuery = (expected) => entries.length === Object.keys(expected).length && uniqueQueryKeys.size === entries.length && entries.every(([key, entryValue]) => expected[key] === entryValue);
50
+ const loopback = isLoopbackPgHost(host);
51
+ let ssl;
52
+ if (entries.length === 0 && loopback) {
53
+ ssl = false;
54
+ } else if (exactQuery({ sslmode: "disable" })) {
55
+ ssl = false;
56
+ } else if (exactQuery({ sslmode: "require", uselibpqcompat: "true" })) {
57
+ ssl = { rejectUnauthorized: false };
58
+ } else if (exactQuery({ sslmode: "verify-full" })) {
59
+ ssl = { rejectUnauthorized: true };
60
+ } else if (entries.length === 2 && uniqueQueryKeys.size === entries.length && parsed.searchParams.get("sslmode") === "verify-full" && entries.every(([key]) => key === "sslmode" || key === "sslrootcert")) {
61
+ const rootCertInput = nonEmpty(parsed.searchParams.get("sslrootcert"));
62
+ if (!path.isAbsolute(rootCertInput)) throw new Error("community_pg_url_invalid");
63
+ let rootCertStats;
64
+ try {
65
+ rootCertStats = lstatSync(rootCertInput);
66
+ } catch {
67
+ throw new Error("community_pg_url_invalid");
68
+ }
69
+ if (!rootCertStats.isFile() || rootCertStats.isSymbolicLink() || rootCertStats.size < 1 || rootCertStats.size > 262144) {
70
+ throw new Error("community_pg_url_invalid");
71
+ }
72
+ const canonicalRootCert = realpathSync(rootCertInput);
73
+ if (path.resolve(canonicalRootCert) !== path.resolve(rootCertInput)) throw new Error("community_pg_url_invalid");
74
+ ssl = { rejectUnauthorized: true, ca: readFileSync(canonicalRootCert, "utf8") };
75
+ } else {
76
+ throw new Error("community_pg_url_invalid");
77
+ }
78
+ if (!host || !user || !password || !database || !Number.isInteger(port) || port < 1 || port > 65535 || /[\/\u0000-\u001f\u007f]/.test(database) || /[\u0000-\u001f\u007f]/.test(host + user + password)) {
79
+ throw new Error("community_pg_url_invalid");
80
+ }
81
+ return { host, port, user, password, database, ssl };
82
+ }
83
+ function redactPgTarget(target) {
84
+ const host = target.host.includes(":") ? `[${target.host}]` : target.host;
85
+ return `postgresql://${encodeURIComponent(target.user)}:***@${host}:${target.port}/${encodeURIComponent(target.database)}`;
86
+ }
87
+ function createPoolConfig(target) {
88
+ return {
89
+ host: target.host,
90
+ port: target.port,
91
+ user: target.user,
92
+ password: target.password,
93
+ database: target.database,
94
+ ssl: target.ssl,
95
+ application_name: "aops-community-probe",
96
+ options: "-c search_path=public",
97
+ connectionTimeoutMillis: 8e3,
98
+ query_timeout: 8e3,
99
+ statement_timeout: 8e3,
100
+ lock_timeout: 8e3,
101
+ idle_in_transaction_session_timeout: 8e3,
102
+ max: 1
103
+ };
104
+ }
105
+ function createCommunityPgPoolConfig(repoUrl, applicationName = "aops-community-probe") {
106
+ return {
107
+ ...createPoolConfig(parsePgTarget(repoUrl)),
108
+ application_name: applicationName
109
+ };
110
+ }
111
+ function resolveRuntime(processEnv = process.env) {
112
+ assertNoAmbientPgEnv(processEnv);
113
+ const repoUrl = nonEmpty(processEnv[COMMUNITY_PG_ENV_KEY]);
114
+ if (repoUrl) parsePgTarget(repoUrl);
115
+ return {
116
+ repoUrl,
117
+ repoDialect: repoUrl ? "pg" : null,
118
+ repoUrlSource: repoUrl ? "env" : "missing",
119
+ envPath: null,
120
+ envExists: false,
121
+ hostSettings: { logLevel: "info" },
122
+ logLevelSource: "default"
123
+ };
124
+ }
125
+ let resolvedRuntimeConfig = resolveRuntime();
126
+ function getResolvedAopsServerRuntimeConfig() {
127
+ return resolvedRuntimeConfig;
128
+ }
129
+ function readRuntimeConfigAdmin() {
130
+ const runtime = getResolvedAopsServerRuntimeConfig();
131
+ const target = runtime.repoUrl ? parsePgTarget(runtime.repoUrl) : null;
132
+ return {
133
+ policy: { owner: "host", surface: "host-admin", writeMode: "process-env-read-only", dialectsAllowed: ["pg"], secretsMode: "redacted" },
134
+ locks: { repoUrl: runtime.repoUrl ? { source: "env", envKey: COMMUNITY_PG_ENV_KEY } : null },
135
+ effective: {
136
+ repoDialect: runtime.repoDialect,
137
+ repoUrlSource: runtime.repoUrlSource,
138
+ redactedRepoUrl: target ? redactPgTarget(target) : null,
139
+ editableRepoUrl: null
140
+ },
141
+ status: { ok: Boolean(runtime.repoUrl), issues: runtime.repoUrl ? [] : ["AOPS_PG_URL is required."], warnings: [] }
142
+ };
143
+ }
144
+ async function runRuntimeConfigAdminTargetProbe(processEnv = process.env) {
145
+ assertNoAmbientPgEnv(processEnv);
146
+ const repoUrl = nonEmpty(processEnv[COMMUNITY_PG_ENV_KEY]);
147
+ const target = parsePgTarget(repoUrl);
148
+ const pool = new Pool(createCommunityPgPoolConfig(repoUrl));
149
+ try {
150
+ const database = await pool.query("select current_database() as name");
151
+ const tables = await pool.query(
152
+ `select candidate.name
153
+ from unnest($1::text[]) as candidate(name)
154
+ join pg_catalog.pg_class c on c.relname = candidate.name and c.relkind in ('r', 'p')
155
+ join pg_catalog.pg_namespace n on n.oid = c.relnamespace and n.nspname = 'public'
156
+ where has_table_privilege(c.oid, 'SELECT')`,
157
+ [COMMUNITY_PG_SCHEMA_TABLES]
158
+ );
159
+ const existingRelations = tables.rows.map((row) => row.name).sort(codepointCompare);
160
+ const missingRelations = COMMUNITY_PG_SCHEMA_TABLES.filter((name) => !existingRelations.includes(name));
161
+ return {
162
+ target: { repoDialect: "pg", redactedRepoUrl: redactPgTarget(target) },
163
+ connection: { ok: true, databaseName: String(database.rows[0]?.name ?? "") || null, message: "Connected to configured PostgreSQL target." },
164
+ schema: { verificationLevel: "sentinel-relations-only", ready: false, sentinelsPresent: missingRelations.length === 0, configuredRelationCount: COMMUNITY_PG_SCHEMA_TABLES.length, existingRelationCount: existingRelations.length, existingRelations, missingRelations },
165
+ warnings: [
166
+ "Full domain migration readiness requires packaged bootstrap and runtime catalog smoke.",
167
+ ...missingRelations.length === 0 ? [] : [`Configured target is missing ${missingRelations.length} Community schema sentinel relation(s).`]
168
+ ]
169
+ };
170
+ } finally {
171
+ await pool.end().catch(() => void 0);
172
+ }
173
+ }
174
+ let activeProbe = null;
175
+ async function testRuntimeConfigAdminTarget(processEnv = process.env) {
176
+ if (activeProbe) return activeProbe;
177
+ activeProbe = runRuntimeConfigAdminTargetProbe(processEnv);
178
+ try {
179
+ return await activeProbe;
180
+ } finally {
181
+ activeProbe = null;
182
+ }
183
+ }
184
+
185
+ export { getResolvedAopsServerRuntimeConfig as g, readRuntimeConfigAdmin as r, testRuntimeConfigAdminTarget as t };
@@ -0,0 +1,18 @@
1
+ function resolveAuthProvider(processEnv = process.env) {
2
+ const configured = String(processEnv.AOPS_AUTH_PROVIDER ?? "trusted-local").trim().toLowerCase();
3
+ if (configured === "trusted-local") return configured;
4
+ if (configured === "authv2-jwt-session" || configured === "remote-session") {
5
+ throw new Error(
6
+ "aops_local_auth_provider_retired:use_trusted-local_or_configure_a_remote-session_target"
7
+ );
8
+ }
9
+ throw new Error("aops_auth_provider_invalid:use_trusted-local");
10
+ }
11
+ function getAuthProvider() {
12
+ return resolveAuthProvider();
13
+ }
14
+ function isTrustedLocalAuthProvider(authProvider = getAuthProvider()) {
15
+ return authProvider === "trusted-local";
16
+ }
17
+
18
+ export { getAuthProvider as g, isTrustedLocalAuthProvider as i };
@@ -0,0 +1,5 @@
1
+ function compareCanonicalText(left, right) {
2
+ return left < right ? -1 : left > right ? 1 : 0;
3
+ }
4
+
5
+ export { compareCanonicalText as c };