@lobu/runtime-server 24.0.0 → 24.1.1
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/dist/component.json +1 -1
- package/dist/connectors/x-dm-adapter.js +65 -30
- package/dist/db/migrations/20261021010000_views_compile_config_hash.sql +16 -0
- package/dist/dependencies.bun.lock +1 -1
- package/dist/owletto/dist/assets/{_-CC8cTmRg.js → _-BorucF19.js} +3 -3
- package/dist/owletto/dist/assets/_-CkGyNi0G.js +2 -0
- package/dist/owletto/dist/assets/_agentId-BrhcaxUk.js +2 -0
- package/dist/owletto/dist/assets/{_agentId-DWUFSrVp.js → _agentId-DgRrCE2B.js} +2 -2
- package/dist/owletto/dist/assets/{_automationId-BnHqdXOC.js → _automationId-DSrZIYcs.js} +2 -2
- package/dist/owletto/dist/assets/{_connectorKey._connectionId-CefXIqy2.js → _connectorKey._connectionId-DWxv1uoi.js} +2 -2
- package/dist/owletto/dist/assets/{_connectorKey.index-C1QPGf9E.js → _connectorKey.index-BTP5ijdT.js} +2 -2
- package/dist/owletto/dist/assets/{_conversationId-DinuPCUp.js → _conversationId-98Y3RuRO.js} +2 -2
- package/dist/owletto/dist/assets/{_deploymentId-BeyzVjRm.js → _deploymentId-B1UWPY0i.js} +2 -2
- package/dist/owletto/dist/assets/{_eventId-3L_qeL_l.js → _eventId-BAnr8g8z.js} +2 -2
- package/dist/owletto/dist/assets/_name-BUfFO_A0.js +2 -0
- package/dist/owletto/dist/assets/{_owner-DbrKma4e.js → _owner-C79BwQ0I.js} +3 -3
- package/dist/owletto/dist/assets/_shape-Ep6JpyFX.js +2 -0
- package/dist/owletto/dist/assets/_skillKey-B24alBfT.js +2 -0
- package/dist/owletto/dist/assets/{_slug-ndDr_CUg.js → _slug-DbPdDc-5.js} +2 -2
- package/dist/owletto/dist/assets/_viewKey-DDUxjjFD.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-hdpq3RoX.js +2 -0
- package/dist/owletto/dist/assets/{accept-invitation-CRKbM2Xy.js → accept-invitation-UXU5Fx2G.js} +2 -2
- package/dist/owletto/dist/assets/{activity-route-view-CFLNukhD.js → activity-route-view-D7ORHntE.js} +2 -2
- package/dist/owletto/dist/assets/{agent-card-controls-Be1Okb2C.js → agent-card-controls-CplnPhbv.js} +2 -2
- package/dist/owletto/dist/assets/{agent-client-setup-list-BA8dU_C6.js → agent-client-setup-list-BlXB4SE5.js} +2 -2
- package/dist/owletto/dist/assets/{agent-connect-pages-CAV-yXus.js → agent-connect-pages-BmknviTI.js} +2 -2
- package/dist/owletto/dist/assets/{agent-editor-form-Bi6WvYX-.js → agent-editor-form-DsSoeQeF.js} +2 -2
- package/dist/owletto/dist/assets/{agent-guardrails-route-DMOjG1D4.js → agent-guardrails-route-TdvvIc_J.js} +2 -2
- package/dist/owletto/dist/assets/{agent-loading-shells-De_2d8Lr.js → agent-loading-shells-B7v6Cffw.js} +2 -2
- package/dist/owletto/dist/assets/{agent-permissions-matrix-gZWl6mAe.js → agent-permissions-matrix-BkZu1LYE.js} +2 -2
- package/dist/owletto/dist/assets/{agent-skill-context-JLaTamGR.js → agent-skill-context-DFucg4c4.js} +2 -2
- package/dist/owletto/dist/assets/{agent-skills-route-DcK41PWj.js → agent-skills-route-B3vvvZZe.js} +2 -2
- package/dist/owletto/dist/assets/{agent-subpage-shell-BBJoyTuC.js → agent-subpage-shell-CZJvnjNC.js} +2 -2
- package/dist/owletto/dist/assets/agent-thread-D38STyeu.js +6 -0
- package/dist/owletto/dist/assets/agents-DAOln24A.js +2 -0
- package/dist/owletto/dist/assets/{agents-workbench-CqaKGggb.js → agents-workbench-DJ67GZ93.js} +2 -2
- package/dist/owletto/dist/assets/{app._appId-Cl1fTuIt.js → app._appId-Cp78oEZ9.js} +2 -2
- package/dist/owletto/dist/assets/{automation-detail-content-BMLL4lxO.js → automation-detail-content-DSwbRpbx.js} +2 -2
- package/dist/owletto/dist/assets/automations-DAOln24A.js +2 -0
- package/dist/owletto/dist/assets/{callback-DTKKsfkz.js → callback-CBexCo3F.js} +2 -2
- package/dist/owletto/dist/assets/{card-yU0TmNRH.js → card-jzhQrMDP.js} +2 -2
- package/dist/owletto/dist/assets/{claim-DJfTvlT2.js → claim-B-wq745Q.js} +2 -2
- package/dist/owletto/dist/assets/{client-rows--FrZfJol.js → client-rows-BYbsXGy9.js} +2 -2
- package/dist/owletto/dist/assets/{clients-L4K1UT8c.js → clients-BhNl1tVq.js} +2 -2
- package/dist/owletto/dist/assets/{code-editor-U54Gwjit.js → code-editor-CEqoCky-.js} +2 -2
- package/dist/owletto/dist/assets/connect-wx-qqLir.js +2 -0
- package/dist/owletto/dist/assets/connect._clientId-kk0_4Svo.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId-QR8o-7M5.js +2 -0
- package/dist/owletto/dist/assets/{connected._clientId.activity-DTpSW1Xy.js → connected._clientId.activity-BqprYeOX.js} +2 -2
- package/dist/owletto/dist/assets/{connected._clientId.index-h9X5H1x8.js → connected._clientId.index-DhRoSzBr.js} +2 -2
- package/dist/owletto/dist/assets/{connection-ByvKkyFm.js → connection-CNm2ukrI.js} +2 -2
- package/dist/owletto/dist/assets/{connection-feed-detail-DWM9lTao.js → connection-feed-detail-WcGCA6qY.js} +2 -2
- package/dist/owletto/dist/assets/{connections-browser-CEwYrYqt.js → connections-browser-CrtnAs0Q.js} +2 -2
- package/dist/owletto/dist/assets/{connector-provenance-BocTm__v.js → connector-provenance-D-ECOlMJ.js} +2 -2
- package/dist/owletto/dist/assets/{connector-scope-lists-OYDOydtz.js → connector-scope-lists-CRFEpSvk.js} +2 -2
- package/dist/owletto/dist/assets/{connectors-CyZpcE5f.js → connectors-CH4KBZyT.js} +2 -2
- package/dist/owletto/dist/assets/{consent-DdfINrVp.js → consent-C9ZpHb7V.js} +2 -2
- package/dist/owletto/dist/assets/{conversations-table-BSznfdYt.js → conversations-table-D_HOe1jN.js} +2 -2
- package/dist/owletto/dist/assets/{core.esm-Dr7tcIB-.js → core.esm-BupT3V0i.js} +2 -2
- package/dist/owletto/dist/assets/create-C4lptGWj.js +2 -0
- package/dist/owletto/dist/assets/{create-CBGwASon.js → create-CCjZxIkK.js} +2 -2
- package/dist/owletto/dist/assets/create-DkgUQAbB.js +2 -0
- package/dist/owletto/dist/assets/{create-automation-form-9T5WnoUs.js → create-automation-form-Bpy92SM5.js} +2 -2
- package/dist/owletto/dist/assets/create._connectorKey-D6Kc-YQ3.js +2 -0
- package/dist/owletto/dist/assets/{cronstrue-BWFEyy_P.js → cronstrue-CWImw-kf.js} +2 -2
- package/dist/owletto/dist/assets/{deployments-wG_8QzOF.js → deployments-C5hvipQh.js} +2 -2
- package/dist/owletto/dist/assets/deployments-CPpFAd_w.js +2 -0
- package/dist/owletto/dist/assets/{deployments-body-2xKS8gRo.js → deployments-body-DGII20dQ.js} +2 -2
- package/dist/owletto/dist/assets/{device-6z-xgsoW.js → device-D-7WBe9E.js} +2 -2
- package/dist/owletto/dist/assets/{device-pin-tombstone-Cwq88RMU.js → device-pin-tombstone-2U0UMu3_.js} +2 -2
- package/dist/owletto/dist/assets/{device._deviceId-BDerBfD9.js → device._deviceId-Bn37UpWH.js} +2 -2
- package/dist/owletto/dist/assets/{entity-avatar-Cc1CuI-0.js → entity-avatar-mdh7Kq5D.js} +2 -2
- package/dist/owletto/dist/assets/{entity-options-DHdMC1Lx.js → entity-options-Clz_WXK-.js} +2 -2
- package/dist/owletto/dist/assets/{entity-page--OkXmlNP.js → entity-page-D3e4iPle.js} +2 -2
- package/dist/owletto/dist/assets/{entity-type-page-89RoK_-P.js → entity-type-page-DebN1vCM.js} +2 -2
- package/dist/owletto/dist/assets/{event-detail-D4YZRtrA.js → event-detail-DV_zfWnC.js} +2 -2
- package/dist/owletto/dist/assets/events-feed-DO3IiJO2.js +2 -0
- package/dist/owletto/dist/assets/{filter-editors-B1_QUpg_.js → filter-editors-Bwhqj7lY.js} +2 -2
- package/dist/owletto/dist/assets/{full-page-spinner-Cqih-8IW.js → full-page-spinner-BVbcpW3R.js} +2 -2
- package/dist/owletto/dist/assets/guardrails-BiJollCA.js +2 -0
- package/dist/owletto/dist/assets/identity-HCFWtdaI.js +2 -0
- package/dist/owletto/dist/assets/index-8wxsyxqt.js +2 -0
- package/dist/owletto/dist/assets/{index-DYCqXaMf.js → index-9YuSRymd.js} +4 -4
- package/dist/owletto/dist/assets/index-B3c-0eZG.js +2 -0
- package/dist/owletto/dist/assets/{index-TgRS2v_F.js → index-B64PGxQm.js} +2 -2
- package/dist/owletto/dist/assets/{index-DfyDUpuI.js → index-BTlx9K_t.js} +2 -2
- package/dist/owletto/dist/assets/index-BX0EA_oB.js +2 -0
- package/dist/owletto/dist/assets/index-CdJJaQDX.js +2 -0
- package/dist/owletto/dist/assets/index-CfT_W8Vo.js +2 -0
- package/dist/owletto/dist/assets/{index-DYzWV5_z.js → index-CxF2XXzl.js} +2 -2
- package/dist/owletto/dist/assets/index-D3WHeGql.js +2 -0
- package/dist/owletto/dist/assets/{index-ZNlrDc_f.js → index-D7gHOpfg.js} +2 -2
- package/dist/owletto/dist/assets/{index-DKPwCasf.js → index-DB1iWI_a.js} +2 -2
- package/dist/owletto/dist/assets/index-DMNzF8Lf.js +2 -0
- package/dist/owletto/dist/assets/index-DyB3IzOA.js +2 -0
- package/dist/owletto/dist/assets/{index-DAOyXG1X.js → index-fgAJydgX.js} +2 -2
- package/dist/owletto/dist/assets/{json-diff-DFvYINBT.js → json-diff-DIN5Jhfx.js} +2 -2
- package/dist/owletto/dist/assets/{list-skeleton-DFsEqLU1.js → list-skeleton-CepswBka.js} +2 -2
- package/dist/owletto/dist/assets/{login-DO0j-AYr.js → login-DxGYyE4n.js} +2 -2
- package/dist/owletto/dist/assets/{logout-BmNwoAf7.js → logout-Bkzc7J44.js} +2 -2
- package/dist/owletto/dist/assets/{member-scope-gate-B2LrMWBU.js → member-scope-gate-DD4YBFn-.js} +2 -2
- package/dist/owletto/dist/assets/{memory-browse-page-Cjpl8EbB.js → memory-browse-page-D_UlBa27.js} +2 -2
- package/dist/owletto/dist/assets/{model-selector-TQcA93xm.js → model-selector-CDrAjH31.js} +2 -2
- package/dist/owletto/dist/assets/models-BAVeysNq.js +2 -0
- package/dist/owletto/dist/assets/{new-BMrFy5Qa.js → new-C2av0diq.js} +2 -2
- package/dist/owletto/dist/assets/{new-ByBhteWA.js → new-ktz9Cs_P.js} +2 -2
- package/dist/owletto/dist/assets/{new-DWp3deoW.js → new-snm1ctHn.js} +2 -2
- package/dist/owletto/dist/assets/{oauth-workspace-access-D_5uESuz.js → oauth-workspace-access-lZNZ9gul.js} +2 -2
- package/dist/owletto/dist/assets/{organization-DTFoYP4V.js → organization-Cb0W823y.js} +2 -2
- package/dist/owletto/dist/assets/{peek-pane-content-DF5iGC3c.js → peek-pane-content-BNR9ImQY.js} +2 -2
- package/dist/owletto/dist/assets/{permissions-C_auqxfP.js → permissions-Dv39zWKt.js} +2 -2
- package/dist/owletto/dist/assets/{proposal-review-shell-DsNiavG_.js → proposal-review-shell-CFhOqCLf.js} +2 -2
- package/dist/owletto/dist/assets/public-shell-ready-DqX8AXfw.js +2 -0
- package/dist/owletto/dist/assets/{recent-3d99S2IE.js → recent-QhnLDU1_.js} +2 -2
- package/dist/owletto/dist/assets/{record-activity-C9KfBkXb.js → record-activity-ZJntBfN_.js} +2 -2
- package/dist/owletto/dist/assets/{record-field-peek-BBZcRuGT.js → record-field-peek-Brh1IQGy.js} +2 -2
- package/dist/owletto/dist/assets/{record-session-BizRugWs.js → record-session-Pbr5czGw.js} +2 -2
- package/dist/owletto/dist/assets/{reset-password-DqfcSn8M.js → reset-password-CzZw6RcC.js} +2 -2
- package/dist/owletto/dist/assets/{runs-panel-T1ZxTVz6.js → runs-panel-C0_DNTcq.js} +2 -2
- package/dist/owletto/dist/assets/{runs-table-D_8QlCCN.js → runs-table-B1APZv7d.js} +2 -2
- package/dist/owletto/dist/assets/{schema-value-normalization-CylKX3PK.js → schema-value-normalization-CKdPjdPC.js} +2 -2
- package/dist/owletto/dist/assets/settings-CgZ5Z7wD.js +2 -0
- package/dist/owletto/dist/assets/{settings-B_ClYztB.js → settings-VDNiffKU.js} +2 -2
- package/dist/owletto/dist/assets/skills-DgDGscm5.js +2 -0
- package/dist/owletto/dist/assets/{source-record-panels-Cg249m1S.js → source-record-panels-BdfOVPWn.js} +2 -2
- package/dist/owletto/dist/assets/{use-mention-search-BYbFvHbJ.js → use-mention-search-Dcunv4L0.js} +2 -2
- package/dist/owletto/dist/assets/{view-param-filters-DMSqkN2J.js → view-param-filters-B0quibBi.js} +2 -2
- package/dist/owletto/dist/index.html +1 -1
- package/dist/server-main.bundle.mjs +455 -201
- package/npm-shrinkwrap.json +8 -8
- package/package.json +1 -1
- package/vendor/connector-sdk/package.json +1 -1
- package/vendor/core/dist/contracts/tools/view-runtime.d.ts +74 -0
- package/vendor/core/dist/contracts/tools/view-runtime.js +86 -0
- package/vendor/core/package.json +6 -1
- package/vendor/views/package.json +1 -1
- package/dist/owletto/dist/assets/_-ksFp4zVf.js +0 -2
- package/dist/owletto/dist/assets/_agentId-MENLoohA.js +0 -2
- package/dist/owletto/dist/assets/_name-Dgedji78.js +0 -2
- package/dist/owletto/dist/assets/_shape-DtVfRFz_.js +0 -2
- package/dist/owletto/dist/assets/_skillKey-CqLHzm7L.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-3CH5w8mr.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-DHQY9A8u.js +0 -2
- package/dist/owletto/dist/assets/agent-thread-Buz3naVF.js +0 -6
- package/dist/owletto/dist/assets/agents-C-ReckCa.js +0 -2
- package/dist/owletto/dist/assets/automations-C-ReckCa.js +0 -2
- package/dist/owletto/dist/assets/connect-4zqtnDHb.js +0 -2
- package/dist/owletto/dist/assets/connect._clientId-Dj0SqgbE.js +0 -2
- package/dist/owletto/dist/assets/connected._clientId-sgtocSvf.js +0 -2
- package/dist/owletto/dist/assets/create-Cf5hp6Z8.js +0 -2
- package/dist/owletto/dist/assets/create-CwThQtd3.js +0 -2
- package/dist/owletto/dist/assets/create._connectorKey-sNHQHNpg.js +0 -2
- package/dist/owletto/dist/assets/deployments-DHh9dyzv.js +0 -2
- package/dist/owletto/dist/assets/events-feed-DsrkV2ix.js +0 -2
- package/dist/owletto/dist/assets/guardrails-B8Rs1be3.js +0 -2
- package/dist/owletto/dist/assets/identity-B0nH4yiC.js +0 -2
- package/dist/owletto/dist/assets/index-4TSkcsth.js +0 -2
- package/dist/owletto/dist/assets/index-BgkhXElB.js +0 -2
- package/dist/owletto/dist/assets/index-CoW4Bz3w.js +0 -2
- package/dist/owletto/dist/assets/index-Codw-Qqi.js +0 -2
- package/dist/owletto/dist/assets/index-DMyXd3bJ.js +0 -2
- package/dist/owletto/dist/assets/index-DYYZLcJ0.js +0 -2
- package/dist/owletto/dist/assets/index-Da6CrGEu.js +0 -2
- package/dist/owletto/dist/assets/index-DneshLbf.js +0 -2
- package/dist/owletto/dist/assets/models-D7aED5Sa.js +0 -2
- package/dist/owletto/dist/assets/public-shell-ready-B2NUI89V.js +0 -2
- package/dist/owletto/dist/assets/settings-DgX1-xo7.js +0 -2
- package/dist/owletto/dist/assets/skills-Drw5tcZw.js +0 -2
|
@@ -3404,14 +3404,6 @@ function packageAt(file) {
|
|
|
3404
3404
|
root = parent;
|
|
3405
3405
|
}
|
|
3406
3406
|
}
|
|
3407
|
-
function sourceDependencies(files) {
|
|
3408
|
-
return Object.fromEntries(files.map((file) => {
|
|
3409
|
-
const pkg = packageAt(file);
|
|
3410
|
-
if (!pkg)
|
|
3411
|
-
throw new Error("Cannot determine source dependency version");
|
|
3412
|
-
return [pkg.name, pkg.version];
|
|
3413
|
-
}));
|
|
3414
|
-
}
|
|
3415
3407
|
function createSourceCapture(entry, projectRoot) {
|
|
3416
3408
|
const root = realpathSync(projectRoot);
|
|
3417
3409
|
const entrypoint = relative(root, realpathSync(entry)).split(sep).join("/");
|
|
@@ -6853,7 +6845,7 @@ function isSemanticallyEqual(existing, params) {
|
|
|
6853
6845
|
// from this comparison and from `score` below — they are reconciled in
|
|
6854
6846
|
// place by applyVolatileState instead of minting a new stored version.
|
|
6855
6847
|
durableMetadataState(existing.metadata) === durableMetadataState(params.metadata) && // Compare the value a supersede would WRITE: a null parentOriginId copies
|
|
6856
|
-
// the predecessor's parent (
|
|
6848
|
+
// the predecessor's parent (EVENT_SUPERSEDE_RULES), so only a caller-supplied
|
|
6857
6849
|
// parent can differ. Comparing the raw param would re-supersede a
|
|
6858
6850
|
// copied-parent head on every parentless re-sync, forever.
|
|
6859
6851
|
(params.parentOriginId == null || (existing.origin_parent_id ?? null) === params.parentOriginId) && existing.interaction_type === (params.interactionType ?? "none") && (existing.interaction_status ?? null) === (params.interactionStatus ?? null) && stableJson(existing.interaction_input_schema ?? null) === stableJson(params.interactionInputSchema ?? null) && stableJson(existing.interaction_input ?? null) === stableJson(params.interactionInput ?? null) && stableJson(existing.interaction_output ?? null) === stableJson(params.interactionOutput ?? null) && (existing.interaction_error ?? null) === (params.interactionError ?? null);
|
|
@@ -6897,37 +6889,42 @@ async function upsertEmbedding(eventId, embedding, embeddingModel, sql = getDb()
|
|
|
6897
6889
|
await sql.begin(async (tx) => replaceIfLive(tx));
|
|
6898
6890
|
}
|
|
6899
6891
|
}
|
|
6900
|
-
function
|
|
6901
|
-
return
|
|
6892
|
+
function requestedLineage(params) {
|
|
6893
|
+
return {
|
|
6894
|
+
origin_parent_id: params.parentOriginId ?? null,
|
|
6895
|
+
connector_key: params.connectorKey ?? null,
|
|
6896
|
+
connection_id: params.connectionId ?? null,
|
|
6897
|
+
feed_key: params.feedKey ?? null,
|
|
6898
|
+
feed_id: params.feedId ?? null,
|
|
6899
|
+
run_id: params.runId ?? null,
|
|
6900
|
+
automation_id: params.automationId ?? null,
|
|
6901
|
+
automation_version_id: params.automationVersionId ?? null,
|
|
6902
|
+
client_id: params.clientId ?? null,
|
|
6903
|
+
identity_ns: params.identity?.ns ?? null,
|
|
6904
|
+
identity_key: params.identity?.key ?? null
|
|
6905
|
+
};
|
|
6902
6906
|
}
|
|
6903
|
-
async function
|
|
6904
|
-
const rows = await sql
|
|
6905
|
-
SELECT
|
|
6906
|
-
|
|
6907
|
-
|
|
6908
|
-
|
|
6909
|
-
|
|
6910
|
-
|
|
6911
|
-
LIMIT 1
|
|
6912
|
-
`;
|
|
6913
|
-
const prior = rows[0];
|
|
6914
|
-
if (!prior) {
|
|
6907
|
+
async function loadPredecessorLineage(sql, supersedesEventId, organizationId) {
|
|
6908
|
+
const rows = await sql.unsafe(
|
|
6909
|
+
`SELECT ${INHERITED_COLUMNS.join(", ")} FROM events
|
|
6910
|
+
WHERE id = $1 AND organization_id = $2
|
|
6911
|
+
LIMIT 1`,
|
|
6912
|
+
[supersedesEventId, organizationId]
|
|
6913
|
+
);
|
|
6914
|
+
if (!rows[0]) {
|
|
6915
6915
|
throw new Error(
|
|
6916
|
-
`insertEvent: cannot supersede event ${supersedesEventId} \u2014 not found in organization ${
|
|
6916
|
+
`insertEvent: cannot supersede event ${supersedesEventId} \u2014 not found in organization ${organizationId}`
|
|
6917
6917
|
);
|
|
6918
6918
|
}
|
|
6919
|
-
return
|
|
6920
|
-
|
|
6921
|
-
|
|
6922
|
-
|
|
6923
|
-
|
|
6924
|
-
|
|
6925
|
-
|
|
6926
|
-
|
|
6927
|
-
|
|
6928
|
-
identityNs: prior.identity_ns ?? null,
|
|
6929
|
-
identityKey: prior.identity_key ?? null
|
|
6930
|
-
};
|
|
6919
|
+
return rows[0];
|
|
6920
|
+
}
|
|
6921
|
+
function successorLineage(prior, requested) {
|
|
6922
|
+
return Object.fromEntries(
|
|
6923
|
+
INHERITED_COLUMNS.map((column) => [
|
|
6924
|
+
column,
|
|
6925
|
+
EVENT_SUPERSEDE_RULES[column] === "chain" ? prior[column] : requested[column] ?? prior[column]
|
|
6926
|
+
])
|
|
6927
|
+
);
|
|
6931
6928
|
}
|
|
6932
6929
|
function isEventsClientIdForeignKeyViolation(error) {
|
|
6933
6930
|
const err = error;
|
|
@@ -7000,7 +6997,6 @@ async function insertEvent(params, options) {
|
|
|
7000
6997
|
params = { ...params, metadata: enrichedMetadata };
|
|
7001
6998
|
}
|
|
7002
6999
|
const entityIdsValue = params.entityIds.length > 0 ? `{${params.entityIds.join(",")}}` : null;
|
|
7003
|
-
const requestedClientId = params.clientId ?? null;
|
|
7004
7000
|
const runInsert = async (activeSql) => {
|
|
7005
7001
|
let supersedesEventId = params.supersedesEventId ?? null;
|
|
7006
7002
|
let previousOccurredAt;
|
|
@@ -7059,25 +7055,18 @@ async function insertEvent(params, options) {
|
|
|
7059
7055
|
return insertRow(activeSql, supersedesEventId, previousOccurredAt);
|
|
7060
7056
|
};
|
|
7061
7057
|
const insertRow = async (sql2, supersedesEventId, previousOccurredAt) => {
|
|
7062
|
-
|
|
7063
|
-
|
|
7064
|
-
|
|
7065
|
-
|
|
7066
|
-
|
|
7067
|
-
runId: params.runId ?? null,
|
|
7068
|
-
automationId: params.automationId ?? null,
|
|
7069
|
-
automationVersionId: params.automationVersionId ?? null,
|
|
7070
|
-
parentOriginId: params.parentOriginId ?? null,
|
|
7071
|
-
identityNs: params.identity?.ns ?? null,
|
|
7072
|
-
identityKey: params.identity?.key ?? null
|
|
7073
|
-
};
|
|
7058
|
+
const requested = requestedLineage(params);
|
|
7059
|
+
let lineage = supersedesEventId == null ? requested : successorLineage(
|
|
7060
|
+
await loadPredecessorLineage(sql2, supersedesEventId, params.organizationId),
|
|
7061
|
+
requested
|
|
7062
|
+
);
|
|
7074
7063
|
if (browserConnector) {
|
|
7075
7064
|
lineage = {
|
|
7076
7065
|
...lineage,
|
|
7077
|
-
|
|
7066
|
+
origin_parent_id: sanitizeBrowserText(lineage.origin_parent_id) ?? null
|
|
7078
7067
|
};
|
|
7079
7068
|
}
|
|
7080
|
-
const insertWithClientId = (activeSql,
|
|
7069
|
+
const insertWithClientId = (activeSql, clientId2) => activeSql`
|
|
7081
7070
|
INSERT INTO events (
|
|
7082
7071
|
entity_ids, organization_id, origin_id, title,
|
|
7083
7072
|
payload_type, payload_text, payload_data, payload_template, attachments, metadata,
|
|
@@ -7104,17 +7093,17 @@ async function insertEvent(params, options) {
|
|
|
7104
7093
|
${params.authorName ?? null},
|
|
7105
7094
|
${params.sourceUrl ?? null},
|
|
7106
7095
|
${params.occurredAt ?? /* @__PURE__ */ new Date()},
|
|
7107
|
-
${lineage.
|
|
7096
|
+
${lineage.origin_parent_id},
|
|
7108
7097
|
${params.originType ?? null},
|
|
7109
|
-
${lineage.
|
|
7110
|
-
${lineage.
|
|
7111
|
-
${lineage.
|
|
7112
|
-
${lineage.
|
|
7113
|
-
${lineage.
|
|
7114
|
-
${lineage.
|
|
7115
|
-
${lineage.
|
|
7098
|
+
${lineage.connector_key},
|
|
7099
|
+
${lineage.connection_id},
|
|
7100
|
+
${lineage.feed_key},
|
|
7101
|
+
${lineage.feed_id},
|
|
7102
|
+
${lineage.run_id},
|
|
7103
|
+
${lineage.automation_id},
|
|
7104
|
+
${lineage.automation_version_id},
|
|
7116
7105
|
${params.semanticType},
|
|
7117
|
-
${
|
|
7106
|
+
${clientId2},
|
|
7118
7107
|
${params.createdBy ?? null},
|
|
7119
7108
|
${params.interactionType ?? "none"},
|
|
7120
7109
|
${params.interactionStatus ?? null},
|
|
@@ -7123,8 +7112,8 @@ async function insertEvent(params, options) {
|
|
|
7123
7112
|
${params.interactionOutput ? sql2.json(params.interactionOutput) : null},
|
|
7124
7113
|
${params.interactionError ?? null},
|
|
7125
7114
|
${supersedesEventId},
|
|
7126
|
-
${lineage.
|
|
7127
|
-
${lineage.
|
|
7115
|
+
${lineage.identity_ns},
|
|
7116
|
+
${lineage.identity_key},
|
|
7128
7117
|
(
|
|
7129
7118
|
SELECT COALESCE(array_agg(DISTINCT x.o), '{}'::text[])
|
|
7130
7119
|
FROM (
|
|
@@ -7134,7 +7123,7 @@ async function insertEvent(params, options) {
|
|
|
7134
7123
|
UNION ALL
|
|
7135
7124
|
SELECT c.organization_id AS o
|
|
7136
7125
|
FROM public.connections c
|
|
7137
|
-
WHERE c.id = ${lineage.
|
|
7126
|
+
WHERE c.id = ${lineage.connection_id}
|
|
7138
7127
|
) x
|
|
7139
7128
|
WHERE x.o IS NOT NULL
|
|
7140
7129
|
AND (x.o <> ${params.organizationId}::text OR ${params.organizationId}::text IS NULL)
|
|
@@ -7142,16 +7131,17 @@ async function insertEvent(params, options) {
|
|
|
7142
7131
|
)
|
|
7143
7132
|
RETURNING id, entity_ids, origin_id, title, semantic_type, created_at
|
|
7144
7133
|
`;
|
|
7134
|
+
const clientId = lineage.client_id;
|
|
7145
7135
|
let result;
|
|
7146
7136
|
const inTransaction = typeof sql2.savepoint === "function";
|
|
7147
7137
|
try {
|
|
7148
|
-
result = inTransaction ? await sql2.savepoint((sp) => insertWithClientId(sp,
|
|
7138
|
+
result = inTransaction ? await sql2.savepoint((sp) => insertWithClientId(sp, clientId)) : await insertWithClientId(sql2, clientId);
|
|
7149
7139
|
} catch (error) {
|
|
7150
|
-
if (!
|
|
7140
|
+
if (!clientId || !isEventsClientIdForeignKeyViolation(error)) {
|
|
7151
7141
|
throw error;
|
|
7152
7142
|
}
|
|
7153
7143
|
logger_default.warn(
|
|
7154
|
-
{ clientId
|
|
7144
|
+
{ clientId },
|
|
7155
7145
|
"[insert-event] retrying insert with client_id NULL \u2014 referenced oauth_clients row no longer exists"
|
|
7156
7146
|
);
|
|
7157
7147
|
result = await insertWithClientId(sql2, null);
|
|
@@ -7639,7 +7629,7 @@ function recordLifecycleEvent(params) {
|
|
|
7639
7629
|
);
|
|
7640
7630
|
});
|
|
7641
7631
|
}
|
|
7642
|
-
var AUDIT_EVENT_RETRY, EVENT_DEDUP_LOCK_NAMESPACE, DURABLE_ATTACHMENT_KEYS, VOLATILE_METADATA_KEYS, UNREAD_BADGE_PREFIX, AUDIT_IDEMPOTENCY_INDEX;
|
|
7632
|
+
var AUDIT_EVENT_RETRY, EVENT_DEDUP_LOCK_NAMESPACE, DURABLE_ATTACHMENT_KEYS, VOLATILE_METADATA_KEYS, UNREAD_BADGE_PREFIX, EVENT_SUPERSEDE_RULES, INHERITED_COLUMNS, AUDIT_IDEMPOTENCY_INDEX;
|
|
7643
7633
|
var init_insert_event = __esm({
|
|
7644
7634
|
"src/utils/insert-event.ts"() {
|
|
7645
7635
|
"use strict";
|
|
@@ -7675,6 +7665,50 @@ var init_insert_event = __esm({
|
|
|
7675
7665
|
"updated_at"
|
|
7676
7666
|
]);
|
|
7677
7667
|
UNREAD_BADGE_PREFIX = /^\(\d+\)\s+/;
|
|
7668
|
+
EVENT_SUPERSEDE_RULES = {
|
|
7669
|
+
id: "version",
|
|
7670
|
+
organization_id: "version",
|
|
7671
|
+
entity_ids: "version",
|
|
7672
|
+
origin_id: "version",
|
|
7673
|
+
title: "version",
|
|
7674
|
+
payload_type: "version",
|
|
7675
|
+
payload_text: "version",
|
|
7676
|
+
payload_data: "version",
|
|
7677
|
+
payload_template: "version",
|
|
7678
|
+
attachments: "version",
|
|
7679
|
+
metadata: "version",
|
|
7680
|
+
score: "version",
|
|
7681
|
+
author_name: "version",
|
|
7682
|
+
source_url: "version",
|
|
7683
|
+
occurred_at: "version",
|
|
7684
|
+
created_at: "version",
|
|
7685
|
+
origin_parent_id: "lineage",
|
|
7686
|
+
origin_type: "version",
|
|
7687
|
+
connector_key: "chain",
|
|
7688
|
+
connection_id: "chain",
|
|
7689
|
+
feed_key: "chain",
|
|
7690
|
+
feed_id: "chain",
|
|
7691
|
+
run_id: "lineage",
|
|
7692
|
+
automation_id: "lineage",
|
|
7693
|
+
automation_version_id: "lineage",
|
|
7694
|
+
semantic_type: "version",
|
|
7695
|
+
client_id: "lineage",
|
|
7696
|
+
created_by: "version",
|
|
7697
|
+
interaction_type: "version",
|
|
7698
|
+
interaction_status: "version",
|
|
7699
|
+
interaction_input_schema: "version",
|
|
7700
|
+
interaction_input: "version",
|
|
7701
|
+
interaction_output: "version",
|
|
7702
|
+
interaction_error: "version",
|
|
7703
|
+
supersedes_event_id: "version",
|
|
7704
|
+
superseded_by: "version",
|
|
7705
|
+
content_length: "version",
|
|
7706
|
+
search_tsv: "version",
|
|
7707
|
+
identity_ns: "chain",
|
|
7708
|
+
identity_key: "chain",
|
|
7709
|
+
linked_org_ids: "version"
|
|
7710
|
+
};
|
|
7711
|
+
INHERITED_COLUMNS = Object.keys(EVENT_SUPERSEDE_RULES).filter((column) => EVENT_SUPERSEDE_RULES[column] !== "version");
|
|
7678
7712
|
AUDIT_IDEMPOTENCY_INDEX = "idx_events_org_idempotency_key";
|
|
7679
7713
|
}
|
|
7680
7714
|
});
|
|
@@ -81524,12 +81558,81 @@ var init_view_content_hash = __esm({
|
|
|
81524
81558
|
}
|
|
81525
81559
|
});
|
|
81526
81560
|
|
|
81561
|
+
// ../core/src/contracts/tools/view-runtime.ts
|
|
81562
|
+
function viewMountEntry(specifier) {
|
|
81563
|
+
return `import { mountView } from "@lobu/views";
|
|
81564
|
+
import * as mod from ${JSON.stringify(specifier)};
|
|
81565
|
+
mountView(mod.view, mod.default);
|
|
81566
|
+
`;
|
|
81567
|
+
}
|
|
81568
|
+
function viewRuntimeEntry() {
|
|
81569
|
+
const imports = VIEW_RUNTIME_MODULES.map(
|
|
81570
|
+
(specifier, i) => `import * as m${i} from ${JSON.stringify(specifier)};`
|
|
81571
|
+
);
|
|
81572
|
+
const entries = VIEW_RUNTIME_MODULES.map(
|
|
81573
|
+
(specifier, i) => `${JSON.stringify(specifier)}: m${i}`
|
|
81574
|
+
);
|
|
81575
|
+
return `${imports.join("\n")}
|
|
81576
|
+
globalThis[${JSON.stringify(VIEW_RUNTIME_GLOBAL)}] = Object.freeze({ ${entries.join(", ")} });
|
|
81577
|
+
`;
|
|
81578
|
+
}
|
|
81579
|
+
function viewRuntimePlugin() {
|
|
81580
|
+
return {
|
|
81581
|
+
name: "lobu-view-runtime",
|
|
81582
|
+
setup(build5) {
|
|
81583
|
+
build5.onResolve(
|
|
81584
|
+
{ filter: /.*/ },
|
|
81585
|
+
(args) => VIEW_RUNTIME_MODULES.includes(args.path) ? { path: args.path, namespace: RUNTIME_NAMESPACE } : void 0
|
|
81586
|
+
);
|
|
81587
|
+
build5.onLoad({ filter: /.*/, namespace: RUNTIME_NAMESPACE }, (args) => ({
|
|
81588
|
+
contents: `module.exports = globalThis[${JSON.stringify(VIEW_RUNTIME_GLOBAL)}][${JSON.stringify(args.path)}];`,
|
|
81589
|
+
loader: "js"
|
|
81590
|
+
}));
|
|
81591
|
+
}
|
|
81592
|
+
};
|
|
81593
|
+
}
|
|
81594
|
+
var VIEW_RUNTIME_GLOBAL, VIEW_RUNTIME_MODULES, VIEW_RUNTIME_PACKAGES, RUNTIME_NAMESPACE, VIEW_BUILD_OPTIONS;
|
|
81595
|
+
var init_view_runtime = __esm({
|
|
81596
|
+
"../core/src/contracts/tools/view-runtime.ts"() {
|
|
81597
|
+
"use strict";
|
|
81598
|
+
VIEW_RUNTIME_GLOBAL = "__lobuViews";
|
|
81599
|
+
VIEW_RUNTIME_MODULES = [
|
|
81600
|
+
"react",
|
|
81601
|
+
"react/jsx-runtime",
|
|
81602
|
+
"react-dom",
|
|
81603
|
+
"react-dom/client",
|
|
81604
|
+
"@lobu/views",
|
|
81605
|
+
"@lobu/views/components"
|
|
81606
|
+
];
|
|
81607
|
+
VIEW_RUNTIME_PACKAGES = [
|
|
81608
|
+
"react",
|
|
81609
|
+
"react-dom",
|
|
81610
|
+
"@lobu/views"
|
|
81611
|
+
];
|
|
81612
|
+
RUNTIME_NAMESPACE = "lobu-view-runtime";
|
|
81613
|
+
VIEW_BUILD_OPTIONS = {
|
|
81614
|
+
bundle: true,
|
|
81615
|
+
write: false,
|
|
81616
|
+
format: "iife",
|
|
81617
|
+
platform: "browser",
|
|
81618
|
+
target: "es2022",
|
|
81619
|
+
jsx: "automatic",
|
|
81620
|
+
minify: true,
|
|
81621
|
+
sourcemap: false,
|
|
81622
|
+
legalComments: "none",
|
|
81623
|
+
define: { "process.env.NODE_ENV": '"production"' },
|
|
81624
|
+
logLevel: "silent"
|
|
81625
|
+
};
|
|
81626
|
+
}
|
|
81627
|
+
});
|
|
81628
|
+
|
|
81527
81629
|
// src/views/views.ts
|
|
81630
|
+
import { createHash as createHash32 } from "node:crypto";
|
|
81528
81631
|
import { existsSync as existsSync7, mkdirSync } from "node:fs";
|
|
81529
81632
|
import { createRequire as createRequire3 } from "node:module";
|
|
81530
81633
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
81531
81634
|
import { join as join13, posix } from "node:path";
|
|
81532
|
-
import { build as build3, transform } from "esbuild";
|
|
81635
|
+
import { build as build3, transform, version as esbuildVersion } from "esbuild";
|
|
81533
81636
|
function isShellOwnedParam(name) {
|
|
81534
81637
|
return name === COLLECTION_QUERY_KEY || name === COLLECTION_PRESET_QUERY_KEY || name === COLLECTION_TABLE_QUERY_KEY || name === "peek" || name.startsWith("peek_");
|
|
81535
81638
|
}
|
|
@@ -81555,6 +81658,7 @@ function mapViewRow(row) {
|
|
|
81555
81658
|
source_files: row.source_files ?? null,
|
|
81556
81659
|
dependencies: row.dependencies ?? null,
|
|
81557
81660
|
source_complete: row.source_complete === true,
|
|
81661
|
+
compile_config_hash: row.compile_config_hash ?? null,
|
|
81558
81662
|
attach: row.attach ?? [],
|
|
81559
81663
|
params: row.params ?? {},
|
|
81560
81664
|
actions: row.actions ?? {},
|
|
@@ -81566,7 +81670,7 @@ async function getView(organizationId, key2) {
|
|
|
81566
81670
|
const sql = getDb();
|
|
81567
81671
|
const rows = await sql`
|
|
81568
81672
|
SELECT key, name, description, source_code, compiled_code, content_hash,
|
|
81569
|
-
source_files, dependencies, source_complete,
|
|
81673
|
+
source_files, dependencies, source_complete, compile_config_hash,
|
|
81570
81674
|
attach, params, actions, last_writer, updated_at
|
|
81571
81675
|
FROM views
|
|
81572
81676
|
WHERE organization_id = ${organizationId} AND key = ${key2}
|
|
@@ -81578,7 +81682,7 @@ async function listViews(organizationId) {
|
|
|
81578
81682
|
const sql = getDb();
|
|
81579
81683
|
const rows = await sql`
|
|
81580
81684
|
SELECT key, name, description, source_code, compiled_code, content_hash,
|
|
81581
|
-
source_files, dependencies, source_complete,
|
|
81685
|
+
source_files, dependencies, source_complete, compile_config_hash,
|
|
81582
81686
|
attach, params, actions, last_writer, updated_at
|
|
81583
81687
|
FROM views
|
|
81584
81688
|
WHERE organization_id = ${organizationId}
|
|
@@ -81589,18 +81693,20 @@ async function listViews(organizationId) {
|
|
|
81589
81693
|
async function setView(organizationId, input) {
|
|
81590
81694
|
const sql = getDb();
|
|
81591
81695
|
const existing = await getView(organizationId, input.key);
|
|
81592
|
-
if (existing && existing.content_hash === input.content_hash && existing.compiled_code === input.compiled_code) {
|
|
81696
|
+
if (existing && existing.content_hash === input.content_hash && existing.compiled_code === input.compiled_code && existing.compile_config_hash === (input.compile_config_hash ?? null)) {
|
|
81593
81697
|
return { view: existing, written: false };
|
|
81594
81698
|
}
|
|
81595
81699
|
const rows = await sql`
|
|
81596
81700
|
INSERT INTO views (
|
|
81597
81701
|
organization_id, key, name, description, source_code, compiled_code,
|
|
81598
|
-
content_hash, source_files, dependencies, source_complete,
|
|
81702
|
+
content_hash, source_files, dependencies, source_complete, compile_config_hash,
|
|
81703
|
+
attach, params, actions, last_writer, updated_at
|
|
81599
81704
|
) VALUES (
|
|
81600
81705
|
${organizationId}, ${input.key}, ${input.name}, ${input.description},
|
|
81601
81706
|
${input.source_code}, ${input.compiled_code}, ${input.content_hash},
|
|
81602
81707
|
${input.source_files ? sql.json(input.source_files) : null},
|
|
81603
81708
|
${input.dependencies ? sql.json(input.dependencies) : null}, ${input.source_complete ?? false},
|
|
81709
|
+
${input.compile_config_hash ?? null},
|
|
81604
81710
|
${sql.json(input.attach)}, ${sql.json(input.params)},
|
|
81605
81711
|
${sql.json(input.actions)}, ${input.last_writer}, NOW()
|
|
81606
81712
|
)
|
|
@@ -81613,13 +81719,14 @@ async function setView(organizationId, input) {
|
|
|
81613
81719
|
source_files = EXCLUDED.source_files,
|
|
81614
81720
|
dependencies = EXCLUDED.dependencies,
|
|
81615
81721
|
source_complete = EXCLUDED.source_complete,
|
|
81722
|
+
compile_config_hash = EXCLUDED.compile_config_hash,
|
|
81616
81723
|
attach = EXCLUDED.attach,
|
|
81617
81724
|
params = EXCLUDED.params,
|
|
81618
81725
|
actions = EXCLUDED.actions,
|
|
81619
81726
|
last_writer = EXCLUDED.last_writer,
|
|
81620
81727
|
updated_at = NOW()
|
|
81621
81728
|
RETURNING key, name, description, source_code, compiled_code, content_hash,
|
|
81622
|
-
source_files, dependencies, source_complete,
|
|
81729
|
+
source_files, dependencies, source_complete, compile_config_hash,
|
|
81623
81730
|
attach, params, actions, last_writer, updated_at
|
|
81624
81731
|
`;
|
|
81625
81732
|
return { view: mapViewRow(rows[0]), written: true };
|
|
@@ -81634,15 +81741,31 @@ async function removeView(organizationId, key2) {
|
|
|
81634
81741
|
return rows.length > 0;
|
|
81635
81742
|
}
|
|
81636
81743
|
function projectView(view) {
|
|
81637
|
-
const {
|
|
81744
|
+
const {
|
|
81745
|
+
compiled_code,
|
|
81746
|
+
source_code,
|
|
81747
|
+
source_files: _files,
|
|
81748
|
+
dependencies: _deps,
|
|
81749
|
+
source_complete: _complete,
|
|
81750
|
+
compile_config_hash: _compiler,
|
|
81751
|
+
...rest
|
|
81752
|
+
} = view;
|
|
81638
81753
|
return {
|
|
81639
81754
|
...rest,
|
|
81755
|
+
content_hash: servedContentHash(view),
|
|
81640
81756
|
compiled_bytes: Buffer.byteLength(compiled_code, "utf8"),
|
|
81641
81757
|
source_bytes: Buffer.byteLength(source_code, "utf8")
|
|
81642
81758
|
};
|
|
81643
81759
|
}
|
|
81644
|
-
function
|
|
81645
|
-
|
|
81760
|
+
function runtimeFunds() {
|
|
81761
|
+
const funds = {};
|
|
81762
|
+
for (const specifier of VIEW_RUNTIME_MODULES) {
|
|
81763
|
+
try {
|
|
81764
|
+
funds[specifier] = require3.resolve(specifier);
|
|
81765
|
+
} catch {
|
|
81766
|
+
}
|
|
81767
|
+
}
|
|
81768
|
+
return funds;
|
|
81646
81769
|
}
|
|
81647
81770
|
function fundPackageDir(file) {
|
|
81648
81771
|
const idx = file.lastIndexOf("/node_modules/");
|
|
@@ -81656,71 +81779,94 @@ function fundPackageDir(file) {
|
|
|
81656
81779
|
}
|
|
81657
81780
|
return null;
|
|
81658
81781
|
}
|
|
81659
|
-
function
|
|
81660
|
-
const funds =
|
|
81661
|
-
for (const specifier of VIEW_ALLOWED_BARE_SPECIFIERS) {
|
|
81662
|
-
try {
|
|
81663
|
-
funds[specifier] = require3.resolve(specifier);
|
|
81664
|
-
} catch {
|
|
81665
|
-
}
|
|
81666
|
-
}
|
|
81782
|
+
function runtimeResolvePlugin() {
|
|
81783
|
+
const funds = runtimeFunds();
|
|
81667
81784
|
const fundDirs = /* @__PURE__ */ new Set();
|
|
81668
81785
|
for (const file of Object.values(funds)) {
|
|
81669
81786
|
const dir = fundPackageDir(file);
|
|
81670
81787
|
if (dir) fundDirs.add(dir);
|
|
81671
81788
|
}
|
|
81672
81789
|
return {
|
|
81673
|
-
name: "lobu-view-resolve",
|
|
81790
|
+
name: "lobu-view-runtime-resolve",
|
|
81674
81791
|
setup(b) {
|
|
81675
81792
|
b.onResolve({ filter: /.*/ }, (args) => {
|
|
81676
81793
|
const importer = args.importer ? posix.normalize(args.importer) : null;
|
|
81677
|
-
if (importer && [...fundDirs].some(
|
|
81678
|
-
(root) => importer === root || importer.startsWith(`${root}/`)
|
|
81679
|
-
)) {
|
|
81794
|
+
if (importer && [...fundDirs].some((root) => importer === root || importer.startsWith(`${root}/`))) {
|
|
81680
81795
|
return void 0;
|
|
81681
81796
|
}
|
|
81682
|
-
|
|
81683
|
-
|
|
81797
|
+
const resolved = funds[args.path];
|
|
81798
|
+
return resolved ? { path: resolved } : null;
|
|
81799
|
+
});
|
|
81800
|
+
}
|
|
81801
|
+
};
|
|
81802
|
+
}
|
|
81803
|
+
function inertResolveDir() {
|
|
81804
|
+
const dir = join13(tmpdir3(), "lobu-views-inert-resolve");
|
|
81805
|
+
mkdirSync(dir, { recursive: true });
|
|
81806
|
+
return dir;
|
|
81807
|
+
}
|
|
81808
|
+
function viewRuntimeScript() {
|
|
81809
|
+
runtimeScript ??= build3({
|
|
81810
|
+
...VIEW_BUILD_OPTIONS,
|
|
81811
|
+
stdin: { contents: viewRuntimeEntry(), loader: "js", resolveDir: inertResolveDir() },
|
|
81812
|
+
plugins: [runtimeResolvePlugin()]
|
|
81813
|
+
}).then((result) => {
|
|
81814
|
+
const code = result.outputFiles?.[0]?.text ?? "";
|
|
81815
|
+
if (!code) throw new Error("View runtime compiled to an empty bundle");
|
|
81816
|
+
return code;
|
|
81817
|
+
}).catch((error) => {
|
|
81818
|
+
runtimeScript = null;
|
|
81819
|
+
throw error;
|
|
81820
|
+
});
|
|
81821
|
+
return runtimeScript;
|
|
81822
|
+
}
|
|
81823
|
+
function viewSourceFilesPlugin(sourceFiles) {
|
|
81824
|
+
const files = sourceFiles.files;
|
|
81825
|
+
return {
|
|
81826
|
+
name: "lobu-view-source",
|
|
81827
|
+
setup(b) {
|
|
81828
|
+
b.onResolve({ filter: /.*/ }, (args) => {
|
|
81829
|
+
if (args.namespace !== VIEW_SOURCE_NAMESPACE && args.path === VIEW_SOURCE_NAMESPACE) {
|
|
81830
|
+
return { path: sourceFiles.entrypoint, namespace: VIEW_SOURCE_NAMESPACE };
|
|
81684
81831
|
}
|
|
81685
|
-
if (args.path.startsWith("
|
|
81832
|
+
if (args.namespace !== VIEW_SOURCE_NAMESPACE || !args.path.startsWith("./") && !args.path.startsWith("../")) {
|
|
81686
81833
|
return {
|
|
81687
81834
|
errors: [
|
|
81688
81835
|
{
|
|
81689
|
-
text: `
|
|
81836
|
+
text: `Unknown view import "${args.path}": the server builds a view from its own source files and the shell runtime (${VIEW_RUNTIME_MODULES.join(", ")}); other dependencies ship through lobu apply`
|
|
81690
81837
|
}
|
|
81691
81838
|
]
|
|
81692
81839
|
};
|
|
81693
81840
|
}
|
|
81694
|
-
|
|
81695
|
-
|
|
81696
|
-
|
|
81841
|
+
const base = posix.normalize(posix.join(posix.dirname(args.importer), args.path));
|
|
81842
|
+
const extension = posix.extname(base);
|
|
81843
|
+
const substitutions = extension === ".js" || extension === ".jsx" ? [".ts", ".tsx"] : extension === ".mjs" ? [".mts"] : extension === ".cjs" ? [".cts"] : [];
|
|
81844
|
+
const candidates = [
|
|
81845
|
+
base,
|
|
81846
|
+
...VIEW_SOURCE_EXTENSIONS.map((ext) => `${base}${ext}`),
|
|
81847
|
+
...substitutions.map((ext) => `${base.slice(0, -extension.length)}${ext}`),
|
|
81848
|
+
...VIEW_SOURCE_EXTENSIONS.map((ext) => `${base}/index${ext}`)
|
|
81849
|
+
];
|
|
81850
|
+
const found = candidates.find(
|
|
81851
|
+
(path15) => Object.hasOwn(files, path15)
|
|
81852
|
+
);
|
|
81853
|
+
if (!found) {
|
|
81854
|
+
return { errors: [{ text: `View import "${args.path}" is not among the view's source files` }] };
|
|
81697
81855
|
}
|
|
81698
|
-
return {
|
|
81699
|
-
|
|
81700
|
-
|
|
81701
|
-
|
|
81702
|
-
|
|
81703
|
-
]
|
|
81704
|
-
}
|
|
81856
|
+
return { path: found, namespace: VIEW_SOURCE_NAMESPACE };
|
|
81857
|
+
});
|
|
81858
|
+
b.onLoad({ filter: /.*/, namespace: VIEW_SOURCE_NAMESPACE }, (args) => {
|
|
81859
|
+
const loader = VIEW_SOURCE_LOADERS[posix.extname(args.path).slice(1)];
|
|
81860
|
+
if (!loader) {
|
|
81861
|
+
return { errors: [{ text: `View source file "${args.path}" has an unsupported extension` }] };
|
|
81862
|
+
}
|
|
81863
|
+
return { contents: files[args.path], loader };
|
|
81705
81864
|
});
|
|
81706
81865
|
}
|
|
81707
81866
|
};
|
|
81708
81867
|
}
|
|
81709
|
-
function
|
|
81710
|
-
return
|
|
81711
|
-
name: "lobu-view-source",
|
|
81712
|
-
setup(b) {
|
|
81713
|
-
b.onLoad(
|
|
81714
|
-
{ filter: /.*/, namespace: "lobu-view-source" },
|
|
81715
|
-
() => ({ contents: source, loader: "tsx" })
|
|
81716
|
-
);
|
|
81717
|
-
}
|
|
81718
|
-
};
|
|
81719
|
-
}
|
|
81720
|
-
function inertResolveDir() {
|
|
81721
|
-
const dir = join13(tmpdir3(), "lobu-views-inert-resolve");
|
|
81722
|
-
mkdirSync(dir, { recursive: true });
|
|
81723
|
-
return dir;
|
|
81868
|
+
function isServerBuildable(dependencies) {
|
|
81869
|
+
return Object.keys(dependencies).every((name) => VIEW_RUNTIME_PACKAGES.includes(name));
|
|
81724
81870
|
}
|
|
81725
81871
|
async function readViewModule(source) {
|
|
81726
81872
|
let js;
|
|
@@ -81736,23 +81882,17 @@ async function readViewModule(source) {
|
|
|
81736
81882
|
throw new ToolUserError(err.message, 400);
|
|
81737
81883
|
}
|
|
81738
81884
|
}
|
|
81739
|
-
async function compileView(
|
|
81885
|
+
async function compileView(sourceFiles, opts) {
|
|
81740
81886
|
let compiled;
|
|
81741
81887
|
try {
|
|
81742
81888
|
const result = await build3({
|
|
81889
|
+
...VIEW_BUILD_OPTIONS,
|
|
81743
81890
|
stdin: {
|
|
81744
|
-
contents:
|
|
81745
|
-
loader: "
|
|
81891
|
+
contents: viewMountEntry(VIEW_SOURCE_NAMESPACE),
|
|
81892
|
+
loader: "js",
|
|
81746
81893
|
resolveDir: inertResolveDir()
|
|
81747
81894
|
},
|
|
81748
|
-
|
|
81749
|
-
platform: "browser",
|
|
81750
|
-
format: "iife",
|
|
81751
|
-
minify: true,
|
|
81752
|
-
jsx: "automatic",
|
|
81753
|
-
logLevel: "silent",
|
|
81754
|
-
write: false,
|
|
81755
|
-
plugins: [viewResolvePlugin(), viewSourcePlugin(source)]
|
|
81895
|
+
plugins: [viewRuntimePlugin(), viewSourceFilesPlugin(sourceFiles)]
|
|
81756
81896
|
});
|
|
81757
81897
|
compiled = result.outputFiles?.[0]?.text ?? "";
|
|
81758
81898
|
} catch (err) {
|
|
@@ -81772,6 +81912,92 @@ async function compileView(source, opts) {
|
|
|
81772
81912
|
}
|
|
81773
81913
|
return compiled;
|
|
81774
81914
|
}
|
|
81915
|
+
function viewCompileFingerprint() {
|
|
81916
|
+
compileFingerprint ??= createHash32("sha256").update(
|
|
81917
|
+
JSON.stringify({
|
|
81918
|
+
pipeline: VIEW_COMPILE_PIPELINE_VERSION,
|
|
81919
|
+
esbuild: esbuildVersion,
|
|
81920
|
+
entry: viewMountEntry(VIEW_SOURCE_NAMESPACE),
|
|
81921
|
+
options: VIEW_BUILD_OPTIONS,
|
|
81922
|
+
runtime: [VIEW_RUNTIME_GLOBAL, ...VIEW_RUNTIME_MODULES]
|
|
81923
|
+
})
|
|
81924
|
+
).digest("hex");
|
|
81925
|
+
return compileFingerprint;
|
|
81926
|
+
}
|
|
81927
|
+
function serverCompileStamp(compiled, fingerprint = viewCompileFingerprint()) {
|
|
81928
|
+
const digest3 = createHash32("sha256").update(compiled).digest("hex").slice(0, 32);
|
|
81929
|
+
return `${fingerprint}:${digest3}`;
|
|
81930
|
+
}
|
|
81931
|
+
function isStaleServerBuild(view) {
|
|
81932
|
+
if (view.compile_config_hash === null || view.source_files === null) return false;
|
|
81933
|
+
const separator = view.compile_config_hash.lastIndexOf(":");
|
|
81934
|
+
if (separator < 0) return false;
|
|
81935
|
+
const fingerprint = view.compile_config_hash.slice(0, separator);
|
|
81936
|
+
if (fingerprint === viewCompileFingerprint()) return false;
|
|
81937
|
+
return view.compile_config_hash === serverCompileStamp(view.compiled_code, fingerprint);
|
|
81938
|
+
}
|
|
81939
|
+
function servedContentHash(view) {
|
|
81940
|
+
if (!isStaleServerBuild(view)) return view.content_hash;
|
|
81941
|
+
return createHash32("sha256").update(`${view.content_hash}\0${viewCompileFingerprint()}`).digest("hex").slice(0, view.content_hash.length || 16);
|
|
81942
|
+
}
|
|
81943
|
+
async function getServedView(organizationId, key2) {
|
|
81944
|
+
const view = await getView(organizationId, key2);
|
|
81945
|
+
if (!view || !isStaleServerBuild(view)) return view;
|
|
81946
|
+
const fingerprint = viewCompileFingerprint();
|
|
81947
|
+
const attempt = `${organizationId}\0${key2}\0${view.content_hash}\0${fingerprint}`;
|
|
81948
|
+
if (failedRebuilds.has(attempt)) return view;
|
|
81949
|
+
let rebuild = inflightRebuilds.get(attempt);
|
|
81950
|
+
if (!rebuild) {
|
|
81951
|
+
rebuild = rebuildView(organizationId, view, fingerprint, attempt).finally(
|
|
81952
|
+
() => inflightRebuilds.delete(attempt)
|
|
81953
|
+
);
|
|
81954
|
+
inflightRebuilds.set(attempt, rebuild);
|
|
81955
|
+
}
|
|
81956
|
+
return rebuild;
|
|
81957
|
+
}
|
|
81958
|
+
async function rebuildView(organizationId, view, fingerprint, attempt) {
|
|
81959
|
+
let compiled;
|
|
81960
|
+
try {
|
|
81961
|
+
compiled = await compileView(view.source_files);
|
|
81962
|
+
} catch (err) {
|
|
81963
|
+
failedRebuilds.add(attempt);
|
|
81964
|
+
if (failedRebuilds.size > MAX_FAILED_REBUILDS) {
|
|
81965
|
+
failedRebuilds.delete(failedRebuilds.values().next().value);
|
|
81966
|
+
}
|
|
81967
|
+
logger_default.warn(
|
|
81968
|
+
{ organization_id: organizationId, view_key: view.key, err },
|
|
81969
|
+
"[views] Stale view bundle failed to rebuild; serving the stored bundle"
|
|
81970
|
+
);
|
|
81971
|
+
return view;
|
|
81972
|
+
}
|
|
81973
|
+
const hash = contentHash(
|
|
81974
|
+
view.source_code,
|
|
81975
|
+
{
|
|
81976
|
+
name: view.name,
|
|
81977
|
+
description: view.description,
|
|
81978
|
+
attach: view.attach,
|
|
81979
|
+
params: view.params,
|
|
81980
|
+
actions: view.actions
|
|
81981
|
+
},
|
|
81982
|
+
compiled,
|
|
81983
|
+
{ sourceFiles: view.source_files, dependencies: view.dependencies }
|
|
81984
|
+
);
|
|
81985
|
+
const sql = getDb();
|
|
81986
|
+
const rows = await sql`
|
|
81987
|
+
UPDATE views SET
|
|
81988
|
+
compiled_code = ${compiled},
|
|
81989
|
+
content_hash = ${hash},
|
|
81990
|
+
compile_config_hash = ${serverCompileStamp(compiled, fingerprint)},
|
|
81991
|
+
updated_at = NOW()
|
|
81992
|
+
WHERE organization_id = ${organizationId} AND key = ${view.key}
|
|
81993
|
+
AND content_hash = ${view.content_hash}
|
|
81994
|
+
AND compile_config_hash = ${view.compile_config_hash}
|
|
81995
|
+
RETURNING key, name, description, source_code, compiled_code, content_hash,
|
|
81996
|
+
source_files, dependencies, source_complete, compile_config_hash,
|
|
81997
|
+
attach, params, actions, last_writer, updated_at
|
|
81998
|
+
`;
|
|
81999
|
+
return rows.length > 0 ? mapViewRow(rows[0]) : getView(organizationId, view.key);
|
|
82000
|
+
}
|
|
81775
82001
|
function viewResourceMeta(view) {
|
|
81776
82002
|
return {
|
|
81777
82003
|
name: view.name,
|
|
@@ -81781,8 +82007,8 @@ function viewResourceMeta(view) {
|
|
|
81781
82007
|
prefersBorder: true
|
|
81782
82008
|
};
|
|
81783
82009
|
}
|
|
81784
|
-
function renderViewShell(view, workspaceUrl) {
|
|
81785
|
-
const
|
|
82010
|
+
function renderViewShell(view, workspaceUrl, runtime) {
|
|
82011
|
+
const inline = (code) => code.replaceAll("</script", "<\\/script");
|
|
81786
82012
|
const workspace = workspaceUrl.replaceAll("&", "&").replaceAll('"', """).replaceAll("<", "<");
|
|
81787
82013
|
return `<!doctype html>
|
|
81788
82014
|
<html lang="en">
|
|
@@ -81797,7 +82023,8 @@ function renderViewShell(view, workspaceUrl) {
|
|
|
81797
82023
|
</head>
|
|
81798
82024
|
<body>
|
|
81799
82025
|
<div id="root"></div>
|
|
81800
|
-
<script>${
|
|
82026
|
+
<script>${inline(runtime)}</script>
|
|
82027
|
+
<script>${inline(view.compiled_code)}</script>
|
|
81801
82028
|
</body>
|
|
81802
82029
|
</html>`;
|
|
81803
82030
|
}
|
|
@@ -81970,16 +82197,18 @@ function renderViewsLoaderShell() {
|
|
|
81970
82197
|
</body>
|
|
81971
82198
|
</html>`;
|
|
81972
82199
|
}
|
|
81973
|
-
var require3, VIEW_KEY_RE, VIEW_ACTION_NAME_RE, LOBU_VIEWS_RESOURCE_URI, VIEW_RESOURCE_PREFIX, VIEW_COMPILED_MAX_BYTES, VIEW_SOURCE_MAX_CHARS,
|
|
82200
|
+
var require3, VIEW_KEY_RE, VIEW_ACTION_NAME_RE, LOBU_VIEWS_RESOURCE_URI, VIEW_RESOURCE_PREFIX, VIEW_COMPILED_MAX_BYTES, VIEW_SOURCE_MAX_CHARS, runtimeScript, VIEW_SOURCE_NAMESPACE, VIEW_SOURCE_EXTENSIONS, VIEW_SOURCE_LOADERS, VIEW_COMPILE_PIPELINE_VERSION, compileFingerprint, MAX_FAILED_REBUILDS, failedRebuilds, inflightRebuilds, BASE_CSS;
|
|
81974
82201
|
var init_views = __esm({
|
|
81975
82202
|
"src/views/views.ts"() {
|
|
81976
82203
|
"use strict";
|
|
81977
82204
|
init_collection_selection();
|
|
81978
82205
|
init_collection_presentation();
|
|
81979
82206
|
init_view_definition();
|
|
81980
|
-
|
|
82207
|
+
init_view_content_hash();
|
|
82208
|
+
init_view_runtime();
|
|
81981
82209
|
init_client();
|
|
81982
82210
|
init_errors2();
|
|
82211
|
+
init_logger2();
|
|
81983
82212
|
init_view_content_hash();
|
|
81984
82213
|
require3 = createRequire3(import.meta.url);
|
|
81985
82214
|
VIEW_KEY_RE = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
@@ -81988,28 +82217,24 @@ var init_views = __esm({
|
|
|
81988
82217
|
VIEW_RESOURCE_PREFIX = "ui://lobu/views/";
|
|
81989
82218
|
VIEW_COMPILED_MAX_BYTES = 2 * 1024 * 1024;
|
|
81990
82219
|
VIEW_SOURCE_MAX_CHARS = 1e6;
|
|
81991
|
-
|
|
81992
|
-
|
|
81993
|
-
|
|
81994
|
-
|
|
81995
|
-
"
|
|
81996
|
-
"
|
|
81997
|
-
"
|
|
81998
|
-
|
|
81999
|
-
|
|
82000
|
-
|
|
82001
|
-
|
|
82002
|
-
|
|
82003
|
-
|
|
82004
|
-
|
|
82005
|
-
|
|
82006
|
-
|
|
82007
|
-
|
|
82008
|
-
|
|
82009
|
-
React.createElement(LobuViewProvider, { def: viewDef }, React.createElement(View))
|
|
82010
|
-
);
|
|
82011
|
-
}
|
|
82012
|
-
`;
|
|
82220
|
+
runtimeScript = null;
|
|
82221
|
+
VIEW_SOURCE_NAMESPACE = "lobu-view-source";
|
|
82222
|
+
VIEW_SOURCE_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js", ".json"];
|
|
82223
|
+
VIEW_SOURCE_LOADERS = {
|
|
82224
|
+
tsx: "tsx",
|
|
82225
|
+
ts: "ts",
|
|
82226
|
+
mts: "ts",
|
|
82227
|
+
cts: "ts",
|
|
82228
|
+
jsx: "jsx",
|
|
82229
|
+
js: "js",
|
|
82230
|
+
mjs: "js",
|
|
82231
|
+
cjs: "js",
|
|
82232
|
+
json: "json"
|
|
82233
|
+
};
|
|
82234
|
+
VIEW_COMPILE_PIPELINE_VERSION = 2;
|
|
82235
|
+
MAX_FAILED_REBUILDS = 256;
|
|
82236
|
+
failedRebuilds = /* @__PURE__ */ new Set();
|
|
82237
|
+
inflightRebuilds = /* @__PURE__ */ new Map();
|
|
82013
82238
|
BASE_CSS = `
|
|
82014
82239
|
:root{color-scheme:light;--fg:var(--color-text-primary,#0a0a0a);--muted:var(--color-text-secondary,#6b7280);--border:var(--color-border-primary,#e5e7eb);--accent:var(--color-text-info,#2563eb);--font:var(--font-sans,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif);--radius:var(--border-radius-md,6px);--radius-lg:var(--border-radius-lg,8px)}
|
|
82015
82240
|
html.dark{color-scheme:dark;--fg:var(--color-text-primary,#fafafa);--muted:var(--color-text-secondary,#9ca3af);--border:var(--color-border-primary,#27272a);--accent:var(--color-text-info,#60a5fa)}
|
|
@@ -82950,7 +83175,7 @@ var init_template_action_capability = __esm({
|
|
|
82950
83175
|
});
|
|
82951
83176
|
|
|
82952
83177
|
// src/utils/source-record-reads.ts
|
|
82953
|
-
import { createHash as
|
|
83178
|
+
import { createHash as createHash33 } from "node:crypto";
|
|
82954
83179
|
function matchablePath(rule, matchPaths) {
|
|
82955
83180
|
return rule.target.identities?.find(
|
|
82956
83181
|
(identity) => matchPaths.includes(identity.eventPath)
|
|
@@ -83357,7 +83582,7 @@ async function readSourceRecordLinks(scope, record4, options) {
|
|
|
83357
83582
|
}
|
|
83358
83583
|
}
|
|
83359
83584
|
}
|
|
83360
|
-
const request2 =
|
|
83585
|
+
const request2 = createHash33("sha256").update(JSON.stringify([
|
|
83361
83586
|
scope.organizationId,
|
|
83362
83587
|
scope.principal,
|
|
83363
83588
|
scope.agentId ?? null,
|
|
@@ -87781,7 +88006,7 @@ var init_judge_runner = __esm({
|
|
|
87781
88006
|
});
|
|
87782
88007
|
|
|
87783
88008
|
// src/gateway/proxy/egress-judge/text-judge.ts
|
|
87784
|
-
import { createHash as
|
|
88009
|
+
import { createHash as createHash34 } from "node:crypto";
|
|
87785
88010
|
function buildUserPrompt(policy, text) {
|
|
87786
88011
|
return `Policy:
|
|
87787
88012
|
${policy.trim()}
|
|
@@ -87790,14 +88015,14 @@ Text:
|
|
|
87790
88015
|
${text}`;
|
|
87791
88016
|
}
|
|
87792
88017
|
function hashTextJudgeKey(policy, text) {
|
|
87793
|
-
const h =
|
|
88018
|
+
const h = createHash34("sha256");
|
|
87794
88019
|
h.update(policy);
|
|
87795
88020
|
h.update(HASH_SEPARATOR);
|
|
87796
88021
|
h.update(text);
|
|
87797
88022
|
return h.digest("hex");
|
|
87798
88023
|
}
|
|
87799
88024
|
function hashPolicy(policy) {
|
|
87800
|
-
return
|
|
88025
|
+
return createHash34("sha256").update(policy).digest("hex");
|
|
87801
88026
|
}
|
|
87802
88027
|
var HASH_SEPARATOR, TEXT_JUDGE_SYSTEM_PROMPT, TextJudge;
|
|
87803
88028
|
var init_text_judge = __esm({
|
|
@@ -87923,13 +88148,13 @@ var init_stage_text = __esm({
|
|
|
87923
88148
|
});
|
|
87924
88149
|
|
|
87925
88150
|
// src/gateway/guardrails/judge-factory.ts
|
|
87926
|
-
import { createHash as
|
|
88151
|
+
import { createHash as createHash35 } from "node:crypto";
|
|
87927
88152
|
function getSharedJudge() {
|
|
87928
88153
|
if (!sharedJudge) sharedJudge = new TextJudge();
|
|
87929
88154
|
return sharedJudge;
|
|
87930
88155
|
}
|
|
87931
88156
|
function inlineJudgeHash(policy, tools) {
|
|
87932
|
-
const h =
|
|
88157
|
+
const h = createHash35("sha256");
|
|
87933
88158
|
h.update(policy);
|
|
87934
88159
|
const normalizedTools = tools && tools.length > 0 ? [...tools].sort().join(",") : "";
|
|
87935
88160
|
h.update("");
|
|
@@ -88614,7 +88839,7 @@ var init_config_audit = __esm({
|
|
|
88614
88839
|
|
|
88615
88840
|
// src/catalog/connector-definitions.ts
|
|
88616
88841
|
import { isDeepStrictEqual as isDeepStrictEqual5 } from "node:util";
|
|
88617
|
-
import { createHash as
|
|
88842
|
+
import { createHash as createHash36 } from "node:crypto";
|
|
88618
88843
|
import { readFile as readFile11 } from "node:fs/promises";
|
|
88619
88844
|
function getOAuthMethods(authSchema) {
|
|
88620
88845
|
const parsedAuthSchema = typeof authSchema === "string" ? (() => {
|
|
@@ -88839,7 +89064,7 @@ async function installConnectorFromMcpUrl(params) {
|
|
|
88839
89064
|
connectorKey,
|
|
88840
89065
|
name: metadata.name,
|
|
88841
89066
|
version: metadata.version,
|
|
88842
|
-
codeHash:
|
|
89067
|
+
codeHash: createHash36("sha256").update(params.mcpUrl).digest("hex").slice(0, 16),
|
|
88843
89068
|
updated,
|
|
88844
89069
|
authSchema,
|
|
88845
89070
|
mcpConfig: metadata.mcpConfig,
|
|
@@ -103302,7 +103527,9 @@ async function handleSet(args, ctx) {
|
|
|
103302
103527
|
}
|
|
103303
103528
|
const retained = args.source_files ? { sourceFiles: args.source_files, dependencies: args.dependencies } : args.compiled_code ? void 0 : {
|
|
103304
103529
|
sourceFiles: { entrypoint: "index.tsx", files: { "index.tsx": args.source_code } },
|
|
103305
|
-
|
|
103530
|
+
// The runtime comes from the shell, so a source-only view bundles
|
|
103531
|
+
// nothing but its own file.
|
|
103532
|
+
dependencies: {}
|
|
103306
103533
|
};
|
|
103307
103534
|
if (retained) {
|
|
103308
103535
|
try {
|
|
@@ -103311,7 +103538,7 @@ async function handleSet(args, ctx) {
|
|
|
103311
103538
|
throw new ToolUserError(error.message, 400);
|
|
103312
103539
|
}
|
|
103313
103540
|
}
|
|
103314
|
-
const compiled = args.compiled_code ? checkCompiledCode(args.compiled_code) : await
|
|
103541
|
+
const compiled = args.compiled_code ? checkCompiledCode(args.compiled_code) : await compileRetained(retained);
|
|
103315
103542
|
const hash = contentHash(
|
|
103316
103543
|
args.source_code,
|
|
103317
103544
|
{
|
|
@@ -103324,8 +103551,9 @@ async function handleSet(args, ctx) {
|
|
|
103324
103551
|
compiled,
|
|
103325
103552
|
retained
|
|
103326
103553
|
);
|
|
103554
|
+
const compileConfigHash = args.compiled_code ? null : serverCompileStamp(compiled);
|
|
103327
103555
|
const current = await getView(ctx.organizationId, key2);
|
|
103328
|
-
if (current && current.content_hash === hash) {
|
|
103556
|
+
if (current && current.content_hash === hash && current.compile_config_hash === compileConfigHash) {
|
|
103329
103557
|
return { action: "set", view: projectView(current), written: false };
|
|
103330
103558
|
}
|
|
103331
103559
|
const { view, written } = await setView(ctx.organizationId, {
|
|
@@ -103337,6 +103565,7 @@ async function handleSet(args, ctx) {
|
|
|
103337
103565
|
source_files: retained?.sourceFiles ?? null,
|
|
103338
103566
|
dependencies: retained?.dependencies ?? null,
|
|
103339
103567
|
source_complete: retained !== void 0,
|
|
103568
|
+
compile_config_hash: compileConfigHash,
|
|
103340
103569
|
content_hash: hash,
|
|
103341
103570
|
attach,
|
|
103342
103571
|
params,
|
|
@@ -103348,6 +103577,15 @@ async function handleSet(args, ctx) {
|
|
|
103348
103577
|
}
|
|
103349
103578
|
return { action: "set", view: projectView(view), written };
|
|
103350
103579
|
}
|
|
103580
|
+
async function compileRetained(retained) {
|
|
103581
|
+
if (!isServerBuildable(retained.dependencies)) {
|
|
103582
|
+
throw new ToolUserError(
|
|
103583
|
+
`View depends on ${Object.keys(retained.dependencies).join(", ")}; save it with lobu apply, which bundles npm dependencies`,
|
|
103584
|
+
400
|
|
103585
|
+
);
|
|
103586
|
+
}
|
|
103587
|
+
return compileView(retained.sourceFiles);
|
|
103588
|
+
}
|
|
103351
103589
|
function checkCompiledCode(compiledCode) {
|
|
103352
103590
|
if (compiledCode.length === 0) {
|
|
103353
103591
|
throw new ToolUserError("set requires compiled_code to be non-empty", 400);
|
|
@@ -106191,7 +106429,7 @@ var init_reaction_enqueue = __esm({
|
|
|
106191
106429
|
});
|
|
106192
106430
|
|
|
106193
106431
|
// src/automations/digest.ts
|
|
106194
|
-
import { createHash as
|
|
106432
|
+
import { createHash as createHash37 } from "node:crypto";
|
|
106195
106433
|
function materialDigestChanges(changes) {
|
|
106196
106434
|
return changes.filter((c) => c.kind === "created" || c.kind === "updated");
|
|
106197
106435
|
}
|
|
@@ -106200,7 +106438,7 @@ function fingerprintMaterialDigestChanges(changes) {
|
|
|
106200
106438
|
const canonical = [...material].sort(
|
|
106201
106439
|
(a, b) => a.entityId - b.entityId || (a.kind < b.kind ? -1 : a.kind > b.kind ? 1 : 0) || (a.name < b.name ? -1 : a.name > b.name ? 1 : 0)
|
|
106202
106440
|
).map((c) => [c.entityId, c.kind, c.name]);
|
|
106203
|
-
return
|
|
106441
|
+
return createHash37("sha256").update(JSON.stringify(canonical)).digest("hex");
|
|
106204
106442
|
}
|
|
106205
106443
|
function automationChangeSetIdempotencyKey(automationId, runId) {
|
|
106206
106444
|
return `automation:${automationId}:run:${runId}:change_set`;
|
|
@@ -111323,7 +111561,7 @@ var init_query_sql = __esm({
|
|
|
111323
111561
|
QuerySqlSchema = Type43.Object({
|
|
111324
111562
|
title: Type43.Optional(
|
|
111325
111563
|
Type43.String({
|
|
111326
|
-
description: '
|
|
111564
|
+
description: 'Human-friendly heading for this result (e.g. "Recent support tickets"). The UI shows it on the result summary and on this call in the activity feed. Set it whenever a person will read the result.',
|
|
111327
111565
|
maxLength: 200
|
|
111328
111566
|
})
|
|
111329
111567
|
),
|
|
@@ -114210,7 +114448,7 @@ var init_audit_args = __esm({
|
|
|
114210
114448
|
});
|
|
114211
114449
|
|
|
114212
114450
|
// src/tools/audit.ts
|
|
114213
|
-
import { createHash as
|
|
114451
|
+
import { createHash as createHash38, randomUUID as randomUUID24 } from "node:crypto";
|
|
114214
114452
|
function captureRequest(params) {
|
|
114215
114453
|
if (!REQUEST_EVENT_TOOLS.has(params.toolName)) return null;
|
|
114216
114454
|
try {
|
|
@@ -114236,7 +114474,7 @@ function captureRequest(params) {
|
|
|
114236
114474
|
}
|
|
114237
114475
|
}
|
|
114238
114476
|
function sha2562(value) {
|
|
114239
|
-
return
|
|
114477
|
+
return createHash38("sha256").update(value).digest("hex");
|
|
114240
114478
|
}
|
|
114241
114479
|
function redactSensitiveText(value) {
|
|
114242
114480
|
return value.replace(HEADER_CREDENTIAL_RE, (_match, key2) => `${key2}=[redacted]`).replace(AUTH_SCHEME_RE, (_match, scheme) => `${scheme} [redacted]`).replace(SENSITIVE_ASSIGNMENT_RE, (_match, key2) => `${key2}=[redacted]`).replace(KNOWN_SECRET_SHAPE_RE, "[redacted]");
|
|
@@ -114391,7 +114629,10 @@ async function recordToolInvocationAudit(params) {
|
|
|
114391
114629
|
const payload = buildPayload(params);
|
|
114392
114630
|
if (!payload) return;
|
|
114393
114631
|
const request2 = captureRequest(params);
|
|
114394
|
-
if (request2)
|
|
114632
|
+
if (request2) {
|
|
114633
|
+
Object.assign(payload, request2);
|
|
114634
|
+
payload.title = typeof params.args?.title === "string" ? redactPreview(params.args.title.trim()) || null : null;
|
|
114635
|
+
}
|
|
114395
114636
|
const success = payload.success === true;
|
|
114396
114637
|
const identity = params.toolName === "manage_automations" ? manageAutomationsIdentity(params.args) : null;
|
|
114397
114638
|
await insertEvent({
|
|
@@ -115353,7 +115594,7 @@ var init_sdk_run = __esm({
|
|
|
115353
115594
|
),
|
|
115354
115595
|
title: Type51.Optional(
|
|
115355
115596
|
Type51.String({
|
|
115356
|
-
description: 'Human-friendly heading for this result (e.g. "Companies missing a domain"). In run_sdk, it also labels browser tab groups opened by the script. The UI
|
|
115597
|
+
description: 'Human-friendly heading for this result (e.g. "Companies missing a domain"). In run_sdk, it also labels browser tab groups opened by the script. The UI shows it above the execution status and on this call in the activity feed; without it the result card has no subject line and the feed reads only the tool name. Set it whenever a person will read the result.',
|
|
115357
115598
|
maxLength: 200
|
|
115358
115599
|
})
|
|
115359
115600
|
)
|
|
@@ -119332,7 +119573,7 @@ var init_pending_interaction_store = __esm({
|
|
|
119332
119573
|
});
|
|
119333
119574
|
|
|
119334
119575
|
// src/gateway/connections/interaction-bridge.ts
|
|
119335
|
-
import { createHash as
|
|
119576
|
+
import { createHash as createHash39, randomUUID as randomUUID27 } from "node:crypto";
|
|
119336
119577
|
import {
|
|
119337
119578
|
Actions as Actions5,
|
|
119338
119579
|
Button as Button3,
|
|
@@ -119351,7 +119592,7 @@ function canonicalJson2(value) {
|
|
|
119351
119592
|
}
|
|
119352
119593
|
function interactionDeliveryId(event) {
|
|
119353
119594
|
if (!event?.raw) return `interaction-${randomUUID27()}`;
|
|
119354
|
-
const digest3 =
|
|
119595
|
+
const digest3 = createHash39("sha256").update(
|
|
119355
119596
|
canonicalJson2({
|
|
119356
119597
|
actionId: event.actionId,
|
|
119357
119598
|
messageId: event.messageId,
|
|
@@ -122621,13 +122862,13 @@ var init_slack3 = __esm({
|
|
|
122621
122862
|
});
|
|
122622
122863
|
|
|
122623
122864
|
// src/gateway/connections/platform-strategies/connector-chat.ts
|
|
122624
|
-
import { createHash as
|
|
122865
|
+
import { createHash as createHash40 } from "node:crypto";
|
|
122625
122866
|
async function postOnce(platform, ctx, target, messageId, content) {
|
|
122626
122867
|
const adapter = ctx.instance.chat.getAdapter(
|
|
122627
122868
|
platform
|
|
122628
122869
|
);
|
|
122629
122870
|
const threadId = `${platform}:${stripPlatformPrefix(platform, target)}`;
|
|
122630
|
-
const contentHash2 =
|
|
122871
|
+
const contentHash2 = createHash40("sha256").update(JSON.stringify(content)).digest("hex");
|
|
122631
122872
|
await adapter.postMessage(
|
|
122632
122873
|
threadId,
|
|
122633
122874
|
content,
|
|
@@ -143477,7 +143718,7 @@ var init_social_login_provisioning = __esm({
|
|
|
143477
143718
|
});
|
|
143478
143719
|
|
|
143479
143720
|
// src/auth/index.tsx
|
|
143480
|
-
import { createHash as
|
|
143721
|
+
import { createHash as createHash41 } from "node:crypto";
|
|
143481
143722
|
import { passkey } from "@better-auth/passkey";
|
|
143482
143723
|
import { APIError as APIError3, betterAuth } from "better-auth";
|
|
143483
143724
|
import { magicLink, organization, phoneNumber } from "better-auth/plugins";
|
|
@@ -143485,7 +143726,7 @@ import { bearer } from "better-auth/plugins/bearer";
|
|
|
143485
143726
|
import { genericOAuth } from "better-auth/plugins/generic-oauth";
|
|
143486
143727
|
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
143487
143728
|
function gravatarUrl(email) {
|
|
143488
|
-
const hash =
|
|
143729
|
+
const hash = createHash41("md5").update(email.trim().toLowerCase()).digest("hex");
|
|
143489
143730
|
return `https://www.gravatar.com/avatar/${hash}?d=retro&s=256`;
|
|
143490
143731
|
}
|
|
143491
143732
|
async function createAuth(env, request2) {
|
|
@@ -146924,7 +147165,7 @@ var init_triggers2 = __esm({
|
|
|
146924
147165
|
});
|
|
146925
147166
|
|
|
146926
147167
|
// src/tools/admin/entity-field-approval.ts
|
|
146927
|
-
import { createHash as
|
|
147168
|
+
import { createHash as createHash42 } from "node:crypto";
|
|
146928
147169
|
function entityChangeOperation(proposal) {
|
|
146929
147170
|
const operation = proposal.operation ?? "update";
|
|
146930
147171
|
switch (operation) {
|
|
@@ -146986,7 +147227,7 @@ function entityChangeIdempotencyKey(organizationId, parentRunId, proposal) {
|
|
|
146986
147227
|
change = { entityData: asCreateProposal(proposal).entity_data };
|
|
146987
147228
|
break;
|
|
146988
147229
|
}
|
|
146989
|
-
const digest3 =
|
|
147230
|
+
const digest3 = createHash42("sha256").update(stableJson({ organizationId, parentRunId, operation, change })).digest("hex");
|
|
146990
147231
|
return `entity-change:${digest3}`;
|
|
146991
147232
|
}
|
|
146992
147233
|
async function loadAutomationLabel(ctx, automationId, attribution) {
|
|
@@ -152625,7 +152866,7 @@ var init_permission_policy_write = __esm({
|
|
|
152625
152866
|
});
|
|
152626
152867
|
|
|
152627
152868
|
// src/http/connector-policy-collection.ts
|
|
152628
|
-
import { createHash as
|
|
152869
|
+
import { createHash as createHash43 } from "node:crypto";
|
|
152629
152870
|
function authorize(c) {
|
|
152630
152871
|
const org = c.get("organizationId");
|
|
152631
152872
|
if (!org || !c.get("user")?.id) return c.json({ error: "unauthorized" }, 401);
|
|
@@ -152650,7 +152891,7 @@ function serializeRule(policy) {
|
|
|
152650
152891
|
}
|
|
152651
152892
|
async function readSnapshot(org, tx) {
|
|
152652
152893
|
const policies = (await listEntityApprovalPolicies(org, "connector_action", tx)).filter((p) => p.principalKind === null && p.effects.execute !== void 0).sort((a, b) => scopeKey(a).localeCompare(scopeKey(b)));
|
|
152653
|
-
const revision =
|
|
152894
|
+
const revision = createHash43("sha256").update(JSON.stringify(policies.map(serializeEntityApprovalPolicy))).digest("hex");
|
|
152654
152895
|
return { policies, revision, rules: policies.map(serializeRule) };
|
|
152655
152896
|
}
|
|
152656
152897
|
async function readConnectorPolicyCollection(c) {
|
|
@@ -156268,7 +156509,7 @@ var init_lobu_skill_generated = __esm({
|
|
|
156268
156509
|
});
|
|
156269
156510
|
|
|
156270
156511
|
// src/utils/mcp-app-bundle.ts
|
|
156271
|
-
import { createHash as
|
|
156512
|
+
import { createHash as createHash44 } from "node:crypto";
|
|
156272
156513
|
import { readFile as readFile12, stat as stat6 } from "node:fs/promises";
|
|
156273
156514
|
import path7 from "node:path";
|
|
156274
156515
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
@@ -156284,7 +156525,7 @@ function bundleFileCandidates(appDir, relPath) {
|
|
|
156284
156525
|
].filter((p) => typeof p === "string");
|
|
156285
156526
|
}
|
|
156286
156527
|
function mcpAppAssetVersion(bytes) {
|
|
156287
|
-
return
|
|
156528
|
+
return createHash44("sha256").update(bytes).digest("hex").slice(0, 16);
|
|
156288
156529
|
}
|
|
156289
156530
|
function withAbsoluteAssetUrls(html, assetBase) {
|
|
156290
156531
|
const headOpen = HEAD_OPEN.exec(html);
|
|
@@ -156818,7 +157059,7 @@ function createServerForContext(env, authCtx, mcpAppsSupported) {
|
|
|
156818
157059
|
if (!hasRequiredMcpScope("read", authCtx.scopes)) {
|
|
156819
157060
|
throw new Error("Reading views requires an MCP session with read access.");
|
|
156820
157061
|
}
|
|
156821
|
-
const storedView = await
|
|
157062
|
+
const storedView = await getServedView(authCtx.organizationId, viewKey);
|
|
156822
157063
|
if (storedView) {
|
|
156823
157064
|
const meta = viewResourceMeta(storedView);
|
|
156824
157065
|
return {
|
|
@@ -156828,7 +157069,8 @@ function createServerForContext(env, authCtx, mcpAppsSupported) {
|
|
|
156828
157069
|
mimeType: MCP_APP_MIME_TYPE,
|
|
156829
157070
|
text: renderViewShell(
|
|
156830
157071
|
storedView,
|
|
156831
|
-
await viewWorkspaceUrl(authCtx.organizationId, authCtx.requestUrl)
|
|
157072
|
+
await viewWorkspaceUrl(authCtx.organizationId, authCtx.requestUrl),
|
|
157073
|
+
await viewRuntimeScript()
|
|
156832
157074
|
),
|
|
156833
157075
|
_meta: mcpAppResourceMeta(authCtx, meta)
|
|
156834
157076
|
}
|
|
@@ -161917,13 +162159,14 @@ async function restGetViewShell(c) {
|
|
|
161917
162159
|
if (!isValidViewKey(key2)) {
|
|
161918
162160
|
throw new ToolUserError("Invalid view key", 400);
|
|
161919
162161
|
}
|
|
161920
|
-
const view = await
|
|
162162
|
+
const view = await getServedView(ctx.organizationId, key2);
|
|
161921
162163
|
if (!view) {
|
|
161922
162164
|
throw new ToolUserError(`Unknown view: ${key2}`, 404);
|
|
161923
162165
|
}
|
|
161924
162166
|
const html = renderViewShell(
|
|
161925
162167
|
view,
|
|
161926
|
-
await viewWorkspaceUrl(ctx.organizationId, c.req.url)
|
|
162168
|
+
await viewWorkspaceUrl(ctx.organizationId, c.req.url),
|
|
162169
|
+
await viewRuntimeScript()
|
|
161927
162170
|
);
|
|
161928
162171
|
c.header("Content-Type", "text/plain; charset=utf-8");
|
|
161929
162172
|
c.header("Cache-Control", "no-store");
|
|
@@ -169052,7 +169295,7 @@ var init_log = __esm({
|
|
|
169052
169295
|
});
|
|
169053
169296
|
|
|
169054
169297
|
// ../connector-worker/dist/daemon/interactive-session.js
|
|
169055
|
-
import { createHash as
|
|
169298
|
+
import { createHash as createHash45, randomBytes as randomBytes12 } from "node:crypto";
|
|
169056
169299
|
import { spawn as spawn2 } from "node:child_process";
|
|
169057
169300
|
import { accessSync, chmodSync as chmodSync2, constants, lstatSync as lstatSync2, mkdtempSync, readFileSync as readFileSync7, rmSync, statSync, writeFileSync } from "node:fs";
|
|
169058
169301
|
import net3 from "node:net";
|
|
@@ -169770,14 +170013,30 @@ async function runAcpTurn(options) {
|
|
|
169770
170013
|
else
|
|
169771
170014
|
events.push({ kind: "assistant", messageId, text });
|
|
169772
170015
|
} else if (update.sessionUpdate === "tool_call") {
|
|
169773
|
-
|
|
169774
|
-
|
|
169775
|
-
|
|
170016
|
+
const tool = { ...update };
|
|
170017
|
+
tools.set(update.toolCallId, tool);
|
|
170018
|
+
events.push({ kind: "tool", tool });
|
|
170019
|
+
} else if (update.sessionUpdate === "tool_call_update") {
|
|
170020
|
+
const tool = tools.get(update.toolCallId);
|
|
170021
|
+
if (tool) {
|
|
170022
|
+
if (update.name != null)
|
|
170023
|
+
tool.name = update.name;
|
|
170024
|
+
if (update.title != null)
|
|
170025
|
+
tool.title = update.title;
|
|
170026
|
+
if (update.content != null)
|
|
170027
|
+
tool.content = update.content;
|
|
170028
|
+
if (update.rawInput !== void 0)
|
|
170029
|
+
tool.rawInput = update.rawInput;
|
|
170030
|
+
if (update.rawOutput !== void 0)
|
|
170031
|
+
tool.rawOutput = update.rawOutput;
|
|
170032
|
+
}
|
|
170033
|
+
if (update.status !== "completed" && update.status !== "failed")
|
|
170034
|
+
return;
|
|
169776
170035
|
events.push({
|
|
169777
170036
|
kind: "tool-result",
|
|
169778
170037
|
toolCallId: update.toolCallId,
|
|
169779
170038
|
failed: update.status === "failed",
|
|
169780
|
-
output: update.rawOutput ?? update.content ??
|
|
170039
|
+
output: update.rawOutput ?? update.content ?? tool?.rawOutput ?? tool?.content ?? null
|
|
169781
170040
|
});
|
|
169782
170041
|
}
|
|
169783
170042
|
});
|
|
@@ -169978,12 +170237,7 @@ var init_automation_acp = __esm({
|
|
|
169978
170237
|
type: "tool_use",
|
|
169979
170238
|
id: event.tool.toolCallId,
|
|
169980
170239
|
name: event.tool.name ?? event.tool.title,
|
|
169981
|
-
input: cappedJsonValue({
|
|
169982
|
-
title: event.tool.title,
|
|
169983
|
-
kind: event.tool.kind,
|
|
169984
|
-
status: event.tool.status,
|
|
169985
|
-
rawInput: event.tool.rawInput
|
|
169986
|
-
})
|
|
170240
|
+
input: cappedJsonValue(event.tool.rawInput ?? {})
|
|
169987
170241
|
}
|
|
169988
170242
|
]);
|
|
169989
170243
|
continue;
|