@tryvira/opencode 0.1.67 → 0.1.76
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 +15 -3
- package/dist/index.js +21686 -539
- package/dist/server.js +23374 -0
- package/package.json +5 -6
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# `@tryvira/opencode` 0.1.
|
|
1
|
+
# `@tryvira/opencode` 0.1.76
|
|
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,9 +15,18 @@ 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`). `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.
|
|
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_ORGANIZATION_UNIT_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
|
+
An embedding host that can construct plugin options programmatically may supply an
|
|
21
|
+
`accessTokenProvider` callback. The SDK calls it for each API request and sends
|
|
22
|
+
the returned token only as `Authorization: Bearer`; when provided, it takes
|
|
23
|
+
precedence over `apiKey`. Keep token refresh, expiry, storage and revocation in
|
|
24
|
+
the host's credential manager. This callback cannot be represented in OpenCode's
|
|
25
|
+
JSON configuration and does not provide browser OAuth or native OpenCode OAuth
|
|
26
|
+
consent by itself. OpenCode OAuth support remains host-acceptance work; the
|
|
27
|
+
existing API-key configuration continues to work.
|
|
28
|
+
|
|
29
|
+
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 a matching native `permission.asked` followed by `permission.replied` with `reply: once` can create a server-owned one-use approval bound to the exact proposal. The host must supply exact tool-call identity and arguments in the permission metadata; without those or the event stream, approval-required actions remain blocked. An ask, saved/always permission, rejection, mismatched arguments or missing reply is not confirmation. 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
30
|
For an isolated loopback-only test boundary, `VIRA_ALLOW_INSECURE_LOCALHOST=true` may be set; production API URLs must remain HTTPS.
|
|
22
31
|
|
|
23
32
|
`enforce` requires a host-provided `authorizeAction` callback that calls the
|
|
@@ -42,3 +51,6 @@ deny path.
|
|
|
42
51
|
### Quality signals
|
|
43
52
|
|
|
44
53
|
On current OpenCode V2, the plugin also subscribes to the server event stream when available. Events carrying `feedback`/`userFeedback` or `outcome`/`businessOutcome` are converted into separate `feedback.user` and `business.outcome` records. Older hosts can call the exported `recordUserCorrection` and `recordBusinessOutcome` helpers. Both paths send only status, reason codes and SHA-256 digests; raw correction or outcome content never leaves the host.
|
|
54
|
+
|
|
55
|
+
### OpenCode 2.3 native approval
|
|
56
|
+
Use the dedicated `@tryvira/opencode/server` entrypoint (object loader) for V2; the root callable entry stays compatible with legacy hosts. When Vira requires approval, the adapter invokes native `permission.assert` for `vira.confirm.<tool>` with the exact proposal, empty saved scope, and an ephemeral nonce. Only the matching once event plus the resolved native assertion admits one server-owned approval. Configure the native rule for that action as ask/allow, never override a native deny. The original native tool permission remains unchanged. Unattended resolution, timeout, rejection, missing stream, and always approval cannot create a grant.
|