@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.
- package/LICENSE +19 -0
- package/NOTICE +7 -0
- package/README.md +28 -0
- package/THIRD_PARTY_NOTICES +13409 -0
- package/THIRD_PARTY_NOTICES.inventory.json +2768 -0
- package/build/client/_app/immutable/chunks/2_TffmqH.js +1 -0
- package/build/client/_app/immutable/chunks/3DOfIKW0.js +1 -0
- package/build/client/_app/immutable/chunks/B2EkC-sy.js +1 -0
- package/build/client/_app/immutable/chunks/BlANKL2r.js +1 -0
- package/build/client/_app/immutable/chunks/CMkIcmi1.js +2 -0
- package/build/client/_app/immutable/chunks/rqnVXeyB.js +1 -0
- package/build/client/_app/immutable/chunks/wbPk3Yxo.js +81 -0
- package/build/client/_app/immutable/entry/app.a0iGCm6X.js +2 -0
- package/build/client/_app/immutable/entry/start.Df7u6fQ1.js +1 -0
- package/build/client/_app/immutable/nodes/0.BYBfjxZ5.js +1 -0
- package/build/client/_app/immutable/nodes/1.BtbjYUHR.js +1 -0
- package/build/client/_app/version.json +1 -0
- package/build/env.js +69 -0
- package/build/handler.js +15 -0
- package/build/index.js +138 -0
- package/build/server/chunks/0-RfB6m2nq.js +6 -0
- package/build/server/chunks/1-UJuUicIe.js +8 -0
- package/build/server/chunks/_server.ts-6bdzoHJH.js +83 -0
- package/build/server/chunks/_server.ts-AwMeEYiZ.js +9 -0
- package/build/server/chunks/_server.ts-B9gjXi95.js +260 -0
- package/build/server/chunks/_server.ts-BX4X0tW0.js +16 -0
- package/build/server/chunks/_server.ts-BkxSxdd0.js +172 -0
- package/build/server/chunks/_server.ts-Bly8fCZa.js +90 -0
- package/build/server/chunks/_server.ts-Bz-Erv-1.js +43 -0
- package/build/server/chunks/_server.ts-CRKd0KAC.js +43 -0
- package/build/server/chunks/_server.ts-CjzSQgpk.js +95 -0
- package/build/server/chunks/_server.ts-Cv-yaXZI.js +6 -0
- package/build/server/chunks/_server.ts-DQWRrk5C.js +14 -0
- package/build/server/chunks/_server.ts-DQzYSH_C.js +125 -0
- package/build/server/chunks/_server.ts-DaIr3NkR.js +10 -0
- package/build/server/chunks/_server.ts-DbdAfdYo.js +8 -0
- package/build/server/chunks/_server.ts-De9ZrSV0.js +84 -0
- package/build/server/chunks/_server.ts-DsTeOL2P.js +17 -0
- package/build/server/chunks/_server.ts-N61POKjl.js +84 -0
- package/build/server/chunks/_server.ts-Ua5Ieisy.js +37 -0
- package/build/server/chunks/_server.ts-XmKDT59M.js +37 -0
- package/build/server/chunks/_server.ts-o9pJceJP.js +54 -0
- package/build/server/chunks/_server.ts-u2UWBqNN.js +276 -0
- package/build/server/chunks/admission-snapshot-C2wGfTWE.js +1034 -0
- package/build/server/chunks/agent-gateway-runtime-C7Kvvy0H.js +2614 -0
- package/build/server/chunks/aops-runtime-config-CHpDUCdE.js +185 -0
- package/build/server/chunks/auth-provider-C07OUlnz.js +18 -0
- package/build/server/chunks/canonical-text-order-DbXJJnFD.js +5 -0
- package/build/server/chunks/commercial-admission-loader-V_vXHdVa.js +2077 -0
- package/build/server/chunks/discovery-BvDEgiqC.js +897 -0
- package/build/server/chunks/error.svelte-B9R6O_Hn.js +44 -0
- package/build/server/chunks/handler-DurXhqww.js +1472 -0
- package/build/server/chunks/hooks.server-DYGrWbgh.js +62 -0
- package/build/server/chunks/index.js-BQnOaW3H.js +11573 -0
- package/build/server/chunks/manifest.js-CCJDdahY.js +180 -0
- package/build/server/chunks/plugin-error-normalize-DNeRsopQ.js +309 -0
- package/build/server/chunks/project-alias-BdnRxWft.js +28 -0
- package/build/server/chunks/registry-DO8ob5o1.js +660 -0
- package/build/server/chunks/request-base-url-zKJpVUv5.js +35 -0
- package/build/server/chunks/request-context-9wzBoKrz.js +421 -0
- package/build/server/chunks/xf-result-BRDjvftr.js +16 -0
- package/build/shims.js +32 -0
- package/cockpit/.vite/manifest.json +198 -0
- package/cockpit/assets/dm-sans-latin-400-normal-BwCSEQnW.woff +0 -0
- package/cockpit/assets/dm-sans-latin-400-normal-CW0RaeGs.woff2 +0 -0
- package/cockpit/assets/dm-sans-latin-500-normal-B9HHJjqV.woff2 +0 -0
- package/cockpit/assets/dm-sans-latin-500-normal-Dr3UlScf.woff +0 -0
- package/cockpit/assets/dm-sans-latin-700-normal-CUSSCpQX.woff +0 -0
- package/cockpit/assets/dm-sans-latin-700-normal-DvUfVpUG.woff2 +0 -0
- package/cockpit/assets/dm-sans-latin-ext-400-normal-BjWJ59Pq.woff +0 -0
- package/cockpit/assets/dm-sans-latin-ext-400-normal-BtiwyxMk.woff2 +0 -0
- package/cockpit/assets/dm-sans-latin-ext-500-normal-BJfUCQsA.woff2 +0 -0
- package/cockpit/assets/dm-sans-latin-ext-500-normal-DR84L5F-.woff +0 -0
- package/cockpit/assets/dm-sans-latin-ext-700-normal-BLI3TTWz.woff +0 -0
- package/cockpit/assets/dm-sans-latin-ext-700-normal-CJIcxD6K.woff2 +0 -0
- package/cockpit/assets/index-CkhZWZ2f.js +18 -0
- package/cockpit/assets/index-TSfC5rf2.css +1 -0
- package/cockpit/assets/jetbrains-mono-cyrillic-400-normal-BEIGL1Tu.woff2 +0 -0
- package/cockpit/assets/jetbrains-mono-cyrillic-400-normal-ugxPyKxw.woff +0 -0
- package/cockpit/assets/jetbrains-mono-greek-400-normal-B9oWc5Lo.woff +0 -0
- package/cockpit/assets/jetbrains-mono-greek-400-normal-C190GLew.woff2 +0 -0
- package/cockpit/assets/jetbrains-mono-latin-400-normal-6-qcROiO.woff +0 -0
- package/cockpit/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
- package/cockpit/assets/jetbrains-mono-latin-ext-400-normal-Bc8Ftmh3.woff2 +0 -0
- package/cockpit/assets/jetbrains-mono-latin-ext-400-normal-fXTG6kC5.woff +0 -0
- package/cockpit/assets/jetbrains-mono-vietnamese-400-normal-CqNFfHCs.woff +0 -0
- package/cockpit/assets/outfit-latin-400-normal-BGsTXAXT.woff2 +0 -0
- package/cockpit/assets/outfit-latin-400-normal-DMwTpYkH.woff +0 -0
- package/cockpit/assets/outfit-latin-600-normal-B7SfZ07L.woff2 +0 -0
- package/cockpit/assets/outfit-latin-600-normal-BEfTtDA7.woff +0 -0
- package/cockpit/assets/outfit-latin-ext-400-normal-5tcqmc2S.woff2 +0 -0
- package/cockpit/assets/outfit-latin-ext-400-normal-DHm7mdGe.woff +0 -0
- package/cockpit/assets/outfit-latin-ext-600-normal-B85nYjL1.woff2 +0 -0
- package/cockpit/assets/outfit-latin-ext-600-normal-CWJcPgd7.woff +0 -0
- package/cockpit/assets/unbounded-cyrillic-600-normal-B-s5c2Kn.woff +0 -0
- package/cockpit/assets/unbounded-cyrillic-600-normal-DW6uzIMB.woff2 +0 -0
- package/cockpit/assets/unbounded-latin-600-normal-BPdB_PEv.woff +0 -0
- package/cockpit/assets/unbounded-latin-600-normal-oRSANpZr.woff2 +0 -0
- package/cockpit/assets/unbounded-latin-ext-600-normal-0iZLtTDV.woff2 +0 -0
- package/cockpit/assets/unbounded-latin-ext-600-normal-ClMPf-bu.woff +0 -0
- package/cockpit/assets/unbounded-vietnamese-600-normal-BzfrgZ_C.woff +0 -0
- package/cockpit/assets/unbounded-vietnamese-600-normal-Cx2bTSHN.woff2 +0 -0
- package/cockpit/community.module-inventory.json +2439 -0
- package/cockpit/index.html +14 -0
- package/community-postgres.json +13 -0
- package/migrations/agentspace/0000_thin_carlie_cooper.sql +764 -0
- package/migrations/agentspace/meta/_journal.json +13 -0
- package/migrations/chatv3/0000_dry_ego.sql +218 -0
- package/migrations/chatv3/0001_nosy_obadiah_stane.sql +35 -0
- package/migrations/chatv3/0002_narrow_darkhawk.sql +4 -0
- package/migrations/chatv3/0003_damp_zarek.sql +2 -0
- package/migrations/chatv3/0004_nervous_martin_li.sql +60 -0
- package/migrations/chatv3/0005_chatv3_server_encrypted_mode.sql +1 -0
- package/migrations/chatv3/0006_chatv3_database_server_keyring.sql +21 -0
- package/migrations/chatv3/meta/_journal.json +55 -0
- package/migrations/docman/0000_curvy_valeria_richards.sql +257 -0
- package/migrations/docman/0001_massive_risque.sql +2 -0
- package/migrations/docman/0002_simple_logan.sql +50 -0
- package/migrations/docman/0003_quick_index.sql +45 -0
- package/migrations/docman/0004_known_summary.sql +9 -0
- package/migrations/docman/0005_vector_signal.sql +9 -0
- package/migrations/docman/0006_document_version_current_invariant.sql +15 -0
- package/migrations/docman/meta/_journal.json +55 -0
- package/migrations/projectman/0000_smooth_klaw.sql +257 -0
- package/migrations/projectman/0001_worthless_zodiak.sql +9 -0
- package/migrations/projectman/0002_board_rename.sql +108 -0
- package/migrations/projectman/0003_review_request.sql +62 -0
- package/migrations/projectman/0004_review_request_idempotency.sql +3 -0
- package/migrations/projectman/0005_allow_multi_sprint_per_task.sql +1 -0
- package/migrations/projectman/meta/_journal.json +48 -0
- package/migrations/sys/0000_loose_praxagora.sql +31 -0
- package/migrations/sys/0001_awesome_ronan.sql +2 -0
- package/migrations/sys/0002_steady_maximus.sql +2 -0
- package/migrations/sys/0003_escalating_rate_limiter.sql +2 -0
- package/migrations/sys/0004_rate_limiter_timestamptz.sql +22 -0
- package/migrations/sys/0005_sys_counters.sql +21 -0
- package/migrations/sys/meta/_journal.json +48 -0
- package/npm-shrinkwrap.json +5069 -0
- package/package.json +88 -0
- package/runtime/agentspace-host-adapter.mjs +64 -0
- package/runtime/agentspace-tooling.mjs +389 -0
- package/runtime/commercial-integrity-worker.mjs +1643 -0
- package/runtime/docman-host-adapter.mjs +177 -0
- package/runtime/docman-policy.mjs +450 -0
- package/runtime/docman-tooling.mjs +20 -0
- package/runtime/projectman-host-adapter.mjs +597 -0
- package/runtime/scope-context.mjs +99 -0
- package/runtime-closure.package.json +376 -0
- package/scripts/community-host.mjs +919 -0
- package/scripts/community-migration-policy-package-v1.json +11854 -0
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { j as json } from './index.js-BQnOaW3H.js';
|
|
2
|
+
import { Effect } from 'effect';
|
|
3
|
+
import { normalizeDocmanFlowAction, saveDocmanGroupFlow, saveDocmanDocumentFlow, saveDocmanSectionFlow, copyDocmanSectionFlow, createLinkedDocmanSection, linkExistingDocmanSection, linkExistingDocmanPageVersion, updateDocmanDocumentSectionLinksFlow, updateDocmanSectionPageLinksFlow, saveDocmanPageVersionDraftFlow, updateDocmanDocumentVersionFlow, updateDocmanPageFlow, copyDocmanPageFlow, createDocmanDocumentVersionFlow, createDocmanPageWithInitialVersionFlow, createLinkedDocmanPage, inferDocmanFlowErrorStatus } from '@aopslabs/domain-product-docman';
|
|
4
|
+
import { a as attachResolvedProjectScope, b as resolveProjectScopeFromLocals } from './request-context-9wzBoKrz.js';
|
|
5
|
+
import { e as errResult, o as okResult } from './xf-result-BRDjvftr.js';
|
|
6
|
+
import './aops-runtime-config-CHpDUCdE.js';
|
|
7
|
+
import 'node:fs';
|
|
8
|
+
import 'node:path';
|
|
9
|
+
import 'pg';
|
|
10
|
+
import '@aopslabs/xf-dm-kits/appConfig';
|
|
11
|
+
import '@aopslabs/xf-dm-kits';
|
|
12
|
+
import '@aopslabs/domain-kit-agentspace';
|
|
13
|
+
import './project-alias-BdnRxWft.js';
|
|
14
|
+
|
|
15
|
+
function toRecord(value) {
|
|
16
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
function inferScopeStatus(result) {
|
|
20
|
+
if (result.ok) return 200;
|
|
21
|
+
const message = String(result.messages?.[0]?.messageText ?? "").trim().toLowerCase();
|
|
22
|
+
if (message === "unauthorized") return 401;
|
|
23
|
+
if (message === "forbidden") return 403;
|
|
24
|
+
if (message === "project_required") return 409;
|
|
25
|
+
if (message === "project_not_found") return 404;
|
|
26
|
+
return 400;
|
|
27
|
+
}
|
|
28
|
+
function normalizeNonEmpty(value) {
|
|
29
|
+
if (typeof value !== "string") return "";
|
|
30
|
+
const trimmed = value.trim();
|
|
31
|
+
return trimmed.length > 0 ? trimmed : "";
|
|
32
|
+
}
|
|
33
|
+
async function resolveDocmanFlowScope(params) {
|
|
34
|
+
const projectSvc = await params.kit.createProjectService();
|
|
35
|
+
const directProject = typeof projectSvc.getById === "function" ? await Effect.runPromise(projectSvc.getById(params.projectId)).catch(() => null) : null;
|
|
36
|
+
const projectId = normalizeNonEmpty(directProject?.id) || normalizeNonEmpty(params.projectId);
|
|
37
|
+
const projectScopeId = normalizeNonEmpty(directProject?.scopeId);
|
|
38
|
+
const defaultScopeId = projectScopeId || projectId;
|
|
39
|
+
if (!defaultScopeId) {
|
|
40
|
+
return {
|
|
41
|
+
ok: false,
|
|
42
|
+
status: 404,
|
|
43
|
+
result: errResult("project_scope_not_found", { projectId: params.projectId })
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
const requestedScopeId = normalizeNonEmpty(params.requestedScopeId);
|
|
47
|
+
if (!requestedScopeId) {
|
|
48
|
+
return { ok: true, scopeId: defaultScopeId };
|
|
49
|
+
}
|
|
50
|
+
if (requestedScopeId === projectId || requestedScopeId === projectScopeId) {
|
|
51
|
+
return { ok: true, scopeId: requestedScopeId };
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
ok: false,
|
|
55
|
+
status: 409,
|
|
56
|
+
result: errResult("scope_not_in_project", {
|
|
57
|
+
projectId: params.projectId,
|
|
58
|
+
scopeId: requestedScopeId
|
|
59
|
+
})
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
async function readJsonBody(request) {
|
|
63
|
+
try {
|
|
64
|
+
return toRecord(await request.json());
|
|
65
|
+
} catch {
|
|
66
|
+
return {};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const POST = async ({ request, locals }) => {
|
|
70
|
+
await attachResolvedProjectScope({ request, locals });
|
|
71
|
+
const body = await readJsonBody(request);
|
|
72
|
+
const attachedScopeId = normalizeNonEmpty(locals.scopeId);
|
|
73
|
+
const requestedScopeId = normalizeNonEmpty(body.scopeId);
|
|
74
|
+
let resolvedScopeId = attachedScopeId;
|
|
75
|
+
if (!resolvedScopeId || requestedScopeId && requestedScopeId !== resolvedScopeId) {
|
|
76
|
+
const scope = await resolveProjectScopeFromLocals({
|
|
77
|
+
input: {
|
|
78
|
+
projectId: body.projectId ?? locals.projectId,
|
|
79
|
+
projectName: body.projectName,
|
|
80
|
+
project: body.project
|
|
81
|
+
},
|
|
82
|
+
locals
|
|
83
|
+
});
|
|
84
|
+
if (!scope.ok) return json(scope.result, { status: inferScopeStatus(scope.result) });
|
|
85
|
+
const resolvedScope = await resolveDocmanFlowScope({
|
|
86
|
+
projectId: scope.projectId,
|
|
87
|
+
requestedScopeId: requestedScopeId || void 0,
|
|
88
|
+
kit: scope.kit
|
|
89
|
+
});
|
|
90
|
+
if (!resolvedScope.ok) {
|
|
91
|
+
return json(resolvedScope.result, { status: resolvedScope.status });
|
|
92
|
+
}
|
|
93
|
+
resolvedScopeId = resolvedScope.scopeId;
|
|
94
|
+
}
|
|
95
|
+
if (!resolvedScopeId) {
|
|
96
|
+
return json(errResult("project_required"), { status: 409 });
|
|
97
|
+
}
|
|
98
|
+
const action = normalizeDocmanFlowAction(body.action);
|
|
99
|
+
if (!action) {
|
|
100
|
+
return json(errResult("unsupported_docman_flow_action"), { status: 400 });
|
|
101
|
+
}
|
|
102
|
+
try {
|
|
103
|
+
if (action === "save-group") {
|
|
104
|
+
const result2 = await saveDocmanGroupFlow({
|
|
105
|
+
scopeId: resolvedScopeId,
|
|
106
|
+
groupId: body.groupId,
|
|
107
|
+
data: body.data
|
|
108
|
+
});
|
|
109
|
+
return json(okResult(result2), { status: 200 });
|
|
110
|
+
}
|
|
111
|
+
if (action === "save-document") {
|
|
112
|
+
const result2 = await saveDocmanDocumentFlow({
|
|
113
|
+
scopeId: resolvedScopeId,
|
|
114
|
+
documentId: body.documentId,
|
|
115
|
+
data: body.data
|
|
116
|
+
});
|
|
117
|
+
return json(okResult(result2), { status: 200 });
|
|
118
|
+
}
|
|
119
|
+
if (action === "save-section") {
|
|
120
|
+
const result2 = await saveDocmanSectionFlow({
|
|
121
|
+
scopeId: resolvedScopeId,
|
|
122
|
+
sectionId: body.sectionId,
|
|
123
|
+
data: body.data
|
|
124
|
+
});
|
|
125
|
+
return json(okResult(result2), { status: 200 });
|
|
126
|
+
}
|
|
127
|
+
if (action === "copy-section") {
|
|
128
|
+
const result2 = await copyDocmanSectionFlow({
|
|
129
|
+
scopeId: resolvedScopeId,
|
|
130
|
+
sourceSectionId: body.sourceSectionId,
|
|
131
|
+
targetDocumentVersionId: body.targetDocumentVersionId,
|
|
132
|
+
parentLinkId: body.parentLinkId,
|
|
133
|
+
position: body.position,
|
|
134
|
+
rename: body.rename,
|
|
135
|
+
clonePages: body.clonePages
|
|
136
|
+
});
|
|
137
|
+
return json(okResult(result2), { status: 200 });
|
|
138
|
+
}
|
|
139
|
+
if (action === "create-linked-section") {
|
|
140
|
+
const result2 = await createLinkedDocmanSection({
|
|
141
|
+
scopeId: resolvedScopeId,
|
|
142
|
+
documentVersionId: body.documentVersionId,
|
|
143
|
+
parentLinkId: body.parentLinkId
|
|
144
|
+
});
|
|
145
|
+
return json(okResult(result2), { status: 200 });
|
|
146
|
+
}
|
|
147
|
+
if (action === "link-existing-section") {
|
|
148
|
+
const result2 = await linkExistingDocmanSection({
|
|
149
|
+
scopeId: resolvedScopeId,
|
|
150
|
+
documentVersionId: body.documentVersionId,
|
|
151
|
+
sectionId: body.sectionId,
|
|
152
|
+
parentLinkId: body.parentLinkId,
|
|
153
|
+
position: body.position,
|
|
154
|
+
titleOverride: body.titleOverride,
|
|
155
|
+
numbering: body.numbering
|
|
156
|
+
});
|
|
157
|
+
return json(okResult(result2), { status: 200 });
|
|
158
|
+
}
|
|
159
|
+
if (action === "link-existing-page-version") {
|
|
160
|
+
const result2 = await linkExistingDocmanPageVersion({
|
|
161
|
+
scopeId: resolvedScopeId,
|
|
162
|
+
sectionId: body.sectionId,
|
|
163
|
+
pageId: body.pageId,
|
|
164
|
+
pageVersionId: body.pageVersionId,
|
|
165
|
+
position: body.position,
|
|
166
|
+
titleOverride: body.titleOverride,
|
|
167
|
+
numbering: body.numbering
|
|
168
|
+
});
|
|
169
|
+
return json(okResult(result2), { status: 200 });
|
|
170
|
+
}
|
|
171
|
+
if (action === "update-document-section-links") {
|
|
172
|
+
const result2 = await updateDocmanDocumentSectionLinksFlow({
|
|
173
|
+
scopeId: resolvedScopeId,
|
|
174
|
+
documentVersionId: body.documentVersionId,
|
|
175
|
+
updates: body.updates
|
|
176
|
+
});
|
|
177
|
+
return json(okResult(result2), { status: 200 });
|
|
178
|
+
}
|
|
179
|
+
if (action === "update-section-page-links") {
|
|
180
|
+
const result2 = await updateDocmanSectionPageLinksFlow({
|
|
181
|
+
scopeId: resolvedScopeId,
|
|
182
|
+
sectionId: body.sectionId,
|
|
183
|
+
updates: body.updates
|
|
184
|
+
});
|
|
185
|
+
return json(okResult(result2), { status: 200 });
|
|
186
|
+
}
|
|
187
|
+
if (action === "save-page-version-draft") {
|
|
188
|
+
const result2 = await saveDocmanPageVersionDraftFlow({
|
|
189
|
+
scopeId: resolvedScopeId,
|
|
190
|
+
pageVersionId: body.pageVersionId,
|
|
191
|
+
documentLinkId: body.documentLinkId,
|
|
192
|
+
data: body.data
|
|
193
|
+
});
|
|
194
|
+
return json(okResult(result2), { status: 200 });
|
|
195
|
+
}
|
|
196
|
+
if (action === "update-document-version") {
|
|
197
|
+
const result2 = await updateDocmanDocumentVersionFlow({
|
|
198
|
+
scopeId: resolvedScopeId,
|
|
199
|
+
documentVersionId: body.documentVersionId,
|
|
200
|
+
documentId: body.documentId,
|
|
201
|
+
data: body.data
|
|
202
|
+
});
|
|
203
|
+
return json(okResult(result2), { status: 200 });
|
|
204
|
+
}
|
|
205
|
+
if (action === "update-page") {
|
|
206
|
+
const result2 = await updateDocmanPageFlow({
|
|
207
|
+
scopeId: resolvedScopeId,
|
|
208
|
+
pageId: body.pageId,
|
|
209
|
+
data: body.data
|
|
210
|
+
});
|
|
211
|
+
return json(okResult(result2), { status: 200 });
|
|
212
|
+
}
|
|
213
|
+
if (action === "copy-page") {
|
|
214
|
+
const result2 = await copyDocmanPageFlow({
|
|
215
|
+
scopeId: resolvedScopeId,
|
|
216
|
+
sourcePageId: body.sourcePageId,
|
|
217
|
+
sourcePageVersionId: body.sourcePageVersionId,
|
|
218
|
+
targetSectionId: body.targetSectionId,
|
|
219
|
+
position: body.position,
|
|
220
|
+
rename: body.rename,
|
|
221
|
+
clonePage: body.clonePage
|
|
222
|
+
});
|
|
223
|
+
return json(okResult(result2), { status: 200 });
|
|
224
|
+
}
|
|
225
|
+
if (action === "create-document-version") {
|
|
226
|
+
const result2 = await createDocmanDocumentVersionFlow({
|
|
227
|
+
scopeId: resolvedScopeId,
|
|
228
|
+
documentId: body.documentId,
|
|
229
|
+
data: body.data,
|
|
230
|
+
documentInitMode: body.documentInitMode,
|
|
231
|
+
sourceVersionId: body.sourceVersionId,
|
|
232
|
+
sourceSectionLinkIds: body.sourceSectionLinkIds
|
|
233
|
+
});
|
|
234
|
+
return json(okResult(result2), { status: 200 });
|
|
235
|
+
}
|
|
236
|
+
if (action === "create-page-with-initial-version") {
|
|
237
|
+
const result2 = await createDocmanPageWithInitialVersionFlow({
|
|
238
|
+
scopeId: resolvedScopeId,
|
|
239
|
+
data: body.format === void 0 ? body.data : {
|
|
240
|
+
...toRecord(body.data),
|
|
241
|
+
format: body.format
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
return json(okResult(result2), { status: 200 });
|
|
245
|
+
}
|
|
246
|
+
const result = await createLinkedDocmanPage({
|
|
247
|
+
scopeId: resolvedScopeId,
|
|
248
|
+
documentVersionId: body.documentVersionId,
|
|
249
|
+
sectionId: body.sectionId,
|
|
250
|
+
parentLinkId: body.parentLinkId,
|
|
251
|
+
format: body.format
|
|
252
|
+
});
|
|
253
|
+
return json(okResult(result), { status: 200 });
|
|
254
|
+
} catch (error) {
|
|
255
|
+
const message = error instanceof Error && error.message.trim().length > 0 ? error.message : "docman_flow_failed";
|
|
256
|
+
return json(errResult(message), { status: inferDocmanFlowErrorStatus(message) });
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
export { POST };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { j as json } from './index.js-BQnOaW3H.js';
|
|
2
|
+
import { o as okResult } from './xf-result-BRDjvftr.js';
|
|
3
|
+
|
|
4
|
+
const GET = async ({ locals }) => {
|
|
5
|
+
if (!locals.principal) {
|
|
6
|
+
return json({ ok: false, error: "auth_principal_missing" }, { status: 500 });
|
|
7
|
+
}
|
|
8
|
+
return json(okResult({
|
|
9
|
+
principal: locals.principal,
|
|
10
|
+
tenantId: locals.tenantId,
|
|
11
|
+
authProvider: "trusted-local",
|
|
12
|
+
authRequired: false
|
|
13
|
+
}));
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { GET };
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { j as json } from './index.js-BQnOaW3H.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { g as getAgentGateway } from './agent-gateway-runtime-C7Kvvy0H.js';
|
|
4
|
+
import { n as normalizePluginFailure, t as toSafePluginFailureLogDetails, i as inferFailureStatusFromPayload, c as classifyInvokeFailureMessage } from './plugin-error-normalize-DNeRsopQ.js';
|
|
5
|
+
import { a as attachResolvedProjectScope, r as resolveHostRequestContext } from './request-context-9wzBoKrz.js';
|
|
6
|
+
import '@aopslabs/host-core';
|
|
7
|
+
import '@aopslabs/manifest';
|
|
8
|
+
import './registry-DO8ob5o1.js';
|
|
9
|
+
import 'node:path';
|
|
10
|
+
import 'node:module';
|
|
11
|
+
import 'node:url';
|
|
12
|
+
import './aops-runtime-config-CHpDUCdE.js';
|
|
13
|
+
import 'node:fs';
|
|
14
|
+
import 'pg';
|
|
15
|
+
import 'node:worker_threads';
|
|
16
|
+
import './admission-snapshot-C2wGfTWE.js';
|
|
17
|
+
import 'node:crypto';
|
|
18
|
+
import 'node:child_process';
|
|
19
|
+
import 'node:util';
|
|
20
|
+
import './project-alias-BdnRxWft.js';
|
|
21
|
+
import './canonical-text-order-DbXJJnFD.js';
|
|
22
|
+
import 'ajv';
|
|
23
|
+
import '@aopslabs/xf-dm-kits/appConfig';
|
|
24
|
+
import '@aopslabs/xf-dm-kits';
|
|
25
|
+
import '@aopslabs/domain-kit-agentspace';
|
|
26
|
+
import './xf-result-BRDjvftr.js';
|
|
27
|
+
import 'effect';
|
|
28
|
+
|
|
29
|
+
const invokeEnvelopeSchema = z.object({
|
|
30
|
+
sourceId: z.string().trim().min(1).optional(),
|
|
31
|
+
input: z.unknown().optional(),
|
|
32
|
+
preview: z.boolean().optional(),
|
|
33
|
+
apply: z.boolean().optional(),
|
|
34
|
+
confirm: z.boolean().optional(),
|
|
35
|
+
idempotencyKey: z.string().trim().min(1).max(200).optional()
|
|
36
|
+
}).strict();
|
|
37
|
+
function isRecord(value) {
|
|
38
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
39
|
+
}
|
|
40
|
+
function normalizeErrorMessage(error) {
|
|
41
|
+
return error instanceof Error ? error.message : String(error ?? "unknown_error");
|
|
42
|
+
}
|
|
43
|
+
function sanitizeInvokeHeaders(input) {
|
|
44
|
+
const headers = new Headers();
|
|
45
|
+
if (!input) return headers;
|
|
46
|
+
for (const [nameRaw, value] of Object.entries(input)) {
|
|
47
|
+
const name = nameRaw.trim().toLowerCase();
|
|
48
|
+
if (!name) continue;
|
|
49
|
+
if (name === "content-length" || name === "content-type" || name === "transfer-encoding" || name === "connection" || name === "keep-alive" || name === "content-encoding") {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
headers.set(name, value);
|
|
53
|
+
}
|
|
54
|
+
return headers;
|
|
55
|
+
}
|
|
56
|
+
function hasClientProvidedContext(input) {
|
|
57
|
+
return isRecord(input) && Object.prototype.hasOwnProperty.call(input, "context");
|
|
58
|
+
}
|
|
59
|
+
function resolveActivitySourceKind(event) {
|
|
60
|
+
const candidate = String(event.request.headers.get("x-activity-source-kind") ?? "").trim().toLowerCase();
|
|
61
|
+
if (candidate === "aops-cli" || candidate === "desktop" || candidate === "runner" || candidate === "system") {
|
|
62
|
+
return candidate;
|
|
63
|
+
}
|
|
64
|
+
return "system";
|
|
65
|
+
}
|
|
66
|
+
async function parseInvokePayload(event) {
|
|
67
|
+
try {
|
|
68
|
+
const rawText = await event.request.text();
|
|
69
|
+
if (!rawText.trim()) {
|
|
70
|
+
return { ok: true, input: void 0 };
|
|
71
|
+
}
|
|
72
|
+
const rawPayload = JSON.parse(rawText);
|
|
73
|
+
const shouldParseEnvelope = isRecord(rawPayload) && ("input" in rawPayload || "preview" in rawPayload || "apply" in rawPayload || "confirm" in rawPayload || "idempotencyKey" in rawPayload || Object.keys(rawPayload).every(
|
|
74
|
+
(key) => key === "sourceId" || key === "input" || key === "preview" || key === "apply" || key === "confirm" || key === "idempotencyKey"
|
|
75
|
+
));
|
|
76
|
+
if (!shouldParseEnvelope) {
|
|
77
|
+
if (hasClientProvidedContext(rawPayload)) {
|
|
78
|
+
return {
|
|
79
|
+
ok: false,
|
|
80
|
+
error: "invalid_input",
|
|
81
|
+
message: "invalid_invoke_payload:context_not_allowed"
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
return { ok: true, input: rawPayload };
|
|
85
|
+
}
|
|
86
|
+
const parsedEnvelope = invokeEnvelopeSchema.safeParse(rawPayload);
|
|
87
|
+
if (!parsedEnvelope.success) {
|
|
88
|
+
return {
|
|
89
|
+
ok: false,
|
|
90
|
+
error: "invalid_input",
|
|
91
|
+
message: `invalid_invoke_payload:${parsedEnvelope.error.issues[0]?.message ?? "invalid_envelope"}`
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
if (hasClientProvidedContext(parsedEnvelope.data.input)) {
|
|
95
|
+
return {
|
|
96
|
+
ok: false,
|
|
97
|
+
error: "invalid_input",
|
|
98
|
+
message: "invalid_invoke_payload:input.context_not_allowed"
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
ok: true,
|
|
103
|
+
sourceId: parsedEnvelope.data.sourceId?.trim().toLowerCase(),
|
|
104
|
+
input: parsedEnvelope.data.input,
|
|
105
|
+
preview: parsedEnvelope.data.preview,
|
|
106
|
+
apply: parsedEnvelope.data.apply,
|
|
107
|
+
confirm: parsedEnvelope.data.confirm,
|
|
108
|
+
idempotencyKey: parsedEnvelope.data.idempotencyKey?.trim()
|
|
109
|
+
};
|
|
110
|
+
} catch {
|
|
111
|
+
return {
|
|
112
|
+
ok: false,
|
|
113
|
+
error: "invalid_input",
|
|
114
|
+
message: "invalid_json_body"
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
const POST = async (event) => {
|
|
119
|
+
await attachResolvedProjectScope(event);
|
|
120
|
+
const toolId = event.params.toolId?.trim().toLowerCase();
|
|
121
|
+
if (!toolId) {
|
|
122
|
+
return json({ ok: false, error: "missing_tool_id" }, { status: 400 });
|
|
123
|
+
}
|
|
124
|
+
const gateway = getAgentGateway();
|
|
125
|
+
const parsedPayload = await parseInvokePayload(event);
|
|
126
|
+
if (!parsedPayload.ok) {
|
|
127
|
+
return json({ ok: false, error: parsedPayload.error, message: parsedPayload.message }, { status: 400 });
|
|
128
|
+
}
|
|
129
|
+
try {
|
|
130
|
+
const result = await gateway.invokeTool({
|
|
131
|
+
toolId,
|
|
132
|
+
sourceId: parsedPayload.sourceId,
|
|
133
|
+
input: parsedPayload.input,
|
|
134
|
+
preview: parsedPayload.preview,
|
|
135
|
+
apply: parsedPayload.apply,
|
|
136
|
+
confirm: parsedPayload.confirm,
|
|
137
|
+
idempotencyKey: parsedPayload.idempotencyKey,
|
|
138
|
+
context: {
|
|
139
|
+
...resolveHostRequestContext(event),
|
|
140
|
+
activitySourceKind: resolveActivitySourceKind(event)
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
const normalized = normalizePluginFailure(result.status, result.data);
|
|
144
|
+
if (normalized.sanitized) {
|
|
145
|
+
console.warn("[agent-invoke] sanitized plugin error response", {
|
|
146
|
+
toolId,
|
|
147
|
+
...toSafePluginFailureLogDetails(normalized.payload)
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
const effectiveStatus = inferFailureStatusFromPayload(normalized.payload, normalized.status);
|
|
151
|
+
const payloadOk = isRecord(normalized.payload) ? normalized.payload.ok !== false : true;
|
|
152
|
+
const responseOk = effectiveStatus < 400 && payloadOk;
|
|
153
|
+
return json(
|
|
154
|
+
{
|
|
155
|
+
ok: responseOk,
|
|
156
|
+
tool: result.tool,
|
|
157
|
+
data: normalized.payload,
|
|
158
|
+
response: normalized.payload
|
|
159
|
+
},
|
|
160
|
+
{ status: effectiveStatus, headers: sanitizeInvokeHeaders(result.headers) }
|
|
161
|
+
);
|
|
162
|
+
} catch (error) {
|
|
163
|
+
const message = normalizeErrorMessage(error);
|
|
164
|
+
const classification = classifyInvokeFailureMessage(message);
|
|
165
|
+
return json(
|
|
166
|
+
{ ok: false, error: classification.error, message },
|
|
167
|
+
{ status: classification.status }
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
export { POST };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
const SERVER_STATUS_PAGE = `<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<meta name="color-scheme" content="light dark" />
|
|
7
|
+
<title>AOPS Community Server</title>
|
|
8
|
+
<style>
|
|
9
|
+
:root {
|
|
10
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
11
|
+
color: #2f2925;
|
|
12
|
+
background: #f7efe1;
|
|
13
|
+
}
|
|
14
|
+
body {
|
|
15
|
+
margin: 0;
|
|
16
|
+
min-height: 100vh;
|
|
17
|
+
display: grid;
|
|
18
|
+
place-items: center;
|
|
19
|
+
}
|
|
20
|
+
main {
|
|
21
|
+
width: min(42rem, calc(100vw - 3rem));
|
|
22
|
+
border: 1px solid #d7c7ad;
|
|
23
|
+
background: #fffaf1;
|
|
24
|
+
padding: 2rem;
|
|
25
|
+
box-shadow: 0.75rem 0.75rem 0 #eadbc2;
|
|
26
|
+
}
|
|
27
|
+
h1 {
|
|
28
|
+
margin: 0 0 0.75rem;
|
|
29
|
+
font-size: clamp(1.35rem, 3vw, 2rem);
|
|
30
|
+
font-weight: 600;
|
|
31
|
+
}
|
|
32
|
+
p {
|
|
33
|
+
line-height: 1.6;
|
|
34
|
+
}
|
|
35
|
+
.status {
|
|
36
|
+
display: inline-flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
gap: 0.55rem;
|
|
39
|
+
margin: 0 0 1.5rem;
|
|
40
|
+
}
|
|
41
|
+
.status::before {
|
|
42
|
+
width: 0.65rem;
|
|
43
|
+
height: 0.65rem;
|
|
44
|
+
border-radius: 50%;
|
|
45
|
+
background: #2d8a5b;
|
|
46
|
+
content: "";
|
|
47
|
+
}
|
|
48
|
+
nav {
|
|
49
|
+
display: flex;
|
|
50
|
+
flex-wrap: wrap;
|
|
51
|
+
gap: 0.65rem 1.25rem;
|
|
52
|
+
margin-top: 1.5rem;
|
|
53
|
+
}
|
|
54
|
+
a {
|
|
55
|
+
color: #8a3f20;
|
|
56
|
+
text-underline-offset: 0.2em;
|
|
57
|
+
}
|
|
58
|
+
</style>
|
|
59
|
+
</head>
|
|
60
|
+
<body>
|
|
61
|
+
<main>
|
|
62
|
+
<h1>AOPS Community Server</h1>
|
|
63
|
+
<p class="status">Server interface is running</p>
|
|
64
|
+
<p>
|
|
65
|
+
This port owns the AOPS API and discovery surface. AOPS Cockpit is a
|
|
66
|
+
separate local service.
|
|
67
|
+
</p>
|
|
68
|
+
<nav aria-label="Server resources">
|
|
69
|
+
<a href="/api/health">Health</a>
|
|
70
|
+
<a href="/api-info">API information</a>
|
|
71
|
+
<a href="/api-info.json">Discovery JSON</a>
|
|
72
|
+
<a href="/openapi.json">OpenAPI</a>
|
|
73
|
+
</nav>
|
|
74
|
+
</main>
|
|
75
|
+
</body>
|
|
76
|
+
</html>`;
|
|
77
|
+
const GET = async () => new Response(SERVER_STATUS_PAGE, {
|
|
78
|
+
status: 200,
|
|
79
|
+
headers: {
|
|
80
|
+
"cache-control": "no-store",
|
|
81
|
+
"content-security-policy": "default-src 'none'; base-uri 'none'; frame-ancestors 'none'; style-src 'unsafe-inline'",
|
|
82
|
+
"content-type": "text/html; charset=utf-8",
|
|
83
|
+
"cross-origin-resource-policy": "same-origin",
|
|
84
|
+
"referrer-policy": "no-referrer",
|
|
85
|
+
"x-content-type-options": "nosniff",
|
|
86
|
+
"x-frame-options": "DENY"
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
export { GET };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { j as json } from './index.js-BQnOaW3H.js';
|
|
2
|
+
import { t as testRuntimeConfigAdminTarget, g as getResolvedAopsServerRuntimeConfig } from './aops-runtime-config-CHpDUCdE.js';
|
|
3
|
+
import { o as okResult } from './xf-result-BRDjvftr.js';
|
|
4
|
+
import 'node:fs';
|
|
5
|
+
import 'node:path';
|
|
6
|
+
import 'pg';
|
|
7
|
+
|
|
8
|
+
function toSafeErrorMessage(_error, fallback = "PostgreSQL status probe failed.") {
|
|
9
|
+
return fallback;
|
|
10
|
+
}
|
|
11
|
+
async function getDbAdminStatus() {
|
|
12
|
+
const runtime = getResolvedAopsServerRuntimeConfig();
|
|
13
|
+
if (!runtime.repoUrl) {
|
|
14
|
+
return {
|
|
15
|
+
checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
16
|
+
env: { repoUrlEnv: "AOPS_PG_URL", repoUrlPresent: false },
|
|
17
|
+
connection: { ok: false, databaseName: null, message: "AOPS_PG_URL is required.", redactedUrl: null },
|
|
18
|
+
schema: { verificationLevel: "sentinel-relations-only", ready: false, sentinelsPresent: false, configuredRelationCount: 5, existingRelationCount: 0, existingRelations: [], missingRelations: ["projects", "docman_documents", "projectman_kanban_boards", "chatv3-rooms", "sys_event_stores"] },
|
|
19
|
+
capabilities: { status: true, probe: true, reset: false, backup: false, restore: false }
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
const probe = await testRuntimeConfigAdminTarget();
|
|
24
|
+
return {
|
|
25
|
+
checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
26
|
+
env: { repoUrlEnv: "AOPS_PG_URL", repoUrlPresent: true },
|
|
27
|
+
connection: { ...probe.connection, redactedUrl: probe.target.redactedRepoUrl },
|
|
28
|
+
schema: probe.schema,
|
|
29
|
+
capabilities: { status: true, probe: true, reset: false, backup: false, restore: false }
|
|
30
|
+
};
|
|
31
|
+
} catch (error) {
|
|
32
|
+
return {
|
|
33
|
+
checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
34
|
+
env: { repoUrlEnv: "AOPS_PG_URL", repoUrlPresent: true },
|
|
35
|
+
connection: { ok: false, databaseName: null, message: toSafeErrorMessage(), redactedUrl: null },
|
|
36
|
+
schema: { verificationLevel: "sentinel-relations-only", ready: false, sentinelsPresent: false, configuredRelationCount: 5, existingRelationCount: 0, existingRelations: [], missingRelations: ["projects", "docman_documents", "projectman_kanban_boards", "chatv3-rooms", "sys_event_stores"] },
|
|
37
|
+
capabilities: { status: true, probe: true, reset: false, backup: false, restore: false }
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const GET = async () => json(okResult(await getDbAdminStatus()), { status: 200 });
|
|
42
|
+
|
|
43
|
+
export { GET };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { j as json } from './index.js-BQnOaW3H.js';
|
|
2
|
+
import { a as getAgentToolDetailDocument } from './discovery-BvDEgiqC.js';
|
|
3
|
+
import { r as resolveRequestBaseUrl } from './request-base-url-zKJpVUv5.js';
|
|
4
|
+
import './agent-gateway-runtime-C7Kvvy0H.js';
|
|
5
|
+
import '@aopslabs/host-core';
|
|
6
|
+
import '@aopslabs/manifest';
|
|
7
|
+
import './registry-DO8ob5o1.js';
|
|
8
|
+
import 'node:path';
|
|
9
|
+
import 'node:module';
|
|
10
|
+
import 'node:url';
|
|
11
|
+
import './aops-runtime-config-CHpDUCdE.js';
|
|
12
|
+
import 'node:fs';
|
|
13
|
+
import 'pg';
|
|
14
|
+
import 'node:worker_threads';
|
|
15
|
+
import './admission-snapshot-C2wGfTWE.js';
|
|
16
|
+
import 'node:crypto';
|
|
17
|
+
import 'node:child_process';
|
|
18
|
+
import 'node:util';
|
|
19
|
+
import './project-alias-BdnRxWft.js';
|
|
20
|
+
import './canonical-text-order-DbXJJnFD.js';
|
|
21
|
+
import 'ajv';
|
|
22
|
+
import 'zod';
|
|
23
|
+
import './auth-provider-C07OUlnz.js';
|
|
24
|
+
|
|
25
|
+
const GET = async ({ params, request, url }) => {
|
|
26
|
+
const toolId = params.toolId?.trim().toLowerCase();
|
|
27
|
+
if (!toolId) {
|
|
28
|
+
return json({ ok: false, error: "missing_tool_id" }, { status: 400 });
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const serverBaseUrl = resolveRequestBaseUrl(request, url);
|
|
32
|
+
const detail = await getAgentToolDetailDocument({ toolId, serverBaseUrl });
|
|
33
|
+
if (!detail) {
|
|
34
|
+
return json({ ok: false, error: "tool_not_found", toolId }, { status: 404 });
|
|
35
|
+
}
|
|
36
|
+
return json(detail, { status: 200 });
|
|
37
|
+
} catch (error) {
|
|
38
|
+
const message = error instanceof Error ? error.message : String(error ?? "unknown_error");
|
|
39
|
+
return json({ ok: false, error: "tool_detail_failed", message }, { status: 500 });
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export { GET };
|