@xopcai/xopc 0.0.314 → 0.0.315
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/browser-ext/manifest.json +1 -1
- package/dist/extensions/feishu/src/outbound/media-load.js +1 -1
- package/dist/extensions/telegram/src/plugin.js +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BFkjfurL.js → agent-avatar-dicebear-BbFOF2SH.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-D9T-QGmd.js +1 -0
- package/dist/gateway/static/root/assets/agents-Ds5sQcPd.js +1 -0
- package/dist/gateway/static/root/assets/{api-BYhRsTAc.js → api-BzloAiIG.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-B4kihr-A.js → app-management-settings-panel-BpUHskXq.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-N9sYmNOx.js → appearance-settings-CQd5Vo6f.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-BMcy10_s.js → apps-page-B7VIsfye.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-k_SuYWyV.js → archive-plugin-BM4O6WfL.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-DRv5QWUK.js → attachment-load-Cdn9MYmI.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-CkJV3DN0.js → automations-page-DnRx-Ra4.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-B5s10G5F.js +7 -0
- package/dist/gateway/static/root/assets/{binary-plugins-Dg3h3TA7.js → binary-plugins-dkhUf4bm.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-DVhdHntT.js → block-editor-BTzqEuAy.js} +3 -3
- package/dist/gateway/static/root/assets/{browser-automation-inputs-BMRYUW8_.js → browser-automation-inputs-Bowij-nJ.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-Byv6-FY2.js → browser-automations-page-CQ7SYTQj.js} +2 -2
- package/dist/gateway/static/root/assets/browser-settings-page-vqLoPOOg.js +3 -0
- package/dist/gateway/static/root/assets/capabilities-settings-panel-DI68WGYd.js +8 -0
- package/dist/gateway/static/root/assets/channels-settings-Cimssy-S.js +1 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-D4AHa51o.js → chat-terminal-dock-DzgFHd6l.js} +1 -1
- package/dist/gateway/static/root/assets/{computer-settings-page-eXPe500D.js → computer-settings-page-380_vIqO.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-BQTFlq_k.js → connector-service-page-DILFakXb.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-COmFp9HC.js +2 -0
- package/dist/gateway/static/root/assets/{date-picker-7MtovynY.js → date-picker-CRVun-T5.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-Bj_xkXID.js → dependency-picker-BoWqt5yU.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-CTmba9zH.js → desktop-pet-DPlkBjft.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-DNM_BlWN.js → desktop-pet-settings-D7FgfX_K.js} +1 -1
- package/dist/gateway/static/root/assets/device-pairing-wizard-BP6yxut8.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-J_olaL7e.js → extension-debug-page-CT_QkSN_.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-pK5RvqN8.js → extension-page-BF1NdcKP.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-BwroEN08.js → extension-settings-page-CKQVZ3Xc.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-FuJTIg_a.js → gateway-config-swr-BPsZPoAT.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-settings-3bIy7XMr.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-CKg_gu8_.js → gateway-startup-retry-cG6EqUJw.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-DFNDLFgv.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-Bo6NZ7zb.js → image-generation-api-DI_QutIx.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-C8-hX8gS.js → imports-page-BUG6G72F.js} +1 -1
- package/dist/gateway/static/root/assets/index-BCi8nfxs.js +89 -0
- package/dist/gateway/static/root/assets/index-DWgd1VK2.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BkBEjUZD.js → keyboard-shortcuts-settings-qnG-4FJs.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-B3iJWhjN.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-CrbKIixo.js → local-apps-page-BpEGeURS.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-CvGwNbml.js → locale-store-BlgpZORR.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-DBHlZts9.js → logs-page-0QPGj-5c.js} +2 -2
- package/dist/gateway/static/root/assets/management-settings-Sl0wwidS.js +1 -0
- package/dist/gateway/static/root/assets/{markdown-view-nXo5nrsv.js → markdown-view-BzjjpL2H.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-upxXJ-4l.js → media-plugins-Bzkdhotn.js} +1 -1
- package/dist/gateway/static/root/assets/messages-2GhUD7SC.js +3 -0
- package/dist/gateway/static/root/assets/note-detail-panel-BXtD71j1.js +5 -0
- package/dist/gateway/static/root/assets/notes-page-DNY4vW-u.js +8 -0
- package/dist/gateway/static/root/assets/{page-context-capture-button-DUyA-K4L.js → page-context-capture-button-CFt4hXQ6.js} +1 -1
- package/dist/gateway/static/root/assets/{page-tabs-Cl-NFPNr.js → page-tabs-Dz_x22MQ.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-DX81PwJ3.js → preview-open-alternatives-C1mkgFAl.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-CrfIGwm8.js → product-open-page-DHZgzSDV.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-D3NhZ7ZZ.js +1 -0
- package/dist/gateway/static/root/assets/{projects-page-nM9a9XNS.js → projects-page-CEr8DX9I.js} +1 -1
- package/dist/gateway/static/root/assets/{registry-api-CHxgohY0.js → registry-api-DMW2apOO.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-Db-B-Mf3.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-D3dLOW04.js → runtime-tools-settings-panel-DEJi0BLL.js} +1 -1
- package/dist/gateway/static/root/assets/scenes-page-BUUX-PnI.js +2 -0
- package/dist/gateway/static/root/assets/{schema-form-ZxuIvD2_.js → schema-form-RVltVpuG.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-Rm4H2okS.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-VxPItcOG.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-TZRfg4yo.js → settings-form-section-BkBO7woF.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-BfvlRT9q.js → settings-page-layout-lLvHc-zF.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-a8qcJpdZ.js → settings-page-zl0XY203.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-Difrpr4T.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-DCt1pTWB.js → share-preview-page-NC4Gj867.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-DPLvEcB-.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-CKdLCf_-.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-BIOcg44X.js → skills-page-CzekvBNQ.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-CgZdzT4I.js → skills-page.utils-BLeiN245.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-_YaRncA6.js → system-settings-panel-Bp75s9nl.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-Bh8H4FYR.js +1 -0
- package/dist/gateway/static/root/assets/{tunnel-api-uOupJOoS.js → tunnel-api-BDiaC6an.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-BezzHBLE.js → use-autosave-C_ntK_Zu.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-C7gFCGAV.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-BmYifdwL.js → voice-api-key-field-D4cfuMp1.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-D_5Q2_A3.js → voice-config-api-Cjvd6maH.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-4DmyEckJ.js → work-discovery-overlay-Ce6ToB0O.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DeZe8bTZ.js → workflow-run-setup-panel-C80nrmKi.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-CVQjo3RI.js +6 -0
- package/dist/gateway/static/root/index.html +8 -8
- package/dist/package.js +1 -1
- package/dist/src/agent/mcp/bundle-mcp-gateway.d.ts +39 -0
- package/dist/src/agent/mcp/bundle-mcp-gateway.js +32 -1
- package/dist/src/agent/mcp/bundle-mcp-runtime.js +11 -0
- package/dist/src/agent/mcp/bundle-mcp-types.d.ts +2 -1
- package/dist/src/agent/mcp/mcp-resource-id.d.ts +6 -0
- package/dist/src/agent/mcp/mcp-resource-id.js +19 -0
- package/dist/src/agent/source-context/browser-tab.d.ts +3 -0
- package/dist/src/agent/source-context/browser-tab.js +29 -0
- package/dist/src/agent/source-context/file-context.d.ts +3 -0
- package/dist/src/agent/source-context/file-context.js +64 -0
- package/dist/src/agent/source-context/index.d.ts +4 -0
- package/dist/src/agent/source-context/index.js +5 -1
- package/dist/src/agent/source-context/injector.js +1 -1
- package/dist/src/agent/source-context/mcp-resource-context.d.ts +8 -0
- package/dist/src/agent/source-context/mcp-resource-context.js +30 -0
- package/dist/src/agent/source-context/session-context.d.ts +8 -0
- package/dist/src/agent/source-context/session-context.js +33 -0
- package/dist/src/agent/source-context/types.d.ts +9 -3
- package/dist/src/agent/source-context/types.js +3 -2
- package/dist/src/channels/index.js +1 -1
- package/dist/src/channels/manager.js +1 -1
- package/dist/src/cli/commands/channels.js +1 -1
- package/dist/src/cli/commands/connectors.js +1 -1
- package/dist/src/cli/commands/extension-marketplace.js +1 -1
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/cli/commands/onboard.js +1 -1
- package/dist/src/config/models-json.d.ts +8 -8
- package/dist/src/extensions/sdk/index.js +1 -1
- package/dist/src/gateway/chat-stream/mapper.js +3 -2
- package/dist/src/gateway/hono/routes/agent-stream.js +2 -2
- package/dist/src/gateway/hono/routes/browser.js +32 -0
- package/dist/src/gateway/hono/routes/devices.js +0 -16
- package/dist/src/gateway/hono/routes/endpoint-tools.js +86 -30
- package/dist/src/gateway/hono/routes/mcp.js +32 -1
- package/dist/src/gateway/hono/routes/session-input-handler.d.ts +6 -2
- package/dist/src/gateway/hono/routes/session-input-handler.js +4 -4
- package/dist/src/gateway/hono/routes/voice.js +1 -1
- package/dist/src/gateway/service/agent-runner.d.ts +1 -1
- package/dist/src/gateway/service/agent-runner.js +2 -2
- package/dist/src/gateway/service/app-context-access.d.ts +0 -4
- package/dist/src/gateway/service/run-gateway-agent.js +1 -1
- package/dist/src/gateway/service/session-input-coordinator.d.ts +1 -1
- package/dist/src/gateway/service/session-input-coordinator.js +3 -3
- package/dist/src/gateway/service.js +42 -5
- package/dist/src/gateway/workspace-file-search.js +25 -12
- package/dist/src/platform/client.d.ts +1 -1
- package/dist/src/platform/contracts.d.ts +1 -1
- package/dist/src/session/client-history.d.ts +2 -1
- package/dist/src/session/client-history.js +3 -2
- package/dist/src/storage/sqlite/endpoint-tool-invocation-repository.d.ts +15 -1
- package/dist/src/storage/sqlite/endpoint-tool-invocation-repository.js +39 -6
- package/dist/src/storage/sqlite/index.d.ts +1 -1
- package/dist/src/storage/sqlite/index.js +2 -2
- package/dist/src/tui/backends/embedded-backend.js +1 -1
- package/dist/src/tui/backends/gateway-realtime-backend.js +1 -1
- package/package.json +4 -4
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-BdOZ6q8Z.js +0 -1
- package/dist/gateway/static/root/assets/agents-CCcavsHq.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-BEa2doeR.js +0 -7
- package/dist/gateway/static/root/assets/browser-settings-page-DRCHGFpO.js +0 -3
- package/dist/gateway/static/root/assets/capabilities-settings-panel-mxRP0gl0.js +0 -8
- package/dist/gateway/static/root/assets/channels-settings-DBt_6GsB.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-BKeBWwcI.js +0 -2
- package/dist/gateway/static/root/assets/device-pairing-wizard-C2XE0QhT.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-CLLDp23J.js +0 -1
- package/dist/gateway/static/root/assets/home-page-B5Epb1PH.js +0 -1
- package/dist/gateway/static/root/assets/index-14F1yGJI.js +0 -89
- package/dist/gateway/static/root/assets/index-cB7rWIDY.css +0 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-6jC3vQpY.js +0 -2
- package/dist/gateway/static/root/assets/management-settings-DsUWLu5m.js +0 -1
- package/dist/gateway/static/root/assets/messages-B_AwRroN.js +0 -3
- package/dist/gateway/static/root/assets/note-detail-panel-0Q9TOtJG.js +0 -5
- package/dist/gateway/static/root/assets/notes-page-D0NmcwNw.js +0 -8
- package/dist/gateway/static/root/assets/project-detail-page-BVfVrYmn.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-C8b_k88G.js +0 -1
- package/dist/gateway/static/root/assets/scenes-page-DEowreZV.js +0 -2
- package/dist/gateway/static/root/assets/sessions-page-B_nPhera.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BqhIOuus.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-CRj5Ruqn.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-BNbXPk--.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-CNMCLbav.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-CAcfAG-c.js +0 -1
- package/dist/gateway/static/root/assets/user-model-page-BFFeneDq.js +0 -2
- package/dist/gateway/static/root/assets/workflows-page-Sv4hEc6W.js +0 -6
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createLogger } from "../../../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../../../utils/logger.js";
|
|
3
|
-
import { getDevice } from "../../../storage/sqlite/device-access-repository.js";
|
|
3
|
+
import { getDevice, listDevices, revokeDevice } from "../../../storage/sqlite/device-access-repository.js";
|
|
4
4
|
import { endpointPrincipalRegistrationSchema, endpointSessionBindingRequestSchema, init_src } from "../../../../packages/endpoint-tools-protocol/src/index.js";
|
|
5
5
|
import { createEndpointPrincipal, getEndpointPrincipal, listEndpointPrincipals, revokeEndpointPrincipal } from "../../../storage/sqlite/endpoint-principal-repository.js";
|
|
6
|
-
import {
|
|
6
|
+
import { listEndpointToolInvocationAuditPage } from "../../../storage/sqlite/endpoint-tool-invocation-repository.js";
|
|
7
7
|
import "../../../storage/sqlite/index.js";
|
|
8
8
|
import { parseEndpointPublicKey } from "../../../endpoint-tools/auth.js";
|
|
9
9
|
import { ENDPOINT_UPLOAD_MAX_BYTES, EndpointUploadError } from "../../../endpoint-tools/upload-service.js";
|
|
@@ -42,19 +42,75 @@ async function readBoundedBody(body, maxBytes) {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
function registerEndpointToolRoutes(authenticated, deps) {
|
|
45
|
-
authenticated.get("/api/endpoint-tools/
|
|
45
|
+
authenticated.get("/api/endpoint-tools/devices", (c) => {
|
|
46
46
|
const endpointsByPrincipal = /* @__PURE__ */ new Map();
|
|
47
47
|
for (const endpoint of deps.service.endpointTools.registry.list()) {
|
|
48
48
|
const endpoints = endpointsByPrincipal.get(endpoint.principalId) ?? [];
|
|
49
49
|
endpoints.push(endpoint);
|
|
50
50
|
endpointsByPrincipal.set(endpoint.principalId, endpoints);
|
|
51
51
|
}
|
|
52
|
+
const devicesById = new Map(listDevices().map((device) => [device.id, device]));
|
|
53
|
+
const principalsById = new Map(listEndpointPrincipals().map((principal) => [principal.id, principal]));
|
|
54
|
+
const devices = [...new Set([...devicesById.keys(), ...principalsById.keys()])].map((id) => {
|
|
55
|
+
const access = devicesById.get(id);
|
|
56
|
+
const principal = principalsById.get(id);
|
|
57
|
+
const lastSeenAt = Math.max(access?.lastSeenAt ?? 0, principal?.lastSeenAt ?? 0) || void 0;
|
|
58
|
+
return {
|
|
59
|
+
id,
|
|
60
|
+
displayName: principal?.displayName ?? access?.displayName ?? id,
|
|
61
|
+
kind: principal?.kind ?? (access?.platform === "chrome" ? "browser" : "mobile"),
|
|
62
|
+
platform: principal?.platform ?? access?.platform ?? "unknown",
|
|
63
|
+
createdAt: Math.min(access?.createdAt ?? Number.POSITIVE_INFINITY, principal?.createdAt ?? Number.POSITIVE_INFINITY),
|
|
64
|
+
...lastSeenAt ? { lastSeenAt } : {},
|
|
65
|
+
access: access ? {
|
|
66
|
+
scopes: access.scopes,
|
|
67
|
+
createdAt: access.createdAt,
|
|
68
|
+
...access.lastSeenAt ? { lastSeenAt: access.lastSeenAt } : {},
|
|
69
|
+
...access.revokedAt ? { revokedAt: access.revokedAt } : {}
|
|
70
|
+
} : null,
|
|
71
|
+
principal: principal ? {
|
|
72
|
+
createdAt: principal.createdAt,
|
|
73
|
+
...principal.lastSeenAt ? { lastSeenAt: principal.lastSeenAt } : {},
|
|
74
|
+
...principal.revokedAt ? { revokedAt: principal.revokedAt } : {}
|
|
75
|
+
} : null,
|
|
76
|
+
endpoints: endpointsByPrincipal.get(id) ?? []
|
|
77
|
+
};
|
|
78
|
+
}).sort((left, right) => (right.lastSeenAt ?? right.createdAt) - (left.lastSeenAt ?? left.createdAt));
|
|
52
79
|
return c.json({
|
|
53
80
|
ok: true,
|
|
54
|
-
payload:
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
81
|
+
payload: devices
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
authenticated.post("/api/endpoint-tools/devices/revoke", async (c) => {
|
|
85
|
+
const body = await c.req.json().catch(() => null);
|
|
86
|
+
if (!Array.isArray(body?.ids) || body.ids.length === 0 || body.ids.length > 100 || body.ids.some((id) => typeof id !== "string" || !id.trim())) return c.json({
|
|
87
|
+
ok: false,
|
|
88
|
+
error: {
|
|
89
|
+
code: "BAD_REQUEST",
|
|
90
|
+
message: "Expected 1 to 100 device ids"
|
|
91
|
+
}
|
|
92
|
+
}, 400);
|
|
93
|
+
const results = [...new Set(body.ids.map((id) => id.trim()))].map((id) => {
|
|
94
|
+
const access = getDevice(id);
|
|
95
|
+
const principal = getEndpointPrincipal(id);
|
|
96
|
+
const accessRevoked = Boolean(access && access.revokedAt === void 0 && revokeDevice(id));
|
|
97
|
+
const principalRevoked = Boolean(principal && principal.revokedAt === void 0 && revokeEndpointPrincipal(id));
|
|
98
|
+
if (accessRevoked) {
|
|
99
|
+
deps.service.realtime.disconnectPrincipal(id);
|
|
100
|
+
deps.service.voiceRealtime.disconnectPrincipal(id);
|
|
101
|
+
}
|
|
102
|
+
if (principalRevoked) {
|
|
103
|
+
for (const endpoint of deps.service.endpointTools.registry.list()) if (endpoint.principalId === id) deps.service.endpointTools.disconnect(endpoint.endpointId, "Device revoked");
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
id,
|
|
107
|
+
found: Boolean(access || principal),
|
|
108
|
+
revoked: accessRevoked || principalRevoked
|
|
109
|
+
};
|
|
110
|
+
});
|
|
111
|
+
return c.json({
|
|
112
|
+
ok: true,
|
|
113
|
+
payload: { results }
|
|
58
114
|
});
|
|
59
115
|
});
|
|
60
116
|
authenticated.post("/api/endpoint-tools/principals", async (c) => {
|
|
@@ -123,36 +179,36 @@ function registerEndpointToolRoutes(authenticated, deps) {
|
|
|
123
179
|
payload: principal
|
|
124
180
|
}, 201);
|
|
125
181
|
});
|
|
126
|
-
authenticated.
|
|
127
|
-
const
|
|
128
|
-
|
|
182
|
+
authenticated.get("/api/endpoint-tools/invocations", (c) => {
|
|
183
|
+
const page = Number(c.req.query("page") ?? 1);
|
|
184
|
+
const pageSize = Number(c.req.query("pageSize") ?? 20);
|
|
185
|
+
const status = c.req.query("status");
|
|
186
|
+
const effect = c.req.query("effect");
|
|
187
|
+
if (!Number.isInteger(page) || page < 1 || !Number.isInteger(pageSize) || pageSize < 1 || pageSize > 100 || status && ![
|
|
188
|
+
"running",
|
|
189
|
+
"succeeded",
|
|
190
|
+
"failed"
|
|
191
|
+
].includes(status) || effect && ![
|
|
192
|
+
"read",
|
|
193
|
+
"write",
|
|
194
|
+
"destructive"
|
|
195
|
+
].includes(effect)) return c.json({
|
|
129
196
|
ok: false,
|
|
130
197
|
error: {
|
|
131
198
|
code: "BAD_REQUEST",
|
|
132
|
-
message: "
|
|
199
|
+
message: "Invalid invocation filters"
|
|
133
200
|
}
|
|
134
201
|
}, 400);
|
|
135
|
-
if (!revokeEndpointPrincipal(principalId)) return c.json({
|
|
136
|
-
ok: false,
|
|
137
|
-
error: {
|
|
138
|
-
code: "NOT_FOUND",
|
|
139
|
-
message: "Endpoint principal not found"
|
|
140
|
-
}
|
|
141
|
-
}, 404);
|
|
142
|
-
for (const endpoint of deps.service.endpointTools.registry.list()) if (endpoint.principalId === principalId) deps.service.endpointTools.disconnect(endpoint.endpointId, "Endpoint principal revoked");
|
|
143
|
-
return c.json({
|
|
144
|
-
ok: true,
|
|
145
|
-
payload: {
|
|
146
|
-
principalId,
|
|
147
|
-
revoked: true
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
authenticated.get("/api/endpoint-tools/invocations", (c) => {
|
|
152
|
-
const limit = Number(c.req.query("limit") ?? 100);
|
|
153
202
|
return c.json({
|
|
154
203
|
ok: true,
|
|
155
|
-
payload:
|
|
204
|
+
payload: listEndpointToolInvocationAuditPage({
|
|
205
|
+
page,
|
|
206
|
+
pageSize,
|
|
207
|
+
query: c.req.query("query"),
|
|
208
|
+
principalId: c.req.query("principalId"),
|
|
209
|
+
status,
|
|
210
|
+
effect
|
|
211
|
+
})
|
|
156
212
|
});
|
|
157
213
|
});
|
|
158
214
|
authenticated.get("/api/endpoint-tools/bindings/:conversationId", (c) => {
|
|
@@ -3,7 +3,7 @@ import { canonicalizeConfiguredMcpServer, normalizeConfiguredMcpServers } from "
|
|
|
3
3
|
import { loadMergedBundleMcpConfig } from "../../../agent/mcp/bundle-mcp-config.js";
|
|
4
4
|
import { getWorkspacePath } from "../../../config/workspace-path-helpers.js";
|
|
5
5
|
import { getMcpOAuthManager } from "../../../agent/mcp/oauth/mcp-oauth-manager.js";
|
|
6
|
-
import { listBundleMcpServerCapabilitiesForGateway, listBundleMcpServerToolsForGateway } from "../../../agent/mcp/bundle-mcp-gateway.js";
|
|
6
|
+
import { listBundleMcpResourcesForGateway, listBundleMcpServerCapabilitiesForGateway, listBundleMcpServerToolsForGateway } from "../../../agent/mcp/bundle-mcp-gateway.js";
|
|
7
7
|
//#region src/gateway/hono/routes/mcp.ts
|
|
8
8
|
function registerMcpRoutes(authenticated, deps) {
|
|
9
9
|
const resolveServer = (id) => {
|
|
@@ -36,6 +36,37 @@ function registerMcpRoutes(authenticated, deps) {
|
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
38
|
});
|
|
39
|
+
authenticated.get("/api/mcp/resources", async (c) => {
|
|
40
|
+
const cfg = deps.service.currentConfig;
|
|
41
|
+
const workspaceDir = getWorkspacePath(cfg) || "./workspace";
|
|
42
|
+
const query = (c.req.query("q") ?? "").trim().toLocaleLowerCase();
|
|
43
|
+
const serverId = (c.req.query("serverId") ?? "").trim();
|
|
44
|
+
try {
|
|
45
|
+
const items = (await listBundleMcpResourcesForGateway({
|
|
46
|
+
workspaceDir,
|
|
47
|
+
cfg
|
|
48
|
+
})).filter((resource) => {
|
|
49
|
+
if (serverId && resource.serverId !== serverId) return false;
|
|
50
|
+
if (!query) return true;
|
|
51
|
+
return [
|
|
52
|
+
resource.name,
|
|
53
|
+
resource.title,
|
|
54
|
+
resource.description,
|
|
55
|
+
resource.uri,
|
|
56
|
+
resource.serverId
|
|
57
|
+
].some((value) => value?.toLocaleLowerCase().includes(query));
|
|
58
|
+
}).slice(0, 20);
|
|
59
|
+
return c.json({
|
|
60
|
+
ok: true,
|
|
61
|
+
payload: { resources: items }
|
|
62
|
+
});
|
|
63
|
+
} catch (err) {
|
|
64
|
+
return c.json({
|
|
65
|
+
ok: false,
|
|
66
|
+
error: err instanceof Error ? err.message : String(err)
|
|
67
|
+
}, 500);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
39
70
|
authenticated.get("/api/mcp/servers/:id/oauth", async (c) => {
|
|
40
71
|
const id = c.req.param("id");
|
|
41
72
|
const server = resolveServer(id);
|
|
@@ -62,9 +62,10 @@ export declare function submitSessionInput(c: Context, deps: AuthenticatedRouteD
|
|
|
62
62
|
url?: string;
|
|
63
63
|
capturedAt?: number;
|
|
64
64
|
documentId?: string;
|
|
65
|
+
fileKind?: "file" | "directory";
|
|
65
66
|
}[];
|
|
66
67
|
contextSnapshots?: {
|
|
67
|
-
kind: import("../../../agent/source-context/types.js").SessionSourceBinding["kind"] | "task" | "browser_page" | "app_context";
|
|
68
|
+
kind: import("../../../agent/source-context/types.js").SessionSourceBinding["kind"] | "task" | "file" | "session" | "mcp_resource" | "browser_tab" | "browser_page" | "app_context";
|
|
68
69
|
sourceId: string;
|
|
69
70
|
version: string;
|
|
70
71
|
title: string;
|
|
@@ -79,6 +80,7 @@ export declare function submitSessionInput(c: Context, deps: AuthenticatedRouteD
|
|
|
79
80
|
url?: string;
|
|
80
81
|
capturedAt?: number;
|
|
81
82
|
documentId?: string;
|
|
83
|
+
fileKind?: "file" | "directory";
|
|
82
84
|
appContext?: {
|
|
83
85
|
version: 1;
|
|
84
86
|
clientInstanceId: string;
|
|
@@ -196,9 +198,10 @@ export declare function replaceLatestSessionTurn(c: Context, deps: Authenticated
|
|
|
196
198
|
url?: string;
|
|
197
199
|
capturedAt?: number;
|
|
198
200
|
documentId?: string;
|
|
201
|
+
fileKind?: "file" | "directory";
|
|
199
202
|
}[];
|
|
200
203
|
contextSnapshots?: {
|
|
201
|
-
kind: import("../../../agent/source-context/types.js").SessionSourceBinding["kind"] | "task" | "browser_page" | "app_context";
|
|
204
|
+
kind: import("../../../agent/source-context/types.js").SessionSourceBinding["kind"] | "task" | "file" | "session" | "mcp_resource" | "browser_tab" | "browser_page" | "app_context";
|
|
202
205
|
sourceId: string;
|
|
203
206
|
version: string;
|
|
204
207
|
title: string;
|
|
@@ -213,6 +216,7 @@ export declare function replaceLatestSessionTurn(c: Context, deps: Authenticated
|
|
|
213
216
|
url?: string;
|
|
214
217
|
capturedAt?: number;
|
|
215
218
|
documentId?: string;
|
|
219
|
+
fileKind?: "file" | "directory";
|
|
216
220
|
appContext?: {
|
|
217
221
|
version: 1;
|
|
218
222
|
clientInstanceId: string;
|
|
@@ -39,7 +39,7 @@ async function submitSessionInput(c, deps, conversationId, options) {
|
|
|
39
39
|
ok: false,
|
|
40
40
|
error: {
|
|
41
41
|
code: "BAD_REQUEST",
|
|
42
|
-
message: `contextRefs must contain at most ${MAX_TURN_CONTEXTS} valid
|
|
42
|
+
message: `contextRefs must contain at most ${MAX_TURN_CONTEXTS} valid source references`
|
|
43
43
|
}
|
|
44
44
|
}, 400);
|
|
45
45
|
const browserContexts = browserPageContextsInputSchema.safeParse(body.browserContexts ?? []);
|
|
@@ -201,7 +201,7 @@ async function submitSessionInput(c, deps, conversationId, options) {
|
|
|
201
201
|
ok: false,
|
|
202
202
|
error: {
|
|
203
203
|
code: result.code,
|
|
204
|
-
message: result.code === "CONTEXT_UNAVAILABLE" ? "A referenced
|
|
204
|
+
message: result.code === "CONTEXT_UNAVAILABLE" ? "A referenced source changed or is no longer available. Select it again." : "Input was not accepted"
|
|
205
205
|
}
|
|
206
206
|
}, result.code === "SESSION_CHANGED" || result.code === "QUEUE_FULL" || result.code === "CONTEXT_UNAVAILABLE" ? 409 : 400);
|
|
207
207
|
return c.json({
|
|
@@ -235,7 +235,7 @@ async function replaceLatestSessionTurn(c, deps, conversationId, targetTurnId) {
|
|
|
235
235
|
ok: false,
|
|
236
236
|
error: {
|
|
237
237
|
code: "BAD_REQUEST",
|
|
238
|
-
message: `contextRefs must contain at most ${MAX_TURN_CONTEXTS} valid
|
|
238
|
+
message: `contextRefs must contain at most ${MAX_TURN_CONTEXTS} valid source references`
|
|
239
239
|
}
|
|
240
240
|
}, 400);
|
|
241
241
|
const content = typeof body.content === "string" ? body.content : "";
|
|
@@ -321,7 +321,7 @@ async function replaceLatestSessionTurn(c, deps, conversationId, targetTurnId) {
|
|
|
321
321
|
});
|
|
322
322
|
if (result.ok === false) {
|
|
323
323
|
const status = result.code === "TARGET_NOT_FOUND" ? 404 : result.code === "BAD_REQUEST" ? 400 : 409;
|
|
324
|
-
const message = result.code === "NOT_LATEST" ? "Only the latest user turn can be replaced" : result.code === "SESSION_BUSY" ? "Session has pending input" : result.code === "TARGET_NOT_FOUND" ? "User turn was not found" : result.code === "CONTEXT_UNAVAILABLE" ? "A referenced
|
|
324
|
+
const message = result.code === "NOT_LATEST" ? "Only the latest user turn can be replaced" : result.code === "SESSION_BUSY" ? "Session has pending input" : result.code === "TARGET_NOT_FOUND" ? "User turn was not found" : result.code === "CONTEXT_UNAVAILABLE" ? "A referenced source changed or is no longer available. Select it again." : "Replacement input was not accepted";
|
|
325
325
|
return c.json({
|
|
326
326
|
ok: false,
|
|
327
327
|
error: {
|
|
@@ -21,8 +21,8 @@ import { VoiceSessionCreationError, resolveStreamingStt, resolveStreamingTts } f
|
|
|
21
21
|
import { getGatewayPrincipal } from "../../security/gateway-principal.js";
|
|
22
22
|
import { createGatewayRouteLogger } from "../lib/route-logger.js";
|
|
23
23
|
import { selectPlatformVoice, voiceSettingsCatalog } from "../../../voice/platform-settings.js";
|
|
24
|
-
import { listLocalVoiceModelStatuses, removeLocalVoiceModel, startLocalVoiceModelInstall } from "../../../voice/local/model-manager.js";
|
|
25
24
|
import { listTtsProvidersForApi } from "../../../voice/tts/list-providers.js";
|
|
25
|
+
import { listLocalVoiceModelStatuses, removeLocalVoiceModel, startLocalVoiceModelInstall } from "../../../voice/local/model-manager.js";
|
|
26
26
|
import { z } from "zod";
|
|
27
27
|
//#region src/gateway/hono/routes/voice.ts
|
|
28
28
|
init_voice();
|
|
@@ -22,7 +22,7 @@ export interface GatewayAgentRunnerOptions {
|
|
|
22
22
|
emit: (type: string, payload: unknown) => void;
|
|
23
23
|
publishRealtime: (topic: string, event: string, data: unknown) => void;
|
|
24
24
|
completeRealtimeTopic: (topic: string) => void;
|
|
25
|
-
resolveTurnContext: (ref: TurnContextRef) => Promise<AgentSourceContext | null>;
|
|
25
|
+
resolveTurnContext: (ref: TurnContextRef, conversationId: string) => Promise<AgentSourceContext | null>;
|
|
26
26
|
}
|
|
27
27
|
export declare class GatewayAgentRunner {
|
|
28
28
|
private readonly opts;
|
|
@@ -76,7 +76,7 @@ var GatewayAgentRunner = class {
|
|
|
76
76
|
size: ref.size
|
|
77
77
|
}));
|
|
78
78
|
},
|
|
79
|
-
prepareContexts: async (refs) => {
|
|
79
|
+
prepareContexts: async (conversationId, refs) => {
|
|
80
80
|
if (!refs?.length) return void 0;
|
|
81
81
|
const unique = /* @__PURE__ */ new Map();
|
|
82
82
|
for (const ref of refs) {
|
|
@@ -87,7 +87,7 @@ var GatewayAgentRunner = class {
|
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
89
|
if (unique.size > MAX_TURN_CONTEXTS) throw new Error(`A message can reference at most ${MAX_TURN_CONTEXTS} sources`);
|
|
90
|
-
const contexts = await Promise.all([...unique.values()].map((ref) => opts.resolveTurnContext(ref)));
|
|
90
|
+
const contexts = await Promise.all([...unique.values()].map((ref) => opts.resolveTurnContext(ref, conversationId)));
|
|
91
91
|
if (contexts.some((context) => context === null)) throw new Error("A referenced source is unavailable or has changed; select it again");
|
|
92
92
|
return fitSourceContextsToBudget(contexts.filter((context) => context !== null));
|
|
93
93
|
},
|
|
@@ -2,10 +2,6 @@ import type { AgentSourceContext } from '../../agent/source-context/types.js';
|
|
|
2
2
|
import { type CapabilityDispatcher } from '../../capabilities/runtime/dispatcher.js';
|
|
3
3
|
import type { ResolvedGatewayAuth } from '../auth.js';
|
|
4
4
|
import type { GatewayPrincipal } from '../security/gateway-principal.js';
|
|
5
|
-
export interface AppContextGrant {
|
|
6
|
-
principal: GatewayPrincipal;
|
|
7
|
-
authRevision: string;
|
|
8
|
-
}
|
|
9
5
|
/** A queued read retains its original scope ceiling, but never a revoked identity. */
|
|
10
6
|
export declare function checkAppContextAccess(source: AgentSourceContext, dispatcher: CapabilityDispatcher, auth: ResolvedGatewayAuth): Promise<void>;
|
|
11
7
|
export declare function prepareAppContext(input: unknown, principal: GatewayPrincipal, auth: ResolvedGatewayAuth, dispatcher: CapabilityDispatcher, previous?: AgentSourceContext): Promise<AgentSourceContext>;
|
|
@@ -11,9 +11,9 @@ import { resolveExecutionContext } from "../../tasks/execution-context.js";
|
|
|
11
11
|
import { TaskRunCoordinator } from "../../tasks/task-run-coordinator.js";
|
|
12
12
|
import { formatAgentRunErrorForClient } from "../../agent/client-error-format.js";
|
|
13
13
|
import "../chat-limits.js";
|
|
14
|
+
import { prependEnvelopeTimestamp } from "../../channels/envelope-timestamp.js";
|
|
14
15
|
import { ChatStreamMapper } from "../chat-stream/mapper.js";
|
|
15
16
|
import { markdownNotificationPreview } from "../../notifications/plain-text.js";
|
|
16
|
-
import { prependEnvelopeTimestamp } from "../../channels/envelope-timestamp.js";
|
|
17
17
|
import { resolveWebchatConversationId } from "../resolve-webchat-session-key.js";
|
|
18
18
|
import { recordExplicitRelationshipFollowUp } from "../../user-context/relationship-continuity.js";
|
|
19
19
|
import { coalesceThinkingDeltas } from "../chat-stream/thinking-delta-coalescer.js";
|
|
@@ -39,7 +39,7 @@ export declare class SessionInputCoordinator {
|
|
|
39
39
|
summary: string;
|
|
40
40
|
}>;
|
|
41
41
|
prepareAttachments: (conversationId: string, attachments?: UserTurnAttachment[]) => Promise<UserTurnAttachment[] | undefined>;
|
|
42
|
-
prepareContexts: (contextRefs?: TurnContextRef[]) => Promise<AgentSourceContext[] | undefined>;
|
|
42
|
+
prepareContexts: (conversationId: string, contextRefs?: TurnContextRef[]) => Promise<AgentSourceContext[] | undefined>;
|
|
43
43
|
steer: (conversationId: string, content: string) => Promise<boolean>;
|
|
44
44
|
emit: (type: string, payload: unknown) => void;
|
|
45
45
|
});
|
|
@@ -109,7 +109,7 @@ var SessionInputCoordinator = class {
|
|
|
109
109
|
const attachments = await this.deps.prepareAttachments(conversationId, input.attachments);
|
|
110
110
|
let sourceContexts;
|
|
111
111
|
try {
|
|
112
|
-
sourceContexts = fitSourceContextsToBudget([...await this.deps.prepareContexts(input.contextRefs) ?? [], ...input.sourceContexts ?? []]);
|
|
112
|
+
sourceContexts = fitSourceContextsToBudget([...await this.deps.prepareContexts(conversationId, input.contextRefs) ?? [], ...input.sourceContexts ?? []]);
|
|
113
113
|
} catch (err) {
|
|
114
114
|
log.warn({
|
|
115
115
|
err,
|
|
@@ -185,7 +185,7 @@ var SessionInputCoordinator = class {
|
|
|
185
185
|
const attachments = await this.deps.prepareAttachments(conversationId, input.attachments);
|
|
186
186
|
let sourceContexts;
|
|
187
187
|
try {
|
|
188
|
-
sourceContexts = fitSourceContextsToBudget([...await this.deps.prepareContexts(input.contextRefs) ?? [], ...input.sourceContexts ?? []]);
|
|
188
|
+
sourceContexts = fitSourceContextsToBudget([...await this.deps.prepareContexts(conversationId, input.contextRefs) ?? [], ...input.sourceContexts ?? []]);
|
|
189
189
|
} catch (err) {
|
|
190
190
|
log.warn({
|
|
191
191
|
err,
|
|
@@ -310,7 +310,7 @@ var SessionInputCoordinator = class {
|
|
|
310
310
|
if (body.contextRefs !== void 0) {
|
|
311
311
|
const existing = getSessionInputById(conversationId, id);
|
|
312
312
|
if (!contextRefsMatchFrozenSnapshot(body.contextRefs, existing?.contextRefs)) try {
|
|
313
|
-
const resolved = await this.deps.prepareContexts(body.contextRefs) ?? [];
|
|
313
|
+
const resolved = await this.deps.prepareContexts(conversationId, body.contextRefs) ?? [];
|
|
314
314
|
sourceContexts = fitSourceContextsToBudget([...existing?.contextSnapshots?.filter((source) => source.kind !== "note" && source.kind !== "task") ?? [], ...resolved]);
|
|
315
315
|
} catch (err) {
|
|
316
316
|
log.warn({
|
|
@@ -7,6 +7,7 @@ import { createLogger } from "../utils/logger/index.js";
|
|
|
7
7
|
import { init_logger } from "../utils/logger.js";
|
|
8
8
|
import { closeXopcDatabase, openXopcDatabase } from "../storage/sqlite/connection.js";
|
|
9
9
|
import { getSqliteDatabase, init_transaction } from "../storage/sqlite/transaction.js";
|
|
10
|
+
import { getBrowserTabBindingById } from "../storage/sqlite/browser-tab-binding-repository.js";
|
|
10
11
|
import { findSessionInput, init_session_input_repository, insertSessionInput } from "../storage/sqlite/session-input-repository.js";
|
|
11
12
|
import { TaskRepository } from "../tasks/task-repository.js";
|
|
12
13
|
import { TaskRunRepository, init_task_run_repository } from "../tasks/task-run-repository.js";
|
|
@@ -37,6 +38,7 @@ import { ProjectService } from "../projects/project-service.js";
|
|
|
37
38
|
import { resolveProjectAgentId } from "../projects/project-agent.js";
|
|
38
39
|
import "../projects/index.js";
|
|
39
40
|
import { resolveEffectiveGatewayPort } from "./host.js";
|
|
41
|
+
import { RealtimeExtensionBrowserProvider } from "../browser/providers/realtime-extension.js";
|
|
40
42
|
import { onSessionTranscriptUpdate } from "../session/transcript-events.js";
|
|
41
43
|
import { buildNoteAgentContext } from "../notes/agent-context.js";
|
|
42
44
|
import { NotesStore } from "../notes/store.js";
|
|
@@ -59,6 +61,9 @@ import "../infra/bus/index.js";
|
|
|
59
61
|
import { collectMediaUrisFromMessages, deleteMediaUris } from "../media/session-references.js";
|
|
60
62
|
import { AgentService } from "../agent/service.js";
|
|
61
63
|
import { ensureStarterAgentsInitialized } from "../agent/starter-agents.js";
|
|
64
|
+
import { setPairingBroadcastSink } from "../channels/pairing/pairing-events.js";
|
|
65
|
+
import { registerClarificationChannelRuntime } from "./clarify-runtime.js";
|
|
66
|
+
import { ChannelManager } from "../channels/manager.js";
|
|
62
67
|
import { getWorkspacePath } from "../config/workspace-path-helpers.js";
|
|
63
68
|
import "../config/index.js";
|
|
64
69
|
import { ManagedComposioEventPoller } from "../connectors/composio-managed-events.js";
|
|
@@ -77,16 +82,18 @@ import { EndpointToolRuntime } from "../endpoint-tools/runtime.js";
|
|
|
77
82
|
import "../endpoint-tools/index.js";
|
|
78
83
|
import { assertGatewayAuthConfigured, extractToken, resolveGatewayAuth, validateToken } from "./auth.js";
|
|
79
84
|
import { prepareAutomationAgentSession } from "./automation-agent-session.js";
|
|
80
|
-
import { registerClarificationChannelRuntime } from "./clarify-runtime.js";
|
|
81
85
|
import { stopTailscaleExposure } from "./tailscale-lifecycle.js";
|
|
86
|
+
import { getGatewayFileSpaceService } from "./file-space-service.js";
|
|
82
87
|
import { createBackgroundTask } from "../infra/background-task.js";
|
|
83
88
|
import { buildTaskAgentContext } from "../agent/source-context/task-context.js";
|
|
89
|
+
import { buildFileAgentContext } from "../agent/source-context/file-context.js";
|
|
90
|
+
import { buildSessionAgentContext } from "../agent/source-context/session-context.js";
|
|
91
|
+
import { buildMcpResourceAgentContext } from "../agent/source-context/mcp-resource-context.js";
|
|
92
|
+
import { buildBrowserTabAgentContext } from "../agent/source-context/browser-tab.js";
|
|
84
93
|
import { WorkDiscoveryService } from "../work-discovery/service.js";
|
|
85
94
|
import { buildVoiceMemoryContext } from "../voice/realtime/memory-context.js";
|
|
86
95
|
import { buildVoicePersonaContext } from "../voice/realtime/persona-context.js";
|
|
87
96
|
import { voiceMemoryBudget, voicePersonaBudget } from "../voice/realtime/conversation-context.js";
|
|
88
|
-
import { setPairingBroadcastSink } from "../channels/pairing/pairing-events.js";
|
|
89
|
-
import { ChannelManager } from "../channels/manager.js";
|
|
90
97
|
import "../notes/index.js";
|
|
91
98
|
import { buildWorkflowChildTools } from "../agent/workflow/workflow-child-tools.js";
|
|
92
99
|
import { WorkflowRunService } from "../workflows/service/workflow-run-service.js";
|
|
@@ -470,9 +477,39 @@ var GatewayService = class {
|
|
|
470
477
|
getAgentService: () => this.ensureAgentService(),
|
|
471
478
|
getChannelManager: () => this.channelManager,
|
|
472
479
|
getConfig: () => this.config,
|
|
473
|
-
resolveTurnContext: async (ref) => {
|
|
480
|
+
resolveTurnContext: async (ref, conversationId) => {
|
|
474
481
|
if (ref.kind === "task") return buildTaskAgentContext(new TaskRepository().get(ref.sourceId), ref.expectedVersion);
|
|
475
|
-
if (ref.kind
|
|
482
|
+
if (ref.kind === "file") {
|
|
483
|
+
const files = getGatewayFileSpaceService(this);
|
|
484
|
+
const space = await files.forContext("session", conversationId).catch(() => null);
|
|
485
|
+
if (!space) return null;
|
|
486
|
+
return buildFileAgentContext(files, ref.sourceId, ref.expectedVersion, space.id);
|
|
487
|
+
}
|
|
488
|
+
if (ref.kind === "session") {
|
|
489
|
+
const [metadata, messages] = await Promise.all([this.sessionIndex.getSessionMetadata(ref.sourceId), this.sessionIndex.getStore().loadMessages(ref.sourceId)]);
|
|
490
|
+
return buildSessionAgentContext(metadata, messages, ref.expectedVersion);
|
|
491
|
+
}
|
|
492
|
+
if (ref.kind === "mcp_resource") return buildMcpResourceAgentContext({
|
|
493
|
+
workspaceDir: this.currentWorkspacePath,
|
|
494
|
+
config: this.config,
|
|
495
|
+
sourceId: ref.sourceId,
|
|
496
|
+
expectedVersion: ref.expectedVersion
|
|
497
|
+
});
|
|
498
|
+
if (ref.kind === "browser_tab") {
|
|
499
|
+
const binding = getBrowserTabBindingById(ref.sourceId);
|
|
500
|
+
if (!binding || binding.conversationId !== conversationId || ref.expectedVersion && ref.expectedVersion !== binding.documentId) return null;
|
|
501
|
+
const wire = await new RealtimeExtensionBrowserProvider(this.endpointTools).send({
|
|
502
|
+
action: "observe",
|
|
503
|
+
sessionId: `context:${binding.conversationId}`,
|
|
504
|
+
target: {
|
|
505
|
+
kind: "attached_tab",
|
|
506
|
+
bindingId: binding.id
|
|
507
|
+
},
|
|
508
|
+
visual: "never"
|
|
509
|
+
}).catch(() => null);
|
|
510
|
+
if (!wire?.result.ok || !wire.result.receipt.observation) return null;
|
|
511
|
+
return buildBrowserTabAgentContext(ref.sourceId, wire.result.receipt.observation, ref.expectedVersion);
|
|
512
|
+
}
|
|
476
513
|
const note = await this.notesService.getNote(ref.sourceId);
|
|
477
514
|
if (!note || note.status === "trashed") return null;
|
|
478
515
|
if (ref.expectedVersion && ref.expectedVersion !== String(note.updatedAt)) return null;
|
|
@@ -35,13 +35,29 @@ async function fuzzySearchWorkspaceFiles(workspaceRoot, query, limit) {
|
|
|
35
35
|
}
|
|
36
36
|
const q = query.trim();
|
|
37
37
|
const capped = Math.min(Math.max(limit, 1), 50);
|
|
38
|
+
const directories = /* @__PURE__ */ new Set();
|
|
39
|
+
for (const file of files) {
|
|
40
|
+
const parts = file.split("/");
|
|
41
|
+
for (let end = 1; end < parts.length; end += 1) {
|
|
42
|
+
const directory = parts.slice(0, end).join("/");
|
|
43
|
+
if (directory) directories.add(directory);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const candidates = [...directories].map((path) => ({
|
|
47
|
+
name: basename(path),
|
|
48
|
+
path,
|
|
49
|
+
isDirectory: true
|
|
50
|
+
}));
|
|
51
|
+
candidates.push(...files.map((path) => ({
|
|
52
|
+
name: basename(path),
|
|
53
|
+
path,
|
|
54
|
+
isDirectory: false
|
|
55
|
+
})));
|
|
38
56
|
const rows = [];
|
|
39
57
|
if (!q) {
|
|
40
|
-
const sorted =
|
|
41
|
-
for (const
|
|
42
|
-
|
|
43
|
-
path: rel,
|
|
44
|
-
isDirectory: false,
|
|
58
|
+
const sorted = candidates.sort((a, b) => a.path.localeCompare(b.path));
|
|
59
|
+
for (const candidate of sorted.slice(0, capped)) rows.push({
|
|
60
|
+
...candidate,
|
|
45
61
|
score: 0
|
|
46
62
|
});
|
|
47
63
|
return rows.map(({ name, path, isDirectory }) => ({
|
|
@@ -50,16 +66,13 @@ async function fuzzySearchWorkspaceFiles(workspaceRoot, query, limit) {
|
|
|
50
66
|
isDirectory
|
|
51
67
|
}));
|
|
52
68
|
}
|
|
53
|
-
for (const
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
const scoreName = fuzzySubsequenceScore(q, name);
|
|
69
|
+
for (const candidate of candidates) {
|
|
70
|
+
const scorePath = fuzzySubsequenceScore(q, candidate.path);
|
|
71
|
+
const scoreName = fuzzySubsequenceScore(q, candidate.name);
|
|
57
72
|
const score = Math.max(scorePath ?? -Infinity, scoreName ?? -Infinity);
|
|
58
73
|
if (score === -Infinity) continue;
|
|
59
74
|
rows.push({
|
|
60
|
-
|
|
61
|
-
path: rel,
|
|
62
|
-
isDirectory: false,
|
|
75
|
+
...candidate,
|
|
63
76
|
score
|
|
64
77
|
});
|
|
65
78
|
}
|
|
@@ -66,10 +66,10 @@ export declare const RuntimeCommandSchema: z.ZodObject<{
|
|
|
66
66
|
read: "read";
|
|
67
67
|
write: "write";
|
|
68
68
|
execute: "execute";
|
|
69
|
+
admin: "admin";
|
|
69
70
|
send: "send";
|
|
70
71
|
purchase: "purchase";
|
|
71
72
|
publish: "publish";
|
|
72
|
-
admin: "admin";
|
|
73
73
|
}>>;
|
|
74
74
|
}, z.core.$strict>;
|
|
75
75
|
data: z.ZodObject<{
|
|
@@ -152,10 +152,10 @@ export declare const AgentManifestSchema: z.ZodObject<{
|
|
|
152
152
|
read: "read";
|
|
153
153
|
write: "write";
|
|
154
154
|
execute: "execute";
|
|
155
|
+
admin: "admin";
|
|
155
156
|
send: "send";
|
|
156
157
|
purchase: "purchase";
|
|
157
158
|
publish: "publish";
|
|
158
|
-
admin: "admin";
|
|
159
159
|
}>>;
|
|
160
160
|
}, z.core.$strict>;
|
|
161
161
|
data: z.ZodObject<{
|
|
@@ -15,7 +15,7 @@ export interface ClientHistoryMessage {
|
|
|
15
15
|
/** Whitelisted display metadata; never includes source snapshot text. */
|
|
16
16
|
metadata?: {
|
|
17
17
|
sourceContexts?: Array<{
|
|
18
|
-
kind: 'note' | 'task' | 'browser_page';
|
|
18
|
+
kind: 'note' | 'task' | 'file' | 'session' | 'browser_tab' | 'browser_page' | 'mcp_resource';
|
|
19
19
|
sourceId: string;
|
|
20
20
|
version: string;
|
|
21
21
|
title: string;
|
|
@@ -24,6 +24,7 @@ export interface ClientHistoryMessage {
|
|
|
24
24
|
url?: string;
|
|
25
25
|
capturedAt?: number;
|
|
26
26
|
documentId?: string;
|
|
27
|
+
fileKind?: 'file' | 'directory';
|
|
27
28
|
}>;
|
|
28
29
|
turnOutcome?: TurnOutcome;
|
|
29
30
|
};
|
|
@@ -11,7 +11,7 @@ function sourceContextDisplayMetadata(metadata) {
|
|
|
11
11
|
const sourceContexts = rows.flatMap((value) => {
|
|
12
12
|
if (!value || typeof value !== "object" || Array.isArray(value)) return [];
|
|
13
13
|
const row = value;
|
|
14
|
-
if (row.kind !== "note" && row.kind !== "task" && row.kind !== "browser_page" || typeof row.sourceId !== "string" || typeof row.version !== "string" || typeof row.title !== "string") return [];
|
|
14
|
+
if (row.kind !== "note" && row.kind !== "task" && row.kind !== "file" && row.kind !== "session" && row.kind !== "browser_tab" && row.kind !== "browser_page" && row.kind !== "mcp_resource" || typeof row.sourceId !== "string" || typeof row.version !== "string" || typeof row.title !== "string") return [];
|
|
15
15
|
return [{
|
|
16
16
|
kind: row.kind,
|
|
17
17
|
sourceId: row.sourceId,
|
|
@@ -21,7 +21,8 @@ function sourceContextDisplayMetadata(metadata) {
|
|
|
21
21
|
...row.truncated === true ? { truncated: true } : {},
|
|
22
22
|
...typeof row.url === "string" ? { url: row.url } : {},
|
|
23
23
|
...typeof row.capturedAt === "number" ? { capturedAt: row.capturedAt } : {},
|
|
24
|
-
...typeof row.documentId === "string" ? { documentId: row.documentId } : {}
|
|
24
|
+
...typeof row.documentId === "string" ? { documentId: row.documentId } : {},
|
|
25
|
+
...row.kind === "file" && (row.fileKind === "file" || row.fileKind === "directory") ? { fileKind: row.fileKind } : {}
|
|
25
26
|
}];
|
|
26
27
|
});
|
|
27
28
|
return sourceContexts.length ? { sourceContexts } : void 0;
|
|
@@ -22,4 +22,18 @@ export declare function finishEndpointToolInvocationAudit(params: {
|
|
|
22
22
|
errorMessage?: string;
|
|
23
23
|
completedAt?: number;
|
|
24
24
|
}): void;
|
|
25
|
-
export
|
|
25
|
+
export interface EndpointToolInvocationAuditPage {
|
|
26
|
+
items: EndpointToolInvocationAudit[];
|
|
27
|
+
page: number;
|
|
28
|
+
pageSize: number;
|
|
29
|
+
total: number;
|
|
30
|
+
totalPages: number;
|
|
31
|
+
}
|
|
32
|
+
export declare function listEndpointToolInvocationAuditPage(options?: {
|
|
33
|
+
page?: number;
|
|
34
|
+
pageSize?: number;
|
|
35
|
+
query?: string;
|
|
36
|
+
principalId?: string;
|
|
37
|
+
status?: EndpointToolInvocationAudit['status'];
|
|
38
|
+
effect?: EndpointEffect;
|
|
39
|
+
}): EndpointToolInvocationAuditPage;
|