@tryvira/opencode 0.1.30 → 0.1.32

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.30
1
+ # `@tryvira/opencode` 0.1.32
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
@@ -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 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);
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 = 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)));
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);
@@ -1967,7 +1977,9 @@ var v1Fallback = { async server(rawContext = {}) {
1967
1977
  }
1968
1978
  };
1969
1979
  } };
1970
- var index_default = { ...v2Plugin, ...v1Fallback };
1980
+ var legacyDefault = async (rawContext = {}, options = {}) => v1Fallback.server({ ...asRecord(rawContext), ...options });
1981
+ Object.assign(legacyDefault, v2Plugin, v1Fallback);
1982
+ var index_default = legacyDefault;
1971
1983
  export {
1972
1984
  ViraOpenCodeActionError,
1973
1985
  adapterVersionFor,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryvira/opencode",
3
- "version": "0.1.30",
3
+ "version": "0.1.32",
4
4
  "description": "OpenCode V2 host lifecycle integration for Vira",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",