@tryvira/opencode 0.1.28 → 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 CHANGED
@@ -1,4 +1,4 @@
1
- # `@tryvira/opencode` 0.1.28
1
+ # `@tryvira/opencode` 0.1.29
2
2
 
3
3
  OpenCode V2 server plugin for Vira host lifecycle governance. The package default
4
4
  exports the V2 setup surface plus a compatibility `server()` transport required
package/dist/index.js CHANGED
@@ -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
- }), ...(options.aiSystemId ?? env("VIRA_AI_SYSTEM_ID")) && (options.connectionId ?? env("VIRA_CONNECTION_ID")) ? {} : { connect: openCodeConnectConfig(scope, options) } });
1715
- let connectedAiSystemId = options.aiSystemId ?? env("VIRA_AI_SYSTEM_ID") ?? "";
1716
- let connectedConnectionId = options.connectionId ?? env("VIRA_CONNECTION_ID") ?? "";
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();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryvira/opencode",
3
- "version": "0.1.28",
3
+ "version": "0.1.29",
4
4
  "description": "OpenCode V2 host lifecycle integration for Vira",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",