@tryvira/opencode 0.1.6 → 0.1.8

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,10 +1,11 @@
1
- # `@tryvira/opencode` 0.1.6
1
+ # `@tryvira/opencode` 0.1.8
2
2
 
3
3
  OpenCode V2 server plugin for Vira host lifecycle governance.
4
4
 
5
5
  It resolves Vira behavior on every `context` hook, observes tool results, and in `enforce` mode blocks tool execution unless a host action authorizer returns an exact Vira `ALLOW` receipt. OpenCode V2 does not expose a supported response-before-display hook, so post-model verification is reported as unsupported rather than claimed as enforced.
6
6
 
7
7
  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`).
8
+ For an isolated loopback-only test boundary, `VIRA_ALLOW_INSECURE_LOCALHOST=true` may be set; production API URLs must remain HTTPS.
8
9
 
9
10
  `enforce` requires a host-provided `authorizeAction` callback that calls the
10
11
  server-owned action authorization boundary and returns the exact Vira
package/dist/index.js CHANGED
@@ -1236,11 +1236,11 @@ function createViraHostRuntime(client, config) {
1236
1236
  try {
1237
1237
  const result = await input.execute(proposal.args);
1238
1238
  const resultDigest = digest(result);
1239
- const observation = await afterTool({ ...proposal, ok: true, result, resultDigest });
1239
+ const observation = await afterTool({ ...proposal, ok: true, result, resultDigest, ...decision.authorityReceiptDigest ? { authorityReceiptDigest: decision.authorityReceiptDigest } : {}, ...decision.decisionDigest ? { decisionDigest: decision.decisionDigest } : {} });
1240
1240
  return { decision, executed: true, result, observation };
1241
1241
  } catch (error) {
1242
1242
  const errorCode = error instanceof Error ? error.message : "GOVERNED_TOOL_FAILED";
1243
- const observation = await afterTool({ ...proposal, ok: false, errorCode, resultDigest: digest({ errorCode }) });
1243
+ const observation = await afterTool({ ...proposal, ok: false, errorCode, resultDigest: digest({ errorCode }), ...decision.authorityReceiptDigest ? { authorityReceiptDigest: decision.authorityReceiptDigest } : {}, ...decision.decisionDigest ? { decisionDigest: decision.decisionDigest } : {} });
1244
1244
  throw Object.assign(error instanceof Error ? error : new Error(errorCode), { decision, observation });
1245
1245
  }
1246
1246
  };
@@ -1288,7 +1288,8 @@ var v2Plugin = Plugin.define({
1288
1288
  const apiUrl = options.apiUrl ?? env("VIRA_CONTROL_URL") ?? env("VIRA_API_URL");
1289
1289
  const apiKey = options.apiKey ?? env("VIRA_API_KEY");
1290
1290
  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") };
1291
- const client = new ViraClient({ baseUrl: required2(apiUrl, "VIRA_HOST_API_URL_REQUIRED"), apiKey });
1291
+ const allowInsecureLocalhost = options.allowInsecureLocalhost ?? env("VIRA_ALLOW_INSECURE_LOCALHOST") === "true";
1292
+ const client = new ViraClient({ baseUrl: required2(apiUrl, "VIRA_HOST_API_URL_REQUIRED"), apiKey, allowInsecureLocalhost });
1292
1293
  const capabilities = { canObserveModel: true, canInjectContext: true, canInterceptToolBefore: true, canInspectToolAfter: true, canPreventSideEffect: mode === "enforce", canInterceptResponseBeforeDisplay: false, ...options.capabilities ?? {} };
1293
1294
  const actionContexts = /* @__PURE__ */ new Map();
1294
1295
  const actionDecisions = /* @__PURE__ */ new Map();
@@ -1387,7 +1388,7 @@ var v1Runtime = () => {
1387
1388
  const mode = env("VIRA_HOST_MODE") ?? "off";
1388
1389
  if (mode === "off") return null;
1389
1390
  const scope = { organizationId: required2(env("VIRA_ORGANIZATION_ID"), "VIRA_HOST_ORGANIZATION_REQUIRED"), projectId: required2(env("VIRA_PROJECT_ID"), "VIRA_HOST_PROJECT_REQUIRED"), environmentId: required2(env("VIRA_ENVIRONMENT_ID"), "VIRA_HOST_ENVIRONMENT_REQUIRED") };
1390
- const client = new ViraClient({ baseUrl: required2(env("VIRA_CONTROL_URL") ?? env("VIRA_API_URL"), "VIRA_HOST_API_URL_REQUIRED"), apiKey: env("VIRA_API_KEY") });
1391
+ const client = new ViraClient({ baseUrl: required2(env("VIRA_CONTROL_URL") ?? env("VIRA_API_URL"), "VIRA_HOST_API_URL_REQUIRED"), apiKey: env("VIRA_API_KEY"), allowInsecureLocalhost: env("VIRA_ALLOW_INSECURE_LOCALHOST") === "true" });
1391
1392
  return { mode, scope, client, runtime: createViraHostRuntime(client, { mode, connect: { ...scope, name: "OpenCode", systemType: "agent", adapterType: "custom-node", adapterVersion: "1.19.5", idempotencyKey: "opencode:vira:connect" }, capabilities: { canObserveModel: true, canInjectContext: true, canInterceptToolBefore: true, canInspectToolAfter: true, canPreventSideEffect: mode === "enforce", canInterceptResponseBeforeDisplay: false }, authorizeAction: async () => ({ decision: "BLOCK", reasonCode: "VIRA_V1_ACTION_AUTHORIZER_UNAVAILABLE" }) }) };
1392
1393
  };
1393
1394
  var index_default = { ...v2Plugin, async server() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryvira/opencode",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "OpenCode V2 host lifecycle integration for Vira",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",