@tryvira/opencode 0.1.21 → 0.1.23

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.20
1
+ # `@tryvira/opencode` 0.1.23
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
@@ -15,7 +15,7 @@ a failed response. User-only, tool-only and image-only events are not recorded
15
15
  as assistant output. Hosts that do not include assistant messages in context
16
16
  events must submit output observations through their normal Vira SDK integration.
17
17
 
18
- Configuration is supplied through OpenCode plugin options or environment variables: `VIRA_CONTROL_URL`, `VIRA_API_KEY`, `VIRA_ORGANIZATION_ID`, `VIRA_PROJECT_ID`, `VIRA_ENVIRONMENT_ID`, `VIRA_AI_SYSTEM_ID`, `VIRA_CONNECTION_ID`, and `VIRA_HOST_MODE` (`off`, `observe`, `enforce`). `adapterVersion` (or `VIRA_ADAPTER_VERSION`) is the stable Vira adapter protocol version and is intentionally separate from the OpenCode application version; leave it at `1` unless the adapter contract changes. V1 `server()` and V2 `setup()` read the same options, so a fixed connection identity is not recreated with a changing host application version.
18
+ Configuration is supplied through OpenCode plugin options or environment variables: `VIRA_CONTROL_URL`, `VIRA_API_KEY`, `VIRA_ORGANIZATION_ID`, `VIRA_PROJECT_ID`, `VIRA_ENVIRONMENT_ID`, `VIRA_AI_SYSTEM_ID`, `VIRA_CONNECTION_ID`, and `VIRA_HOST_MODE` (`off`, `observe`, `enforce`). `VIRA_HOST_TIMEOUT_MS` controls the bounded host lifecycle timeout (default 30 seconds, maximum 120 seconds) and is applied consistently to the SDK HTTP request and semantic/runtime hook. Use it when a provider-backed semantic decision legitimately takes longer than the default; timeouts still fail closed. `adapterVersion` (or `VIRA_ADAPTER_VERSION`) is the stable Vira adapter protocol version and is intentionally separate from the OpenCode application version; leave it at `1` unless the adapter contract changes. V1 `server()` and V2 `setup()` read the same options, so a fixed connection identity is not recreated with a changing host application version.
19
19
 
20
20
  In `enforce` mode, V2 uses OpenCode's native `permission.evaluate` hook. Effectful tool calls are changed to `ask`; the customer confirms the exact tool in OpenCode's own permission UI, and only then does the plugin create a server-owned one-use approval bound to that proposal. JSON options cannot contain a confirmation callback or a `confirmed` flag. `permissionMode:"deny"` disables the native bridge and therefore fails closed. A denial, expiry, changed argument set, or replay remains blocked. The optional `confirmAction` is retained only as a programmatic embedding seam for tests/host adapters; it is not a JSON-configured approval mechanism. V1 hosts without the native permission hook remain fail-closed for approval-required actions.
21
21
  For an isolated loopback-only test boundary, `VIRA_ALLOW_INSECURE_LOCALHOST=true` may be set; production API URLs must remain HTTPS.
package/dist/index.js CHANGED
@@ -1585,7 +1585,7 @@ var hostVersionFor = (options, rawContext = {}) => {
1585
1585
  return options.hostVersion?.trim() || text2(app.version).trim() || text2(raw.version).trim() || envValue("VIRA_HOST_VERSION")?.trim() || "unknown";
1586
1586
  };
1587
1587
  var adapterVersionFor = (options) => options.adapterVersion ?? envValue("VIRA_ADAPTER_VERSION") ?? "1";
