@xopcai/xopc 0.0.475 → 0.0.476
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/telegram/xopc.extension.json +1 -1
- package/dist/gateway/server/chunks.bin +916 -865
- package/dist/gateway/server/chunks.json +1 -1
- package/dist/gateway/server/schema.sql +13 -0
- package/dist/gateway/server/upgrades/281_session_agent_reactions.sql +13 -0
- package/dist/gateway/static/root/assets/{apps-page-BknrhGJ9.js → apps-page-B9Ho8S53.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-C1s0jwt9.js → automations-page-BL6ASYrU.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-DIwYmYb1.js → automations-workspace-BFk-AF43.js} +2 -2
- package/dist/gateway/static/root/assets/{capabilities-page-2vSlbM-C.js → capabilities-page-D9EpUcuB.js} +2 -2
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-CfEq0ob4.js → capabilities-settings-panel-ComYXaP1.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-Bi0L3VP1.js → channels-Aa2Iun4r.js} +1 -1
- package/dist/gateway/static/root/assets/chat-page-BbahuZ59.js +72 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-CYAZic7B.js → chat-terminal-dock-BALrP7_l.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-Bn6Z5xfy.js → connectors-page-BUqNvStL.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-CNrjzlYX.js → extension-debug-page-gW4GEEcj.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-iframe-host-DnautIj8.js → extension-iframe-host-DOPywUKI.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-message-router-D81YD6lm.js → extension-message-router-TTAx3dPv.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-BEY_ML_j.js → extension-page-Iq7vFC-g.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-provider-CrMilva_.js → extension-provider-BNnLkq95.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-QRbfKUay.js → extension-settings-page-C0oLjaz6.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-Cs1kOdTH.js → home-page-pT-lEQsu.js} +3 -3
- package/dist/gateway/static/root/assets/index-BtHMU5k4.css +1 -0
- package/dist/gateway/static/root/assets/{index-D0R_YIRE.js → index-DdEh8KeB.js} +5 -5
- package/dist/gateway/static/root/assets/{local-app-workbench-page-DLGY-zR3.js → local-app-workbench-page-ReBczGac.js} +1 -1
- package/dist/gateway/static/root/assets/{note-detail-panel-BS7pKIMu.js → note-detail-panel-DAhIT6xP.js} +3 -3
- package/dist/gateway/static/root/assets/{notes-page-DBz5y6aX.js → notes-page-zAJJ2OiQ.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-capture-button-Dtvz4KwD.js → page-context-capture-button-Bd__UBi9.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-page-DpmhcQoZ.js → personal-page-DHik8uj6.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-profile-settings-KGDtrQK7.js → personal-profile-settings-Cd2xUVbw.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-settings-panel-DBlUrnCy.js → personal-settings-panel-CHRra9hc.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-runtime-BWkErYI2.js → preview-runtime-MJUo7XlD.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-D6Y3kdtF.js → project-detail-page-BBF8eVJa.js} +1 -1
- package/dist/gateway/static/root/assets/{route-preload-CvsNMwNp.js → route-preload-Bl10PwKS.js} +2 -2
- package/dist/gateway/static/root/assets/{routine-panel-Cudq6VgR.js → routine-panel-BjqenuXU.js} +2 -2
- package/dist/gateway/static/root/assets/{session-manager-CJvUtul5.js → session-manager-fvJusKsK.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-DEU9sOgT.js → settings-page-B_8kxJQW.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-BRQ6t9CI.js → share-preview-page-C49EIXte.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-CQSN1jLt.js → shares-settings-C_ITdQqP.js} +1 -1
- package/dist/gateway/static/root/assets/{space-page-Cjp2j2Xx.js → space-page-DmvjU1jc.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-CH7jSUWA.js → task-detail-page-DHYm_bsg.js} +1 -1
- package/dist/gateway/static/root/assets/{task-header-title-DemBzQyz.js → task-header-title-Buwr7WTV.js} +1 -1
- package/dist/gateway/static/root/assets/{task-result-evidence-ZKcxDYVE.js → task-result-evidence-DpV1mZJA.js} +1 -1
- package/dist/gateway/static/root/assets/{use-composer-attachments-O2une3Cn.js → use-composer-attachments-4FKbf6PB.js} +1 -1
- package/dist/gateway/static/root/assets/{use-file-preview-expanded-6TirYKSr.js → use-file-preview-expanded-CRBn6UTd.js} +1 -1
- package/dist/gateway/static/root/assets/{use-personal-work-CaO6D7sJ.js → use-personal-work-srLCZOam.js} +1 -1
- package/dist/gateway/static/root/assets/{use-realtime-voice-D3hr1-yf.js → use-realtime-voice-tyo85cre.js} +1 -1
- package/dist/gateway/static/root/assets/{use-workspace-tree-D6IwkuTh.js → use-workspace-tree-VwHdfiR8.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-settings-BgdC-Ae5.js → voice-settings-DOajN2ay.js} +1 -1
- package/dist/gateway/static/root/assets/{workspace-api-DdVYTEEV.js → workspace-api-CIfedJeG.js} +2 -2
- package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-BTLLCHMI.js → workspace-file-preview-dialog-Xi5feqPq.js} +1 -1
- package/dist/gateway/static/root/index.html +17 -17
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.d.ts +1 -0
- package/dist/src/agent/agent-manager.js +1 -0
- package/dist/src/agent/mcp/conversation-setup.d.ts +1 -0
- package/dist/src/agent/mcp/conversation-setup.js +24 -0
- package/dist/src/agent/service.js +1 -0
- package/dist/src/agent/service.types.d.ts +1 -0
- package/dist/src/agent/tools/capability-catalog-tool.d.ts +10 -0
- package/dist/src/agent/tools/capability-catalog-tool.js +63 -0
- package/dist/src/agent/tools/factory.d.ts +1 -0
- package/dist/src/agent/tools/factory.js +25 -0
- package/dist/src/agent/tools/xopc-use-tool.d.ts +1 -0
- package/dist/src/agent/tools/xopc-use-tool.js +2 -1
- package/dist/src/agent-config/schema.d.ts +3 -0
- package/dist/src/agent-config/schema.js +1 -0
- package/dist/src/capabilities/capability-catalog.d.ts +47 -0
- package/dist/src/capabilities/capability-catalog.js +162 -0
- package/dist/src/capabilities/store-connector.d.ts +1 -0
- package/dist/src/capabilities/store-connector.js +6 -3
- package/dist/src/chat-commands/builtins/config.js +1 -1
- package/dist/src/chat-commands/context.js +1 -1
- package/dist/src/cli/commands/agent.js +1 -1
- package/dist/src/cli/commands/doctor/checks/channel-plugins.js +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +5 -5
- package/dist/src/cli/commands/extension-dev.js +1 -1
- package/dist/src/cli/commands/extension-marketplace.js +1 -1
- package/dist/src/cli/commands/extension.js +1 -1
- package/dist/src/cli/commands/onboard/channels/registry.js +1 -1
- package/dist/src/cli/commands/skills.js +1 -1
- package/dist/src/cli/extension-cli-register.js +1 -1
- package/dist/src/cli/utils/session.js +1 -1
- package/dist/src/config/index.js +1 -1
- package/dist/src/config/schema.d.ts +2 -0
- package/dist/src/config/schema.js +6 -3
- package/dist/src/extensions/index.js +2 -2
- package/dist/src/extensions/loader.js +1 -1
- package/dist/src/extensions/update.js +1 -1
- package/dist/src/gateway/agent-reactions/reaction.d.ts +27 -0
- package/dist/src/gateway/agent-reactions/reaction.js +186 -0
- package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
- package/dist/src/gateway/hono/routes/capabilities.js +27 -0
- package/dist/src/gateway/hono/routes/connectors.js +1 -1
- package/dist/src/gateway/hono/routes/home.js +1 -1
- package/dist/src/gateway/hono/routes/mobile-capability-actions.d.ts +4 -0
- package/dist/src/gateway/hono/routes/mobile-capability-actions.js +290 -0
- package/dist/src/gateway/hono/routes/music-generation.js +1 -0
- package/dist/src/gateway/hono/routes/personal-agent.js +15 -6
- package/dist/src/gateway/hono/routes/sessions.js +34 -1
- package/dist/src/gateway/security/gateway-scopes.js +3 -0
- package/dist/src/gateway/service/agent-runner.d.ts +2 -0
- package/dist/src/gateway/service/agent-runner.js +5 -1
- package/dist/src/gateway/service/config-coordinator.d.ts +1 -0
- package/dist/src/gateway/service/config-coordinator.js +1 -1
- package/dist/src/gateway/service/run-gateway-agent.d.ts +3 -0
- package/dist/src/gateway/service/run-gateway-agent.js +43 -1
- package/dist/src/gateway/service/task-conversation-query-service.d.ts +4 -0
- package/dist/src/gateway/service.js +19 -10
- package/dist/src/home-intelligence/host.js +5 -5
- package/dist/src/personal-agent/repository.d.ts +1 -0
- package/dist/src/personal-agent/repository.js +1 -0
- package/dist/src/personal-agent/service.d.ts +2 -2
- package/dist/src/personal-agent/service.js +6 -3
- package/dist/src/providers/model-call.js +1 -0
- package/dist/src/realtime/runtime.js +1 -0
- package/dist/src/session/client-history.d.ts +1 -0
- package/dist/src/session/client-history.js +2 -0
- package/dist/src/session/types.d.ts +4 -0
- package/dist/src/storage/sqlite/agent-reaction-repository.d.ts +15 -0
- package/dist/src/storage/sqlite/agent-reaction-repository.js +73 -0
- package/dist/src/storage/sqlite/row-mappers.js +1 -1
- package/dist/src/storage/sqlite/schema.d.ts +2 -2
- package/dist/src/storage/sqlite/schema.js +7 -7
- package/dist/src/storage/sqlite/schema.sql +13 -0
- package/dist/src/storage/sqlite/upgrades/281_session_agent_reactions.sql +13 -0
- package/dist/src/tui/backends/embedded-backend.js +1 -1
- package/dist/src/tui/extension-host/load-extensions.js +1 -1
- package/dist/src/tui/tui-commands.js +1 -1
- package/dist/src/tui/tui-management.js +1 -1
- package/dist/src/tui/tui.js +1 -1
- package/dist/src/usage/recorder.js +6 -2
- package/dist/src/usage/types.d.ts +1 -0
- package/package.json +2 -2
- package/dist/gateway/static/root/assets/chat-page-DV7fS7_1.js +0 -72
- package/dist/gateway/static/root/assets/index-g7f1Sp02.css +0 -1
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { AgentCatalogRepository, init_repository } from "../../../agent-catalog/repository.js";
|
|
2
|
+
import { pluginAuthorizations } from "../../../extensions/agent-plugins/setup-contract.js";
|
|
3
|
+
import { AgentPluginStore } from "../../../extensions/agent-plugins/store.js";
|
|
4
|
+
import { getWorkspacePath } from "../../../config/workspace-path-helpers.js";
|
|
5
|
+
import { personalAgentId } from "../../../personal-agent/repository.js";
|
|
6
|
+
import { checkUrlSafety } from "../../../agent/tools/url-safety.js";
|
|
7
|
+
import { PluginSetupService, setupActionSchema } from "../../../extensions/agent-plugins/setup.js";
|
|
8
|
+
import { McpConnectionDrafts, McpDraftError } from "../../../agent/mcp/connection-drafts.js";
|
|
9
|
+
import { AgentCatalogService } from "../../../agent-catalog/service.js";
|
|
10
|
+
import { searchSkillMarketplaces } from "../../../agent/skills/marketplace/search.js";
|
|
11
|
+
import { evictAllEmbeddedSessionRunners } from "../../../agent/embedded/session-runner.js";
|
|
12
|
+
import { withGatewayConfigWriteLock } from "../lib/config-write-lock.js";
|
|
13
|
+
import { getGatewayPrincipal, getPersonalOwnerId } from "../../security/gateway-principal.js";
|
|
14
|
+
import { randomUUID } from "node:crypto";
|
|
15
|
+
import { z } from "zod";
|
|
16
|
+
//#region src/gateway/hono/routes/mobile-capability-actions.ts
|
|
17
|
+
init_repository();
|
|
18
|
+
const prefix = "/api/capabilities/mobile-actions";
|
|
19
|
+
const install = z.strictObject({ selection: z.uuid() });
|
|
20
|
+
const httpMcp = z.strictObject({
|
|
21
|
+
serverId: z.string().regex(/^[a-zA-Z0-9_-]{1,64}$/).refine((id) => ![
|
|
22
|
+
"__proto__",
|
|
23
|
+
"constructor",
|
|
24
|
+
"prototype"
|
|
25
|
+
].includes(id.toLowerCase())),
|
|
26
|
+
url: z.url().max(2048)
|
|
27
|
+
});
|
|
28
|
+
const mcpAction = z.discriminatedUnion("action", [z.strictObject({ action: z.enum([
|
|
29
|
+
"probe",
|
|
30
|
+
"authorize",
|
|
31
|
+
"status",
|
|
32
|
+
"save",
|
|
33
|
+
"remove"
|
|
34
|
+
]) }), z.strictObject({
|
|
35
|
+
action: z.literal("redirect"),
|
|
36
|
+
url: z.url().max(8192)
|
|
37
|
+
})]);
|
|
38
|
+
const pluginAction = z.union([
|
|
39
|
+
z.strictObject({ action: z.literal("start") }),
|
|
40
|
+
z.strictObject({
|
|
41
|
+
action: z.literal("status"),
|
|
42
|
+
server: z.string().min(1).max(120)
|
|
43
|
+
}),
|
|
44
|
+
z.strictObject({
|
|
45
|
+
action: z.literal("redirect"),
|
|
46
|
+
server: z.string().min(1).max(120),
|
|
47
|
+
url: z.url().max(8192)
|
|
48
|
+
}),
|
|
49
|
+
setupActionSchema
|
|
50
|
+
]);
|
|
51
|
+
const agentProfile = z.strictObject({
|
|
52
|
+
expectedRevision: z.number().int().positive(),
|
|
53
|
+
name: z.string().trim().min(1).max(100),
|
|
54
|
+
description: z.string().trim().max(2e3)
|
|
55
|
+
});
|
|
56
|
+
/** The native surface accepts exact product operations from a paired owner device, never general Gateway administration. */
|
|
57
|
+
function registerMobileCapabilityActions(app, { service, strictRateLimitMiddleware }) {
|
|
58
|
+
const drafts = new McpConnectionDrafts({
|
|
59
|
+
readConfig: () => service.currentConfig,
|
|
60
|
+
saveConfig: (next, expected) => service.saveConfig(next, expected)
|
|
61
|
+
});
|
|
62
|
+
const pluginStore = new AgentPluginStore();
|
|
63
|
+
const pluginSetup = new PluginSetupService(pluginStore);
|
|
64
|
+
const owner = "gateway-owner";
|
|
65
|
+
const selections = /* @__PURE__ */ new Map();
|
|
66
|
+
const guard = (fn) => async (c) => {
|
|
67
|
+
if (!getPersonalOwnerId(c)) return c.json({
|
|
68
|
+
ok: false,
|
|
69
|
+
error: "A paired owner device is required."
|
|
70
|
+
}, 403);
|
|
71
|
+
c.header("Cache-Control", "no-store");
|
|
72
|
+
try {
|
|
73
|
+
return c.json({
|
|
74
|
+
ok: true,
|
|
75
|
+
payload: await fn(c)
|
|
76
|
+
});
|
|
77
|
+
} catch (err) {
|
|
78
|
+
const message = err instanceof McpDraftError ? err.message : err instanceof z.ZodError ? "Invalid request." : "This operation could not be completed.";
|
|
79
|
+
return c.json({
|
|
80
|
+
ok: false,
|
|
81
|
+
error: message
|
|
82
|
+
}, err instanceof McpDraftError ? err.status : 400);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
app.get(prefix + "/skills", strictRateLimitMiddleware, guard(async (c) => {
|
|
86
|
+
const query = z.string().trim().min(2).max(160).parse(c.req.query("q"));
|
|
87
|
+
const result = await searchSkillMarketplaces({
|
|
88
|
+
config: service.currentConfig,
|
|
89
|
+
query,
|
|
90
|
+
limit: 15
|
|
91
|
+
});
|
|
92
|
+
const installed = new Set(service.marketplace.getSkillsApi().catalog.map((skill) => skill.directoryId.toLowerCase()));
|
|
93
|
+
const now = Date.now(), principal = getGatewayPrincipal(c).principalId;
|
|
94
|
+
for (const [key, value] of selections) if (value.expiresAt <= now) selections.delete(key);
|
|
95
|
+
return {
|
|
96
|
+
items: result.results.map((row) => {
|
|
97
|
+
const alreadyInstalled = installed.has(row.id.toLowerCase()) || installed.has(row.name.toLowerCase()) || installed.has(row.install.reference.split("/").at(-1)?.toLowerCase() ?? "");
|
|
98
|
+
const selection = alreadyInstalled || row.security.status === "fail" ? void 0 : randomUUID();
|
|
99
|
+
if (selection) {
|
|
100
|
+
if (selections.size >= 600) selections.delete(selections.keys().next().value);
|
|
101
|
+
selections.set(selection, {
|
|
102
|
+
principal,
|
|
103
|
+
provider: row.provider,
|
|
104
|
+
name: row.install.reference,
|
|
105
|
+
expiresAt: now + 10 * 6e4
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
id: row.install.reference,
|
|
110
|
+
name: row.name,
|
|
111
|
+
description: row.description,
|
|
112
|
+
provider: row.provider,
|
|
113
|
+
author: row.author,
|
|
114
|
+
security: row.security.status,
|
|
115
|
+
installed: alreadyInstalled,
|
|
116
|
+
selection
|
|
117
|
+
};
|
|
118
|
+
}),
|
|
119
|
+
incomplete: result.sources.some((source) => !source.ok)
|
|
120
|
+
};
|
|
121
|
+
}));
|
|
122
|
+
app.post(prefix + "/skills", strictRateLimitMiddleware, guard(async (c) => {
|
|
123
|
+
const body = install.parse(await c.req.json());
|
|
124
|
+
const item = selections.get(body.selection);
|
|
125
|
+
if (!item || item.expiresAt <= Date.now() || item.principal !== getGatewayPrincipal(c).principalId) throw new McpDraftError(409, "Search again before installing this skill.");
|
|
126
|
+
selections.delete(body.selection);
|
|
127
|
+
try {
|
|
128
|
+
return {
|
|
129
|
+
installed: true,
|
|
130
|
+
name: (await service.marketplace.installSkill({
|
|
131
|
+
name: item.name,
|
|
132
|
+
provider: item.provider,
|
|
133
|
+
target: "global",
|
|
134
|
+
overwrite: false
|
|
135
|
+
})).skillId
|
|
136
|
+
};
|
|
137
|
+
} catch (error) {
|
|
138
|
+
selections.set(body.selection, item);
|
|
139
|
+
throw error;
|
|
140
|
+
}
|
|
141
|
+
}));
|
|
142
|
+
app.post(prefix + "/mcp", strictRateLimitMiddleware, guard(async (c) => {
|
|
143
|
+
const input = httpMcp.parse(await c.req.json());
|
|
144
|
+
const url = new URL(input.url);
|
|
145
|
+
if (url.protocol !== "https:" || url.username || url.password || url.search || url.hash || !checkUrlSafety(url.href).safe) throw new McpDraftError(400, "Use a public HTTPS MCP endpoint without credentials or query parameters.");
|
|
146
|
+
return drafts.create(getGatewayPrincipal(c).principalId, {
|
|
147
|
+
serverId: input.serverId,
|
|
148
|
+
server: {
|
|
149
|
+
type: "http",
|
|
150
|
+
url: url.href,
|
|
151
|
+
xopcPublicOnly: true
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}));
|
|
155
|
+
app.post(prefix + "/mcp/:id", strictRateLimitMiddleware, guard(async (c) => {
|
|
156
|
+
const id = z.uuid().parse(c.req.param("id"));
|
|
157
|
+
const principal = getGatewayPrincipal(c).principalId;
|
|
158
|
+
const body = mcpAction.parse(await c.req.json());
|
|
159
|
+
switch (body.action) {
|
|
160
|
+
case "probe": {
|
|
161
|
+
const { state, toolCount, errorCode } = await drafts.probe(principal, id);
|
|
162
|
+
return {
|
|
163
|
+
state,
|
|
164
|
+
toolCount,
|
|
165
|
+
errorCode
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
case "authorize": {
|
|
169
|
+
const { state, authorizationUrl } = drafts.authorize(principal, id);
|
|
170
|
+
return {
|
|
171
|
+
state,
|
|
172
|
+
authorizationUrl
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
case "status": {
|
|
176
|
+
const { state, authorizationUrl, toolCount } = drafts.authorization(principal, id);
|
|
177
|
+
return {
|
|
178
|
+
state,
|
|
179
|
+
authorizationUrl,
|
|
180
|
+
toolCount
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
case "redirect":
|
|
184
|
+
drafts.redirect(principal, id, body.url);
|
|
185
|
+
return { state: "authorizing" };
|
|
186
|
+
case "save": return withGatewayConfigWriteLock(service, () => drafts.commit(principal, id, true));
|
|
187
|
+
case "remove":
|
|
188
|
+
drafts.remove(principal, id);
|
|
189
|
+
return { state: "cancelled" };
|
|
190
|
+
}
|
|
191
|
+
}));
|
|
192
|
+
function editableAgent(c) {
|
|
193
|
+
const id = c.req.param("id");
|
|
194
|
+
const agent = new AgentCatalogRepository().get(id);
|
|
195
|
+
if (!agent || agent.enabled === false || agent.id === personalAgentId(getPersonalOwnerId(c))) throw new McpDraftError(404, "This agent profile is not editable here.");
|
|
196
|
+
return agent;
|
|
197
|
+
}
|
|
198
|
+
function publicAgentProfile(agent) {
|
|
199
|
+
return {
|
|
200
|
+
revision: agent.revision,
|
|
201
|
+
name: agent.profile?.name ?? agent.id,
|
|
202
|
+
description: agent.profile?.description ?? ""
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
app.get(prefix + "/agent/:id", guard((c) => publicAgentProfile(editableAgent(c))));
|
|
206
|
+
app.post(prefix + "/agent/:id", strictRateLimitMiddleware, guard(async (c) => {
|
|
207
|
+
const agent = editableAgent(c);
|
|
208
|
+
const { expectedRevision, name, description } = agentProfile.parse(await c.req.json());
|
|
209
|
+
if (agent.revision !== expectedRevision) throw new McpDraftError(409, "The agent profile changed. Reopen it before saving.");
|
|
210
|
+
const updated = await new AgentCatalogService().update(agent.id, { profile: {
|
|
211
|
+
...agent.profile,
|
|
212
|
+
name,
|
|
213
|
+
description
|
|
214
|
+
} }, expectedRevision);
|
|
215
|
+
service.refreshAgentCatalog();
|
|
216
|
+
return publicAgentProfile(updated);
|
|
217
|
+
}));
|
|
218
|
+
function pluginSummary(id) {
|
|
219
|
+
const plugin = pluginStore.pending(id) ?? pluginStore.get(id);
|
|
220
|
+
if (!plugin) throw new McpDraftError(404, "Install the reviewed plugin package before setting it up.");
|
|
221
|
+
const job = pluginSetup.get(id, owner);
|
|
222
|
+
const fields = Object.entries(plugin.layout?.userConfig ?? {}).map(([id, field]) => ({
|
|
223
|
+
id,
|
|
224
|
+
title: field.title ?? id,
|
|
225
|
+
type: field.type,
|
|
226
|
+
sensitive: field.sensitive
|
|
227
|
+
}));
|
|
228
|
+
const accounts = pluginAuthorizations(plugin.manifest).map((account) => ({
|
|
229
|
+
id: account.id,
|
|
230
|
+
title: account.title,
|
|
231
|
+
description: account.description,
|
|
232
|
+
methods: account.methods.map((method) => ({
|
|
233
|
+
id: method.id,
|
|
234
|
+
title: method.title,
|
|
235
|
+
type: method.type,
|
|
236
|
+
fields: "fields" in method ? method.fields : [],
|
|
237
|
+
instructions: method.instructions
|
|
238
|
+
}))
|
|
239
|
+
}));
|
|
240
|
+
return {
|
|
241
|
+
active: plugin.receipt.enabled,
|
|
242
|
+
accounts,
|
|
243
|
+
fields,
|
|
244
|
+
job: job && job.packageRevision === plugin.receipt.revision ? {
|
|
245
|
+
revision: job.revision,
|
|
246
|
+
state: job.state,
|
|
247
|
+
connections: job.connections.map(({ name, state }) => ({
|
|
248
|
+
name,
|
|
249
|
+
state
|
|
250
|
+
})),
|
|
251
|
+
authorizations: job.authorizations.map(({ id, state }) => ({
|
|
252
|
+
id,
|
|
253
|
+
state
|
|
254
|
+
})),
|
|
255
|
+
missingConfig: job.missingConfig
|
|
256
|
+
} : void 0
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
app.get(prefix + "/plugin/:id", guard((c) => pluginSummary(c.req.param("id"))));
|
|
260
|
+
app.post(prefix + "/plugin/:id", strictRateLimitMiddleware, guard(async (c) => {
|
|
261
|
+
const id = c.req.param("id");
|
|
262
|
+
const body = pluginAction.parse(await c.req.json());
|
|
263
|
+
const config = service.currentConfig;
|
|
264
|
+
if (body.action === "start") {
|
|
265
|
+
pluginSetup.create(id, owner);
|
|
266
|
+
return pluginSummary(id);
|
|
267
|
+
}
|
|
268
|
+
if (body.action === "status") {
|
|
269
|
+
const auth = await pluginSetup.authorization(id, owner, body.server, config);
|
|
270
|
+
return {
|
|
271
|
+
...pluginSummary(id),
|
|
272
|
+
authorizationUrl: auth && ("challenge" in auth ? auth.challenge?.url : "authorizationUrl" in auth ? auth.authorizationUrl : void 0)
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
if (body.action === "redirect") {
|
|
276
|
+
if (!pluginSetup.redirect(id, owner, body.server, body.url, config)) throw new McpDraftError(400, "The callback does not match this authorization.");
|
|
277
|
+
return pluginSummary(id);
|
|
278
|
+
}
|
|
279
|
+
if ("workspacePaths" in body && body.workspacePaths !== void 0) throw new McpDraftError(400, "Mobile setup preserves workspace access.");
|
|
280
|
+
if (body.action === "prepare") pluginSetup.startPrepare(id, owner, body.expectedRevision, config, getWorkspacePath(config) || process.cwd(), body.idempotencyKey);
|
|
281
|
+
else {
|
|
282
|
+
await pluginSetup.act(id, owner, body, config, getWorkspacePath(config) || process.cwd());
|
|
283
|
+
evictAllEmbeddedSessionRunners();
|
|
284
|
+
service.marketplace.reloadSkills();
|
|
285
|
+
}
|
|
286
|
+
return pluginSummary(id);
|
|
287
|
+
}));
|
|
288
|
+
}
|
|
289
|
+
//#endregion
|
|
290
|
+
export { registerMobileCapabilityActions };
|
|
@@ -66,6 +66,7 @@ function registerMusicGenerationRoutes(app, deps) {
|
|
|
66
66
|
const session = await deps.service.sessionIndexInstance.getSessionMetadata(conversationId);
|
|
67
67
|
if (!session?.transcriptId || session.sourceChannel !== "webchat" || session.sessionType !== "chat") return c.json({ error: "Conversation not found" }, 404);
|
|
68
68
|
return c.json({
|
|
69
|
+
transcriptId: session.transcriptId,
|
|
69
70
|
configured: Boolean(await configuredMusicModel()),
|
|
70
71
|
jobs: listMusicJobs(conversationId, session.transcriptId)
|
|
71
72
|
});
|
|
@@ -49,6 +49,7 @@ const OnboardingSchema = z.object({
|
|
|
49
49
|
}).strict();
|
|
50
50
|
const ProfileSchema = z.object({
|
|
51
51
|
voiceCallPreferences: voiceCallPreferencesPatchSchema.optional(),
|
|
52
|
+
messageReactionsEnabled: z.boolean().optional(),
|
|
52
53
|
revision: z.number().int().positive(),
|
|
53
54
|
displayName: z.string().trim().min(1).max(60),
|
|
54
55
|
appearance: PersonalAppearanceSchema,
|
|
@@ -74,6 +75,10 @@ const PersonalSchedulePatchSchema = PersonalScheduleSchema.partial().extend({
|
|
|
74
75
|
expectedRevision: z.number().int().nonnegative()
|
|
75
76
|
}).refine((value) => Object.keys(value).length > 1);
|
|
76
77
|
function registerPersonalAgentRoutes(authenticated, deps) {
|
|
78
|
+
const profilePayload = (record) => record && {
|
|
79
|
+
...record,
|
|
80
|
+
messageReactionsAvailable: deps.service.currentConfig?.experimental?.personalAgentMessageReactions === true
|
|
81
|
+
};
|
|
77
82
|
const owner = getPersonalOwnerId;
|
|
78
83
|
registerProactivityRoutes(authenticated, deps, owner);
|
|
79
84
|
authenticated.get("/api/personal-agent/schedules", async (c) => {
|
|
@@ -254,7 +259,7 @@ function registerPersonalAgentRoutes(authenticated, deps) {
|
|
|
254
259
|
ensurePersonalConversationVisibility(ownerId);
|
|
255
260
|
return c.json({
|
|
256
261
|
ok: true,
|
|
257
|
-
payload: getPersonalAgent(ownerId)
|
|
262
|
+
payload: profilePayload(getPersonalAgent(ownerId))
|
|
258
263
|
});
|
|
259
264
|
});
|
|
260
265
|
authenticated.get("/api/personal-agent/unread", (c) => {
|
|
@@ -511,7 +516,7 @@ function registerPersonalAgentRoutes(authenticated, deps) {
|
|
|
511
516
|
} : void 0);
|
|
512
517
|
return c.json({
|
|
513
518
|
ok: true,
|
|
514
|
-
payload: record
|
|
519
|
+
payload: profilePayload(record)
|
|
515
520
|
});
|
|
516
521
|
} catch (error) {
|
|
517
522
|
return c.json({
|
|
@@ -531,13 +536,13 @@ function registerPersonalAgentRoutes(authenticated, deps) {
|
|
|
531
536
|
ok: false,
|
|
532
537
|
error: "Invalid profile"
|
|
533
538
|
}, 400);
|
|
534
|
-
const { revision, displayName, appearance, voicePreference, voiceCallPreferences } = parsed.data;
|
|
539
|
+
const { revision, displayName, appearance, voicePreference, voiceCallPreferences, messageReactionsEnabled } = parsed.data;
|
|
535
540
|
const naturalModel = voiceCallPreferences?.naturalModel;
|
|
536
541
|
if (naturalModel && naturalModel !== "boson/higgs-realtime" && naturalModel !== legacyNaturalModel(deps.service.currentConfig) && naturalModel !== getPersonalAgent(ownerId)?.voiceCallPreferences.naturalModel) return c.json({
|
|
537
542
|
ok: false,
|
|
538
543
|
error: "Selected natural voice model is unavailable"
|
|
539
544
|
}, 400);
|
|
540
|
-
if (voicePreference) {
|
|
545
|
+
if (voicePreference && JSON.stringify(voicePreference) !== JSON.stringify(getPersonalAgent(ownerId)?.voicePreference)) {
|
|
541
546
|
const { resolveStreamingTts } = await import("../../../voice/realtime/runtime.js");
|
|
542
547
|
const route = resolveStreamingTts(deps.service.currentConfig);
|
|
543
548
|
if (!route?.provider.plugin.listVoices || route.route.provider !== voicePreference.provider || route.route.model !== voicePreference.model) return c.json({
|
|
@@ -553,10 +558,14 @@ function registerPersonalAgentRoutes(authenticated, deps) {
|
|
|
553
558
|
error: "Selected voice is unavailable"
|
|
554
559
|
}, 400);
|
|
555
560
|
}
|
|
556
|
-
const updated = await patchPersonalProfile(deps.service, ownerId, revision, displayName, appearance, voicePreference, voiceCallPreferences);
|
|
561
|
+
const updated = await patchPersonalProfile(deps.service, ownerId, revision, displayName, appearance, voicePreference, voiceCallPreferences, messageReactionsEnabled);
|
|
562
|
+
if (updated && messageReactionsEnabled !== void 0) deps.service.realtime.broker.publish("sessions", "session.agent-reaction.preference", {
|
|
563
|
+
conversationId: updated.conversationId,
|
|
564
|
+
enabled: messageReactionsEnabled
|
|
565
|
+
});
|
|
557
566
|
return updated ? c.json({
|
|
558
567
|
ok: true,
|
|
559
|
-
payload: updated
|
|
568
|
+
payload: profilePayload(updated)
|
|
560
569
|
}) : c.json({
|
|
561
570
|
ok: false,
|
|
562
571
|
error: "Profile changed or personal Agent is unavailable"
|
|
@@ -4,11 +4,12 @@ import { init_src } from "../../../../packages/gateway-contract/src/index.js";
|
|
|
4
4
|
import "../../../session/types.js";
|
|
5
5
|
import { SidebarLayoutConflictError, getSidebarLayout, replaceSidebarLayout, sortBySidebarLayout } from "../../../storage/sqlite/sidebar-layout-repository.js";
|
|
6
6
|
import { summarizeAiUsageByConversations } from "../../../storage/sqlite/ai-usage-repository.js";
|
|
7
|
-
import { isPersonalConversation } from "../../../personal-agent/repository.js";
|
|
7
|
+
import { getPersonalAgentByConversation, isPersonalConversation } from "../../../personal-agent/repository.js";
|
|
8
8
|
import { messagesToClientHistory } from "../../../session/client-history.js";
|
|
9
9
|
import { SessionEnvironmentService } from "../../../execution-environments/session-environment-service.js";
|
|
10
10
|
import { evictEmbeddedSessionRunner } from "../../../agent/embedded/session-runner.js";
|
|
11
11
|
import { deleteMediaUrisNoLongerReferenced } from "../../../media/session-references.js";
|
|
12
|
+
import { DEFAULT_AGENT_REACTION, readAgentReactions } from "../../../storage/sqlite/agent-reaction-repository.js";
|
|
12
13
|
import { getGatewayPrincipal } from "../../security/gateway-principal.js";
|
|
13
14
|
import { createGatewayRouteLogger, logRouteError } from "../lib/route-logger.js";
|
|
14
15
|
import { patchChatModelConfig } from "./chat-model-config.js";
|
|
@@ -454,6 +455,38 @@ function registerSessionsRoutes(authenticated, deps) {
|
|
|
454
455
|
compact
|
|
455
456
|
});
|
|
456
457
|
if (!result) return c.json({ error: "Session not found" }, 404);
|
|
458
|
+
const actor = getPersonalAgentByConversation(key);
|
|
459
|
+
const transcriptId = result.session.transcriptId;
|
|
460
|
+
if (actor && transcriptId) {
|
|
461
|
+
const available = service.currentConfig?.experimental?.personalAgentMessageReactions === true;
|
|
462
|
+
result.session.agentReactions = {
|
|
463
|
+
available,
|
|
464
|
+
enabled: available && actor.messageReactionsEnabled
|
|
465
|
+
};
|
|
466
|
+
if (result.session.agentReactions.enabled) {
|
|
467
|
+
const messages = result.session.messages;
|
|
468
|
+
const entries = messages.flatMap((row) => row.role === "user" && row.transcriptEntryId ? [row.transcriptEntryId] : []);
|
|
469
|
+
const reactions = new Map(readAgentReactions(key, transcriptId, entries, actor.displayName).map((reaction) => [reaction.entryId, reaction]));
|
|
470
|
+
const activeRunId = service.getActiveWebchatRunId(key);
|
|
471
|
+
for (const row of messages) {
|
|
472
|
+
const entryId = row.transcriptEntryId;
|
|
473
|
+
if (row.role !== "user" || !entryId) continue;
|
|
474
|
+
const saved = reactions.get(entryId);
|
|
475
|
+
if (saved) row.agentReaction = saved;
|
|
476
|
+
else if (!activeRunId || row.turnId !== activeRunId || row.metadata?.steered) row.agentReaction = {
|
|
477
|
+
conversationId: key,
|
|
478
|
+
transcriptId,
|
|
479
|
+
clientMessageId: row.metadata?.clientMessageId ?? entryId,
|
|
480
|
+
entryId,
|
|
481
|
+
actorAgentId: actor.agentId,
|
|
482
|
+
actorName: actor.displayName,
|
|
483
|
+
runId: row.turnId ?? entryId,
|
|
484
|
+
emoji: DEFAULT_AGENT_REACTION,
|
|
485
|
+
createdAtMs: row.timestamp ?? 0
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
}
|
|
457
490
|
const revision = result.pagination.revision;
|
|
458
491
|
if (typeof revision === "number") {
|
|
459
492
|
const contentHash = createHash("sha256").update(JSON.stringify(result)).digest("base64url");
|
|
@@ -58,6 +58,9 @@ function requiredGatewayScope(method, path) {
|
|
|
58
58
|
if (path.startsWith("/api/automations") || path.startsWith("/api/automation-runs")) return methodScope(method, "automations.read", "automations.write");
|
|
59
59
|
if (path === "/api/voice/selection" || path === "/api/voice/catalog/refresh" || path === "/api/voice/boson" || path === "/api/voice/boson/reveal-api-key") return "voice.configure";
|
|
60
60
|
if (path.startsWith("/api/voice") || path.startsWith("/api/media") || path.startsWith("/api/clarifications")) return "sessions.write";
|
|
61
|
+
if (method === "GET" && path === "/api/capabilities/mobile-catalog") return "agents.read";
|
|
62
|
+
if (method === "GET" && /^\/api\/capabilities\/mobile-actions\/(?:skills|(?:agent|plugin)\/[^/]+)$/.test(path)) return "agents.read";
|
|
63
|
+
if (method === "POST" && /^\/api\/capabilities\/mobile-actions\/(?:skills|mcp(?:\/[^/]+)?|(?:agent|plugin)\/[^/]+)$/.test(path)) return "sessions.write";
|
|
61
64
|
if (method === "GET" && path === "/api/chat/skills") return "agents.read";
|
|
62
65
|
if (path.startsWith("/api/commands") || path.startsWith("/api/skills")) return methodScope(method, "agents.read", "gateway.admin");
|
|
63
66
|
if (path === "/api/user-model/refresh" || path.startsWith("/api/user-model/refresh/")) return "gateway.admin";
|
|
@@ -16,6 +16,7 @@ import type { UserTurnAttachment, UserTurnInput } from '../user-turn-input.js';
|
|
|
16
16
|
import type { AgentSourceContext, TurnContextRef } from '../../agent/source-context/types.js';
|
|
17
17
|
import { SessionInputCoordinator, type ReplaceLatestTurnInput, type SubmitSessionInput } from './session-input-coordinator.js';
|
|
18
18
|
export interface GatewayAgentRunnerOptions {
|
|
19
|
+
canReact?: (endpointId: string) => boolean;
|
|
19
20
|
canResumeDeviceInteraction?: (conversationId: string, checkpoint: import('@xopcai/gateway-contract').DeviceInteractionCheckpoint) => boolean;
|
|
20
21
|
afterConnectionResume?: (input: import('../../storage/sqlite/session-input-repository.js').SessionInput, status: string) => Promise<void>;
|
|
21
22
|
validateConnectionResume?: (input: import('../../storage/sqlite/session-input-repository.js').SessionInput) => Promise<boolean>;
|
|
@@ -47,6 +48,7 @@ export declare class GatewayAgentRunner {
|
|
|
47
48
|
private readonly externalClarificationResponses;
|
|
48
49
|
readonly inputs: SessionInputCoordinator;
|
|
49
50
|
readonly nextTurnSuggestions: NextTurnSuggestionService;
|
|
51
|
+
private readonly reactions;
|
|
50
52
|
private readonly unsubscribeConnectionWait;
|
|
51
53
|
constructor(opts: GatewayAgentRunnerOptions);
|
|
52
54
|
/** True when a webchat agent run is currently in-flight for `conversationId`. */
|
|
@@ -20,6 +20,7 @@ import { completePhoneAssistanceFromUser, preparePhoneContinuation } from "../..
|
|
|
20
20
|
import { describeActiveExecution } from "./active-execution.js";
|
|
21
21
|
import { runGatewayAgent } from "./run-gateway-agent.js";
|
|
22
22
|
import { NextTurnSuggestionService } from "../next-turn-suggestions/service.js";
|
|
23
|
+
import { AgentReactionService } from "../agent-reactions/reaction.js";
|
|
23
24
|
import { fitSourceContextsToBudget } from "../../agent/source-context/budget.js";
|
|
24
25
|
import { SessionInputCoordinator } from "./session-input-coordinator.js";
|
|
25
26
|
import crypto from "node:crypto";
|
|
@@ -50,6 +51,7 @@ var GatewayAgentRunner = class {
|
|
|
50
51
|
externalClarificationResponses = /* @__PURE__ */ new Map();
|
|
51
52
|
inputs;
|
|
52
53
|
nextTurnSuggestions;
|
|
54
|
+
reactions = new AgentReactionService();
|
|
53
55
|
unsubscribeConnectionWait;
|
|
54
56
|
constructor(opts) {
|
|
55
57
|
this.opts = opts;
|
|
@@ -230,7 +232,9 @@ var GatewayAgentRunner = class {
|
|
|
230
232
|
sessionIndex: this.opts.sessionIndex,
|
|
231
233
|
emit: this.opts.emit,
|
|
232
234
|
publishRealtime: this.opts.publishRealtime,
|
|
233
|
-
completeRealtimeTopic: this.opts.completeRealtimeTopic
|
|
235
|
+
completeRealtimeTopic: this.opts.completeRealtimeTopic,
|
|
236
|
+
reactions: this.reactions,
|
|
237
|
+
canReact: this.opts.canReact
|
|
234
238
|
}, message, channel, chatId, origin, attachments, thinking, cancellation ? {
|
|
235
239
|
...runOptions,
|
|
236
240
|
signal: runOptions?.signal ? AbortSignal.any([runOptions.signal, cancellation.signal]) : cancellation.signal
|
|
@@ -4,8 +4,8 @@ import { getModelRegistry } from "../../providers/model-registry.js";
|
|
|
4
4
|
import { init_providers } from "../../providers/index.js";
|
|
5
5
|
import { configureTracing } from "../../observability/runtime.js";
|
|
6
6
|
import { reloadImageGenerationProviders } from "../../agent/image/generation/provider-registry.js";
|
|
7
|
-
import { evictAllEmbeddedSessionRunners } from "../../agent/embedded/session-runner.js";
|
|
8
7
|
import { loadConfig, saveConfig } from "../../config/loader.js";
|
|
8
|
+
import { evictAllEmbeddedSessionRunners } from "../../agent/embedded/session-runner.js";
|
|
9
9
|
import { ConfigHotReloader } from "../../config/reload.js";
|
|
10
10
|
import "../../config/index.js";
|
|
11
11
|
import { computeExtensionActivationPatch } from "../../extensions/bundled-extension-activation.js";
|
|
@@ -7,6 +7,7 @@ import type { ChatStreamEvent } from '../chat-stream/protocol.js';
|
|
|
7
7
|
import type { UserTurnAttachment } from '../user-turn-input.js';
|
|
8
8
|
import type { AgentSourceContext } from '../../agent/source-context/types.js';
|
|
9
9
|
import { type ActiveExecution } from './active-execution.js';
|
|
10
|
+
import type { AgentReactionService } from '../agent-reactions/reaction.js';
|
|
10
11
|
export type RunGatewayAgentYield = ChatStreamEvent;
|
|
11
12
|
export type RunGatewayAgentOptions = {
|
|
12
13
|
inputReceivedAtMs?: number;
|
|
@@ -31,6 +32,8 @@ export type RunGatewayAgentDeps = {
|
|
|
31
32
|
emit: (type: string, payload: unknown) => void;
|
|
32
33
|
publishRealtime: (topic: string, event: string, data: unknown) => void;
|
|
33
34
|
completeRealtimeTopic: (topic: string) => void;
|
|
35
|
+
reactions?: AgentReactionService;
|
|
36
|
+
canReact?: (endpointId: string) => boolean;
|
|
34
37
|
};
|
|
35
38
|
/**
|
|
36
39
|
* @param runOptions.signal — When set (e.g. client disconnect), aborts in-flight generation and persists partial output.
|
|
@@ -43,6 +43,9 @@ async function* runGatewayAgent(deps, message, channel, chatId, origin, attachme
|
|
|
43
43
|
const runStartedMonotonic = performance.now();
|
|
44
44
|
const inputReceivedAtMs = runOptions?.inputReceivedAtMs ?? runStartedAtMs;
|
|
45
45
|
let firstTextSeen = false;
|
|
46
|
+
let reactionWindow;
|
|
47
|
+
let reactionPending = false;
|
|
48
|
+
let publishReactionFallback;
|
|
46
49
|
const cappedAttachments = attachments && attachments.length > 10 ? attachments.slice(0, 10) : attachments;
|
|
47
50
|
if (attachments && cappedAttachments && attachments.length > cappedAttachments.length) log.debug({
|
|
48
51
|
dropped: attachments.length - cappedAttachments.length,
|
|
@@ -140,7 +143,10 @@ async function* runGatewayAgent(deps, message, channel, chatId, origin, attachme
|
|
|
140
143
|
};
|
|
141
144
|
const emitAndYield = function* (events) {
|
|
142
145
|
for (const event of events) {
|
|
143
|
-
|
|
146
|
+
const firstText = !firstTextSeen && event.type === "assistant_delta" && Boolean(event.payload.delta.trim());
|
|
147
|
+
const reactionClosed = firstText || event.type === "clarify_request" || event.type === "review" || event.type === "error" || event.type === "run_end";
|
|
148
|
+
if (reactionClosed) reactionWindow?.abort();
|
|
149
|
+
if (firstText) {
|
|
144
150
|
firstTextSeen = true;
|
|
145
151
|
const latencyMs = performance.now() - runStartedMonotonic;
|
|
146
152
|
const queueMs = Math.max(0, runStartedAtMs - inputReceivedAtMs);
|
|
@@ -164,6 +170,7 @@ async function* runGatewayAgent(deps, message, channel, chatId, origin, attachme
|
|
|
164
170
|
}
|
|
165
171
|
if (taskRun) captureTaskEvent(event);
|
|
166
172
|
if (channel === "webchat") publishRealtime(runTopic, event.type, event);
|
|
173
|
+
if (reactionClosed || event.type === "user_message" && !reactionPending) publishReactionFallback?.();
|
|
167
174
|
yield event;
|
|
168
175
|
}
|
|
169
176
|
};
|
|
@@ -196,6 +203,38 @@ async function* runGatewayAgent(deps, message, channel, chatId, origin, attachme
|
|
|
196
203
|
runId,
|
|
197
204
|
...runOptions?.inputIdentity
|
|
198
205
|
});
|
|
206
|
+
const identity = runOptions?.inputIdentity;
|
|
207
|
+
const reactions = deps.reactions;
|
|
208
|
+
if (personalTurn && reactions && webchatTranscriptId && !runOptions?.presentation && !runOptions?.taskRunId && identity && origin.type === "endpoint" && deps.config.experimental?.personalAgentMessageReactions) {
|
|
209
|
+
const target = {
|
|
210
|
+
...identity,
|
|
211
|
+
conversationId,
|
|
212
|
+
runId,
|
|
213
|
+
transcriptId: webchatTranscriptId,
|
|
214
|
+
actorAgentId: webchatMetadata.agentId
|
|
215
|
+
};
|
|
216
|
+
const publish = (reaction) => {
|
|
217
|
+
publishReactionFallback = void 0;
|
|
218
|
+
publishRealtime("sessions", "session.agent-reaction", reaction);
|
|
219
|
+
};
|
|
220
|
+
publishReactionFallback = () => reactions.publishFallback(target, publish);
|
|
221
|
+
const endpointId = origin.endpointId;
|
|
222
|
+
if (deps.canReact?.(endpointId)) {
|
|
223
|
+
reactionWindow = new AbortController();
|
|
224
|
+
reactionPending = true;
|
|
225
|
+
reactions.consider({
|
|
226
|
+
target,
|
|
227
|
+
text: message,
|
|
228
|
+
started: runStartedMonotonic,
|
|
229
|
+
signal: AbortSignal.any([mergedSignal, reactionWindow.signal]),
|
|
230
|
+
eligible: () => deps.canReact?.(endpointId) === true,
|
|
231
|
+
publish
|
|
232
|
+
}).catch(() => {}).finally(() => {
|
|
233
|
+
reactionPending = false;
|
|
234
|
+
publishReactionFallback?.();
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
}
|
|
199
238
|
}
|
|
200
239
|
let streamError;
|
|
201
240
|
let embeddedAborted = false;
|
|
@@ -277,6 +316,8 @@ async function* runGatewayAgent(deps, message, channel, chatId, origin, attachme
|
|
|
277
316
|
summary: streamError
|
|
278
317
|
};
|
|
279
318
|
} finally {
|
|
319
|
+
reactionWindow?.abort();
|
|
320
|
+
publishReactionFallback?.();
|
|
280
321
|
if (mergedSignal.aborted) {
|
|
281
322
|
terminalStatus = "cancelled";
|
|
282
323
|
taskRunStatus = "cancelled";
|
|
@@ -393,6 +434,7 @@ async function* runGatewayAgent(deps, message, channel, chatId, origin, attachme
|
|
|
393
434
|
}
|
|
394
435
|
throw error;
|
|
395
436
|
} finally {
|
|
437
|
+
reactionWindow?.abort();
|
|
396
438
|
if (personalTurn) recordPersonalPerformance({
|
|
397
439
|
phase: "turn_complete",
|
|
398
440
|
conversationId: streamConversationId,
|
|
@@ -14,6 +14,10 @@ export declare class TaskConversationQueryService {
|
|
|
14
14
|
}): Promise<{
|
|
15
15
|
session: {
|
|
16
16
|
messages: import("../../session/types.js").Message[];
|
|
17
|
+
agentReactions?: {
|
|
18
|
+
available: boolean;
|
|
19
|
+
enabled: boolean;
|
|
20
|
+
};
|
|
17
21
|
transcriptSummary?: import("../../session/types.js").SessionTranscriptSummary;
|
|
18
22
|
transcriptRows?: import("../../session/session-context-for-llm.js").TranscriptStoredRow[];
|
|
19
23
|
key: string;
|