@rzx/ohs 1.2.21 → 1.2.22
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/frontend/index.js +5 -3
- package/dist/frontend/index.js.map +4 -4
- package/dist/index.js +148 -78
- package/dist/index.js.map +12 -12
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1154,7 +1154,7 @@ var init_runtime_config = __esm(() => {
|
|
|
1154
1154
|
// ../../packages/protocol/src/plugin-apps.ts
|
|
1155
1155
|
function readPluginAppAction(metadata) {
|
|
1156
1156
|
try {
|
|
1157
|
-
const value = record(copyPluginAppJson(metadata.pluginAppAction, PLUGIN_APP_LIMITS.
|
|
1157
|
+
const value = record(copyPluginAppJson(metadata.pluginAppAction, PLUGIN_APP_LIMITS.maxArgsBytes + 32 * 1024));
|
|
1158
1158
|
if (value.schemaVersion !== 1 || !["not_started", "completed", "unknown"].includes(String(value.executionState)) || !["native-tools", "mcp-server"].includes(String(value.backendKind)))
|
|
1159
1159
|
return;
|
|
1160
1160
|
parsePluginAppSource(value.source);
|
|
@@ -1176,7 +1176,7 @@ function readPluginAppAction(metadata) {
|
|
|
1176
1176
|
"toolUseId"
|
|
1177
1177
|
])
|
|
1178
1178
|
identifier(value[key]);
|
|
1179
|
-
record(copyPluginAppJson(value.args, PLUGIN_APP_LIMITS.
|
|
1179
|
+
record(copyPluginAppJson(value.args, PLUGIN_APP_LIMITS.maxArgsBytes));
|
|
1180
1180
|
return value;
|
|
1181
1181
|
} catch {
|
|
1182
1182
|
return;
|
|
@@ -1285,11 +1285,11 @@ function parseClosePluginAppInput(value) {
|
|
|
1285
1285
|
return { expectedRevision: revision(input.expectedRevision) };
|
|
1286
1286
|
}
|
|
1287
1287
|
function parsePluginAppToolRequest(value) {
|
|
1288
|
-
const input = record(copyPluginAppJson(value, PLUGIN_APP_LIMITS.
|
|
1288
|
+
const input = record(copyPluginAppJson(value, PLUGIN_APP_LIMITS.maxArgsBytes + 16 * 1024));
|
|
1289
1289
|
fields(input, ["requestId", "expectedRevision", "toolName", "args", "source", "lease"]);
|
|
1290
1290
|
const lease = record(input.lease);
|
|
1291
1291
|
fields(lease, ["token", "backendGeneration"]);
|
|
1292
|
-
const args = record(copyPluginAppJson(input.args, PLUGIN_APP_LIMITS.
|
|
1292
|
+
const args = record(copyPluginAppJson(input.args, PLUGIN_APP_LIMITS.maxArgsBytes));
|
|
1293
1293
|
return {
|
|
1294
1294
|
requestId: identifier(input.requestId),
|
|
1295
1295
|
expectedRevision: revision(input.expectedRevision),
|
|
@@ -1315,6 +1315,7 @@ var init_plugin_apps = __esm(() => {
|
|
|
1315
1315
|
resourceBytes: 8 * 1024 * 1024,
|
|
1316
1316
|
appDataBytes: 256 * 1024,
|
|
1317
1317
|
argsBytes: 64 * 1024,
|
|
1318
|
+
maxArgsBytes: 64 * 1024 * 1024,
|
|
1318
1319
|
resultBytes: 1024 * 1024,
|
|
1319
1320
|
widgetStateBytes: 32 * 1024,
|
|
1320
1321
|
handoffBytes: 32 * 1024,
|
|
@@ -422816,6 +422817,7 @@ var init_schema_v1 = __esm(() => {
|
|
|
422816
422817
|
metadata: recordType(stringType(), unknownType()).optional(),
|
|
422817
422818
|
components: componentsSchema,
|
|
422818
422819
|
permissions: objectType({
|
|
422820
|
+
pluginData: arrayType(literalType("write")).min(1).max(1).optional(),
|
|
422819
422821
|
filesystem: permissionListSchema.optional(),
|
|
422820
422822
|
network: permissionListSchema.optional(),
|
|
422821
422823
|
process: permissionListSchema.optional(),
|
|
@@ -423071,6 +423073,12 @@ async function loadNativeAppMetadata(plugin) {
|
|
|
423071
423073
|
const definition = PluginAppManifestSchema.parse(JSON.parse(file.bytes.toString("utf8")));
|
|
423072
423074
|
const resources = [];
|
|
423073
423075
|
for (const backend of definition.backends) {
|
|
423076
|
+
for (const policy of backend.toolPolicies ?? []) {
|
|
423077
|
+
if (policy.authorization && !plugin.manifest.permissions?.pluginData?.includes("write"))
|
|
423078
|
+
throw new Error("plugin data write not declared");
|
|
423079
|
+
if (backend.kind === "native-tools" && !backend.tools.some((tool) => tool.tool === policy.tool && tool.visibility.includes("app")))
|
|
423080
|
+
throw new Error("tool policy requires an exact app tool");
|
|
423081
|
+
}
|
|
423074
423082
|
if (backendIds.has(backend.id) || backendIds.size >= PLUGIN_APP_LIMITS.backendCount)
|
|
423075
423083
|
throw new Error("duplicate backend");
|
|
423076
423084
|
backendIds.add(backend.id);
|
|
@@ -423126,7 +423134,7 @@ async function loadNativeAppMetadata(plugin) {
|
|
|
423126
423134
|
}] };
|
|
423127
423135
|
}
|
|
423128
423136
|
}
|
|
423129
|
-
var id, uri, nativeBackend, PluginAppManifestSchema;
|
|
423137
|
+
var id, uri, toolPolicies, nativeBackend, PluginAppManifestSchema;
|
|
423130
423138
|
var init_apps = __esm(() => {
|
|
423131
423139
|
init_zod();
|
|
423132
423140
|
init_src();
|
|
@@ -423142,9 +423150,15 @@ var init_apps = __esm(() => {
|
|
|
423142
423150
|
return false;
|
|
423143
423151
|
}
|
|
423144
423152
|
}, "resource must be an exact ui:// URI");
|
|
423153
|
+
toolPolicies = arrayType(objectType({
|
|
423154
|
+
tool: stringType().min(1).max(256),
|
|
423155
|
+
authorization: literalType("plugin-data-write").optional(),
|
|
423156
|
+
maxArgumentsBytes: numberType().int().min(1).max(PLUGIN_APP_LIMITS.maxArgsBytes).optional()
|
|
423157
|
+
}).strict()).max(256).refine((items) => new Set(items.map((item) => item.tool)).size === items.length).optional();
|
|
423145
423158
|
nativeBackend = objectType({
|
|
423146
423159
|
id,
|
|
423147
423160
|
kind: literalType("native-tools"),
|
|
423161
|
+
toolPolicies,
|
|
423148
423162
|
resources: arrayType(objectType({ uri, entry: stringType().min(3).refine((value) => value.startsWith("./")) }).strict()).min(1).max(32),
|
|
423149
423163
|
tools: arrayType(objectType({
|
|
423150
423164
|
tool: stringType().min(1).max(256),
|
|
@@ -423156,7 +423170,7 @@ var init_apps = __esm(() => {
|
|
|
423156
423170
|
schemaVersion: literalType(1),
|
|
423157
423171
|
backends: arrayType(discriminatedUnionType("kind", [
|
|
423158
423172
|
nativeBackend,
|
|
423159
|
-
objectType({ id, kind: literalType("mcp-server"), server: stringType().min(1).max(256) }).strict()
|
|
423173
|
+
objectType({ id, kind: literalType("mcp-server"), server: stringType().min(1).max(256), toolPolicies }).strict()
|
|
423160
423174
|
])).min(1).max(PLUGIN_APP_LIMITS.backendCount),
|
|
423161
423175
|
surfaces: arrayType(objectType({
|
|
423162
423176
|
id,
|
|
@@ -426330,6 +426344,7 @@ var init_src14 = __esm(() => {
|
|
|
426330
426344
|
init_src();
|
|
426331
426345
|
init_src();
|
|
426332
426346
|
init_src();
|
|
426347
|
+
init_src();
|
|
426333
426348
|
});
|
|
426334
426349
|
|
|
426335
426350
|
// src/runtime-modes.ts
|
|
@@ -430182,7 +430197,9 @@ async function authorizeToolCall2({ toolUse, tool }, permissionChecker, hookExec
|
|
|
430182
430197
|
executionState: "not_started"
|
|
430183
430198
|
};
|
|
430184
430199
|
}
|
|
430185
|
-
|
|
430200
|
+
const approval = execution?.pluginAppToolApproval;
|
|
430201
|
+
const approvedAppCall = !!approval && approval.runId === execution?.scope.runId && approval.toolUseId === toolUse.id && approval.binding.definition.name === toolUse.name && execution?.capabilityView?.appTools?.get(toolUse.name) === approval.binding && execution?.capabilityView?.tools.get(toolUse.name) === approval.binding && approval.argumentsJson === JSON.stringify(toolUse.input);
|
|
430202
|
+
if (decision.action === "ask" && !approvedAppCall) {
|
|
430186
430203
|
let allowed = false;
|
|
430187
430204
|
if (execution) {
|
|
430188
430205
|
const requestId = `permission_${randomUUID32()}`;
|
|
@@ -430198,12 +430215,12 @@ async function authorizeToolCall2({ toolUse, tool }, permissionChecker, hookExec
|
|
|
430198
430215
|
type: "permission.requested",
|
|
430199
430216
|
data: { requestId, request }
|
|
430200
430217
|
});
|
|
430201
|
-
const
|
|
430218
|
+
const approval2 = await execution.effects.requestPermission(request, execution.scope);
|
|
430202
430219
|
await execution.emit({
|
|
430203
430220
|
type: "permission.resolved",
|
|
430204
|
-
data: { requestId, decision:
|
|
430221
|
+
data: { requestId, decision: approval2 }
|
|
430205
430222
|
});
|
|
430206
|
-
allowed =
|
|
430223
|
+
allowed = approval2.status === "approved";
|
|
430207
430224
|
}
|
|
430208
430225
|
signal?.throwIfAborted();
|
|
430209
430226
|
if (!allowed) {
|
|
@@ -430360,11 +430377,11 @@ function parsePluginAppSource2(value) {
|
|
|
430360
430377
|
return { sessionId: identifier2(input.sessionId), appId: identifier2(input.appId) };
|
|
430361
430378
|
}
|
|
430362
430379
|
function parsePluginAppToolRequest2(value) {
|
|
430363
|
-
const input = record6(copyPluginAppJson2(value, PLUGIN_APP_LIMITS2.
|
|
430380
|
+
const input = record6(copyPluginAppJson2(value, PLUGIN_APP_LIMITS2.maxArgsBytes + 16 * 1024));
|
|
430364
430381
|
fields2(input, ["requestId", "expectedRevision", "toolName", "args", "source", "lease"]);
|
|
430365
430382
|
const lease = record6(input.lease);
|
|
430366
430383
|
fields2(lease, ["token", "backendGeneration"]);
|
|
430367
|
-
const args = record6(copyPluginAppJson2(input.args, PLUGIN_APP_LIMITS2.
|
|
430384
|
+
const args = record6(copyPluginAppJson2(input.args, PLUGIN_APP_LIMITS2.maxArgsBytes));
|
|
430368
430385
|
return {
|
|
430369
430386
|
requestId: identifier2(input.requestId),
|
|
430370
430387
|
expectedRevision: revision2(input.expectedRevision),
|
|
@@ -441911,6 +441928,66 @@ function readonlyMap(entries) {
|
|
|
441911
441928
|
});
|
|
441912
441929
|
return view;
|
|
441913
441930
|
}
|
|
441931
|
+
function capturedAppToolPolicy(capture, name) {
|
|
441932
|
+
const tool = capture.tools.get(name);
|
|
441933
|
+
if (!tool)
|
|
441934
|
+
throw new Error("plugin_app_tool_unavailable");
|
|
441935
|
+
const declared = capture.definition.toolPolicies?.find((policy) => policy.tool === name);
|
|
441936
|
+
const granted = declared?.authorization === "plugin-data-write" && capture.pluginDataWriteApproved === true && tool.ownerPluginId === capture.pluginId && isToolVisibleTo2(tool.definition, "app") && !isToolVisibleTo2(tool.definition, "model");
|
|
441937
|
+
return Object.freeze({
|
|
441938
|
+
confirmation: granted ? "granted" : "required",
|
|
441939
|
+
maxArgumentsBytes: declared?.maxArgumentsBytes ?? PLUGIN_APP_LIMITS2.argsBytes,
|
|
441940
|
+
...granted ? { authorization: "plugin-data-write" } : {}
|
|
441941
|
+
});
|
|
441942
|
+
}
|
|
441943
|
+
function captureAppToolBindings(input, names, serverId, originOnly = false) {
|
|
441944
|
+
const bindings = [];
|
|
441945
|
+
for (const name of names) {
|
|
441946
|
+
const definition = input.toolRegistry.get(name);
|
|
441947
|
+
const source = input.toolRegistry.inspect(name)?.source;
|
|
441948
|
+
const owned = input.definition.kind === "native-tools" ? source?.kind === "plugin" && source.id === input.pluginId : source?.kind === "mcp" && source.id === input.definition.server;
|
|
441949
|
+
if (!definition || !owned || !originOnly && !isToolVisibleTo2(definition, "app"))
|
|
441950
|
+
continue;
|
|
441951
|
+
bindings.push([name, Object.freeze({
|
|
441952
|
+
ownerPluginId: input.pluginId,
|
|
441953
|
+
definition: immutableCopy(definition),
|
|
441954
|
+
source,
|
|
441955
|
+
...serverId ? { serverId } : {},
|
|
441956
|
+
definitionIdentity: toolDefinitionIdentity2(definition),
|
|
441957
|
+
invoke: definition.execute.bind(definition)
|
|
441958
|
+
})]);
|
|
441959
|
+
}
|
|
441960
|
+
return readonlyMap(bindings);
|
|
441961
|
+
}
|
|
441962
|
+
function capturedBackend(input, port, tools, originTools = tools) {
|
|
441963
|
+
return Object.freeze({
|
|
441964
|
+
pluginId: input.pluginId,
|
|
441965
|
+
pluginVersion: input.pluginVersion,
|
|
441966
|
+
pluginDigest: input.pluginDigest,
|
|
441967
|
+
pluginDataWriteApproved: input.pluginDataWriteApproved === true,
|
|
441968
|
+
definitionDigest: input.metadata.definitionDigest,
|
|
441969
|
+
definition: input.definition,
|
|
441970
|
+
surfaces: Object.freeze(input.metadata.definition.surfaces.filter((surface) => surface.backend === input.definition.id)),
|
|
441971
|
+
port,
|
|
441972
|
+
tools,
|
|
441973
|
+
originTools,
|
|
441974
|
+
isCurrentTool: (name) => {
|
|
441975
|
+
if (!port.isCurrent())
|
|
441976
|
+
return false;
|
|
441977
|
+
const captured = tools.get(name);
|
|
441978
|
+
const current = captured && input.toolRegistry.get(captured.definition.name);
|
|
441979
|
+
const source = captured && input.toolRegistry.inspect(captured.definition.name)?.source;
|
|
441980
|
+
return !!captured && !!current && current.execute === captured.definition.execute && toolDefinitionIdentity2(current) === captured.definitionIdentity && source?.kind === captured.source?.kind && source?.id === captured.source?.id && isToolVisibleTo2(current, "app");
|
|
441981
|
+
}
|
|
441982
|
+
});
|
|
441983
|
+
}
|
|
441984
|
+
function immutableCopy(value) {
|
|
441985
|
+
if (Array.isArray(value))
|
|
441986
|
+
return Object.freeze(value.map(immutableCopy));
|
|
441987
|
+
if (value && typeof value === "object")
|
|
441988
|
+
return Object.freeze(Object.fromEntries(Object.entries(value).map(([key, item]) => [key, immutableCopy(item)])));
|
|
441989
|
+
return value;
|
|
441990
|
+
}
|
|
441914
441991
|
function identity2(app) {
|
|
441915
441992
|
return JSON.stringify([
|
|
441916
441993
|
app.sessionId,
|
|
@@ -441930,7 +442007,7 @@ function matches(app, capture) {
|
|
|
441930
442007
|
return app.pluginId === capture.pluginId && app.pluginVersion === capture.pluginVersion && app.pluginDigest === capture.pluginDigest && app.definitionDigest === capture.definitionDigest && app.backendId === capture.definition.id && app.backendKind === capture.definition.kind && (capture.surfaces.some((s2) => s2.resourceUri === app.resourceUri) || capture.definition.kind === "native-tools" && capture.definition.resources.some((r2) => r2.uri === app.resourceUri) || [...(capture.originTools ?? capture.tools).values()].some((t2) => t2.definition.ui?.resourceUri === app.resourceUri));
|
|
441931
442008
|
}
|
|
441932
442009
|
function sameCapture(a2, b2) {
|
|
441933
|
-
return a2.port.isCurrent() && a2.port.generation === b2.port.generation && a2.tools.size === b2.tools.size && [...a2.tools].every(([name, binding]) => {
|
|
442010
|
+
return a2.port.isCurrent() && a2.port.generation === b2.port.generation && a2.pluginDataWriteApproved === b2.pluginDataWriteApproved && a2.tools.size === b2.tools.size && [...a2.tools].every(([name, binding]) => {
|
|
441934
442011
|
const next = b2.tools.get(name);
|
|
441935
442012
|
return !!next && next.definitionIdentity === binding.definitionIdentity && next.definition.execute === binding.definition.execute && next.ownerPluginId === binding.ownerPluginId && next.source?.id === binding.source?.id;
|
|
441936
442013
|
});
|
|
@@ -452268,6 +452345,12 @@ async function loadNativeAppMetadata2(plugin) {
|
|
|
452268
452345
|
const definition = PluginAppManifestSchema2.parse(JSON.parse(file.bytes.toString("utf8")));
|
|
452269
452346
|
const resources = [];
|
|
452270
452347
|
for (const backend of definition.backends) {
|
|
452348
|
+
for (const policy of backend.toolPolicies ?? []) {
|
|
452349
|
+
if (policy.authorization && !plugin.manifest.permissions?.pluginData?.includes("write"))
|
|
452350
|
+
throw new Error("plugin data write not declared");
|
|
452351
|
+
if (backend.kind === "native-tools" && !backend.tools.some((tool) => tool.tool === policy.tool && tool.visibility.includes("app")))
|
|
452352
|
+
throw new Error("tool policy requires an exact app tool");
|
|
452353
|
+
}
|
|
452271
452354
|
if (backendIds.has(backend.id) || backendIds.size >= PLUGIN_APP_LIMITS2.backendCount)
|
|
452272
452355
|
throw new Error("duplicate backend");
|
|
452273
452356
|
backendIds.add(backend.id);
|
|
@@ -456573,53 +456656,6 @@ function toolError(message) {
|
|
|
456573
456656
|
isError: true
|
|
456574
456657
|
};
|
|
456575
456658
|
}
|
|
456576
|
-
function captureAppToolBindings(input, names, serverId, originOnly = false) {
|
|
456577
|
-
const bindings = [];
|
|
456578
|
-
for (const name of names) {
|
|
456579
|
-
const definition = input.toolRegistry.get(name);
|
|
456580
|
-
const source = input.toolRegistry.inspect(name)?.source;
|
|
456581
|
-
const owned = input.definition.kind === "native-tools" ? source?.kind === "plugin" && source.id === input.pluginId : source?.kind === "mcp" && source.id === input.definition.server;
|
|
456582
|
-
if (!definition || !owned || !originOnly && !isToolVisibleTo2(definition, "app"))
|
|
456583
|
-
continue;
|
|
456584
|
-
bindings.push([name, Object.freeze({
|
|
456585
|
-
ownerPluginId: input.pluginId,
|
|
456586
|
-
definition: immutableCopy(definition),
|
|
456587
|
-
source,
|
|
456588
|
-
...serverId ? { serverId } : {},
|
|
456589
|
-
definitionIdentity: toolDefinitionIdentity2(definition),
|
|
456590
|
-
invoke: definition.execute.bind(definition)
|
|
456591
|
-
})]);
|
|
456592
|
-
}
|
|
456593
|
-
return readonlyMap(bindings);
|
|
456594
|
-
}
|
|
456595
|
-
function capturedBackend(input, port, tools, originTools = tools) {
|
|
456596
|
-
return Object.freeze({
|
|
456597
|
-
pluginId: input.pluginId,
|
|
456598
|
-
pluginVersion: input.pluginVersion,
|
|
456599
|
-
pluginDigest: input.pluginDigest,
|
|
456600
|
-
definitionDigest: input.metadata.definitionDigest,
|
|
456601
|
-
definition: input.definition,
|
|
456602
|
-
surfaces: Object.freeze(input.metadata.definition.surfaces.filter((surface) => surface.backend === input.definition.id)),
|
|
456603
|
-
port,
|
|
456604
|
-
tools,
|
|
456605
|
-
originTools,
|
|
456606
|
-
isCurrentTool: (name) => {
|
|
456607
|
-
if (!port.isCurrent())
|
|
456608
|
-
return false;
|
|
456609
|
-
const captured = tools.get(name);
|
|
456610
|
-
const current = captured && input.toolRegistry.get(captured.definition.name);
|
|
456611
|
-
const source = captured && input.toolRegistry.inspect(captured.definition.name)?.source;
|
|
456612
|
-
return !!captured && !!current && current.execute === captured.definition.execute && toolDefinitionIdentity2(current) === captured.definitionIdentity && source?.kind === captured.source?.kind && source?.id === captured.source?.id && isToolVisibleTo2(current, "app");
|
|
456613
|
-
}
|
|
456614
|
-
});
|
|
456615
|
-
}
|
|
456616
|
-
function immutableCopy(value) {
|
|
456617
|
-
if (Array.isArray(value))
|
|
456618
|
-
return Object.freeze(value.map(immutableCopy));
|
|
456619
|
-
if (value && typeof value === "object")
|
|
456620
|
-
return Object.freeze(Object.fromEntries(Object.entries(value).map(([key, item]) => [key, immutableCopy(item)])));
|
|
456621
|
-
return value;
|
|
456622
|
-
}
|
|
456623
456659
|
function createNativePluginAppResourceSnapshot() {
|
|
456624
456660
|
let active = true;
|
|
456625
456661
|
return Object.freeze({ generation: randomUUID40(), isCurrent: () => active, revoke: () => {
|
|
@@ -456718,6 +456754,12 @@ function mcpToolResultToAppResult(original) {
|
|
|
456718
456754
|
throw new Error("plugin_app_mcp_result_unavailable");
|
|
456719
456755
|
return { result: parseMcpCallResultData2(original.mcpResult) };
|
|
456720
456756
|
}
|
|
456757
|
+
function resolvePluginMcpEnvironment(env, input) {
|
|
456758
|
+
return Object.fromEntries(Object.entries(env).map(([key, value]) => [
|
|
456759
|
+
key,
|
|
456760
|
+
value === "${VYKOR_SESSION_ID}" ? createHash222("sha256").update(input.sessionId ?? randomUUID41()).digest("hex") : value === "${VYKOR_WORKSPACE_ROOT}" ? input.cwd : value
|
|
456761
|
+
]));
|
|
456762
|
+
}
|
|
456721
456763
|
async function installRuntimeIntegrations(options) {
|
|
456722
456764
|
const { runtime } = options;
|
|
456723
456765
|
const memory = options.memory;
|
|
@@ -456776,10 +456818,7 @@ async function installRuntimeIntegrations(options) {
|
|
|
456776
456818
|
const serverOwners = new Map([...inventory.mcpServers].map(([id2, owner]) => [owner.serverName, { id: id2, ...owner }]));
|
|
456777
456819
|
for (const [name, config2] of Object.entries(mcpServers)) {
|
|
456778
456820
|
if (serverOwners.has(name) && config2.type === "stdio" && config2.env) {
|
|
456779
|
-
mcpServers[name] = { ...config2, env:
|
|
456780
|
-
key,
|
|
456781
|
-
value === "${VYKOR_SESSION_ID}" ? createHash222("sha256").update(options.sessionId ?? randomUUID41()).digest("hex") : value
|
|
456782
|
-
])) };
|
|
456821
|
+
mcpServers[name] = { ...config2, env: resolvePluginMcpEnvironment(config2.env, options) };
|
|
456783
456822
|
}
|
|
456784
456823
|
}
|
|
456785
456824
|
const enabledMcpServers = filterEnabledMcpServers(mcpServers);
|
|
@@ -457041,6 +457080,7 @@ async function installRuntimeIntegrations(options) {
|
|
|
457041
457080
|
pluginDigest,
|
|
457042
457081
|
metadata,
|
|
457043
457082
|
definition,
|
|
457083
|
+
pluginDataWriteApproved: plugin.manifest.permissions?.pluginData?.includes("write") === true,
|
|
457044
457084
|
toolRegistry: getTrustedToolCatalogue(runtime.toolRegistry)
|
|
457045
457085
|
};
|
|
457046
457086
|
if (definition.kind === "native-tools") {
|
|
@@ -457778,12 +457818,19 @@ var require2, __create2, __defProp2, __getOwnPropDesc, __getOwnPropNames2, __get
|
|
|
457778
457818
|
return [...capture.tools].filter(([name]) => capture.isCurrentTool(name)).map(([name, tool]) => ({
|
|
457779
457819
|
name,
|
|
457780
457820
|
description: tool.definition.description,
|
|
457781
|
-
inputSchema: structuredClone(tool.definition.inputSchema)
|
|
457821
|
+
inputSchema: structuredClone(tool.definition.inputSchema),
|
|
457822
|
+
policy: capturedAppToolPolicy(capture, name)
|
|
457782
457823
|
}));
|
|
457783
457824
|
},
|
|
457784
457825
|
assertTool: async (app, request) => {
|
|
457826
|
+
return (await this.host.prepareTool(app, request)).name;
|
|
457827
|
+
},
|
|
457828
|
+
prepareTool: async (app, request) => {
|
|
457785
457829
|
await this.refresh(app);
|
|
457786
|
-
|
|
457830
|
+
const tool = this.tool(app, request), capture = this.require(app, request.lease);
|
|
457831
|
+
const policy = capturedAppToolPolicy(capture, request.toolName);
|
|
457832
|
+
copyPluginAppJson2(request.args, policy.maxArgumentsBytes);
|
|
457833
|
+
return { name: tool.definition.name, policy };
|
|
457787
457834
|
}
|
|
457788
457835
|
});
|
|
457789
457836
|
}
|
|
@@ -457885,7 +457932,7 @@ var require2, __create2, __defProp2, __getOwnPropDesc, __getOwnPropNames2, __get
|
|
|
457885
457932
|
return tool;
|
|
457886
457933
|
}
|
|
457887
457934
|
async prepare(app, request, view) {
|
|
457888
|
-
await this.
|
|
457935
|
+
const prepared = await this.host.prepareTool(app, request);
|
|
457889
457936
|
const tool = this.tool(app, request);
|
|
457890
457937
|
const server = tool.serverId ? view.mcpServers.get(tool.serverId) : undefined;
|
|
457891
457938
|
if (app.backendKind === "mcp-server" && (!server || server.ownerPluginId !== app.pluginId))
|
|
@@ -457900,7 +457947,7 @@ var require2, __create2, __defProp2, __getOwnPropDesc, __getOwnPropNames2, __get
|
|
|
457900
457947
|
skills: readonlyMap([]),
|
|
457901
457948
|
agents: readonlyMap([])
|
|
457902
457949
|
});
|
|
457903
|
-
return {
|
|
457950
|
+
return { ...prepared, capabilityView, binding: tool };
|
|
457904
457951
|
}
|
|
457905
457952
|
}, GOAL_UPDATE_TOOL_NAME = "GoalUpdate", textSchema, object22 = (properties) => ({
|
|
457906
457953
|
type: "object",
|
|
@@ -458510,9 +458557,14 @@ var require2, __create2, __defProp2, __getOwnPropDesc, __getOwnPropNames2, __get
|
|
|
458510
458557
|
}
|
|
458511
458558
|
await options.onToolEvent?.(event);
|
|
458512
458559
|
}
|
|
458513
|
-
}, "app"
|
|
458560
|
+
}, "app", prepared.policy.confirmation === "granted" ? {
|
|
458561
|
+
runId: options.scope.runId,
|
|
458562
|
+
toolUseId: toolUse.id,
|
|
458563
|
+
binding: prepared.binding,
|
|
458564
|
+
argumentsJson: JSON.stringify(request.args)
|
|
458565
|
+
} : undefined);
|
|
458514
458566
|
}
|
|
458515
|
-
async executeIndependentTool(toolUse, options, audience = "model") {
|
|
458567
|
+
async executeIndependentTool(toolUse, options, audience = "model", pluginAppToolApproval) {
|
|
458516
458568
|
const capabilityView = options.capabilityView;
|
|
458517
458569
|
const controller = new AbortController;
|
|
458518
458570
|
const signal = AbortSignal.any([controller.signal, options.scope.signal, ...options.signal ? [options.signal] : []]);
|
|
@@ -458543,6 +458595,7 @@ var require2, __create2, __defProp2, __getOwnPropDesc, __getOwnPropNames2, __get
|
|
|
458543
458595
|
scope,
|
|
458544
458596
|
capabilityView,
|
|
458545
458597
|
effects: this.effects,
|
|
458598
|
+
...audience === "app" && pluginAppToolApproval ? { pluginAppToolApproval } : {},
|
|
458546
458599
|
children: this.childManager.createController(scope, capabilityView),
|
|
458547
458600
|
emit: options.onToolEvent ?? (async () => {}),
|
|
458548
458601
|
takeSteeredInputs: async () => [],
|
|
@@ -466238,7 +466291,7 @@ rm -- "$1"`, WslFileOperations2 = class {
|
|
|
466238
466291
|
}
|
|
466239
466292
|
}, ZodDiscriminatedUnion2, ZodIntersection2, ZodTuple2, ZodRecord2, ZodMap2, ZodSet2, ZodFunction2, ZodLazy2, ZodLiteral2, ZodEnum2, ZodNativeEnum2, ZodPromise2, ZodEffects2, ZodOptional2, ZodNullable2, ZodDefault2, ZodCatch2, ZodNaN2, BRAND2, ZodBranded2, ZodPipeline2, ZodReadonly2, late2, ZodFirstPartyTypeKind2, instanceOfType = (cls, params = {
|
|
466240
466293
|
message: `Input not instance of ${cls.name}`
|
|
466241
|
-
}) => custom2((data) => data instanceof cls, params), stringType2, numberType2, nanType2, bigIntType2, booleanType2, dateType2, symbolType2, undefinedType2, nullType2, anyType2, unknownType2, neverType2, voidType2, arrayType2, objectType2, strictObjectType2, unionType2, discriminatedUnionType2, intersectionType2, tupleType2, recordType2, mapType2, setType2, functionType2, lazyType2, literalType2, enumType2, nativeEnumType2, promiseType2, effectsType2, optionalType2, nullableType2, preprocessType2, pipelineType2, ostring = () => stringType2().optional(), onumber = () => numberType2().optional(), oboolean = () => booleanType2().optional(), coerce, NEVER, declaredPathSchema2, toolComponentSchema2, pathListSchema2, componentsSchema2, permissionListSchema2, VykorPluginManifestV1Schema2, NativePluginPathError2, PluginFileReadError2, id2, uri2, nativeBackend2, PluginAppManifestSchema2, NATIVE_PLUGIN_COMPONENT_KINDS2, MANIFEST_RELATIVE_PATH2, eventSet2, typeSet2, PERMISSION_CATEGORIES2, deferredKinds2, _a3, NEVER2, $ZodAsyncError, $ZodEncodeError, globalConfig, util_exports, EVALUATING, captureStackTrace, allowsEval, getParsedType22 = (data) => {
|
|
466294
|
+
}) => custom2((data) => data instanceof cls, params), stringType2, numberType2, nanType2, bigIntType2, booleanType2, dateType2, symbolType2, undefinedType2, nullType2, anyType2, unknownType2, neverType2, voidType2, arrayType2, objectType2, strictObjectType2, unionType2, discriminatedUnionType2, intersectionType2, tupleType2, recordType2, mapType2, setType2, functionType2, lazyType2, literalType2, enumType2, nativeEnumType2, promiseType2, effectsType2, optionalType2, nullableType2, preprocessType2, pipelineType2, ostring = () => stringType2().optional(), onumber = () => numberType2().optional(), oboolean = () => booleanType2().optional(), coerce, NEVER, declaredPathSchema2, toolComponentSchema2, pathListSchema2, componentsSchema2, permissionListSchema2, VykorPluginManifestV1Schema2, NativePluginPathError2, PluginFileReadError2, id2, uri2, toolPolicies2, nativeBackend2, PluginAppManifestSchema2, NATIVE_PLUGIN_COMPONENT_KINDS2, MANIFEST_RELATIVE_PATH2, eventSet2, typeSet2, PERMISSION_CATEGORIES2, deferredKinds2, _a3, NEVER2, $ZodAsyncError, $ZodEncodeError, globalConfig, util_exports, EVALUATING, captureStackTrace, allowsEval, getParsedType22 = (data) => {
|
|
466242
466295
|
const t2 = typeof data;
|
|
466243
466296
|
switch (t2) {
|
|
466244
466297
|
case "undefined":
|
|
@@ -470238,6 +470291,7 @@ Keep the summary concise and focused on information needed for continuing the ta
|
|
|
470238
470291
|
resourceBytes: 8 * 1024 * 1024,
|
|
470239
470292
|
appDataBytes: 256 * 1024,
|
|
470240
470293
|
argsBytes: 64 * 1024,
|
|
470294
|
+
maxArgsBytes: 64 * 1024 * 1024,
|
|
470241
470295
|
resultBytes: 1024 * 1024,
|
|
470242
470296
|
widgetStateBytes: 32 * 1024,
|
|
470243
470297
|
handoffBytes: 32 * 1024,
|
|
@@ -471395,7 +471449,7 @@ ${reminder}`;
|
|
|
471395
471449
|
appTools: new Map(appBinding ? [[toolUse.name, appBinding]] : []),
|
|
471396
471450
|
delegatableTools: undefined
|
|
471397
471451
|
}
|
|
471398
|
-
} : original;
|
|
471452
|
+
} : { ...original, pluginAppToolApproval: undefined };
|
|
471399
471453
|
const toolRegistry = runToolRegistry2(this.toolRegistry, [], undefined, execution.capabilityView, options.audience);
|
|
471400
471454
|
const signal = AbortSignal.any([
|
|
471401
471455
|
execution.scope.signal,
|
|
@@ -507284,6 +507338,9 @@ ${INVARIANT_GUIDANCE2}`;
|
|
|
507284
507338
|
});
|
|
507285
507339
|
init_src22();
|
|
507286
507340
|
init_src18();
|
|
507341
|
+
init_src18();
|
|
507342
|
+
init_src22();
|
|
507343
|
+
init_src18();
|
|
507287
507344
|
init_src22();
|
|
507288
507345
|
init_src22();
|
|
507289
507346
|
PluginPreparationError = class extends Error {
|
|
@@ -518761,6 +518818,7 @@ ${GREP_LIMIT_HINT2}` : "")
|
|
|
518761
518818
|
metadata: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
|
|
518762
518819
|
components: componentsSchema2,
|
|
518763
518820
|
permissions: external_exports.object({
|
|
518821
|
+
pluginData: external_exports.array(external_exports.literal("write")).min(1).max(1).optional(),
|
|
518764
518822
|
filesystem: permissionListSchema2.optional(),
|
|
518765
518823
|
network: permissionListSchema2.optional(),
|
|
518766
518824
|
process: permissionListSchema2.optional(),
|
|
@@ -518800,9 +518858,15 @@ ${GREP_LIMIT_HINT2}` : "")
|
|
|
518800
518858
|
return false;
|
|
518801
518859
|
}
|
|
518802
518860
|
}, "resource must be an exact ui:// URI");
|
|
518861
|
+
toolPolicies2 = external_exports.array(external_exports.object({
|
|
518862
|
+
tool: external_exports.string().min(1).max(256),
|
|
518863
|
+
authorization: external_exports.literal("plugin-data-write").optional(),
|
|
518864
|
+
maxArgumentsBytes: external_exports.number().int().min(1).max(PLUGIN_APP_LIMITS2.maxArgsBytes).optional()
|
|
518865
|
+
}).strict()).max(256).refine((items) => new Set(items.map((item) => item.tool)).size === items.length).optional();
|
|
518803
518866
|
nativeBackend2 = external_exports.object({
|
|
518804
518867
|
id: id2,
|
|
518805
518868
|
kind: external_exports.literal("native-tools"),
|
|
518869
|
+
toolPolicies: toolPolicies2,
|
|
518806
518870
|
resources: external_exports.array(external_exports.object({ uri: uri2, entry: external_exports.string().min(3).refine((value) => value.startsWith("./")) }).strict()).min(1).max(32),
|
|
518807
518871
|
tools: external_exports.array(external_exports.object({
|
|
518808
518872
|
tool: external_exports.string().min(1).max(256),
|
|
@@ -518814,7 +518878,7 @@ ${GREP_LIMIT_HINT2}` : "")
|
|
|
518814
518878
|
schemaVersion: external_exports.literal(1),
|
|
518815
518879
|
backends: external_exports.array(external_exports.discriminatedUnion("kind", [
|
|
518816
518880
|
nativeBackend2,
|
|
518817
|
-
external_exports.object({ id: id2, kind: external_exports.literal("mcp-server"), server: external_exports.string().min(1).max(256) }).strict()
|
|
518881
|
+
external_exports.object({ id: id2, kind: external_exports.literal("mcp-server"), server: external_exports.string().min(1).max(256), toolPolicies: toolPolicies2 }).strict()
|
|
518818
518882
|
])).min(1).max(PLUGIN_APP_LIMITS2.backendCount),
|
|
518819
518883
|
surfaces: external_exports.array(external_exports.object({
|
|
518820
518884
|
id: id2,
|
|
@@ -523089,7 +523153,6 @@ ${GREP_LIMIT_HINT2}` : "")
|
|
|
523089
523153
|
init_src102();
|
|
523090
523154
|
init_src22();
|
|
523091
523155
|
init_src18();
|
|
523092
|
-
init_src22();
|
|
523093
523156
|
init_src18();
|
|
523094
523157
|
McpConnectionStageError = class extends Error {
|
|
523095
523158
|
constructor(cause) {
|
|
@@ -534297,7 +534360,7 @@ class PluginAppOperationService {
|
|
|
534297
534360
|
if (session.status === "closing" || session.status === "archived" || app.status !== "open" || app.controlRevision !== revision || app.activeActionRunId !== ownerRunId)
|
|
534298
534361
|
throw new ApplicationError(409, "应用状态或确认版本已变化");
|
|
534299
534362
|
if (bridge.hasWork(source.sessionId) && bridge.activeRunId(source.sessionId) !== ownerRunId || !ownerRunId && this.options.store.runs.listRuns(source.sessionId).some((run) => run.status === "pending" || run.status === "running"))
|
|
534300
|
-
throw new
|
|
534363
|
+
throw new PluginAppBusyError;
|
|
534301
534364
|
return app;
|
|
534302
534365
|
}
|
|
534303
534366
|
async invoke(value) {
|
|
@@ -534351,7 +534414,8 @@ class PluginAppOperationService {
|
|
|
534351
534414
|
kind: "tool",
|
|
534352
534415
|
source: request.source,
|
|
534353
534416
|
requestId: request.requestId,
|
|
534354
|
-
expectedRevision: request.expectedRevision
|
|
534417
|
+
expectedRevision: request.expectedRevision,
|
|
534418
|
+
...error instanceof PluginAppBusyError ? { reason: "busy" } : {}
|
|
534355
534419
|
});
|
|
534356
534420
|
throw error;
|
|
534357
534421
|
}
|
|
@@ -534443,11 +534507,17 @@ class PluginAppOperationService {
|
|
|
534443
534507
|
}
|
|
534444
534508
|
}
|
|
534445
534509
|
}
|
|
534510
|
+
var PluginAppBusyError;
|
|
534446
534511
|
var init_plugin_app_operation_service = __esm(() => {
|
|
534447
534512
|
init_dist2();
|
|
534448
534513
|
init_src();
|
|
534449
534514
|
init_application_error();
|
|
534450
534515
|
init_plugin_app_admission_error();
|
|
534516
|
+
PluginAppBusyError = class PluginAppBusyError extends ApplicationError {
|
|
534517
|
+
constructor() {
|
|
534518
|
+
super(409, "会话正在处理其他操作");
|
|
534519
|
+
}
|
|
534520
|
+
};
|
|
534451
534521
|
});
|
|
534452
534522
|
|
|
534453
534523
|
// ../../packages/server/src/application/session/plugin-app-operation-executor.ts
|
|
@@ -667623,7 +667693,7 @@ function createSessionPluginAppsRoutes(runtime, conversation) {
|
|
|
667623
667693
|
const input = await readJson(c), from = source(c);
|
|
667624
667694
|
return jsonResponse({ app: await runtime.mutate(from.sessionId, async () => runtime.apps.close(from, input)) });
|
|
667625
667695
|
}).post("/:sessionId/plugin-apps/:appId/actions", async (c) => {
|
|
667626
|
-
const response = await runtime.actions.invoke(fixed(c, parsePluginAppToolRequest(await readJson(c))));
|
|
667696
|
+
const response = await runtime.actions.invoke(fixed(c, parsePluginAppToolRequest(await readJson(c, undefined, PLUGIN_APP_LIMITS.maxArgsBytes + 16 * 1024))));
|
|
667627
667697
|
return jsonResponse(response, ["pending", "running"].includes(response.receipt.status) ? 202 : 200);
|
|
667628
667698
|
}).get("/:sessionId/plugin-apps/:appId/actions/:requestId", (c) => jsonResponse(runtime.actions.read(source(c), c.req.param("requestId")))).post("/:sessionId/plugin-apps/:appId/actions/:requestId/cancel", async (c) => {
|
|
667629
667699
|
const from = source(c);
|
|
@@ -672419,4 +672489,4 @@ program.command("doctor").description("Check environment and dependencies").acti
|
|
|
672419
672489
|
});
|
|
672420
672490
|
program.parse();
|
|
672421
672491
|
|
|
672422
|
-
//# debugId=
|
|
672492
|
+
//# debugId=4E50131CAB954F1F64756E2164756E21
|