1588
- var openCodeConnectConfig = (scope, options) => ({ ...scope, name: "OpenCode", systemType: "agent", adapterType: "custom-node", adapterVersion: adapterVersionFor(options), idempotencyKey: "opencode:vira:connect", reuseExistingConnectionOnConflict: true });
1588
+ 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-v1", reuseExistingConnectionOnConflict: true });
1589
1589
  var resolveOpenCodeToolBinding = (tools, toolName) => {
1590
1590
  const allowedToolIds = Array.isArray(tools.allowed_tool_ids) ? tools.allowed_tool_ids.map(text2) : [];
1591
1591
  const bindings = Array.isArray(tools.tool_bindings) ? tools.tool_bindings.filter((value) => value && typeof value === "object").map((value) => asRecord(value)) : [];
@@ -1818,7 +1818,9 @@ var v1Runtime = (options) => {
1818
1818
  const mode = options.mode ?? env("VIRA_HOST_MODE") ?? "off";
1819
1819
  if (mode === "off") return null;
1820
1820
  const scope = { organizationId: required2(options.organizationId ?? env("VIRA_ORGANIZATION_ID"), "VIRA_HOST_ORGANIZATION_REQUIRED"), projectId: required2(options.projectId ?? env("VIRA_PROJECT_ID"), "VIRA_HOST_PROJECT_REQUIRED"), environmentId: required2(options.environmentId ?? env("VIRA_ENVIRONMENT_ID"), "VIRA_HOST_ENVIRONMENT_REQUIRED") };
1821
- const client = new ViraClient({ baseUrl: required2(options.apiUrl ?? env("VIRA_CONTROL_URL") ?? env("VIRA_API_URL"), "VIRA_HOST_API_URL_REQUIRED"), apiKey: options.apiKey ?? env("VIRA_API_KEY"), allowInsecureLocalhost: options.allowInsecureLocalhost ?? env("VIRA_ALLOW_INSECURE_LOCALHOST") === "true" });
1821
+ const configuredTimeout = Number(options.timeoutMs ?? env("VIRA_HOST_TIMEOUT_MS") ?? 3e4);
1822
+ const timeoutMs = Number.isFinite(configuredTimeout) ? configuredTimeout : 3e4;
1823
+ const client = new ViraClient({ baseUrl: required2(options.apiUrl ?? env("VIRA_CONTROL_URL") ?? env("VIRA_API_URL"), "VIRA_HOST_API_URL_REQUIRED"), apiKey: options.apiKey ?? env("VIRA_API_KEY"), timeoutMs, allowInsecureLocalhost: options.allowInsecureLocalhost ?? env("VIRA_ALLOW_INSECURE_LOCALHOST") === "true" });
1822
1824
  const actionContexts = /* @__PURE__ */ new Map();
1823
1825
  const actionDecisions = /* @__PURE__ */ new Map();
1824
1826
  const contextKey = (identity) => identity.organizationId + ":" + identity.projectId + ":" + identity.environmentId + ":" + identity.conversationId + ":" + (identity.sessionId ?? identity.conversationId);
@@ -1844,7 +1846,7 @@ var v1Runtime = (options) => {
1844
1846
  }
1845
1847
  };
1846
1848
  const authorizeAction = options.authorizeAction ?? serverAuthorizeAction;
1847
- return { mode, scope, client, actionContexts, actionDecisions, contextKey, runtime: createViraHostRuntime(client, { mode, ...(options.aiSystemId ?? env("VIRA_AI_SYSTEM_ID")) && (options.connectionId ?? env("VIRA_CONNECTION_ID")) ? {} : { connect: openCodeConnectConfig(scope, options) }, capabilities: { canObserveModel: true, canInjectContext: true, canInterceptToolBefore: true, canInspectToolAfter: true, canPreventSideEffect: mode === "enforce", canInterceptResponseBeforeDisplay: false, ...options.capabilities ?? {} }, authorizeAction }) };
1849
+ return { mode, scope, client, actionContexts, actionDecisions, contextKey, runtime: createViraHostRuntime(client, { mode, timeoutMs, ...(options.aiSystemId ?? env("VIRA_AI_SYSTEM_ID")) && (options.connectionId ?? env("VIRA_CONNECTION_ID")) ? {} : { connect: openCodeConnectConfig(scope, options) }, capabilities: { canObserveModel: true, canInjectContext: true, canInterceptToolBefore: true, canInspectToolAfter: true, canPreventSideEffect: mode === "enforce", canInterceptResponseBeforeDisplay: false, ...options.capabilities ?? {} }, authorizeAction }) };
1848
1850
  };
1849
1851
  var v1Fallback = { async server(rawContext = {}) {
1850
1852
  const options = readHostOptions(rawContext);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryvira/opencode",
3
- "version": "0.1.21",
3
+ "version": "0.1.23",
4
4
  "description": "OpenCode V2 host lifecycle integration for Vira",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",