@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
package/dist/component.json
CHANGED
|
@@ -31,10 +31,16 @@ export function xDirectMessagesProgram() {
|
|
|
31
31
|
const UPDATE_PAGES_PER_PASS = 10;
|
|
32
32
|
// Matching recent text without a request id is ambiguous, not delivery proof.
|
|
33
33
|
const RESEND_WINDOW_MS = 10 * 60 * 1000;
|
|
34
|
+
// Reconcile 503 responses before retrying: a failed response can still land.
|
|
35
|
+
const UNAVAILABLE_SEND_RETRY_DELAYS_MS = [3000, 7000];
|
|
36
|
+
// Abort network work before Chrome's 80s awaited-evaluation deadline.
|
|
37
|
+
const SEND_TIMEOUT_MS = 70000;
|
|
34
38
|
const BATCH_EVENTS = 500;
|
|
35
39
|
const BATCH_BYTES = 128 * 1024;
|
|
36
|
-
function fail(message) {
|
|
37
|
-
|
|
40
|
+
function fail(message, status) {
|
|
41
|
+
const error = new Error(`X direct messages: ${message}`);
|
|
42
|
+
if (status !== undefined) error.status = status;
|
|
43
|
+
throw error;
|
|
38
44
|
}
|
|
39
45
|
function cookie(name) {
|
|
40
46
|
const raw = document.cookie
|
|
@@ -49,13 +55,16 @@ export function xDirectMessagesProgram() {
|
|
|
49
55
|
return match[1];
|
|
50
56
|
}
|
|
51
57
|
async function request(path, init = {}) {
|
|
58
|
+
init.signal?.throwIfAborted();
|
|
52
59
|
const self = account();
|
|
53
60
|
const csrf = cookie("ct0");
|
|
54
61
|
if (!csrf) fail("Sign in to X in the paired browser");
|
|
55
62
|
const response = await fetch(path, {
|
|
56
63
|
credentials: "include",
|
|
57
|
-
signal: AbortSignal.timeout(20000),
|
|
58
64
|
...init,
|
|
65
|
+
signal: init.signal
|
|
66
|
+
? AbortSignal.any([init.signal, AbortSignal.timeout(20000)])
|
|
67
|
+
: AbortSignal.timeout(20000),
|
|
59
68
|
headers: {
|
|
60
69
|
authorization: WEB_CLIENT_BEARER,
|
|
61
70
|
"x-csrf-token": csrf,
|
|
@@ -73,6 +82,7 @@ export function xDirectMessagesProgram() {
|
|
|
73
82
|
}
|
|
74
83
|
fail(
|
|
75
84
|
`request failed (HTTP ${response.status}${code === null ? "" : `, X error ${code}`})`,
|
|
85
|
+
response.status,
|
|
76
86
|
);
|
|
77
87
|
}
|
|
78
88
|
const body = await response.json();
|
|
@@ -85,10 +95,11 @@ export function xDirectMessagesProgram() {
|
|
|
85
95
|
);
|
|
86
96
|
return body?.inbox_initial_state ?? fail("Inbox state is unavailable");
|
|
87
97
|
}
|
|
88
|
-
async function conversation(conversationId, maxId) {
|
|
98
|
+
async function conversation(conversationId, maxId, signal) {
|
|
89
99
|
const page = maxId ? `&max_id=${encodeURIComponent(maxId)}` : "";
|
|
90
100
|
const body = await request(
|
|
91
101
|
`${DM_API}/conversation/${conversationId}.json?context=FETCH_DM_CONVERSATION&${DM_PARAMS}${page}`,
|
|
102
|
+
signal ? { signal } : {},
|
|
92
103
|
);
|
|
93
104
|
return body?.conversation_timeline ?? fail("Conversation is unavailable");
|
|
94
105
|
}
|
|
@@ -294,6 +305,7 @@ export function xDirectMessagesProgram() {
|
|
|
294
305
|
}
|
|
295
306
|
async function send(input) {
|
|
296
307
|
const self = account();
|
|
308
|
+
const signal = AbortSignal.timeout(SEND_TIMEOUT_MS);
|
|
297
309
|
const conversationId = String(input.conversation_id ?? "");
|
|
298
310
|
if (!CONVERSATION_ID.test(conversationId))
|
|
299
311
|
fail("conversation_id must be an exact X DM conversation id");
|
|
@@ -308,41 +320,64 @@ export function xDirectMessagesProgram() {
|
|
|
308
320
|
typeof input.idempotency_key === "string" ? input.idempotency_key : "";
|
|
309
321
|
if (!idempotencyKey) fail("idempotency_key is required");
|
|
310
322
|
const requestId = await requestIdOf(self, conversationId, idempotencyKey);
|
|
323
|
+
const delivered = (prior) => ({
|
|
324
|
+
sent: true,
|
|
325
|
+
deduplicated: true,
|
|
326
|
+
id: prior.id,
|
|
327
|
+
message_id: prior.message_id,
|
|
328
|
+
conversation_id: conversationId,
|
|
329
|
+
occurred_at: prior.occurred_at,
|
|
330
|
+
});
|
|
331
|
+
const readConversation = () => {
|
|
332
|
+
if (account() !== self) fail("X account changed before the send read");
|
|
333
|
+
return conversation(conversationId, undefined, signal);
|
|
334
|
+
};
|
|
311
335
|
// Only an existing conversation the account can read is a send target.
|
|
312
|
-
const before = await
|
|
336
|
+
const before = await readConversation();
|
|
313
337
|
const prior = earlierAttempt(before, self, requestId, text);
|
|
314
|
-
if (prior)
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
338
|
+
if (prior) return delivered(prior);
|
|
339
|
+
let response;
|
|
340
|
+
for (const delay of [...UNAVAILABLE_SEND_RETRY_DELAYS_MS, null]) {
|
|
341
|
+
if (account() !== self) fail("X account changed before the send");
|
|
342
|
+
try {
|
|
343
|
+
response = await request(`${DM_API}/new2.json`, {
|
|
344
|
+
method: "POST",
|
|
345
|
+
signal,
|
|
346
|
+
headers: { "content-type": "application/json" },
|
|
347
|
+
body: JSON.stringify({
|
|
348
|
+
conversation_id: conversationId,
|
|
349
|
+
recipient_ids: false,
|
|
350
|
+
request_id: requestId,
|
|
351
|
+
text,
|
|
352
|
+
cards_platform: "Web-12",
|
|
353
|
+
include_cards: 1,
|
|
354
|
+
include_quote_count: true,
|
|
355
|
+
dm_users: false,
|
|
356
|
+
}),
|
|
357
|
+
});
|
|
358
|
+
break;
|
|
359
|
+
} catch (error) {
|
|
360
|
+
if (error?.status !== 503) throw error;
|
|
361
|
+
signal.throwIfAborted();
|
|
362
|
+
if (delay !== null)
|
|
363
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
364
|
+
const landed = earlierAttempt(
|
|
365
|
+
await readConversation(),
|
|
366
|
+
self,
|
|
367
|
+
requestId,
|
|
368
|
+
text,
|
|
369
|
+
);
|
|
370
|
+
if (landed) return delivered(landed);
|
|
371
|
+
if (delay === null) throw error;
|
|
372
|
+
}
|
|
323
373
|
}
|
|
324
|
-
if (account() !== self) fail("X account changed before the send");
|
|
325
|
-
const response = await request(`${DM_API}/new2.json`, {
|
|
326
|
-
method: "POST",
|
|
327
|
-
headers: { "content-type": "application/json" },
|
|
328
|
-
body: JSON.stringify({
|
|
329
|
-
conversation_id: conversationId,
|
|
330
|
-
recipient_ids: false,
|
|
331
|
-
request_id: requestId,
|
|
332
|
-
text,
|
|
333
|
-
cards_platform: "Web-12",
|
|
334
|
-
include_cards: 1,
|
|
335
|
-
include_quote_count: true,
|
|
336
|
-
dm_users: false,
|
|
337
|
-
}),
|
|
338
|
-
});
|
|
339
374
|
const created = messagesOf(response).find(
|
|
340
375
|
(message) => String(message.conversation_id) === conversationId,
|
|
341
376
|
);
|
|
342
377
|
const messageId = created ? String(created.id ?? "") : "";
|
|
343
378
|
if (!/^[0-9]+$/.test(messageId))
|
|
344
379
|
fail("X accepted the send but returned no message id");
|
|
345
|
-
const after = await
|
|
380
|
+
const after = await readConversation();
|
|
346
381
|
const landed = rowsOf(after, self).find(
|
|
347
382
|
(row) => row.message_id === messageId && row.from_me,
|
|
348
383
|
);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
-- migrate:up
|
|
2
|
+
-- lobu:no-quiesce old code never reads the column, and a bundle it writes no longer matches the stamp's digest
|
|
3
|
+
-- `<compiler fingerprint>:<bundle digest>` for a compiled_code the server
|
|
4
|
+
-- compiled itself: the fingerprint covers the bootstrap, the bundled
|
|
5
|
+
-- @lobu/views runtime, pinned package versions and esbuild. NULL for a bundle
|
|
6
|
+
-- the caller supplied and for rows saved before this column existed. When the
|
|
7
|
+
-- digest still matches compiled_code and the fingerprint differs from the
|
|
8
|
+
-- running server's, the bundle is stale and the server rebuilds it from
|
|
9
|
+
-- source_code when the view is served. A writer that replaces compiled_code
|
|
10
|
+
-- without restamping leaves a mismatched digest, so that bundle is never
|
|
11
|
+
-- rebuilt.
|
|
12
|
+
ALTER TABLE public.views ADD COLUMN IF NOT EXISTS compile_config_hash text;
|
|
13
|
+
|
|
14
|
+
-- migrate:down
|
|
15
|
+
|
|
16
|
+
ALTER TABLE public.views DROP COLUMN IF EXISTS compile_config_hash;
|
|
@@ -1529,7 +1529,7 @@
|
|
|
1529
1529
|
|
|
1530
1530
|
"vfile-message": ["vfile-message@4.0.3", "", { "dependencies": { "@types/unist": "^3.0.0", "unist-util-stringify-position": "^4.0.0" } }, "sha512-QTHzsGd1EhbZs4AsQ20JX1rC3cOlt/IWJruk893DfLRr57lcnOeMaWG4K0JrRta4mIJZKth2Au3mM3u03/JWKw=="],
|
|
1531
1531
|
|
|
1532
|
-
"vite": ["vite@6.4.
|
|
1532
|
+
"vite": ["vite@6.4.5", "", { "dependencies": { "esbuild": "^0.25.0", "fdir": "^6.4.4", "picomatch": "^4.0.2", "postcss": "^8.5.3", "rollup": "^4.34.9", "tinyglobby": "^0.2.13" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0", "jiti": ">=1.21.0", "less": "*", "lightningcss": "^1.21.0", "sass": "*", "sass-embedded": "*", "stylus": "*", "sugarss": "*", "terser": "^5.16.0", "tsx": "^4.8.1", "yaml": "^2.4.2" }, "optionalPeers": ["less", "lightningcss", "sass", "sass-embedded", "stylus", "sugarss", "terser", "tsx"], "bin": "bin/vite.js" }, "sha512-4enwjFfi4IwtEh0w+jPzpLVOFQiPHmmzPxcHXQOyEur47o6u0jE573DmGpjA+7irXoMLYRZD5ZaFUEneS3abPg=="],
|
|
1533
1533
|
|
|
1534
1534
|
"web-streams-polyfill": ["web-streams-polyfill@3.3.3", "", {}, "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw=="],
|
|
1535
1535
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/entity-page
|
|
2
|
-
import{al as x,am as m,an as p,ao as y,i as j,m as P,j as e,r as g,ap as R,l as f,_ as v}from"./index-
|
|
3
|
-
//# sourceMappingURL=_-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/entity-page-D3e4iPle.js","assets/index-9YuSRymd.js","assets/index-BSH07yVD.css","assets/record-activity-ZJntBfN_.js","assets/filter-editors-Bwhqj7lY.js","assets/connection-label-BobuYiAG.js","assets/source-record-panels-BdfOVPWn.js","assets/events-feed-DO3IiJO2.js","assets/conversations-table-D_HOe1jN.js","assets/clients-BhNl1tVq.js","assets/schema-value-normalization-CKdPjdPC.js","assets/card-jzhQrMDP.js","assets/client-rows-BYbsXGy9.js","assets/agent-loading-shells-B7v6Cffw.js","assets/member-scope-gate-DD4YBFn-.js","assets/record-field-peek-Brh1IQGy.js","assets/record-session-Pbr5czGw.js","assets/entity-avatar-mdh7Kq5D.js","assets/view-param-filters-B0quibBi.js","assets/app-bridge-BCm4muqj.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{al as x,am as m,an as p,ao as y,i as j,m as P,j as e,r as g,ap as R,l as f,_ as v}from"./index-9YuSRymd.js";import{P as r}from"./public-shell-ready-DqX8AXfw.js";const E=f(async()=>({default:(await v(async()=>{const{EntityPage:s}=await import("./entity-page-D3e4iPle.js");return{EntityPage:s}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]))).EntityPage}));function l(){return e.jsx("div",{"data-public-loading":"true",children:e.jsx(R,{})})}function S(){const{owner:s,_splat:c}=x.useParams(),a=m(c||""),d=a?.viewKey,{path:u}=p(s,a?.entityPath),{data:t,isLoading:n,error:i}=y(u,{slug:s},{includeBootstrap:!0}),{session:h,isReady:o}=j();return P({active:!n&&o&&!h&&(!!i||!t),owner:s}),n||!o&&!t?e.jsx(l,{}):i||!t||!t.entity?e.jsxs(e.Fragment,{children:[e.jsx(r,{}),e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Not Found"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"We couldn't resolve this path."})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(r,{}),e.jsx(g.Suspense,{fallback:e.jsx(l,{}),children:e.jsx(E,{namespace:t.workspace,path:t.path,entity:t.entity,viewKey:d})})]})}export{S as component};
|
|
3
|
+
//# sourceMappingURL=_-BorucF19.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{c3 as t,j as p,c4 as m}from"./index-9YuSRymd.js";import{A as e}from"./activity-route-view-D7ORHntE.js";import"./record-activity-ZJntBfN_.js";import"./filter-editors-Bwhqj7lY.js";import"./connection-label-BobuYiAG.js";import"./source-record-panels-BdfOVPWn.js";import"./events-feed-DO3IiJO2.js";import"./conversations-table-D_HOe1jN.js";import"./clients-BhNl1tVq.js";import"./schema-value-normalization-CKdPjdPC.js";import"./card-jzhQrMDP.js";import"./client-rows-BYbsXGy9.js";import"./agent-loading-shells-B7v6Cffw.js";import"./member-scope-gate-DD4YBFn-.js";import"./public-shell-ready-DqX8AXfw.js";function w(){const{owner:o,_splat:r}=t.useParams(),i=t.useSearch();return p.jsx(e,{owner:o,search:i,entityScope:m(r||"").path})}export{w as component};
|
|
2
|
+
//# sourceMappingURL=_-CkGyNi0G.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{hd as r,j as e}from"./index-9YuSRymd.js";import{A as n}from"./agents-workbench-DJ67GZ93.js";import"./agent-editor-form-DsSoeQeF.js";import"./model-selector-CDrAjH31.js";import"./proposal-review-shell-CFhOqCLf.js";function i(){const{owner:o,agentId:t}=r.useParams();return e.jsx(n,{owner:o,agentId:t})}export{i as component};
|
|
2
|
+
//# sourceMappingURL=_agentId-BrhcaxUk.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{o as L,gd as y,r as u,ge as C,j as n,Q as D,gf as S,i as P,bh as R,a_ as E,aR as M,bb as N,ch as O,gg as Q,gh as $,bo as B,w as _}from"./index-
|
|
2
|
-
//# sourceMappingURL=_agentId-
|
|
1
|
+
import{o as L,gd as y,r as u,ge as C,j as n,Q as D,gf as S,i as P,bh as R,a_ as E,aR as M,bb as N,ch as O,gg as Q,gh as $,bo as B,w as _}from"./index-9YuSRymd.js";import{L as z,A as F}from"./agent-thread-D38STyeu.js";import{A as H,C as U}from"./agent-loading-shells-B7v6Cffw.js";import"./app-bridge-BCm4muqj.js";import"./use-mention-search-Dcunv4L0.js";import"./index-Vcq4gwWv.js";import"./events-feed-DO3IiJO2.js";import"./conversations-table-D_HOe1jN.js";import"./clients-BhNl1tVq.js";import"./schema-value-normalization-CKdPjdPC.js";import"./card-jzhQrMDP.js";function W({owner:t,agent:s,threadId:e,afterMessagesContent:d,className:r,initialDraft:p,newChatRequested:m=!1,preventAutoNavigate:g}){const o=L(),i=s.agentId,{data:a=[]}=y(i,{orgSlug:t}),[l,x]=u.useState(()=>C()),[h,A]=u.useState(null);u.useEffect(()=>{!m||e||(x(C()),A(null),o({to:".",search:(f=>{const{new:b,...w}=f;return w}),replace:!0}))},[m,e,o]);const v=u.useMemo(()=>!h||a.some(f=>f.id===h.id)?a:[h,...a],[a,h]),c=e??l,T=!e||!v.some(f=>f.id===e),j=u.useCallback(()=>{if(v.some(b=>b.id===c))return;A({id:c,title:`Conversation ${v.length+1}`,createdAt:Date.now(),updatedAt:Date.now()});const f=S(t,i,c);o({...f,replace:!0})},[v,c,o,t,i]),k=u.useCallback(()=>{T&&!g&&j()},[T,j,g]);return n.jsx("div",{className:D("flex min-h-0 flex-1 flex-col",r),children:n.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:n.jsx(z,{agentId:i,workspaceSlug:t,thread:c,loadHistory:!!e,onFirstUserMessage:k,initialDraft:p,children:n.jsx(F,{afterMessagesContent:d})},`${i}:${c}`)})})}function q({owner:t,agentId:s,threadId:e,initialDraft:d,newChatRequested:r,afterMessagesContent:p,preventAutoNavigate:m}){const{isAuthenticated:g}=P(),{isMember:o,isLoading:i}=R(),a=g&&o,{data:l=[],isLoading:x}=E({enabled:a}),h=s??null,A=l.find(c=>c.agentId===h)??null;return a&&x||i?n.jsx(H,{}):A?n.jsx(W,{owner:t,agent:A,threadId:e,initialDraft:d,newChatRequested:r,afterMessagesContent:p,preventAutoNavigate:m,className:"min-h-0 flex-1 overflow-hidden"}):n.jsx(M,{icon:N,title:"Agent not found",description:"This agent may have been removed."})}function G(t){return[...t].sort((s,e)=>e.updatedAt-s.updatedAt)[0]}function J({owner:t,agentId:s,threadId:e,initialDraft:d,forceComposer:r=!1,newChatRequested:p=!1,afterMessagesContent:m,preventAutoNavigate:g}){const o=L(),{data:i=[],isLoading:a}=O(Q(t,s,{strict:!1})),l=u.useMemo(()=>G(i),[i]);return u.useEffect(()=>{if(e||r||a||!l)return;const x=S(t,s,l.id);o({...x,replace:!0})},[s,a,l,o,t,e,r]),!e&&!r&&(a||l)?n.jsx(U,{}):n.jsx(q,{owner:t,agentId:s,threadId:e,initialDraft:d,newChatRequested:p,afterMessagesContent:m,preventAutoNavigate:g})}function ie(){const{owner:t,agentId:s}=$.useParams(),{threadId:e}=B({strict:!1}),{new:d,prompt:r}=_({strict:!1});return n.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden px-4 pt-2.5 pb-4 lg:px-6 lg:pb-6",children:n.jsx("div",{className:"mx-auto flex min-h-0 w-full max-w-3xl flex-1 flex-col",children:n.jsx(J,{owner:t,agentId:s,threadId:e,initialDraft:r,forceComposer:!e,newChatRequested:!!d})})})}export{ie as component};
|
|
2
|
+
//# sourceMappingURL=_agentId-DgRrCE2B.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{o as N,n as A,ao as b,i as k,bh as L,e7 as C,j as t,B as n,gK as y,bb as R,S as _,L as $,b9 as D,h2 as u,ai as O}from"./index-
|
|
2
|
-
//# sourceMappingURL=_automationId-
|
|
1
|
+
import{o as N,n as A,ao as b,i as k,bh as L,e7 as C,j as t,B as n,gK as y,bb as R,S as _,L as $,b9 as D,h2 as u,ai as O}from"./index-9YuSRymd.js";import{A as z}from"./automation-detail-content-DSwbRpbx.js";import"./create-automation-form-Bpy92SM5.js";import"./cronstrue-CWImw-kf.js";import"./entity-options-Clz_WXK-.js";import"./connection-label-BobuYiAG.js";import"./model-selector-CDrAjH31.js";import"./skill-editor-D_W3QlRz.js";import"./code-editor-CEqoCky-.js";import"./index-CDz3-ieP.js";import"./index-Vcq4gwWv.js";import"./use-mention-search-Dcunv4L0.js";import"./proposal-review-shell-CFhOqCLf.js";import"./json-diff-DIN5Jhfx.js";import"./deployments-C5hvipQh.js";import"./events-feed-DO3IiJO2.js";import"./conversations-table-D_HOe1jN.js";import"./clients-BhNl1tVq.js";import"./schema-value-normalization-CKdPjdPC.js";import"./card-jzhQrMDP.js";function P({owner:e,automationId:o,view:a,runId:s}){const r=N(),{orgContext:p,hasOrgContext:x}=A(),{data:h,isLoading:m}=b(`/${e}`,p),{isAuthenticated:g}=k(),{isLoading:c}=L(),f=h?.workspace?.id??"",v=g?!x||m||c:m||c,i=C(o,void 0,f).data?.automation,j=i?.automation_name??"Automation",l=()=>void r({to:"/$owner/automations",params:{owner:e}}),d=()=>void r({to:"/$owner/automations/$automationId",params:{owner:e,automationId:o},search:{view:"activity",run_id:void 0}}),w=!s&&a==="definition";return t.jsx("div",{className:"flex flex-1 flex-col gap-6 px-4 pt-2.5 pb-8 lg:px-6",children:t.jsxs("div",{className:"mx-auto flex w-full min-w-0 max-w-3xl flex-col gap-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsxs(n,{type:"button",variant:"ghost",size:"sm",className:"h-8 gap-1.5 text-muted-foreground hover:text-foreground",onClick:l,children:[t.jsx(y,{className:"h-3.5 w-3.5"}),"Automations"]}),t.jsxs("h1",{className:"flex min-w-0 items-center gap-2 truncate font-display text-xl font-semibold",children:[t.jsx(R,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":!0}),v&&!i?t.jsx(_,{className:"h-5 w-40"}):s?"Review change":j]})]}),s?null:w?t.jsx(n,{type:"button",variant:"ghost",size:"sm",className:"h-8 text-muted-foreground hover:text-foreground",onClick:d,children:"Done"}):t.jsx(n,{asChild:!0,variant:"ghost",size:"sm",className:"h-8 gap-1.5",children:t.jsxs($,{to:"/$owner/automations/$automationId",params:{owner:e,automationId:o},search:{view:"definition",run_id:void 0},children:[t.jsx(D,{className:"h-3.5 w-3.5"}),"Edit"]})})]}),t.jsx(z,{owner:e,agentId:i?.managed_agent_id??null,automationId:o,view:a,runId:s,onDone:s?l:d})]})})}function ot(){const{owner:e,automationId:o}=u.useParams(),a=u.useSearch();return t.jsx(O,{owner:e,children:()=>t.jsx(P,{owner:e,automationId:o,view:a.view,runId:a.run_id})})}export{ot as component};
|
|
2
|
+
//# sourceMappingURL=_automationId-DSrZIYcs.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{iD as I,j as e,ai as J,o as U,aA as q,d7 as z,cg as Q,cP as X,S as A,B as Y,L as p,aB as Z,im as K,io as ee,aP as ne,gb as h,ih as se,g9 as ae,aW as oe,i4 as te,ga as ie,ht as E,aJ as ce,x as re}from"./index-
|
|
2
|
-
//# sourceMappingURL=_connectorKey._connectionId-
|
|
1
|
+
import{iD as I,j as e,ai as J,o as U,aA as q,d7 as z,cg as Q,cP as X,S as A,B as Y,L as p,aB as Z,im as K,io as ee,aP as ne,gb as h,ih as se,g9 as ae,aW as oe,i4 as te,ga as ie,ht as E,aJ as ce,x as re}from"./index-9YuSRymd.js";import{R as de,c as le,C as me}from"./device-pin-tombstone-2U0UMu3_.js";import{a as pe}from"./connector-provenance-D-ECOlMJ.js";import{f as ue,C as he,F as xe,a as fe,b as ve,A as je,c as Ce}from"./connection-feed-detail-WcGCA6qY.js";import{S as De,g as Ne}from"./runs-table-B1APZv7d.js";import{c as ge}from"./connection-label-BobuYiAG.js";import"./runs-panel-C0_DNTcq.js";import"./filter-editors-Bwhqj7lY.js";import"./connector-scope-lists-CRFEpSvk.js";import"./entity-options-Clz_WXK-.js";function ye(){const{owner:l,connectorKey:n,connectionId:v}=I.useParams(),{addFeed:o,feedId:c,settings:x,auth_result:t}=I.useSearch();return e.jsx(J,{owner:l,children:m=>e.jsx($e,{organizationId:m.organizationId,ownerSlug:m.ownerSlug,isWorkspaceLoading:m.isWorkspaceLoading,connectorKey:n,connectionId:Number(v),showAddFeed:o===!0,feedId:c,openSettings:x===!0,authResult:t})})}function $e({organizationId:l,ownerSlug:n,isWorkspaceLoading:v,connectorKey:o,connectionId:c,showAddFeed:x,feedId:t,openSettings:m,authResult:R}){const y=U(),{data:B=[]}=q(),{data:P=[],isLoading:M,isError:j,refetch:T}=z(l??"",{connectorKey:o,connectionIds:[c]}),{data:g=[]}=Q(l??""),{data:W=[],isLoading:O,isError:S,refetch:H}=X(t?c:null),s=P.find(i=>i.id===c),a=g.find(i=>i.key===o),r=t?W.find(i=>i.id===t):null;if(v||M||t&&O||!l)return e.jsxs("div",{className:"flex flex-1 flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1",children:[e.jsx(A,{className:"h-7 w-56"}),e.jsx(A,{className:"h-4 w-24"})]}),e.jsx(de,{})]});if(j||t&&S)return e.jsxs("div",{role:"alert",className:"space-y-2",children:[e.jsxs("p",{children:["Could not load this ",j?"connection":"feed","."]}),e.jsx(Y,{variant:"outline",size:"sm",onClick:()=>void(j?T():H()),children:"Retry"})]});if(!s)return e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Connection not found."}),e.jsxs(p,{to:"/$owner/connectors/$connectorKey",params:{owner:n,connectorKey:o},className:"mt-2 inline-block text-sm text-primary hover:underline",children:["Back to ",a?.name??o]})]});const $=ge({...s,connector_name:s.connector_name??a?.name??null}),C=!t&&!x,V=()=>void y({to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:n,connectorKey:o,connectionId:String(c)},search:{},replace:!0});let u,f=$,_,k,D;t?r?(f=ue(r,a),r.store==="channel_messages"?(u=e.jsx(he,{feed:r,hideHeader:!0}),D="chat channel"):(_=e.jsx(xe,{feed:r,ownerSlug:n}),k=e.jsx(fe,{feed:r}),u=e.jsx(ve,{feed:r,connectorDef:a,ownerSlug:n}))):(u=e.jsx("p",{className:"text-sm text-muted-foreground",children:"Feed not found."}),f="Feed"):x&&(u=e.jsx(je,{onClose:V,organizationId:l,connections:[s],connectorDefinitions:g}),f="Add feed",D=Ce);const d=B.find(i=>i.id===s.device_worker_id&&Z(i,n)),w=d?K(d):void 0,N=w?ee(n,w,ne()):void 0,F=[e.jsx(p,{to:"/$owner/connectors",params:{owner:n},className:h,children:"Connectors"},"connectors"),...d&&N?[e.jsx(p,{to:"/$owner/connectors/app/$appId",params:{owner:n,appId:N.id},className:h,children:N.name},"app"),e.jsx(p,{to:"/$owner/connectors/device/$deviceId",params:{owner:n,deviceId:d.id},className:h,children:se(d)},"device")]:[e.jsx(p,{to:"/$owner/connectors/$connectorKey",params:{owner:n,connectorKey:o},search:{},className:h,children:a?.name??o},"connector")]];C||F.push(e.jsx(p,{to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:n,connectorKey:o,connectionId:String(c)},search:{},className:h,children:$},"connection"));const b=C?le(s):null,G=D??b??void 0,L=e.jsx(ae,{breadcrumb:e.jsx(ie,{crumbs:F}),icon:a?e.jsx(oe,{icon:a.icon,name:a.name,faviconDomain:a.favicon_domain??te(a.auth_schema)}):null,title:f,status:_??e.jsx(De,{status:Ne(s.status),showDot:!0,children:s.status}),meta:k,caption:G,captionTone:b?"error":"muted"});return C?d&&a&&ce(a)?e.jsx(re,{to:"/$owner/connectors/device/$deviceId",params:{owner:n,deviceId:d.id},search:{connection:s.id,settings:m||void 0},hash:`connection-${s.id}`,replace:!0}):e.jsxs(E,{header:L,children:[e.jsx(pe,{connectorDef:a,connectorKey:o,ownerSlug:n,deviceWorkerId:s.device_worker_id,deviceLabel:s.device_label}),e.jsx(me,{embedded:!0,connection:s,connectorDef:a,ownerSlug:n,openSettings:m,authResult:R},s.id)]}):e.jsx(E,{header:L,children:e.jsx("div",{className:"mt-0",children:u})})}export{ye as component};
|
|
2
|
+
//# sourceMappingURL=_connectorKey._connectionId-DWxv1uoi.js.map
|
package/dist/owletto/dist/assets/{_connectorKey.index-C1QPGf9E.js → _connectorKey.index-BTP5ijdT.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ax as Pe,ay as De,az as Ee,aH as me,aE as ae,hr as ls,hs as os,j as e,ht as le,B as g,L as K,aG as he,g9 as oe,ga as ce,gb as X,hu as cs,$ as ds,hv as te,r as p,hw as we,hx as Fe,cx as us,hy as Ae,bJ as Y,hz as _e,z as $,bp as Le,bq as Re,br as Oe,bs as Be,bt as Ke,hk as ms,I as F,bA as G,a2 as q,A as Se,hA as hs,hB as xs,bd as ps,hC as fs,a$ as xe,hD as gs,hE as js,hF as Ue,hG as Ie,hH as ze,af as ne,P as U,b8 as de,hI as vs,ft as ys,hJ as Ns,e_ as J,hK as bs,S as D,hL as B,i as Cs,hM as ks,hN as ws,hO as As,hP as _s,hQ as Ss,hR as $s,hS as Ps,hT as Ds,bR as se,hU as Es,hV as Fs,bQ as Ls,ec as Rs,g$ as Os,Q as re,ed as Bs,bU as Ks,cT as Me,hW as H,hX as Us,ai as Is,hY as Te,aw as ie,u as Ve,hZ as qe,aK as zs,h_ as We,h$ as Ms,i0 as Ye,i1 as Ts,ee as Vs,av as qs,d7 as Ws,aS as Ys,aC as M,i2 as Xe,o as Q,aX as Qe,aW as pe,aT as Xs,i3 as Qs,i4 as Gs}from"./index-DYCqXaMf.js";import{C as Hs,a as Ge}from"./connections-browser-CEwYrYqt.js";import{C as Js}from"./connector-provenance-BocTm__v.js";import{R as Zs}from"./runs-panel-T1ZxTVz6.js";import"./connection-label-BobuYiAG.js";import"./filter-editors-B1_QUpg_.js";import"./runs-table-D_8QlCCN.js";function et({ownerSlug:s,familyKind:t,familyId:a}){const n=t==="inference",r=Pe({enabled:n}),i=De({enabled:n}),h=Ee({enabled:!n}),o=n?r:h,l=n?i.data?.find(c=>c.slug===a)?.displayName??a:me(a),x=(n?(r.data??[]).filter(c=>c.kind===a).map(c=>({key:`${ae}${c.slug}`,name:c.displayName||c.slug,status:[c.isDefault?"Default":null,c.status].filter(Boolean).join(" · ")})):(h.data?.sandboxes??[]).filter(c=>c.providerKind===a).map(c=>({key:`${ls}${c.id}`,name:c.name,status:c.connected?"Connected":"Needs credentials"}))).map(c=>({id:c.key,name:c.name,description:c.status,tone:null,link:os({to:"/$owner/connectors/$connectorKey",params:{owner:s,connectorKey:c.key},search:{}})})),u=`${n?ae:he}${a}`;return e.jsx(le,{header:e.jsx(oe,{title:l,breadcrumb:e.jsx(ce,{crumbs:[e.jsx(K,{to:"/$owner/connectors",params:{owner:s},className:X,children:"Connectors"},"connectors")]})}),children:e.jsx(Hs,{entries:x,isLoading:o.isLoading,isError:o.isError,onRetry:()=>void o.refetch(),action:e.jsx(g,{asChild:!0,variant:"outline",size:"sm",children:n?e.jsx(K,{to:"/$owner/connectors/$connectorKey",params:{owner:s,connectorKey:u},search:{addAccount:!0},children:"Add connection"}):e.jsx(K,{to:"/$owner/connectors/create/$connectorKey",params:{owner:s,connectorKey:u},children:"Add connection"})})})})}function st({catalog:s,initialProvider:t,initialSlug:a,allowOAuth:n=!0,initialModel:r,onDone:i}){const h=cs(),o=ds(),l=s.find(d=>d.slug===t)??s[0],x=n&&l&&te(l)?"oauth":"api-key",[u,c]=p.useState(l?.slug??""),[j,N]=p.useState(a??l?.slug??""),[m,y]=p.useState(l?.displayName??""),[b,P]=p.useState(l?.baseUrl??""),[w,k]=p.useState(r??l?.defaultModel??""),[E,_]=p.useState(""),[z,R]=p.useState(l?.apiKeyPlaceholder??""),[I,O]=p.useState(x),[v,f]=p.useState(""),[A,W]=p.useState(null),[T,V]=p.useState(!1),[fe,ge]=p.useState(!1),C=s.find(d=>d.slug===u),Z=we(C?.modalities??[]),je=n&&!!C&&te(C),ve=C?Fe(C):!1,ye=je&&I==="oauth",Ne=ve&&!ye,L=us().slug,ee=p.useCallback(()=>{ge(!0),o.invalidateQueries({queryKey:["inference-providers"]})},[o]),Ze=p.useCallback(()=>{o.invalidateQueries({queryKey:["inference-providers"]}),i()},[o,i]),es=p.useCallback(async()=>{if(!(!L||!C)){V(!0);try{const d=await Ae(L,C.slug);if(d.mode!=="redirect")throw new Error("Unexpected sign-in mode");window.open(d.authorizeUrl,"_blank","noreferrer")}catch(d){Y.error(d instanceof Error?d.message:"Failed to start sign-in")}finally{V(!1)}}},[L,C]),ss=p.useCallback(async()=>{if(!(!L||!C||!v.trim())){V(!0);try{const d=await _e(L,C.slug,{code:v.trim()});if(d.status!=="success")throw new Error(d.error||"Sign-in not complete");ee(),Y.success(`Signed in with ${C.displayName}`)}catch(d){Y.error(d instanceof Error?d.message:"Failed to complete sign-in")}finally{V(!1)}}},[L,C,v,ee]),ts=p.useCallback(async()=>{if(!(!L||!C)){V(!0);try{const d=await Ae(L,C.slug);if(d.mode!=="device")throw new Error("Unexpected sign-in mode");W({userCode:d.userCode,deviceAuthId:d.deviceAuthId,verificationUrl:d.verificationUrl}),window.open(d.verificationUrl,"_blank","noreferrer")}catch(d){Y.error(d instanceof Error?d.message:"Failed to start sign-in")}finally{V(!1)}}},[L,C]),as=p.useCallback(async()=>{if(!(!L||!C||!A)){V(!0);try{const d=await _e(L,C.slug,{deviceAuthId:A.deviceAuthId,userCode:A.userCode});if(d.status==="success"){ee(),Y.success(`Signed in with ${C.displayName}`);return}W(S=>S&&{...S,message:d.error||"Waiting for approval..."})}catch(d){Y.error(d instanceof Error?d.message:"Failed to check status")}finally{V(!1)}}},[L,C,A,ee]),ns=C?.supportedAuthTypes.includes("device-code")??!1,rs=d=>{c(d);const S=s.find(ue=>ue.slug===d);S&&(N(S.slug),y(S.displayName),P(S.baseUrl),k(S.slug===t&&r?r:S.defaultModel??""),R(S.apiKeyPlaceholder),O(n&&te(S)?"oauth":"api-key"),f(""),W(null),ge(!1))},be=/^[a-z0-9][a-z0-9-]*$/.test(j),Ce=be&&Ne&&E.trim().length>0&&!h.isPending,is=d=>{if(d.preventDefault(),!Ce)return;const S={};b.trim()&&(S.base_url=b.trim()),w.trim()&&(S.model=w.trim());const ue=Object.keys(S).length>0?{text:S}:void 0;h.mutate({slug:j.trim(),kind:u,displayName:m.trim()||void 0,apiKey:E.trim(),capabilities:ue},{onSuccess:()=>i()})},ke=!!(t&&s.some(d=>d.slug===t));return e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-medium",children:ke&&C?`Connect ${C.displayName}`:"Add an inference provider"}),e.jsxs("form",{onSubmit:is,className:"grid max-w-md gap-3",children:[ke&&C?e.jsx("p",{className:"text-xs text-muted-foreground",children:Z.length>0?`Serves text, plus ${Z.join(", ").toLowerCase()}.`:"Serves text (chat)."}):e.jsxs("div",{className:"grid gap-2",children:[e.jsx($,{htmlFor:"ip-provider",children:"Provider"}),e.jsxs(Le,{value:u,onValueChange:rs,children:[e.jsx(Re,{id:"ip-provider",className:"w-full",children:e.jsx(Oe,{})}),e.jsx(Be,{children:s.map(d=>{const S=we(d.modalities);return e.jsx(Ke,{value:d.slug,children:e.jsxs("span",{className:"flex items-center gap-2",children:[d.iconUrl?e.jsx("img",{src:d.iconUrl,alt:"",className:"h-4 w-4 shrink-0 rounded-sm",loading:"lazy"}):e.jsx(ms,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),d.displayName,S.length>0?e.jsxs("span",{className:"text-xs text-muted-foreground",children:["· ",S.join(", ")]}):null]})},d.slug)})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Z.length>0?`Serves text, plus ${Z.join(", ").toLowerCase()}.`:"Serves text (chat)."})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx($,{htmlFor:"ip-display",children:"Name"}),e.jsx(F,{id:"ip-display",placeholder:"Friendly name",value:m,onChange:d=>y(d.target.value)})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs($,{htmlFor:"ip-slug",children:["Slug ",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(F,{id:"ip-slug",placeholder:"my-provider",value:j,onChange:d=>N(d.target.value),autoComplete:"off",required:!0}),j&&!be?e.jsx("p",{className:"text-xs text-destructive",children:"Lowercase letters, numbers, and hyphens only."}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"A stable identifier agents reference this provider by."})]}),je&&ve?e.jsxs("div",{className:"grid gap-2",children:[e.jsx($,{children:"Auth method"}),e.jsxs("div",{className:"inline-flex w-fit rounded-md border border-border p-1",children:[e.jsx(g,{type:"button",size:"sm",variant:I==="oauth"?"secondary":"ghost",onClick:()=>O("oauth"),children:"Sign in"}),e.jsx(g,{type:"button",size:"sm",variant:I==="api-key"?"secondary":"ghost",onClick:()=>O("api-key"),children:"API key"})]})]}):null,Ne?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx($,{htmlFor:"ip-base-url",children:"Base URL"}),e.jsx(F,{id:"ip-base-url",placeholder:"https://api.example.com/v1",value:b,onChange:d=>P(d.target.value),autoComplete:"off"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Override the upstream URL — e.g. a self-hosted vLLM, Azure, or LiteLLM endpoint."})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx($,{htmlFor:"ip-model",children:"Default model"}),e.jsx(F,{id:"ip-model",placeholder:"gpt-4o-mini",value:w,onChange:d=>k(d.target.value),autoComplete:"off"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs($,{htmlFor:"ip-key",children:["API key ",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(F,{id:"ip-key",type:"password",placeholder:z||void 0,value:E,onChange:d=>_(d.target.value),autoComplete:"off",required:!0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Stored encrypted in the vault. It's never shown again — rotate it here if it changes."})]}),e.jsx(G,{onCancel:i,children:e.jsx(g,{type:"submit",disabled:!Ce,children:h.isPending?e.jsxs(e.Fragment,{children:[e.jsx(q,{size:"lg",className:"mr-2"}),"Creating..."]}):"Create provider"})})]}):ye?e.jsxs("div",{className:"grid gap-3",children:[fe?e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Signed in with ",C?.displayName??"provider",". This covers your agents in this org."]}):ns?e.jsxs("div",{className:"grid gap-2",children:[e.jsx(g,{type:"button",variant:"outline",className:"justify-self-start",onClick:()=>void ts(),disabled:T||!L,children:A?"Get a new code":"Get device code"}),A?e.jsxs("div",{className:"grid gap-2",children:[e.jsx($,{htmlFor:"ip-device-code",children:"Device code"}),e.jsx(F,{id:"ip-device-code",readOnly:!0,value:A.userCode}),e.jsx(g,{type:"button",variant:"default",className:"justify-self-start",asChild:!0,children:e.jsxs("a",{href:A.verificationUrl,target:"_blank",rel:"noreferrer",children:["Open ",C?.displayName??"provider"," to approve",e.jsx(Se,{className:"h-4 w-4"})]})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:A.message||"We opened the approval page. Enter the code above if asked, approve, then check status."}),e.jsx(g,{type:"button",variant:"outline",className:"justify-self-start",onClick:()=>void as(),disabled:T,children:T?"Checking...":"Check status"})]}):null]}):e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(g,{type:"button",variant:"outline",className:"justify-self-start",onClick:()=>void es(),disabled:T||!L,children:["Sign in with ",C?.displayName??"provider",e.jsx(Se,{className:"h-4 w-4"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx($,{htmlFor:"ip-oauth-code",children:"Paste code#state"}),e.jsx(F,{id:"ip-oauth-code",placeholder:"code#state",value:v,onChange:d=>f(d.target.value),autoComplete:"off"})]}),e.jsx(g,{type:"button",className:"justify-self-start",onClick:()=>void ss(),disabled:T||!v.trim(),children:T?"Finishing...":"Finish sign-in"})]}),e.jsx(G,{onCancel:i,children:e.jsx(g,{type:"button",onClick:Ze,disabled:!fe,children:"Done"})})]}):e.jsxs("div",{className:"grid gap-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"This provider cannot be added from the catalog yet."}),e.jsx(G,{onCancel:i})]})]})]})}const tt={text:"Text",image:"Image",stt:"Speech-to-text",tts:"Text-to-speech"};function at({provider:s,catalog:t,autoOpenEdit:a}){const n=hs(),[r,i]=p.useState(a?"edit":null),h=xs(s.kind,t);p.useEffect(()=>{a&&i("edit")},[a]);const l=(t.find(c=>c.slug===s.kind)?.modalities??["text"]).filter(c=>c!=="text"),x=h&&l.length>0,u=c=>i(j=>j===c?null:c);return e.jsxs("div",{className:"overflow-hidden rounded-lg border",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3 px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:"Credential"}),e.jsxs("p",{className:"truncate text-[11px] text-muted-foreground",children:[s.slug,s.createdAt?` · created ${ps(s.createdAt)}`:""]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.isDefault?null:e.jsx(g,{variant:"outline",size:"sm",className:"h-8 text-xs",disabled:n.isPending,onClick:()=>n.mutate({providerSlug:s.slug}),children:"Set as default"}),x?e.jsx(g,{variant:"outline",size:"sm",className:"h-8 text-xs",onClick:()=>u("capabilities"),children:"Configure"}):null,e.jsx(g,{variant:"outline",size:"sm",className:"h-8 text-xs",onClick:()=>u("edit"),children:"Edit"})]})]}),r==="edit"?e.jsx("div",{className:"border-t px-3 py-3",children:e.jsx(rt,{provider:s,supportsUpstreamConfig:h,onDone:()=>i(null)})}):null,r==="capabilities"&&x?e.jsx("div",{className:"border-t px-3 py-3",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Other modalities (optional)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This provider's text base URL and model are set under Edit. Only set these if you want a modality routed to a different endpoint — otherwise it uses the provider's defaults."})]}),l.map(c=>e.jsx(it,{providerSlug:s.slug,modality:c,block:s.capabilities[c]??{}},c))]})}):null]})}function nt({provider:s,onDeleted:t}){const a=fs(),[n,r]=p.useState(!1);return e.jsxs("div",{className:"rounded-lg border border-destructive/30 bg-destructive/5 p-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Delete provider"}),e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Removes ",s.displayName||s.slug," and its stored key from this workspace. Agents referencing it will need another connected provider before they can run."]}),e.jsx("div",{className:"mt-3",children:n?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(g,{variant:"destructive",size:"sm",disabled:a.isPending,onClick:()=>a.mutate({providerSlug:s.slug},{onSuccess:t,onSettled:()=>r(!1)}),children:[a.isPending?e.jsx(q,{size:"md",className:"mr-1.5"}):null,"Confirm delete"]}),e.jsx(g,{variant:"ghost",size:"sm",disabled:a.isPending,onClick:()=>r(!1),children:"Cancel"})]}):e.jsxs(g,{variant:"outline",size:"sm",className:"text-destructive hover:text-destructive",disabled:a.isPending,onClick:()=>r(!0),children:[e.jsx(xe,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete provider"]})})]})}function rt({provider:s,supportsUpstreamConfig:t,onDone:a}){const n=gs(),r=js(),i=Ue(),[h,o]=p.useState(s.displayName??""),[l,x]=p.useState(""),u=s.capabilities.text??{},[c,j]=p.useState(u.base_url??""),[N,m]=p.useState(u.model??""),[y,b]=p.useState(null),P=h.trim().length>0&&h.trim()!==(s.displayName??""),w=t&&l.trim().length>0,k=c.trim()!==(u.base_url??""),E=N.trim()!==(u.model??""),_=t&&(k||E),z={base_url:c.trim()||void 0,model:N.trim()||void 0,models_endpoint:u.models_endpoint},R=Ie(z),I=t&&_&&ze(R),O=n.isPending||r.isPending||i.isPending,v=(P||w||_)&&!I&&!O,f=async A=>{if(A.preventDefault(),!!v){b(null);try{await Promise.all([P?n.mutateAsync({providerSlug:s.slug,displayName:h.trim()}):Promise.resolve(),_?i.mutateAsync({providerSlug:s.slug,modality:"text",block:z}):Promise.resolve(),w?r.mutateAsync({providerSlug:s.slug,value:l.trim()}):Promise.resolve()]),a()}catch{b("Some changes could not be saved. Review the fields and try again.")}}};return e.jsxs("form",{onSubmit:f,className:"grid max-w-md gap-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx($,{htmlFor:`edit-name-${s.slug}`,children:"Name"}),e.jsx(F,{id:`edit-name-${s.slug}`,value:h,onChange:A=>o(A.target.value),placeholder:s.slug}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["The slug (",e.jsx("code",{children:s.slug}),") is fixed — agents reference it."]})]}),t?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx($,{htmlFor:`edit-base-${s.slug}`,children:"Base URL"}),e.jsx(F,{id:`edit-base-${s.slug}`,placeholder:"https://api.example.com/v1",value:c,onChange:A=>j(A.target.value),autoComplete:"off"}),R.base_url?e.jsx("p",{className:"text-xs text-destructive",children:R.base_url}):null]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx($,{htmlFor:`edit-model-${s.slug}`,children:"Default model"}),e.jsx(F,{id:`edit-model-${s.slug}`,placeholder:"gpt-4o-mini",value:N,onChange:A=>m(A.target.value),autoComplete:"off"}),R.model?e.jsx("p",{className:"text-xs text-destructive",children:R.model}):null]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx($,{htmlFor:`edit-key-${s.slug}`,children:"New API key"}),e.jsx(F,{id:`edit-key-${s.slug}`,type:"password",value:l,onChange:A=>x(A.target.value),autoComplete:"off",placeholder:"Leave blank to keep the current key"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Enter a value only to replace the stored key. The old key is discarded."})]})]}):null,y?e.jsx("p",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:y}):null,e.jsx(G,{onCancel:a,children:e.jsx(g,{type:"submit",disabled:!v,children:O?e.jsxs(e.Fragment,{children:[e.jsx(q,{size:"lg",className:"mr-2"}),"Saving..."]}):"Save"})})]})}function it({providerSlug:s,modality:t,block:a}){const n=Ue(),[r,i]=p.useState(!1),[h,o]=p.useState(a.base_url??""),[l,x]=p.useState(a.model??""),[u,c]=p.useState(a.models_endpoint??""),[j,N]=p.useState(!!a.models_endpoint),m=!!(a.base_url||a.model||a.models_endpoint),y={base_url:h.trim()||void 0,model:l.trim()||void 0,models_endpoint:u.trim()||void 0},b=Ie(y),P=ze(b),w=()=>{P||n.mutate({providerSlug:s,modality:t,block:y})};return e.jsxs("div",{className:ne,children:[e.jsxs("button",{type:"button",className:"flex w-full items-center justify-between px-3 py-2 text-left",onClick:()=>i(k=>!k),children:[e.jsx("span",{className:"text-sm font-medium",children:tt[t]}),m?e.jsx(U,{variant:"outline",children:"Custom"}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"Static"})]}),r?e.jsxs("div",{className:"grid gap-3 border-t px-3 py-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx($,{htmlFor:`base-${s}-${t}`,children:"Base URL"}),e.jsx(F,{id:`base-${s}-${t}`,placeholder:"https://api.example.com/v1",value:h,onChange:k=>o(k.target.value),autoComplete:"off"}),b.base_url?e.jsx("p",{className:"text-xs text-destructive",children:b.base_url}):null]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx($,{htmlFor:`model-${s}-${t}`,children:"Model"}),e.jsx(F,{id:`model-${s}-${t}`,placeholder:"gpt-4o-mini",value:l,onChange:k=>x(k.target.value),autoComplete:"off"}),b.model?e.jsx("p",{className:"text-xs text-destructive",children:b.model}):null]}),j?e.jsxs("div",{className:"grid gap-2",children:[e.jsx($,{htmlFor:`endpoint-${s}-${t}`,children:"Models endpoint"}),e.jsx(F,{id:`endpoint-${s}-${t}`,placeholder:"/v1/models",value:u,onChange:k=>c(k.target.value),autoComplete:"off"}),b.models_endpoint?e.jsx("p",{className:"text-xs text-destructive",children:b.models_endpoint}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"Path used to list this modality's models (e.g. /v1/models)."})]}):e.jsx("button",{type:"button",className:"justify-self-start text-xs text-muted-foreground hover:text-foreground",onClick:()=>N(!0),children:"Advanced"}),e.jsx(G,{onCancel:()=>i(!1),children:e.jsx(g,{size:"sm",disabled:P||n.isPending,onClick:w,children:n.isPending?e.jsxs(e.Fragment,{children:[e.jsx(q,{size:"lg",className:"mr-2"}),"Saving..."]}):"Save"})})]}):null]})}function lt({sandbox:s}){const t=Object.entries(s.details??{});return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(ct,{kind:s.providerKind}),e.jsx("span",{className:"text-sm font-medium",children:s.name}),e.jsx(U,{variant:"secondary",className:"h-4 px-1.5 py-0 text-[10px] uppercase tracking-wide",children:s.providerKind}),s.connected?e.jsx(U,{className:"h-4 border-transparent bg-emerald-500/10 px-1.5 py-0 text-[10px] uppercase tracking-wide text-emerald-500",children:"Connected"}):e.jsx(U,{variant:"destructive",className:"h-4 border-transparent bg-destructive/10 px-1.5 py-0 text-[10px] uppercase tracking-wide text-destructive",children:"No credential"})]}),t.length>0?e.jsx("p",{className:"font-mono text-[11px] text-muted-foreground",children:t.map(([a,n])=>`${a}: ${n}`).join(" | ")}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Remote sandbox agents execute in instead of the built-in local runtime."}),s.connected?null:e.jsxs("div",{className:"flex gap-2 rounded-md border border-amber-200 bg-amber-50 p-3 text-sm text-amber-950 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-100",children:[e.jsx(de,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsx("p",{children:"This sandbox has no vault credential. Delete it and re-add the provider with a valid key, or set the credential via the API."})]})]})})}function ot({sandbox:s,onDeleted:t}){const a=vs(),[n,r]=p.useState(!1);return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"rounded-lg border border-destructive/30 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(xe,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"Remove sandbox"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Agents pinned to this runtime fall back to the built-in local sandbox."})]})]}),n?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(g,{variant:"destructive",size:"sm",disabled:a.isPending,onClick:()=>a.mutate({id:s.id},{onSuccess:t}),children:a.isPending?e.jsx(q,{}):"Delete permanently"}),e.jsx(g,{variant:"ghost",size:"sm",onClick:()=>r(!1),children:"Cancel"})]}):e.jsx(g,{variant:"outline",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>r(!0),children:"Delete sandbox"})]})})}function ct({kind:s}){return s==="vercel"?e.jsxs("svg",{viewBox:"0 0 24 24",className:"h-4 w-4 shrink-0 fill-foreground","aria-hidden":!0,children:[e.jsx("title",{children:"Vercel"}),e.jsx("path",{d:"M12 3 22 20H2L12 3Z"})]}):s==="builtin"?e.jsx(ys,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):e.jsx(Ns,{className:"h-4 w-4 shrink-0 text-muted-foreground"})}const dt={data:!1,chat:!1,actions:!1,audience:!1,inference:!0,runtime:!1},ut={data:!1,chat:!1,actions:!1,audience:!1,inference:!1,runtime:!0};function Kt(){const{owner:s,connectorKey:t}=H.useParams(),{instances:a}=H.useSearch(),{kind:n,id:r}=Us(t);return e.jsx(Is,{owner:s,children:({ownerSlug:i,organizationId:h,isWorkspaceLoading:o})=>{if(a&&(n==="inference"||n==="sandbox-provider"))return e.jsx(et,{ownerSlug:i,familyKind:n,familyId:r});switch(n){case"inference":return e.jsx(xt,{ownerSlug:i,providerSlug:r});case"sandbox":return e.jsx(ht,{ownerSlug:i,sandboxId:r});case"sandbox-provider":return e.jsx(mt,{ownerSlug:i,providerKind:r});default:return e.jsx(jt,{ownerSlug:i,organizationId:h,isWorkspaceLoading:o,connectorKey:t})}}})}function mt({ownerSlug:s,providerKind:t}){const a=Q();return p.useEffect(()=>{a({to:"/$owner/connectors/create/$connectorKey",params:{owner:s,connectorKey:`${he}${t}`},replace:!0})},[a,s,t]),null}function ht({ownerSlug:s,sandboxId:t}){const a=Q(),{data:n,isLoading:r,isError:i,refetch:h}=Ee(),o=n?.sandboxes.find(x=>x.id===t)??null;if(r)return e.jsxs(M,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{className:"h-6 w-6 rounded"}),e.jsx(D,{className:"h-5 w-40"})]}),e.jsx(D,{className:"h-24 w-full rounded-lg"})]});if(i)return e.jsx(M,{children:e.jsxs("div",{role:"alert",children:[e.jsx("p",{children:"Could not load this instance."}),e.jsx(g,{variant:"outline",onClick:()=>void h(),children:"Retry"})]})});if(!o)return e.jsxs(M,{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"This sandbox isn't in this workspace, so its details aren't available."}),e.jsx(g,{variant:"outline",size:"sm",onClick:()=>void a({to:"/$owner/connectors",params:{owner:s}}),children:"Back to connectors"})]});const l=o.name||me(o.providerKind);return e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsxs(le,{header:e.jsx(oe,{breadcrumb:e.jsx(ce,{crumbs:[e.jsx(K,{to:"/$owner/connectors",params:{owner:s},className:X,children:"Connectors"},"connectors"),e.jsx(K,{to:"/$owner/connectors/$connectorKey",params:{owner:s,connectorKey:`${he}${o.providerKind}`},search:{instances:!0},className:X,children:me(o.providerKind)},"family")]}),icon:e.jsx(pe,{name:l,faviconDomain:Xs(o.providerKind)}),title:l,badge:e.jsxs(e.Fragment,{children:[e.jsx(U,{variant:"secondary",children:o.providerKind}),o.connected?e.jsx(U,{className:"border-transparent bg-emerald-500/10 text-emerald-500",children:"Connected"}):e.jsx(U,{variant:"destructive",children:"No credential"})]}),status:e.jsx(Qe,{facets:ut})}),children:[e.jsx(lt,{sandbox:o}),e.jsx(B,{title:"Settings",muted:!0,children:e.jsx(ot,{sandbox:o,onDeleted:()=>void a({to:"/$owner/connectors",params:{owner:s}})})})]})})}function xt({ownerSlug:s,providerSlug:t}){const a=Q(),{model:n,reason:r,agentId:i,addAccount:h}=H.useSearch(),{data:o=[],isLoading:l,isError:x,refetch:u}=Pe(),c=De(),{data:j=[],isLoading:N}=c,m=h?null:o.find(E=>E.slug===t)??null,y=j.find(E=>E.slug===(m?.kind??t))??null;if(l||N)return e.jsx("div",{children:e.jsxs(M,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{className:"h-6 w-6 rounded"}),e.jsx(D,{className:"h-5 w-40"})]}),e.jsx(D,{className:"h-16 w-full rounded-lg"}),e.jsx(D,{className:"h-24 w-full rounded-lg"}),e.jsx(D,{className:"h-32 w-full rounded-lg"})]})});if(x)return e.jsx(M,{children:e.jsxs("div",{role:"alert",children:[e.jsx("p",{children:"Could not load this account."}),e.jsx(g,{variant:"outline",onClick:()=>void u(),children:"Retry"})]})});if(!m&&!y&&!c.isError)return e.jsxs(M,{className:"space-y-3",children:[e.jsx(Xe,{connector:{key:t,name:t},showDescription:!1,className:"gap-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This connector isn't installed in this workspace, so its details aren't available."})]});const b=m?m.displayName||m.slug:y?.displayName||t,P=m!==null,w=r?e.jsx(gt,{agentId:i,model:n,providerName:b}):n?e.jsx(ft,{providerName:b,model:n,isConnected:P}):null,k=e.jsx(oe,{breadcrumb:e.jsx(ce,{crumbs:[e.jsx(K,{to:"/$owner/connectors",params:{owner:s},className:X,children:"Connectors"},"connectors"),...m?[e.jsx(K,{to:"/$owner/connectors/$connectorKey",params:{owner:s,connectorKey:`${ae}${m.kind}`},search:{instances:!0},className:X,children:y?.displayName??m.kind},"family")]:[]]}),icon:e.jsx(pe,{iconUrl:y?.iconUrl,name:b}),title:b,badge:m?e.jsxs(e.Fragment,{children:[m.isDefault?e.jsx(U,{variant:"secondary",children:"Default"}):null,m.status?e.jsx(U,{variant:"outline",children:m.status}):null,m.hasCustomUpstream?e.jsx(U,{variant:"outline",children:"Custom upstream"}):null]}):null,status:e.jsx(Qe,{facets:dt})});return e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsxs(le,{header:k,children:[w,e.jsx("div",{className:"space-y-6",children:m?e.jsx(at,{provider:m,catalog:j,autoOpenEdit:!!n}):e.jsx(pt,{ownerSlug:s,providerSlug:t,existingSlugs:o.map(E=>E.slug),catalog:j,catalogError:c.isError?c.error:null,model:n})}),m?e.jsx(B,{title:"Settings",muted:!0,children:e.jsx(nt,{provider:m,onDeleted:()=>void a({to:"/$owner/connectors",params:{owner:s}})})}):null]})})}function pt({ownerSlug:s,providerSlug:t,existingSlugs:a,catalog:n,catalogError:r,model:i}){const h=Q(),o=n.find(u=>u.slug===t),l=a.includes(t)&&!!o&&te(o);let x=t;for(let u=2;a.includes(x);u++)x=`${t}-${u}`;return r?e.jsx("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 p-3 text-sm text-destructive",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(de,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Failed to load provider catalog."}),e.jsx("p",{className:"mt-1 text-xs",children:r instanceof Error?r.message:"Check the workspace URL and try again."})]})]})}):e.jsxs("div",{className:"space-y-3 rounded-lg border p-4",children:[l&&e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsx("p",{children:"Subscription sign-in is managed on the existing connection."}),e.jsx(g,{asChild:!0,variant:"outline",size:"sm",children:e.jsx(K,{to:"/$owner/connectors/$connectorKey",params:{owner:s,connectorKey:`${ae}${t}`},search:{},children:"Open existing connection"})})]}),(!l||o&&Fe(o))&&e.jsx(st,{catalog:n,initialProvider:t,initialSlug:x,allowOAuth:!l,initialModel:i?.includes("/")?i.split("/").slice(1).join("/"):i,onDone:()=>void h({to:"/$owner/connectors",params:{owner:s}})},`${n.length}:${t}`)]})}function ft({providerName:s,model:t,isConnected:a}){return e.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 p-3 text-sm text-amber-950 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-100",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(de,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsxs("p",{children:["Review ",e.jsx("strong",{children:s})," for model"," ",e.jsx("strong",{children:t}),"."," ",a?"Its edit controls are open.":"It is not connected yet; add it to continue."]})]})})}function gt({agentId:s,model:t,providerName:a}){return e.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 p-3 text-sm text-amber-950 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-100",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(de,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium",children:"This agent needs a model provider before it can reply."}),e.jsxs("p",{children:[s?e.jsxs("span",{children:["Agent ",e.jsx("strong",{children:s})," is"," "]}):null,"configured to use ",t?e.jsx("strong",{children:t}):"a model"," ","from ",e.jsx("strong",{children:a}),", but that provider is not ready in this workspace."]}),e.jsx("p",{children:"Connect the provider below, then retry the message."})]})]})})}function jt({ownerSlug:s,organizationId:t,isWorkspaceLoading:a,connectorKey:n}){const{data:r=[],isLoading:i,isError:h,refetch:o}=qs(t??""),{data:l=[],isLoading:x,isError:u,refetch:c}=Ws(t??"",{connectorKey:n}),j=p.useMemo(()=>r.find(y=>y.key===n),[r,n]),N=p.useMemo(()=>Ys(n,r,{name:l[0]?.connector_name??n}),[n,r,l]);if(a||i)return e.jsx("div",{children:e.jsxs(M,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{className:"h-6 w-6 rounded"}),e.jsx(D,{className:"h-5 w-40"})]}),e.jsx(D,{className:"h-16 w-full rounded-lg"}),e.jsx(D,{className:"h-24 w-full rounded-lg"}),e.jsx(D,{className:"h-32 w-full rounded-lg"})]})});if(h||u)return e.jsx(M,{children:e.jsxs("div",{role:"alert",className:"space-y-2",children:[e.jsx("p",{children:"Could not load this connector."}),e.jsx(g,{variant:"outline",onClick:()=>{o(),c()},children:"Retry"})]})});const m=j?e.jsx(yt,{connector:j,ownerSlug:s}):e.jsxs("div",{className:"space-y-3",children:[e.jsx(Xe,{connector:N,showDescription:!1,className:"gap-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["This connector isn't installed in this workspace, so its details aren't available.",l.length>0?" Existing connections keep working.":""]})]});return e.jsx("div",{className:"flex flex-1 flex-col",children:j&&t?e.jsx(vt,{hero:m,connector:j,organizationId:t,ownerSlug:s,connectorKey:n,connections:l,isLoading:x,refetchConnections:c}):e.jsxs(M,{className:"space-y-6",children:[m,l.length>0&&!x?e.jsx(Ge,{section:!0,connections:l,ownerSlug:s,connectorKey:n}):e.jsx(He,{organizationId:t??"",ownerSlug:s,connectorKey:n,connections:l,isLoading:x})]})})}function vt({hero:s,connector:t,organizationId:a,ownerSlug:n,connectorKey:r,connections:i,isLoading:h,refetchConnections:o}){const{isAdmin:l,isLoading:x}=J(a),u=(t.operations_summary?.total??0)>0;return e.jsxs(le,{header:s,children:[e.jsx(bs,{organizationId:a,connectorKey:r}),e.jsx(At,{connector:t,organizationId:a,ownerSlug:n,connectorKey:r,connections:i,isLoading:h,refetchConnections:o}),i.length>0?e.jsx(Ge,{section:!0,connections:i,connector:t,ownerSlug:n,connectorKey:r}):null,e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:auto-cols-fr sm:grid-flow-col",children:[e.jsx(St,{connector:t,organizationId:a,ownerSlug:n}),u&&x?e.jsx(D,{className:"h-20 w-full rounded-lg"}):u&&l?e.jsx(Ct,{connector:t,organizationId:a,ownerSlug:n}):u&&!l?e.jsx(B,{title:"Actions",muted:!0,children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Only workspace admins can view and configure connector actions."})}):null]}),e.jsx(Nt,{connector:t,organizationId:a,ownerSlug:n,connectionCount:i.length}),!h&&i.length>0?e.jsx(B,{title:"Recent activity",children:e.jsx(Zs,{scope:{connectorKey:r},ownerSlug:n})}):null]})}function yt({connector:s,ownerSlug:t}){return e.jsx(oe,{breadcrumb:e.jsx(ce,{crumbs:[e.jsx(K,{to:"/$owner/connectors",params:{owner:t},className:X,children:"Connectors"},"connectors")]}),icon:e.jsx(pe,{icon:s.icon,name:s.name,faviconDomain:s.favicon_domain??Gs(s.auth_schema),className:"h-10 w-10"}),title:s.name,badge:e.jsx(Js,{connectorDef:s,ownerSlug:t}),caption:s.description})}function Nt({connector:s,organizationId:t,ownerSlug:a,connectionCount:n}){const r=Te(s.auth_schema),i=zs(s.auth_schema),h=r.find(w=>w.type==="oauth"),o=We(s.auth_schema),l=r.some(w=>w.type==="env_keys"),x=r.some(w=>w.type==="browser"),u=i.some(w=>w.type==="interactive"),c=!!(h||o||l||x),j=Ms(s),{isAdmin:N}=J(t),{data:m=[]}=ie(t,{connectorKey:s.key,profileKind:"env"}),{data:y=[]}=ie(t,{profileKind:"browser_session",connectorKey:s.key}),b=N&&s.installed!==!1;return!!(h||o)||l&&m.length>0||x&&y.length>0||!c||b?e.jsxs("div",{className:"space-y-6",children:[h?e.jsx(kt,{connector:s,organizationId:t,oauthMethod:h}):null,o?e.jsx(B,{title:"App installation",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Install the ",s.name," app to create or repair the workspace connection."]}),e.jsx(Ye,{organizationId:t,connectorKey:s.key,provider:o.provider,providerLabel:s.name,installShape:o.installShape,variant:"outline"})]})}):null,l&&m.length>0?e.jsx($e,{profiles:m,type:"env"}):null,x&&y.length>0?e.jsx($e,{profiles:y,type:"browser_session"}):null,c?null:j?e.jsx(B,{title:"Device runtime",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[s.name," runs on a linked device — there are no workspace credentials to configure here. Pair a device, then create a connection pinned to it."]}),e.jsx(g,{asChild:!0,variant:"outline",size:"sm",children:e.jsx(K,{to:"/$owner/connectors",params:{owner:a},search:{},children:"View devices"})})]})}):u?e.jsx(B,{title:"Authentication",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[s.name," pairs when you create a connection — there is no workspace-level credential to configure here."]})}):e.jsx(B,{title:"Authentication",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"This connector doesn't need workspace credentials. Create a connection above to get started."})}),e.jsx(bt,{connector:s,organizationId:t,ownerSlug:a,connectionCount:n})]}):null}function bt({connector:s,organizationId:t,ownerSlug:a,connectionCount:n}){const r=Q(),{isAdmin:i}=J(t),h=Qs(),[o,l]=p.useState(!1),[x,u]=p.useState(null),c=s.installed!==!1;if(!i||!c)return null;const j=n>0,N=h.isPending,m=()=>{u(null),h.mutate({connector_key:s.key},{onSuccess:()=>{r({to:"/$owner/connectors",params:{owner:a}})},onError:y=>{u(y instanceof Error?y.message:"Failed to remove connector"),l(!1)}})};return e.jsxs("div",{className:"rounded-lg border border-destructive/30 bg-destructive/5 p-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Remove connector"}),e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Archives ",s.name," in this workspace. Existing synced data stays in memory."]}),j?e.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:["Delete"," ",e.jsxs("span",{className:"font-medium text-foreground",children:[n," connection",n===1?"":"s"]})," ","first — uninstall is blocked while any connection still references this connector."]}):null,x?e.jsx("p",{className:"mt-2 rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:x}):null,e.jsx("div",{className:"mt-3",children:o?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(g,{variant:"destructive",size:"sm",disabled:N,onClick:m,children:[N?e.jsx(q,{size:"md",className:"mr-1.5"}):null,"Confirm remove"]}),e.jsx(g,{variant:"ghost",size:"sm",disabled:N,onClick:()=>l(!1),children:"Cancel"})]}):e.jsxs(g,{variant:"outline",size:"sm",className:"text-destructive hover:text-destructive",disabled:N||j,onClick:()=>l(!0),children:[e.jsx(xe,{className:"mr-1.5 h-3.5 w-3.5"}),"Remove connector"]})})]})}function Ct({connector:s,organizationId:t,ownerSlug:a}){const n=Ve();return e.jsx(qe,{title:"Actions",summary:`${s.operations_summary?.total??0} actions · organization policies`,onOpen:()=>n?.open({href:"",title:"Actions",connectorPanel:{section:"actions",connectorKey:s.key,organizationId:t,ownerSlug:a}})})}function kt({connector:s,organizationId:t,oauthMethod:a}){const{isAdmin:n,isLoading:r}=J(t),{setup:i}=H.useSearch(),h=H.useNavigate(),{data:o=[],refetch:l,isLoading:x,isError:u}=ie(t,{connectorKey:s.key,provider:a.provider}),c=o.filter(j=>j.profile_kind==="oauth_app");return r||x?e.jsx(D,{className:"h-28 w-full"}):u?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:"Could not load OAuth apps. Reload the page to try again."}):e.jsx(wt,{connector:s,oauthMethod:a,appProfiles:c,isAdmin:n,initialOpen:i==="oauth_app",onClose:()=>{i==="oauth_app"&&h({search:j=>({...j,setup:void 0}),hash:"",replace:!0})},refetchProfiles:l})}function wt({initialOpen:s=!1,onClose:t,connector:a,oauthMethod:n,appProfiles:r,isAdmin:i,refetchProfiles:h}){const o=Ps(),l=Ds(),[x,u]=se(a.key,s&&i),[c,j]=p.useState(!1);p.useEffect(()=>{s&&i&&u(!0)},[s,i,u]);const N=`${Es()}/connect/oauth/callback`,[m,y]=se(a.key,`${a.name} OAuth App`),[b,P]=se(a.key,""),[w,k]=se(a.key,null),E=Fs(n),_=Ls(`${a.key}:${x}`,Rs(E),E),{values:z,setValues:R}=_,I=r.find(v=>v.is_default_for_connector&&v.connector_key===a.key),O=()=>{_.canSubmit&&(k(null),o.mutate({connector_key:a.key,profile_kind:"oauth_app",display_name:m.trim()||`${a.name} OAuth App`,slug:b.trim()||void 0,credentials:Pt(Vs(z))},{onSuccess:v=>{const f=v.auth_profile?.slug;f&&!I&&l.mutate({connector_key:a.key,auth_profile_slug:f}),u(!1),t?.(),y(`${a.name} OAuth App`),P(""),h()},onError:v=>{k(v instanceof Error?v.message:"Failed to add OAuth app")}}))};return e.jsxs(B,{id:"connector-oauth-apps",title:`${$t(n.provider)} app configuration`,action:i&&!x?e.jsxs(g,{variant:"outline",size:"sm",onClick:()=>u(!0),children:[e.jsx(Me,{className:"size-3.5"}),"Add OAuth app"]}):null,children:[i&&e.jsxs("div",{className:"space-y-2",children:[e.jsx($,{children:"OAuth callback URL"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"min-w-0 flex-1 break-all text-xs",children:N}),e.jsxs(g,{variant:"outline",size:"sm",onClick:()=>{navigator.clipboard.writeText(N).then(()=>j(!0)).catch(()=>k("Could not copy the callback URL. Select and copy it above."))},children:[e.jsx(Os,{className:"mr-1.5 h-3.5 w-3.5"}),c?"Copied":"Copy callback URL"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Register this exact URL in your provider’s app settings before saving the client configuration."})]}),r.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No app configured on this server. Choose a managed option if available, or add your own app here."}):e.jsx("div",{className:"space-y-2",children:r.map(v=>e.jsxs("div",{className:re(ne,"flex flex-wrap items-center gap-3 p-3"),children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:v.display_name}),v.is_default_for_connector&&v.connector_key===a.key?e.jsx(U,{variant:"secondary",className:"text-[10px]",children:"Default"}):null,e.jsx(Je,{status:v.status})]}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",children:v.slug})]}),i&&!v.is_default_for_connector&&v.connector_key===a.key&&v.status==="active"?e.jsx(g,{variant:"outline",size:"sm",disabled:l.isPending,onClick:()=>l.mutate({connector_key:a.key,auth_profile_slug:v.slug}),children:"Set default"}):null]},v.slug))}),i&&x?e.jsxs("div",{className:re(ne,"space-y-3 p-3"),children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx($,{htmlFor:"oauth-app-name",children:"Display name"}),e.jsx(F,{id:"oauth-app-name",value:m,onChange:v=>y(v.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx($,{htmlFor:"oauth-app-slug",children:"Slug"}),e.jsx(F,{id:"oauth-app-slug",placeholder:"optional",value:b,onChange:v=>P(v.target.value)})]}),e.jsx(Bs,{schema:_.revision??void 0,values:z,onValuesChange:R,fieldIdPrefix:"oauth-app-"}),e.jsx(Ks,{visible:_.hasConflict,onReload:_.reset}),w?e.jsx("p",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:w}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(g,{variant:"outline",size:"sm",disabled:o.isPending,onClick:()=>{u(!1),t?.()},children:"Cancel"}),e.jsxs(g,{size:"sm",disabled:o.isPending||!_.canSubmit,onClick:O,children:[o.isPending?e.jsx(q,{size:"md",className:"mr-1.5"}):null,"Save OAuth app"]})]})]}):null]})}function At({connector:s,organizationId:t,ownerSlug:a,connectorKey:n,connections:r,isLoading:i,refetchConnections:h}){const l=Te(s.auth_schema).find(N=>N.type==="oauth"),{data:x=[],refetch:u,isLoading:c,isError:j}=ie(t,{connectorKey:s.key,provider:l?.provider});if(l){if(j)return e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:"Could not load accounts. Reload the page to try again."});const N=x.filter(y=>y.profile_kind==="oauth_app"),m=x.filter(y=>y.profile_kind==="oauth_account");return e.jsx(_t,{connector:s,organizationId:t,oauthMethod:l,appProfiles:N,accounts:m,connections:r,isLoading:i||c,refetchProfiles:u,refetchConnections:h})}return e.jsx(He,{connector:s,organizationId:t,ownerSlug:a,connectorKey:n,connections:r,isLoading:i})}function _t({connector:s,organizationId:t,oauthMethod:a,appProfiles:n,accounts:r,connections:i,isLoading:h,refetchProfiles:o,refetchConnections:l}){const{session:x}=Cs(),{isAdmin:u,isLoading:c}=J(t),j=ks(),N=ws(),m=As(),[y,b]=p.useState(""),[P,w]=p.useState([]),k=n.filter(f=>f.status==="active"),E=k.find(f=>f.is_default_for_connector&&f.connector_key===s.key),_=(u?k.find(f=>f.slug===y):void 0)??E??(u&&k.length===1?k[0]:void 0),z=new Set(i.map(f=>f.auth_profile_slug)),R=r.filter(f=>f.created_by===x?.user?.id),I=R.filter(f=>!z.has(f.slug)),O=!i.some(f=>f.created_by===x?.user?.id)&&R.length===0;if(h||c||!x?.user?.id||!O&&I.length===0&&!m.error&&!m.continueUrl)return null;const v=f=>m.begin(async()=>{const A=await j.mutateAsync({connector_key:s.key,app_auth_profile_slug:f,requested_scopes:Ts(a,P)});return o(),l(),A});return e.jsxs(B,{title:O?"Connect your account":"Your accounts",children:[O&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Connect your own account to grant access. Your connection is private to you."}),u&&k.length>1?e.jsxs("div",{className:"space-y-1",children:[e.jsx($,{children:"App used for this account"}),e.jsxs(Le,{value:_?.slug??"",onValueChange:b,children:[e.jsx(Re,{"aria-label":"App used for this account",children:e.jsx(Oe,{placeholder:"Choose an OAuth app"})}),e.jsx(Be,{children:k.map(f=>e.jsxs(Ke,{value:f.slug,children:[f.display_name,f.is_default_for_connector&&f.connector_key===s.key?" (workspace default)":""]},f.slug))})]})]}):_?e.jsxs("p",{className:"text-sm",children:["App: ",_.display_name,_.is_default_for_connector&&_.connector_key===s.key?" (workspace default)":""]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:u?"Configure an OAuth app below, then connect your account.":"Ask an administrator to configure and set the workspace-default OAuth app."}),_&&e.jsx(_s,{requiredScopes:$s(a),optionalScopes:Ss(a),selectedOptionalScopes:P,onToggleOptionalScope:(f,A)=>w(W=>A?[...new Set([...W,f])]:W.filter(T=>T!==f))}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(g,{size:"sm",disabled:!_||m.pending,onClick:()=>{_&&v(_.slug)},children:"Connect account"}),u&&e.jsx(g,{asChild:!0,size:"sm",variant:"outline",children:e.jsx("a",{href:"#connector-oauth-apps",children:"Manage app"})})]})]}),I.map(f=>e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 py-2",children:[e.jsx("span",{className:"text-sm",children:f.display_name}),e.jsx(g,{variant:"outline",size:"sm",disabled:m.pending,onClick:()=>void m.begin(()=>f.status==="active"?j.mutateAsync({connector_key:s.key,auth_profile_slug:f.slug}):N.mutateAsync({auth_profile_slug:f.slug})),children:f.status==="active"?"Use this account":"Reconnect"})]},f.slug)),m.error&&e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:m.error}),m.continueUrl&&e.jsx("a",{href:m.continueUrl,target:"_blank",rel:"noreferrer",className:"text-sm underline",children:"Continue authorization in your browser"})]})}function $e({profiles:s,type:t}){const a=t==="env"?"Credentials":"Browser sessions";return e.jsx(B,{title:a,children:e.jsx("div",{className:"space-y-2",children:s.map(n=>e.jsxs("div",{className:re(ne,"p-3"),children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium",children:n.display_name}),e.jsx(Je,{status:n.status})]}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",children:n.slug})]},n.slug))})})}function St({connector:s,organizationId:t,ownerSlug:a}){const n=Ve(),r=Object.keys(s.feeds_schema??{}).length;return r?e.jsx(qe,{title:"Feeds",summary:`${r} ${r===1?"feed type":"feed types"}`,onOpen:()=>n?.open({href:"",title:"Feeds",connectorPanel:{section:"feeds",connectorKey:s.key,organizationId:t,ownerSlug:a}})}):null}function He({connector:s,organizationId:t,ownerSlug:a,connectorKey:n,connections:r,isLoading:i}){const h=Q(),o=We(s?.auth_schema);if(i)return e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{className:"h-4 w-24"}),e.jsx(D,{className:"h-16 w-full rounded-lg"})]});if(r.length===0){const l=s&&o?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Ye,{organizationId:t,connectorKey:n,provider:o.provider,providerLabel:s.name,installShape:o.installShape,size:"default",label:`Install ${s.name}`}),e.jsx(g,{asChild:!0,variant:"outline",children:e.jsx(K,{to:"/$owner/connectors/create/$connectorKey",params:{owner:a,connectorKey:n},children:"Use your own app"})})]}):e.jsxs(g,{size:"default",onClick:()=>h({to:"/$owner/connectors/create/$connectorKey",params:{owner:a,connectorKey:n}}),children:[e.jsx(Me,{className:"mr-1.5 h-4 w-4"}),"Create connection"]});return e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:l})}return null}function Je({status:s}){const t=s==="active"?"text-green-500":s==="error"||s==="revoked"?"text-destructive":"text-amber-500";return e.jsxs("span",{className:re("text-xs",t),children:["· ",s]})}function $t(s){return s.charAt(0).toUpperCase()+s.slice(1)}function Pt(s){const t={};for(const[a,n]of Object.entries(s))typeof n=="string"&&n.trim()?t[a]=n.trim():(typeof n=="number"||typeof n=="boolean")&&(t[a]=String(n));return t}export{vt as ConnectorDetailShell,_t as OAuthAccountsSection,wt as OAuthAppProfilesSection,Kt as component};
|
|
2
|
-
//# sourceMappingURL=_connectorKey.index-
|
|
1
|
+
import{ax as Pe,ay as De,az as Ee,aH as me,aE as ae,hr as ls,hs as os,j as e,ht as le,B as g,L as K,aG as he,g9 as oe,ga as ce,gb as X,hu as cs,$ as ds,hv as te,r as p,hw as we,hx as Fe,cx as us,hy as Ae,bJ as Y,hz as _e,z as $,bp as Le,bq as Re,br as Oe,bs as Be,bt as Ke,hk as ms,I as F,bA as G,a2 as q,A as Se,hA as hs,hB as xs,bd as ps,hC as fs,a$ as xe,hD as gs,hE as js,hF as Ue,hG as Ie,hH as ze,af as ne,P as U,b8 as de,hI as vs,ft as ys,hJ as Ns,e_ as J,hK as bs,S as D,hL as B,i as Cs,hM as ks,hN as ws,hO as As,hP as _s,hQ as Ss,hR as $s,hS as Ps,hT as Ds,bR as se,hU as Es,hV as Fs,bQ as Ls,ec as Rs,g$ as Os,Q as re,ed as Bs,bU as Ks,cT as Me,hW as H,hX as Us,ai as Is,hY as Te,aw as ie,u as Ve,hZ as qe,aK as zs,h_ as We,h$ as Ms,i0 as Ye,i1 as Ts,ee as Vs,av as qs,d7 as Ws,aS as Ys,aC as M,i2 as Xe,o as Q,aX as Qe,aW as pe,aT as Xs,i3 as Qs,i4 as Gs}from"./index-9YuSRymd.js";import{C as Hs,a as Ge}from"./connections-browser-CrtnAs0Q.js";import{C as Js}from"./connector-provenance-D-ECOlMJ.js";import{R as Zs}from"./runs-panel-C0_DNTcq.js";import"./connection-label-BobuYiAG.js";import"./filter-editors-Bwhqj7lY.js";import"./runs-table-B1APZv7d.js";function et({ownerSlug:s,familyKind:t,familyId:a}){const n=t==="inference",r=Pe({enabled:n}),i=De({enabled:n}),h=Ee({enabled:!n}),o=n?r:h,l=n?i.data?.find(c=>c.slug===a)?.displayName??a:me(a),x=(n?(r.data??[]).filter(c=>c.kind===a).map(c=>({key:`${ae}${c.slug}`,name:c.displayName||c.slug,status:[c.isDefault?"Default":null,c.status].filter(Boolean).join(" · ")})):(h.data?.sandboxes??[]).filter(c=>c.providerKind===a).map(c=>({key:`${ls}${c.id}`,name:c.name,status:c.connected?"Connected":"Needs credentials"}))).map(c=>({id:c.key,name:c.name,description:c.status,tone:null,link:os({to:"/$owner/connectors/$connectorKey",params:{owner:s,connectorKey:c.key},search:{}})})),u=`${n?ae:he}${a}`;return e.jsx(le,{header:e.jsx(oe,{title:l,breadcrumb:e.jsx(ce,{crumbs:[e.jsx(K,{to:"/$owner/connectors",params:{owner:s},className:X,children:"Connectors"},"connectors")]})}),children:e.jsx(Hs,{entries:x,isLoading:o.isLoading,isError:o.isError,onRetry:()=>void o.refetch(),action:e.jsx(g,{asChild:!0,variant:"outline",size:"sm",children:n?e.jsx(K,{to:"/$owner/connectors/$connectorKey",params:{owner:s,connectorKey:u},search:{addAccount:!0},children:"Add connection"}):e.jsx(K,{to:"/$owner/connectors/create/$connectorKey",params:{owner:s,connectorKey:u},children:"Add connection"})})})})}function st({catalog:s,initialProvider:t,initialSlug:a,allowOAuth:n=!0,initialModel:r,onDone:i}){const h=cs(),o=ds(),l=s.find(d=>d.slug===t)??s[0],x=n&&l&&te(l)?"oauth":"api-key",[u,c]=p.useState(l?.slug??""),[j,N]=p.useState(a??l?.slug??""),[m,y]=p.useState(l?.displayName??""),[b,P]=p.useState(l?.baseUrl??""),[w,k]=p.useState(r??l?.defaultModel??""),[E,_]=p.useState(""),[z,R]=p.useState(l?.apiKeyPlaceholder??""),[I,O]=p.useState(x),[v,f]=p.useState(""),[A,W]=p.useState(null),[T,V]=p.useState(!1),[fe,ge]=p.useState(!1),C=s.find(d=>d.slug===u),Z=we(C?.modalities??[]),je=n&&!!C&&te(C),ve=C?Fe(C):!1,ye=je&&I==="oauth",Ne=ve&&!ye,L=us().slug,ee=p.useCallback(()=>{ge(!0),o.invalidateQueries({queryKey:["inference-providers"]})},[o]),Ze=p.useCallback(()=>{o.invalidateQueries({queryKey:["inference-providers"]}),i()},[o,i]),es=p.useCallback(async()=>{if(!(!L||!C)){V(!0);try{const d=await Ae(L,C.slug);if(d.mode!=="redirect")throw new Error("Unexpected sign-in mode");window.open(d.authorizeUrl,"_blank","noreferrer")}catch(d){Y.error(d instanceof Error?d.message:"Failed to start sign-in")}finally{V(!1)}}},[L,C]),ss=p.useCallback(async()=>{if(!(!L||!C||!v.trim())){V(!0);try{const d=await _e(L,C.slug,{code:v.trim()});if(d.status!=="success")throw new Error(d.error||"Sign-in not complete");ee(),Y.success(`Signed in with ${C.displayName}`)}catch(d){Y.error(d instanceof Error?d.message:"Failed to complete sign-in")}finally{V(!1)}}},[L,C,v,ee]),ts=p.useCallback(async()=>{if(!(!L||!C)){V(!0);try{const d=await Ae(L,C.slug);if(d.mode!=="device")throw new Error("Unexpected sign-in mode");W({userCode:d.userCode,deviceAuthId:d.deviceAuthId,verificationUrl:d.verificationUrl}),window.open(d.verificationUrl,"_blank","noreferrer")}catch(d){Y.error(d instanceof Error?d.message:"Failed to start sign-in")}finally{V(!1)}}},[L,C]),as=p.useCallback(async()=>{if(!(!L||!C||!A)){V(!0);try{const d=await _e(L,C.slug,{deviceAuthId:A.deviceAuthId,userCode:A.userCode});if(d.status==="success"){ee(),Y.success(`Signed in with ${C.displayName}`);return}W(S=>S&&{...S,message:d.error||"Waiting for approval..."})}catch(d){Y.error(d instanceof Error?d.message:"Failed to check status")}finally{V(!1)}}},[L,C,A,ee]),ns=C?.supportedAuthTypes.includes("device-code")??!1,rs=d=>{c(d);const S=s.find(ue=>ue.slug===d);S&&(N(S.slug),y(S.displayName),P(S.baseUrl),k(S.slug===t&&r?r:S.defaultModel??""),R(S.apiKeyPlaceholder),O(n&&te(S)?"oauth":"api-key"),f(""),W(null),ge(!1))},be=/^[a-z0-9][a-z0-9-]*$/.test(j),Ce=be&&Ne&&E.trim().length>0&&!h.isPending,is=d=>{if(d.preventDefault(),!Ce)return;const S={};b.trim()&&(S.base_url=b.trim()),w.trim()&&(S.model=w.trim());const ue=Object.keys(S).length>0?{text:S}:void 0;h.mutate({slug:j.trim(),kind:u,displayName:m.trim()||void 0,apiKey:E.trim(),capabilities:ue},{onSuccess:()=>i()})},ke=!!(t&&s.some(d=>d.slug===t));return e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-medium",children:ke&&C?`Connect ${C.displayName}`:"Add an inference provider"}),e.jsxs("form",{onSubmit:is,className:"grid max-w-md gap-3",children:[ke&&C?e.jsx("p",{className:"text-xs text-muted-foreground",children:Z.length>0?`Serves text, plus ${Z.join(", ").toLowerCase()}.`:"Serves text (chat)."}):e.jsxs("div",{className:"grid gap-2",children:[e.jsx($,{htmlFor:"ip-provider",children:"Provider"}),e.jsxs(Le,{value:u,onValueChange:rs,children:[e.jsx(Re,{id:"ip-provider",className:"w-full",children:e.jsx(Oe,{})}),e.jsx(Be,{children:s.map(d=>{const S=we(d.modalities);return e.jsx(Ke,{value:d.slug,children:e.jsxs("span",{className:"flex items-center gap-2",children:[d.iconUrl?e.jsx("img",{src:d.iconUrl,alt:"",className:"h-4 w-4 shrink-0 rounded-sm",loading:"lazy"}):e.jsx(ms,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),d.displayName,S.length>0?e.jsxs("span",{className:"text-xs text-muted-foreground",children:["· ",S.join(", ")]}):null]})},d.slug)})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Z.length>0?`Serves text, plus ${Z.join(", ").toLowerCase()}.`:"Serves text (chat)."})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx($,{htmlFor:"ip-display",children:"Name"}),e.jsx(F,{id:"ip-display",placeholder:"Friendly name",value:m,onChange:d=>y(d.target.value)})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs($,{htmlFor:"ip-slug",children:["Slug ",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(F,{id:"ip-slug",placeholder:"my-provider",value:j,onChange:d=>N(d.target.value),autoComplete:"off",required:!0}),j&&!be?e.jsx("p",{className:"text-xs text-destructive",children:"Lowercase letters, numbers, and hyphens only."}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"A stable identifier agents reference this provider by."})]}),je&&ve?e.jsxs("div",{className:"grid gap-2",children:[e.jsx($,{children:"Auth method"}),e.jsxs("div",{className:"inline-flex w-fit rounded-md border border-border p-1",children:[e.jsx(g,{type:"button",size:"sm",variant:I==="oauth"?"secondary":"ghost",onClick:()=>O("oauth"),children:"Sign in"}),e.jsx(g,{type:"button",size:"sm",variant:I==="api-key"?"secondary":"ghost",onClick:()=>O("api-key"),children:"API key"})]})]}):null,Ne?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx($,{htmlFor:"ip-base-url",children:"Base URL"}),e.jsx(F,{id:"ip-base-url",placeholder:"https://api.example.com/v1",value:b,onChange:d=>P(d.target.value),autoComplete:"off"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Override the upstream URL — e.g. a self-hosted vLLM, Azure, or LiteLLM endpoint."})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx($,{htmlFor:"ip-model",children:"Default model"}),e.jsx(F,{id:"ip-model",placeholder:"gpt-4o-mini",value:w,onChange:d=>k(d.target.value),autoComplete:"off"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs($,{htmlFor:"ip-key",children:["API key ",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(F,{id:"ip-key",type:"password",placeholder:z||void 0,value:E,onChange:d=>_(d.target.value),autoComplete:"off",required:!0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Stored encrypted in the vault. It's never shown again — rotate it here if it changes."})]}),e.jsx(G,{onCancel:i,children:e.jsx(g,{type:"submit",disabled:!Ce,children:h.isPending?e.jsxs(e.Fragment,{children:[e.jsx(q,{size:"lg",className:"mr-2"}),"Creating..."]}):"Create provider"})})]}):ye?e.jsxs("div",{className:"grid gap-3",children:[fe?e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Signed in with ",C?.displayName??"provider",". This covers your agents in this org."]}):ns?e.jsxs("div",{className:"grid gap-2",children:[e.jsx(g,{type:"button",variant:"outline",className:"justify-self-start",onClick:()=>void ts(),disabled:T||!L,children:A?"Get a new code":"Get device code"}),A?e.jsxs("div",{className:"grid gap-2",children:[e.jsx($,{htmlFor:"ip-device-code",children:"Device code"}),e.jsx(F,{id:"ip-device-code",readOnly:!0,value:A.userCode}),e.jsx(g,{type:"button",variant:"default",className:"justify-self-start",asChild:!0,children:e.jsxs("a",{href:A.verificationUrl,target:"_blank",rel:"noreferrer",children:["Open ",C?.displayName??"provider"," to approve",e.jsx(Se,{className:"h-4 w-4"})]})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:A.message||"We opened the approval page. Enter the code above if asked, approve, then check status."}),e.jsx(g,{type:"button",variant:"outline",className:"justify-self-start",onClick:()=>void as(),disabled:T,children:T?"Checking...":"Check status"})]}):null]}):e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(g,{type:"button",variant:"outline",className:"justify-self-start",onClick:()=>void es(),disabled:T||!L,children:["Sign in with ",C?.displayName??"provider",e.jsx(Se,{className:"h-4 w-4"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx($,{htmlFor:"ip-oauth-code",children:"Paste code#state"}),e.jsx(F,{id:"ip-oauth-code",placeholder:"code#state",value:v,onChange:d=>f(d.target.value),autoComplete:"off"})]}),e.jsx(g,{type:"button",className:"justify-self-start",onClick:()=>void ss(),disabled:T||!v.trim(),children:T?"Finishing...":"Finish sign-in"})]}),e.jsx(G,{onCancel:i,children:e.jsx(g,{type:"button",onClick:Ze,disabled:!fe,children:"Done"})})]}):e.jsxs("div",{className:"grid gap-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"This provider cannot be added from the catalog yet."}),e.jsx(G,{onCancel:i})]})]})]})}const tt={text:"Text",image:"Image",stt:"Speech-to-text",tts:"Text-to-speech"};function at({provider:s,catalog:t,autoOpenEdit:a}){const n=hs(),[r,i]=p.useState(a?"edit":null),h=xs(s.kind,t);p.useEffect(()=>{a&&i("edit")},[a]);const l=(t.find(c=>c.slug===s.kind)?.modalities??["text"]).filter(c=>c!=="text"),x=h&&l.length>0,u=c=>i(j=>j===c?null:c);return e.jsxs("div",{className:"overflow-hidden rounded-lg border",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3 px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:"Credential"}),e.jsxs("p",{className:"truncate text-[11px] text-muted-foreground",children:[s.slug,s.createdAt?` · created ${ps(s.createdAt)}`:""]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.isDefault?null:e.jsx(g,{variant:"outline",size:"sm",className:"h-8 text-xs",disabled:n.isPending,onClick:()=>n.mutate({providerSlug:s.slug}),children:"Set as default"}),x?e.jsx(g,{variant:"outline",size:"sm",className:"h-8 text-xs",onClick:()=>u("capabilities"),children:"Configure"}):null,e.jsx(g,{variant:"outline",size:"sm",className:"h-8 text-xs",onClick:()=>u("edit"),children:"Edit"})]})]}),r==="edit"?e.jsx("div",{className:"border-t px-3 py-3",children:e.jsx(rt,{provider:s,supportsUpstreamConfig:h,onDone:()=>i(null)})}):null,r==="capabilities"&&x?e.jsx("div",{className:"border-t px-3 py-3",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Other modalities (optional)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This provider's text base URL and model are set under Edit. Only set these if you want a modality routed to a different endpoint — otherwise it uses the provider's defaults."})]}),l.map(c=>e.jsx(it,{providerSlug:s.slug,modality:c,block:s.capabilities[c]??{}},c))]})}):null]})}function nt({provider:s,onDeleted:t}){const a=fs(),[n,r]=p.useState(!1);return e.jsxs("div",{className:"rounded-lg border border-destructive/30 bg-destructive/5 p-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Delete provider"}),e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Removes ",s.displayName||s.slug," and its stored key from this workspace. Agents referencing it will need another connected provider before they can run."]}),e.jsx("div",{className:"mt-3",children:n?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(g,{variant:"destructive",size:"sm",disabled:a.isPending,onClick:()=>a.mutate({providerSlug:s.slug},{onSuccess:t,onSettled:()=>r(!1)}),children:[a.isPending?e.jsx(q,{size:"md",className:"mr-1.5"}):null,"Confirm delete"]}),e.jsx(g,{variant:"ghost",size:"sm",disabled:a.isPending,onClick:()=>r(!1),children:"Cancel"})]}):e.jsxs(g,{variant:"outline",size:"sm",className:"text-destructive hover:text-destructive",disabled:a.isPending,onClick:()=>r(!0),children:[e.jsx(xe,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete provider"]})})]})}function rt({provider:s,supportsUpstreamConfig:t,onDone:a}){const n=gs(),r=js(),i=Ue(),[h,o]=p.useState(s.displayName??""),[l,x]=p.useState(""),u=s.capabilities.text??{},[c,j]=p.useState(u.base_url??""),[N,m]=p.useState(u.model??""),[y,b]=p.useState(null),P=h.trim().length>0&&h.trim()!==(s.displayName??""),w=t&&l.trim().length>0,k=c.trim()!==(u.base_url??""),E=N.trim()!==(u.model??""),_=t&&(k||E),z={base_url:c.trim()||void 0,model:N.trim()||void 0,models_endpoint:u.models_endpoint},R=Ie(z),I=t&&_&&ze(R),O=n.isPending||r.isPending||i.isPending,v=(P||w||_)&&!I&&!O,f=async A=>{if(A.preventDefault(),!!v){b(null);try{await Promise.all([P?n.mutateAsync({providerSlug:s.slug,displayName:h.trim()}):Promise.resolve(),_?i.mutateAsync({providerSlug:s.slug,modality:"text",block:z}):Promise.resolve(),w?r.mutateAsync({providerSlug:s.slug,value:l.trim()}):Promise.resolve()]),a()}catch{b("Some changes could not be saved. Review the fields and try again.")}}};return e.jsxs("form",{onSubmit:f,className:"grid max-w-md gap-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx($,{htmlFor:`edit-name-${s.slug}`,children:"Name"}),e.jsx(F,{id:`edit-name-${s.slug}`,value:h,onChange:A=>o(A.target.value),placeholder:s.slug}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["The slug (",e.jsx("code",{children:s.slug}),") is fixed — agents reference it."]})]}),t?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx($,{htmlFor:`edit-base-${s.slug}`,children:"Base URL"}),e.jsx(F,{id:`edit-base-${s.slug}`,placeholder:"https://api.example.com/v1",value:c,onChange:A=>j(A.target.value),autoComplete:"off"}),R.base_url?e.jsx("p",{className:"text-xs text-destructive",children:R.base_url}):null]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx($,{htmlFor:`edit-model-${s.slug}`,children:"Default model"}),e.jsx(F,{id:`edit-model-${s.slug}`,placeholder:"gpt-4o-mini",value:N,onChange:A=>m(A.target.value),autoComplete:"off"}),R.model?e.jsx("p",{className:"text-xs text-destructive",children:R.model}):null]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx($,{htmlFor:`edit-key-${s.slug}`,children:"New API key"}),e.jsx(F,{id:`edit-key-${s.slug}`,type:"password",value:l,onChange:A=>x(A.target.value),autoComplete:"off",placeholder:"Leave blank to keep the current key"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Enter a value only to replace the stored key. The old key is discarded."})]})]}):null,y?e.jsx("p",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:y}):null,e.jsx(G,{onCancel:a,children:e.jsx(g,{type:"submit",disabled:!v,children:O?e.jsxs(e.Fragment,{children:[e.jsx(q,{size:"lg",className:"mr-2"}),"Saving..."]}):"Save"})})]})}function it({providerSlug:s,modality:t,block:a}){const n=Ue(),[r,i]=p.useState(!1),[h,o]=p.useState(a.base_url??""),[l,x]=p.useState(a.model??""),[u,c]=p.useState(a.models_endpoint??""),[j,N]=p.useState(!!a.models_endpoint),m=!!(a.base_url||a.model||a.models_endpoint),y={base_url:h.trim()||void 0,model:l.trim()||void 0,models_endpoint:u.trim()||void 0},b=Ie(y),P=ze(b),w=()=>{P||n.mutate({providerSlug:s,modality:t,block:y})};return e.jsxs("div",{className:ne,children:[e.jsxs("button",{type:"button",className:"flex w-full items-center justify-between px-3 py-2 text-left",onClick:()=>i(k=>!k),children:[e.jsx("span",{className:"text-sm font-medium",children:tt[t]}),m?e.jsx(U,{variant:"outline",children:"Custom"}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"Static"})]}),r?e.jsxs("div",{className:"grid gap-3 border-t px-3 py-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx($,{htmlFor:`base-${s}-${t}`,children:"Base URL"}),e.jsx(F,{id:`base-${s}-${t}`,placeholder:"https://api.example.com/v1",value:h,onChange:k=>o(k.target.value),autoComplete:"off"}),b.base_url?e.jsx("p",{className:"text-xs text-destructive",children:b.base_url}):null]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx($,{htmlFor:`model-${s}-${t}`,children:"Model"}),e.jsx(F,{id:`model-${s}-${t}`,placeholder:"gpt-4o-mini",value:l,onChange:k=>x(k.target.value),autoComplete:"off"}),b.model?e.jsx("p",{className:"text-xs text-destructive",children:b.model}):null]}),j?e.jsxs("div",{className:"grid gap-2",children:[e.jsx($,{htmlFor:`endpoint-${s}-${t}`,children:"Models endpoint"}),e.jsx(F,{id:`endpoint-${s}-${t}`,placeholder:"/v1/models",value:u,onChange:k=>c(k.target.value),autoComplete:"off"}),b.models_endpoint?e.jsx("p",{className:"text-xs text-destructive",children:b.models_endpoint}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"Path used to list this modality's models (e.g. /v1/models)."})]}):e.jsx("button",{type:"button",className:"justify-self-start text-xs text-muted-foreground hover:text-foreground",onClick:()=>N(!0),children:"Advanced"}),e.jsx(G,{onCancel:()=>i(!1),children:e.jsx(g,{size:"sm",disabled:P||n.isPending,onClick:w,children:n.isPending?e.jsxs(e.Fragment,{children:[e.jsx(q,{size:"lg",className:"mr-2"}),"Saving..."]}):"Save"})})]}):null]})}function lt({sandbox:s}){const t=Object.entries(s.details??{});return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(ct,{kind:s.providerKind}),e.jsx("span",{className:"text-sm font-medium",children:s.name}),e.jsx(U,{variant:"secondary",className:"h-4 px-1.5 py-0 text-[10px] uppercase tracking-wide",children:s.providerKind}),s.connected?e.jsx(U,{className:"h-4 border-transparent bg-emerald-500/10 px-1.5 py-0 text-[10px] uppercase tracking-wide text-emerald-500",children:"Connected"}):e.jsx(U,{variant:"destructive",className:"h-4 border-transparent bg-destructive/10 px-1.5 py-0 text-[10px] uppercase tracking-wide text-destructive",children:"No credential"})]}),t.length>0?e.jsx("p",{className:"font-mono text-[11px] text-muted-foreground",children:t.map(([a,n])=>`${a}: ${n}`).join(" | ")}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Remote sandbox agents execute in instead of the built-in local runtime."}),s.connected?null:e.jsxs("div",{className:"flex gap-2 rounded-md border border-amber-200 bg-amber-50 p-3 text-sm text-amber-950 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-100",children:[e.jsx(de,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsx("p",{children:"This sandbox has no vault credential. Delete it and re-add the provider with a valid key, or set the credential via the API."})]})]})})}function ot({sandbox:s,onDeleted:t}){const a=vs(),[n,r]=p.useState(!1);return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"rounded-lg border border-destructive/30 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(xe,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"Remove sandbox"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Agents pinned to this runtime fall back to the built-in local sandbox."})]})]}),n?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(g,{variant:"destructive",size:"sm",disabled:a.isPending,onClick:()=>a.mutate({id:s.id},{onSuccess:t}),children:a.isPending?e.jsx(q,{}):"Delete permanently"}),e.jsx(g,{variant:"ghost",size:"sm",onClick:()=>r(!1),children:"Cancel"})]}):e.jsx(g,{variant:"outline",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>r(!0),children:"Delete sandbox"})]})})}function ct({kind:s}){return s==="vercel"?e.jsxs("svg",{viewBox:"0 0 24 24",className:"h-4 w-4 shrink-0 fill-foreground","aria-hidden":!0,children:[e.jsx("title",{children:"Vercel"}),e.jsx("path",{d:"M12 3 22 20H2L12 3Z"})]}):s==="builtin"?e.jsx(ys,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):e.jsx(Ns,{className:"h-4 w-4 shrink-0 text-muted-foreground"})}const dt={data:!1,chat:!1,actions:!1,audience:!1,inference:!0,runtime:!1},ut={data:!1,chat:!1,actions:!1,audience:!1,inference:!1,runtime:!0};function Kt(){const{owner:s,connectorKey:t}=H.useParams(),{instances:a}=H.useSearch(),{kind:n,id:r}=Us(t);return e.jsx(Is,{owner:s,children:({ownerSlug:i,organizationId:h,isWorkspaceLoading:o})=>{if(a&&(n==="inference"||n==="sandbox-provider"))return e.jsx(et,{ownerSlug:i,familyKind:n,familyId:r});switch(n){case"inference":return e.jsx(xt,{ownerSlug:i,providerSlug:r});case"sandbox":return e.jsx(ht,{ownerSlug:i,sandboxId:r});case"sandbox-provider":return e.jsx(mt,{ownerSlug:i,providerKind:r});default:return e.jsx(jt,{ownerSlug:i,organizationId:h,isWorkspaceLoading:o,connectorKey:t})}}})}function mt({ownerSlug:s,providerKind:t}){const a=Q();return p.useEffect(()=>{a({to:"/$owner/connectors/create/$connectorKey",params:{owner:s,connectorKey:`${he}${t}`},replace:!0})},[a,s,t]),null}function ht({ownerSlug:s,sandboxId:t}){const a=Q(),{data:n,isLoading:r,isError:i,refetch:h}=Ee(),o=n?.sandboxes.find(x=>x.id===t)??null;if(r)return e.jsxs(M,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{className:"h-6 w-6 rounded"}),e.jsx(D,{className:"h-5 w-40"})]}),e.jsx(D,{className:"h-24 w-full rounded-lg"})]});if(i)return e.jsx(M,{children:e.jsxs("div",{role:"alert",children:[e.jsx("p",{children:"Could not load this instance."}),e.jsx(g,{variant:"outline",onClick:()=>void h(),children:"Retry"})]})});if(!o)return e.jsxs(M,{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"This sandbox isn't in this workspace, so its details aren't available."}),e.jsx(g,{variant:"outline",size:"sm",onClick:()=>void a({to:"/$owner/connectors",params:{owner:s}}),children:"Back to connectors"})]});const l=o.name||me(o.providerKind);return e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsxs(le,{header:e.jsx(oe,{breadcrumb:e.jsx(ce,{crumbs:[e.jsx(K,{to:"/$owner/connectors",params:{owner:s},className:X,children:"Connectors"},"connectors"),e.jsx(K,{to:"/$owner/connectors/$connectorKey",params:{owner:s,connectorKey:`${he}${o.providerKind}`},search:{instances:!0},className:X,children:me(o.providerKind)},"family")]}),icon:e.jsx(pe,{name:l,faviconDomain:Xs(o.providerKind)}),title:l,badge:e.jsxs(e.Fragment,{children:[e.jsx(U,{variant:"secondary",children:o.providerKind}),o.connected?e.jsx(U,{className:"border-transparent bg-emerald-500/10 text-emerald-500",children:"Connected"}):e.jsx(U,{variant:"destructive",children:"No credential"})]}),status:e.jsx(Qe,{facets:ut})}),children:[e.jsx(lt,{sandbox:o}),e.jsx(B,{title:"Settings",muted:!0,children:e.jsx(ot,{sandbox:o,onDeleted:()=>void a({to:"/$owner/connectors",params:{owner:s}})})})]})})}function xt({ownerSlug:s,providerSlug:t}){const a=Q(),{model:n,reason:r,agentId:i,addAccount:h}=H.useSearch(),{data:o=[],isLoading:l,isError:x,refetch:u}=Pe(),c=De(),{data:j=[],isLoading:N}=c,m=h?null:o.find(E=>E.slug===t)??null,y=j.find(E=>E.slug===(m?.kind??t))??null;if(l||N)return e.jsx("div",{children:e.jsxs(M,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{className:"h-6 w-6 rounded"}),e.jsx(D,{className:"h-5 w-40"})]}),e.jsx(D,{className:"h-16 w-full rounded-lg"}),e.jsx(D,{className:"h-24 w-full rounded-lg"}),e.jsx(D,{className:"h-32 w-full rounded-lg"})]})});if(x)return e.jsx(M,{children:e.jsxs("div",{role:"alert",children:[e.jsx("p",{children:"Could not load this account."}),e.jsx(g,{variant:"outline",onClick:()=>void u(),children:"Retry"})]})});if(!m&&!y&&!c.isError)return e.jsxs(M,{className:"space-y-3",children:[e.jsx(Xe,{connector:{key:t,name:t},showDescription:!1,className:"gap-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This connector isn't installed in this workspace, so its details aren't available."})]});const b=m?m.displayName||m.slug:y?.displayName||t,P=m!==null,w=r?e.jsx(gt,{agentId:i,model:n,providerName:b}):n?e.jsx(ft,{providerName:b,model:n,isConnected:P}):null,k=e.jsx(oe,{breadcrumb:e.jsx(ce,{crumbs:[e.jsx(K,{to:"/$owner/connectors",params:{owner:s},className:X,children:"Connectors"},"connectors"),...m?[e.jsx(K,{to:"/$owner/connectors/$connectorKey",params:{owner:s,connectorKey:`${ae}${m.kind}`},search:{instances:!0},className:X,children:y?.displayName??m.kind},"family")]:[]]}),icon:e.jsx(pe,{iconUrl:y?.iconUrl,name:b}),title:b,badge:m?e.jsxs(e.Fragment,{children:[m.isDefault?e.jsx(U,{variant:"secondary",children:"Default"}):null,m.status?e.jsx(U,{variant:"outline",children:m.status}):null,m.hasCustomUpstream?e.jsx(U,{variant:"outline",children:"Custom upstream"}):null]}):null,status:e.jsx(Qe,{facets:dt})});return e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsxs(le,{header:k,children:[w,e.jsx("div",{className:"space-y-6",children:m?e.jsx(at,{provider:m,catalog:j,autoOpenEdit:!!n}):e.jsx(pt,{ownerSlug:s,providerSlug:t,existingSlugs:o.map(E=>E.slug),catalog:j,catalogError:c.isError?c.error:null,model:n})}),m?e.jsx(B,{title:"Settings",muted:!0,children:e.jsx(nt,{provider:m,onDeleted:()=>void a({to:"/$owner/connectors",params:{owner:s}})})}):null]})})}function pt({ownerSlug:s,providerSlug:t,existingSlugs:a,catalog:n,catalogError:r,model:i}){const h=Q(),o=n.find(u=>u.slug===t),l=a.includes(t)&&!!o&&te(o);let x=t;for(let u=2;a.includes(x);u++)x=`${t}-${u}`;return r?e.jsx("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 p-3 text-sm text-destructive",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(de,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Failed to load provider catalog."}),e.jsx("p",{className:"mt-1 text-xs",children:r instanceof Error?r.message:"Check the workspace URL and try again."})]})]})}):e.jsxs("div",{className:"space-y-3 rounded-lg border p-4",children:[l&&e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsx("p",{children:"Subscription sign-in is managed on the existing connection."}),e.jsx(g,{asChild:!0,variant:"outline",size:"sm",children:e.jsx(K,{to:"/$owner/connectors/$connectorKey",params:{owner:s,connectorKey:`${ae}${t}`},search:{},children:"Open existing connection"})})]}),(!l||o&&Fe(o))&&e.jsx(st,{catalog:n,initialProvider:t,initialSlug:x,allowOAuth:!l,initialModel:i?.includes("/")?i.split("/").slice(1).join("/"):i,onDone:()=>void h({to:"/$owner/connectors",params:{owner:s}})},`${n.length}:${t}`)]})}function ft({providerName:s,model:t,isConnected:a}){return e.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 p-3 text-sm text-amber-950 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-100",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(de,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsxs("p",{children:["Review ",e.jsx("strong",{children:s})," for model"," ",e.jsx("strong",{children:t}),"."," ",a?"Its edit controls are open.":"It is not connected yet; add it to continue."]})]})})}function gt({agentId:s,model:t,providerName:a}){return e.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 p-3 text-sm text-amber-950 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-100",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(de,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium",children:"This agent needs a model provider before it can reply."}),e.jsxs("p",{children:[s?e.jsxs("span",{children:["Agent ",e.jsx("strong",{children:s})," is"," "]}):null,"configured to use ",t?e.jsx("strong",{children:t}):"a model"," ","from ",e.jsx("strong",{children:a}),", but that provider is not ready in this workspace."]}),e.jsx("p",{children:"Connect the provider below, then retry the message."})]})]})})}function jt({ownerSlug:s,organizationId:t,isWorkspaceLoading:a,connectorKey:n}){const{data:r=[],isLoading:i,isError:h,refetch:o}=qs(t??""),{data:l=[],isLoading:x,isError:u,refetch:c}=Ws(t??"",{connectorKey:n}),j=p.useMemo(()=>r.find(y=>y.key===n),[r,n]),N=p.useMemo(()=>Ys(n,r,{name:l[0]?.connector_name??n}),[n,r,l]);if(a||i)return e.jsx("div",{children:e.jsxs(M,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{className:"h-6 w-6 rounded"}),e.jsx(D,{className:"h-5 w-40"})]}),e.jsx(D,{className:"h-16 w-full rounded-lg"}),e.jsx(D,{className:"h-24 w-full rounded-lg"}),e.jsx(D,{className:"h-32 w-full rounded-lg"})]})});if(h||u)return e.jsx(M,{children:e.jsxs("div",{role:"alert",className:"space-y-2",children:[e.jsx("p",{children:"Could not load this connector."}),e.jsx(g,{variant:"outline",onClick:()=>{o(),c()},children:"Retry"})]})});const m=j?e.jsx(yt,{connector:j,ownerSlug:s}):e.jsxs("div",{className:"space-y-3",children:[e.jsx(Xe,{connector:N,showDescription:!1,className:"gap-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["This connector isn't installed in this workspace, so its details aren't available.",l.length>0?" Existing connections keep working.":""]})]});return e.jsx("div",{className:"flex flex-1 flex-col",children:j&&t?e.jsx(vt,{hero:m,connector:j,organizationId:t,ownerSlug:s,connectorKey:n,connections:l,isLoading:x,refetchConnections:c}):e.jsxs(M,{className:"space-y-6",children:[m,l.length>0&&!x?e.jsx(Ge,{section:!0,connections:l,ownerSlug:s,connectorKey:n}):e.jsx(He,{organizationId:t??"",ownerSlug:s,connectorKey:n,connections:l,isLoading:x})]})})}function vt({hero:s,connector:t,organizationId:a,ownerSlug:n,connectorKey:r,connections:i,isLoading:h,refetchConnections:o}){const{isAdmin:l,isLoading:x}=J(a),u=(t.operations_summary?.total??0)>0;return e.jsxs(le,{header:s,children:[e.jsx(bs,{organizationId:a,connectorKey:r}),e.jsx(At,{connector:t,organizationId:a,ownerSlug:n,connectorKey:r,connections:i,isLoading:h,refetchConnections:o}),i.length>0?e.jsx(Ge,{section:!0,connections:i,connector:t,ownerSlug:n,connectorKey:r}):null,e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:auto-cols-fr sm:grid-flow-col",children:[e.jsx(St,{connector:t,organizationId:a,ownerSlug:n}),u&&x?e.jsx(D,{className:"h-20 w-full rounded-lg"}):u&&l?e.jsx(Ct,{connector:t,organizationId:a,ownerSlug:n}):u&&!l?e.jsx(B,{title:"Actions",muted:!0,children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Only workspace admins can view and configure connector actions."})}):null]}),e.jsx(Nt,{connector:t,organizationId:a,ownerSlug:n,connectionCount:i.length}),!h&&i.length>0?e.jsx(B,{title:"Recent activity",children:e.jsx(Zs,{scope:{connectorKey:r},ownerSlug:n})}):null]})}function yt({connector:s,ownerSlug:t}){return e.jsx(oe,{breadcrumb:e.jsx(ce,{crumbs:[e.jsx(K,{to:"/$owner/connectors",params:{owner:t},className:X,children:"Connectors"},"connectors")]}),icon:e.jsx(pe,{icon:s.icon,name:s.name,faviconDomain:s.favicon_domain??Gs(s.auth_schema),className:"h-10 w-10"}),title:s.name,badge:e.jsx(Js,{connectorDef:s,ownerSlug:t}),caption:s.description})}function Nt({connector:s,organizationId:t,ownerSlug:a,connectionCount:n}){const r=Te(s.auth_schema),i=zs(s.auth_schema),h=r.find(w=>w.type==="oauth"),o=We(s.auth_schema),l=r.some(w=>w.type==="env_keys"),x=r.some(w=>w.type==="browser"),u=i.some(w=>w.type==="interactive"),c=!!(h||o||l||x),j=Ms(s),{isAdmin:N}=J(t),{data:m=[]}=ie(t,{connectorKey:s.key,profileKind:"env"}),{data:y=[]}=ie(t,{profileKind:"browser_session",connectorKey:s.key}),b=N&&s.installed!==!1;return!!(h||o)||l&&m.length>0||x&&y.length>0||!c||b?e.jsxs("div",{className:"space-y-6",children:[h?e.jsx(kt,{connector:s,organizationId:t,oauthMethod:h}):null,o?e.jsx(B,{title:"App installation",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Install the ",s.name," app to create or repair the workspace connection."]}),e.jsx(Ye,{organizationId:t,connectorKey:s.key,provider:o.provider,providerLabel:s.name,installShape:o.installShape,variant:"outline"})]})}):null,l&&m.length>0?e.jsx($e,{profiles:m,type:"env"}):null,x&&y.length>0?e.jsx($e,{profiles:y,type:"browser_session"}):null,c?null:j?e.jsx(B,{title:"Device runtime",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[s.name," runs on a linked device — there are no workspace credentials to configure here. Pair a device, then create a connection pinned to it."]}),e.jsx(g,{asChild:!0,variant:"outline",size:"sm",children:e.jsx(K,{to:"/$owner/connectors",params:{owner:a},search:{},children:"View devices"})})]})}):u?e.jsx(B,{title:"Authentication",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[s.name," pairs when you create a connection — there is no workspace-level credential to configure here."]})}):e.jsx(B,{title:"Authentication",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"This connector doesn't need workspace credentials. Create a connection above to get started."})}),e.jsx(bt,{connector:s,organizationId:t,ownerSlug:a,connectionCount:n})]}):null}function bt({connector:s,organizationId:t,ownerSlug:a,connectionCount:n}){const r=Q(),{isAdmin:i}=J(t),h=Qs(),[o,l]=p.useState(!1),[x,u]=p.useState(null),c=s.installed!==!1;if(!i||!c)return null;const j=n>0,N=h.isPending,m=()=>{u(null),h.mutate({connector_key:s.key},{onSuccess:()=>{r({to:"/$owner/connectors",params:{owner:a}})},onError:y=>{u(y instanceof Error?y.message:"Failed to remove connector"),l(!1)}})};return e.jsxs("div",{className:"rounded-lg border border-destructive/30 bg-destructive/5 p-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Remove connector"}),e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Archives ",s.name," in this workspace. Existing synced data stays in memory."]}),j?e.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:["Delete"," ",e.jsxs("span",{className:"font-medium text-foreground",children:[n," connection",n===1?"":"s"]})," ","first — uninstall is blocked while any connection still references this connector."]}):null,x?e.jsx("p",{className:"mt-2 rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:x}):null,e.jsx("div",{className:"mt-3",children:o?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(g,{variant:"destructive",size:"sm",disabled:N,onClick:m,children:[N?e.jsx(q,{size:"md",className:"mr-1.5"}):null,"Confirm remove"]}),e.jsx(g,{variant:"ghost",size:"sm",disabled:N,onClick:()=>l(!1),children:"Cancel"})]}):e.jsxs(g,{variant:"outline",size:"sm",className:"text-destructive hover:text-destructive",disabled:N||j,onClick:()=>l(!0),children:[e.jsx(xe,{className:"mr-1.5 h-3.5 w-3.5"}),"Remove connector"]})})]})}function Ct({connector:s,organizationId:t,ownerSlug:a}){const n=Ve();return e.jsx(qe,{title:"Actions",summary:`${s.operations_summary?.total??0} actions · organization policies`,onOpen:()=>n?.open({href:"",title:"Actions",connectorPanel:{section:"actions",connectorKey:s.key,organizationId:t,ownerSlug:a}})})}function kt({connector:s,organizationId:t,oauthMethod:a}){const{isAdmin:n,isLoading:r}=J(t),{setup:i}=H.useSearch(),h=H.useNavigate(),{data:o=[],refetch:l,isLoading:x,isError:u}=ie(t,{connectorKey:s.key,provider:a.provider}),c=o.filter(j=>j.profile_kind==="oauth_app");return r||x?e.jsx(D,{className:"h-28 w-full"}):u?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:"Could not load OAuth apps. Reload the page to try again."}):e.jsx(wt,{connector:s,oauthMethod:a,appProfiles:c,isAdmin:n,initialOpen:i==="oauth_app",onClose:()=>{i==="oauth_app"&&h({search:j=>({...j,setup:void 0}),hash:"",replace:!0})},refetchProfiles:l})}function wt({initialOpen:s=!1,onClose:t,connector:a,oauthMethod:n,appProfiles:r,isAdmin:i,refetchProfiles:h}){const o=Ps(),l=Ds(),[x,u]=se(a.key,s&&i),[c,j]=p.useState(!1);p.useEffect(()=>{s&&i&&u(!0)},[s,i,u]);const N=`${Es()}/connect/oauth/callback`,[m,y]=se(a.key,`${a.name} OAuth App`),[b,P]=se(a.key,""),[w,k]=se(a.key,null),E=Fs(n),_=Ls(`${a.key}:${x}`,Rs(E),E),{values:z,setValues:R}=_,I=r.find(v=>v.is_default_for_connector&&v.connector_key===a.key),O=()=>{_.canSubmit&&(k(null),o.mutate({connector_key:a.key,profile_kind:"oauth_app",display_name:m.trim()||`${a.name} OAuth App`,slug:b.trim()||void 0,credentials:Pt(Vs(z))},{onSuccess:v=>{const f=v.auth_profile?.slug;f&&!I&&l.mutate({connector_key:a.key,auth_profile_slug:f}),u(!1),t?.(),y(`${a.name} OAuth App`),P(""),h()},onError:v=>{k(v instanceof Error?v.message:"Failed to add OAuth app")}}))};return e.jsxs(B,{id:"connector-oauth-apps",title:`${$t(n.provider)} app configuration`,action:i&&!x?e.jsxs(g,{variant:"outline",size:"sm",onClick:()=>u(!0),children:[e.jsx(Me,{className:"size-3.5"}),"Add OAuth app"]}):null,children:[i&&e.jsxs("div",{className:"space-y-2",children:[e.jsx($,{children:"OAuth callback URL"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"min-w-0 flex-1 break-all text-xs",children:N}),e.jsxs(g,{variant:"outline",size:"sm",onClick:()=>{navigator.clipboard.writeText(N).then(()=>j(!0)).catch(()=>k("Could not copy the callback URL. Select and copy it above."))},children:[e.jsx(Os,{className:"mr-1.5 h-3.5 w-3.5"}),c?"Copied":"Copy callback URL"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Register this exact URL in your provider’s app settings before saving the client configuration."})]}),r.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No app configured on this server. Choose a managed option if available, or add your own app here."}):e.jsx("div",{className:"space-y-2",children:r.map(v=>e.jsxs("div",{className:re(ne,"flex flex-wrap items-center gap-3 p-3"),children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:v.display_name}),v.is_default_for_connector&&v.connector_key===a.key?e.jsx(U,{variant:"secondary",className:"text-[10px]",children:"Default"}):null,e.jsx(Je,{status:v.status})]}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",children:v.slug})]}),i&&!v.is_default_for_connector&&v.connector_key===a.key&&v.status==="active"?e.jsx(g,{variant:"outline",size:"sm",disabled:l.isPending,onClick:()=>l.mutate({connector_key:a.key,auth_profile_slug:v.slug}),children:"Set default"}):null]},v.slug))}),i&&x?e.jsxs("div",{className:re(ne,"space-y-3 p-3"),children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx($,{htmlFor:"oauth-app-name",children:"Display name"}),e.jsx(F,{id:"oauth-app-name",value:m,onChange:v=>y(v.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx($,{htmlFor:"oauth-app-slug",children:"Slug"}),e.jsx(F,{id:"oauth-app-slug",placeholder:"optional",value:b,onChange:v=>P(v.target.value)})]}),e.jsx(Bs,{schema:_.revision??void 0,values:z,onValuesChange:R,fieldIdPrefix:"oauth-app-"}),e.jsx(Ks,{visible:_.hasConflict,onReload:_.reset}),w?e.jsx("p",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:w}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(g,{variant:"outline",size:"sm",disabled:o.isPending,onClick:()=>{u(!1),t?.()},children:"Cancel"}),e.jsxs(g,{size:"sm",disabled:o.isPending||!_.canSubmit,onClick:O,children:[o.isPending?e.jsx(q,{size:"md",className:"mr-1.5"}):null,"Save OAuth app"]})]})]}):null]})}function At({connector:s,organizationId:t,ownerSlug:a,connectorKey:n,connections:r,isLoading:i,refetchConnections:h}){const l=Te(s.auth_schema).find(N=>N.type==="oauth"),{data:x=[],refetch:u,isLoading:c,isError:j}=ie(t,{connectorKey:s.key,provider:l?.provider});if(l){if(j)return e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:"Could not load accounts. Reload the page to try again."});const N=x.filter(y=>y.profile_kind==="oauth_app"),m=x.filter(y=>y.profile_kind==="oauth_account");return e.jsx(_t,{connector:s,organizationId:t,oauthMethod:l,appProfiles:N,accounts:m,connections:r,isLoading:i||c,refetchProfiles:u,refetchConnections:h})}return e.jsx(He,{connector:s,organizationId:t,ownerSlug:a,connectorKey:n,connections:r,isLoading:i})}function _t({connector:s,organizationId:t,oauthMethod:a,appProfiles:n,accounts:r,connections:i,isLoading:h,refetchProfiles:o,refetchConnections:l}){const{session:x}=Cs(),{isAdmin:u,isLoading:c}=J(t),j=ks(),N=ws(),m=As(),[y,b]=p.useState(""),[P,w]=p.useState([]),k=n.filter(f=>f.status==="active"),E=k.find(f=>f.is_default_for_connector&&f.connector_key===s.key),_=(u?k.find(f=>f.slug===y):void 0)??E??(u&&k.length===1?k[0]:void 0),z=new Set(i.map(f=>f.auth_profile_slug)),R=r.filter(f=>f.created_by===x?.user?.id),I=R.filter(f=>!z.has(f.slug)),O=!i.some(f=>f.created_by===x?.user?.id)&&R.length===0;if(h||c||!x?.user?.id||!O&&I.length===0&&!m.error&&!m.continueUrl)return null;const v=f=>m.begin(async()=>{const A=await j.mutateAsync({connector_key:s.key,app_auth_profile_slug:f,requested_scopes:Ts(a,P)});return o(),l(),A});return e.jsxs(B,{title:O?"Connect your account":"Your accounts",children:[O&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Connect your own account to grant access. Your connection is private to you."}),u&&k.length>1?e.jsxs("div",{className:"space-y-1",children:[e.jsx($,{children:"App used for this account"}),e.jsxs(Le,{value:_?.slug??"",onValueChange:b,children:[e.jsx(Re,{"aria-label":"App used for this account",children:e.jsx(Oe,{placeholder:"Choose an OAuth app"})}),e.jsx(Be,{children:k.map(f=>e.jsxs(Ke,{value:f.slug,children:[f.display_name,f.is_default_for_connector&&f.connector_key===s.key?" (workspace default)":""]},f.slug))})]})]}):_?e.jsxs("p",{className:"text-sm",children:["App: ",_.display_name,_.is_default_for_connector&&_.connector_key===s.key?" (workspace default)":""]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:u?"Configure an OAuth app below, then connect your account.":"Ask an administrator to configure and set the workspace-default OAuth app."}),_&&e.jsx(_s,{requiredScopes:$s(a),optionalScopes:Ss(a),selectedOptionalScopes:P,onToggleOptionalScope:(f,A)=>w(W=>A?[...new Set([...W,f])]:W.filter(T=>T!==f))}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(g,{size:"sm",disabled:!_||m.pending,onClick:()=>{_&&v(_.slug)},children:"Connect account"}),u&&e.jsx(g,{asChild:!0,size:"sm",variant:"outline",children:e.jsx("a",{href:"#connector-oauth-apps",children:"Manage app"})})]})]}),I.map(f=>e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 py-2",children:[e.jsx("span",{className:"text-sm",children:f.display_name}),e.jsx(g,{variant:"outline",size:"sm",disabled:m.pending,onClick:()=>void m.begin(()=>f.status==="active"?j.mutateAsync({connector_key:s.key,auth_profile_slug:f.slug}):N.mutateAsync({auth_profile_slug:f.slug})),children:f.status==="active"?"Use this account":"Reconnect"})]},f.slug)),m.error&&e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:m.error}),m.continueUrl&&e.jsx("a",{href:m.continueUrl,target:"_blank",rel:"noreferrer",className:"text-sm underline",children:"Continue authorization in your browser"})]})}function $e({profiles:s,type:t}){const a=t==="env"?"Credentials":"Browser sessions";return e.jsx(B,{title:a,children:e.jsx("div",{className:"space-y-2",children:s.map(n=>e.jsxs("div",{className:re(ne,"p-3"),children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium",children:n.display_name}),e.jsx(Je,{status:n.status})]}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",children:n.slug})]},n.slug))})})}function St({connector:s,organizationId:t,ownerSlug:a}){const n=Ve(),r=Object.keys(s.feeds_schema??{}).length;return r?e.jsx(qe,{title:"Feeds",summary:`${r} ${r===1?"feed type":"feed types"}`,onOpen:()=>n?.open({href:"",title:"Feeds",connectorPanel:{section:"feeds",connectorKey:s.key,organizationId:t,ownerSlug:a}})}):null}function He({connector:s,organizationId:t,ownerSlug:a,connectorKey:n,connections:r,isLoading:i}){const h=Q(),o=We(s?.auth_schema);if(i)return e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{className:"h-4 w-24"}),e.jsx(D,{className:"h-16 w-full rounded-lg"})]});if(r.length===0){const l=s&&o?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Ye,{organizationId:t,connectorKey:n,provider:o.provider,providerLabel:s.name,installShape:o.installShape,size:"default",label:`Install ${s.name}`}),e.jsx(g,{asChild:!0,variant:"outline",children:e.jsx(K,{to:"/$owner/connectors/create/$connectorKey",params:{owner:a,connectorKey:n},children:"Use your own app"})})]}):e.jsxs(g,{size:"default",onClick:()=>h({to:"/$owner/connectors/create/$connectorKey",params:{owner:a,connectorKey:n}}),children:[e.jsx(Me,{className:"mr-1.5 h-4 w-4"}),"Create connection"]});return e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:l})}return null}function Je({status:s}){const t=s==="active"?"text-green-500":s==="error"||s==="revoked"?"text-destructive":"text-amber-500";return e.jsxs("span",{className:re("text-xs",t),children:["· ",s]})}function $t(s){return s.charAt(0).toUpperCase()+s.slice(1)}function Pt(s){const t={};for(const[a,n]of Object.entries(s))typeof n=="string"&&n.trim()?t[a]=n.trim():(typeof n=="number"||typeof n=="boolean")&&(t[a]=String(n));return t}export{vt as ConnectorDetailShell,_t as OAuthAccountsSection,wt as OAuthAppProfilesSection,Kt as component};
|
|
2
|
+
//# sourceMappingURL=_connectorKey.index-BTP5ijdT.js.map
|