@tryvira/opencode 0.1.27 → 0.1.29
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 +22 -4
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1599,7 +1599,7 @@ var hostVersionFor = (options, rawContext = {}) => {
|
|
|
1599
1599
|
return options.hostVersion?.trim() || text2(app.version).trim() || text2(raw.version).trim() || envValue("VIRA_HOST_VERSION")?.trim() || "unknown";
|
|
1600
1600
|
};
|
|
1601
1601
|
var adapterVersionFor = (options) => options.adapterVersion ?? envValue("VIRA_ADAPTER_VERSION") ?? "1";
|
|
1602
|
-
var openCodeConnectConfig = (scope, options) => ({ ...scope, name: "OpenCode", systemType: "agent", adapterType: "custom-node", adapterVersion: adapterVersionFor(options), capabilities: ["conversation_input", "conversation_output", "model_call", "tool_selection", "tool_execution", "external_action", "user_feedback", "business_outcome"], privacyPolicy: { allowConversationText: false, allowToolArguments: false }, idempotencyKey: "opencode:vira:connect:capabilities-
|
|
1602
|
+
var openCodeConnectConfig = (scope, options) => ({ ...scope, name: "OpenCode", systemType: "agent", adapterType: "custom-node", adapterVersion: adapterVersionFor(options), capabilities: ["conversation_input", "conversation_output", "model_call", "tool_selection", "tool_execution", "external_action", "user_feedback", "business_outcome"], privacyPolicy: { allowConversationText: false, allowToolArguments: false }, idempotencyKey: "opencode:vira:connect:capabilities-v4", reuseExistingConnectionOnConflict: true });
|
|
1603
1603
|
var resolveOpenCodeToolBinding = (tools, toolName) => {
|
|
1604
1604
|
const allowedToolIds = Array.isArray(tools.allowed_tool_ids) ? tools.allowed_tool_ids.map(text2) : [];
|
|
1605
1605
|
const bindings = Array.isArray(tools.tool_bindings) ? tools.tool_bindings.filter((value) => value && typeof value === "object").map((value) => asRecord(value)) : [];
|
|
@@ -1688,6 +1688,24 @@ var v2Plugin = Plugin.define({
|
|
|
1688
1688
|
}
|
|
1689
1689
|
};
|
|
1690
1690
|
const nativeConfirm = desktopPermission.confirm;
|
|
1691
|
+
let bootstrapAiSystemId = options.aiSystemId ?? env("VIRA_AI_SYSTEM_ID") ?? "";
|
|
1692
|
+
let bootstrapConnectionId = options.connectionId ?? env("VIRA_CONNECTION_ID") ?? "";
|
|
1693
|
+
if (!bootstrapAiSystemId || !bootstrapConnectionId) {
|
|
1694
|
+
try {
|
|
1695
|
+
const listed = await client.listAISystems();
|
|
1696
|
+
const system = listed?.body?.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
|
+
if (system?.id) {
|
|
1698
|
+
const connections = await client.listSystemConnections(String(system.id));
|
|
1699
|
+
const requested = new Set(openCodeConnectConfig(scope, options).capabilities);
|
|
1700
|
+
const connection = connections?.body?.connections?.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
|
+
if (connection?.id) {
|
|
1702
|
+
bootstrapAiSystemId = String(system.id);
|
|
1703
|
+
bootstrapConnectionId = String(connection.id);
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
} catch {
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1691
1709
|
const runtime = createViraHostRuntime(client, { mode, capabilities, authorizeAction: options.authorizeAction ?? (async (proposal) => {
|
|
1692
1710
|
const bound = actionContexts.get(contextKey(proposal));
|
|
1693
1711
|
if (!bound) return { decision: "BLOCK", reasonCode: "RUNTIME_ACTION_CONTEXT_UNAVAILABLE" };
|
|
@@ -1711,9 +1729,9 @@ var v2Plugin = Plugin.define({
|
|
|
1711
1729
|
if (!dataVersion) return { decision: "BLOCK", reasonCode: "RUNTIME_ACTION_DATA_VERSION_UNAVAILABLE" };
|
|
1712
1730
|
const refs = Array.isArray(bound.context.signal_attestation_refs) ? bound.context.signal_attestation_refs : [];
|
|
1713
1731
|
return authorizeWithOneShotCustomerConfirmation({ client, proposal, proposalBody, signalAttestationRefs: refs, executionId: bound.executionId, sessionId: proposal.sessionId ?? proposal.conversationId, dataVersion, scope, context: bound.context, confirmAction: options.confirmAction ?? nativeConfirm, approvalId: approval?.approvalId });
|
|
1714
|
-
}), ...
|
|
1715
|
-
let connectedAiSystemId =
|
|
1716
|
-
let connectedConnectionId =
|
|
1732
|
+
}), ...bootstrapAiSystemId && bootstrapConnectionId ? {} : { connect: openCodeConnectConfig(scope, options) } });
|
|
1733
|
+
let connectedAiSystemId = bootstrapAiSystemId;
|
|
1734
|
+
let connectedConnectionId = bootstrapConnectionId;
|
|
1717
1735
|
if (!connectedAiSystemId || !connectedConnectionId) {
|
|
1718
1736
|
await runtime.connectOnce();
|
|
1719
1737
|
const identity = runtime.getConnectionIdentity();
|