@tryvira/opencode 0.1.30 → 0.1.31
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/README.md +1 -1
- package/dist/index.js +12 -2
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1693,11 +1693,13 @@ var v2Plugin = Plugin.define({
|
|
|
1693
1693
|
if (!bootstrapAiSystemId || !bootstrapConnectionId) {
|
|
1694
1694
|
try {
|
|
1695
1695
|
const listed = await client.listAISystems();
|
|
1696
|
-
const
|
|
1696
|
+
const systems = Array.isArray(listed?.body?.systems) ? listed.body.systems : [];
|
|
1697
|
+
const system = systems.find((item) => String(item.name ?? "") === "OpenCode" && String(item.systemType ?? "") === "agent" && String(item.organizationId ?? "") === scope.organizationId && String(item.projectId ?? "") === scope.projectId && String(item.environmentId ?? "") === scope.environmentId);
|
|
1697
1698
|
if (system?.id) {
|
|
1698
1699
|
const connections = await client.listSystemConnections(String(system.id));
|
|
1700
|
+
const connectionRows = Array.isArray(connections?.body?.connections) ? connections.body.connections : [];
|
|
1699
1701
|
const requested = new Set(openCodeConnectConfig(scope, options).capabilities);
|
|
1700
|
-
const connection =
|
|
1702
|
+
const connection = connectionRows.find((item) => String(item.adapterType ?? "") === "custom-node" && requested.size <= (Array.isArray(item.capabilities) ? item.capabilities.length : 0) && [...requested].every((capability) => Array.isArray(item.capabilities) && item.capabilities.includes(capability)));
|
|
1701
1703
|
if (connection?.id) {
|
|
1702
1704
|
bootstrapAiSystemId = String(system.id);
|
|
1703
1705
|
bootstrapConnectionId = String(connection.id);
|
|
@@ -1940,6 +1942,14 @@ var v1Fallback = { async server(rawContext = {}) {
|
|
|
1940
1942
|
if (Object.keys(hostOptions).length) output.options = hostOptions;
|
|
1941
1943
|
if (result.status === "applied" && result.projection) output.system = [...Array.isArray(output.system) ? output.system : [], result.projection];
|
|
1942
1944
|
},
|
|
1945
|
+
"permission.ask": async (input, output) => {
|
|
1946
|
+
if (mode !== "enforce") return;
|
|
1947
|
+
const metadata = asRecord(input.metadata);
|
|
1948
|
+
const proposal = { ...identity(input), requestId: text2(input.messageID ?? input.requestId) || `opencode:${Date.now()}`, callId: required2(input.callID ?? input.id, "VIRA_HOST_TOOL_CALL_REQUIRED"), toolName: required2(metadata.tool ?? metadata.toolName ?? input.type, "VIRA_HOST_TOOL_NAME_REQUIRED"), args: asRecord(metadata.args ?? metadata.input ?? metadata.arguments), traceId: text2(input.traceID), turnId: text2(input.turnID) };
|
|
1949
|
+
const decision = await runtime.beforeTool(proposal);
|
|
1950
|
+
actionDecisions.set(contextKey(proposal) + ":" + proposal.callId, decision);
|
|
1951
|
+
output.status = decision.decision === "ALLOW" ? "allow" : "deny";
|
|
1952
|
+
},
|
|
1943
1953
|
"tool.execute.before": async (input, output) => {
|
|
1944
1954
|
const proposal = { ...identity(input), requestId: text2(input.messageID ?? input.requestId) || `opencode:${Date.now()}`, callId: required2(input.callID ?? input.id, "VIRA_HOST_TOOL_CALL_REQUIRED"), toolName: required2(input.tool ?? input.name, "VIRA_HOST_TOOL_NAME_REQUIRED"), args: asRecord(output.args ?? input.args ?? input.input), traceId: text2(input.traceID), turnId: text2(input.turnID) };
|
|
1945
1955
|
const decision = await runtime.beforeTool(proposal);
|