@tryvira/opencode 0.1.3 → 0.1.4
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/dist/index.js +5 -3
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -491,10 +491,11 @@ var ViraClient = class {
|
|
|
491
491
|
required(input.scope.projectId, "SDK_ACTION_PROJECT_REQUIRED");
|
|
492
492
|
required(input.scope.environmentId, "SDK_ACTION_ENVIRONMENT_REQUIRED");
|
|
493
493
|
required(input.executionId, "SDK_ACTION_EXECUTION_REQUIRED");
|
|
494
|
+
required(input.sessionId, "SDK_ACTION_SESSION_REQUIRED");
|
|
494
495
|
return this.request({
|
|
495
496
|
method: "POST",
|
|
496
497
|
path: "/v1/runtime/actions/authorize",
|
|
497
|
-
body: { executionId: input.executionId, scope: input.scope, context: input.context, proposal: input.proposal }
|
|
498
|
+
body: { executionId: input.executionId, sessionId: input.sessionId, scope: input.scope, context: input.context, proposal: input.proposal, ...input.approval ? { approval: input.approval } : {} }
|
|
498
499
|
});
|
|
499
500
|
}
|
|
500
501
|
listBehaviorStrategies() {
|
|
@@ -1276,7 +1277,8 @@ var v2Plugin = Plugin.define({
|
|
|
1276
1277
|
const bound = actionContexts.get(contextKey);
|
|
1277
1278
|
if (!bound) return { decision: "BLOCK", reasonCode: "RUNTIME_ACTION_CONTEXT_UNAVAILABLE" };
|
|
1278
1279
|
try {
|
|
1279
|
-
const
|
|
1280
|
+
const approval = asRecord(asRecord(proposal).approval);
|
|
1281
|
+
const response = await client.authorizeHostAction({ executionId: bound.executionId, sessionId: proposal.sessionId ?? proposal.conversationId, scope, context: bound.context, proposal: { proposal_id: proposal.conversationId + ":" + proposal.callId, tool_key: proposal.toolName, arguments: proposal.args, arguments_digest: digest2(proposal.args), request_context_digest: digest2(bound.context), schema_digest: String(asRecord(asRecord(bound.context).tools).schema_digest ?? "") }, ...Object.keys(approval).length ? { approval } : {} });
|
|
1280
1282
|
const body = asRecord(response?.body);
|
|
1281
1283
|
return body.allowed === true ? { decision: "ALLOW", authorityReceiptDigest: text(body.authority_receipt_digest), decisionDigest: text(body.decision_digest) } : { decision: "BLOCK", reasonCode: text(body.reason_code) || "POLICY_DENIED", authorityReceiptDigest: text(body.authority_receipt_digest) };
|
|
1282
1284
|
} catch (error) {
|
|
@@ -1308,7 +1310,7 @@ var v2Plugin = Plugin.define({
|
|
|
1308
1310
|
registrations.push(await ctx.tool.hook("execute.before", async (event) => {
|
|
1309
1311
|
const identity = sessionIdentity(event);
|
|
1310
1312
|
const decision = await runtime.beforeTool({ ...identity, requestId: text(event.messageID ?? event.requestId) || `opencode:${Date.now()}`, callId: required2(event.callID ?? event.id, "VIRA_HOST_TOOL_CALL_REQUIRED"), toolName: required2(event.tool ?? event.name, "VIRA_HOST_TOOL_NAME_REQUIRED"), args: asRecord(event.input ?? event.args), traceId: text(event.traceID), turnId: text(event.turnID) });
|
|
1311
|
-
if (decision.decision !== "ALLOW") throw new ViraOpenCodeActionError(decision.decision, text(decision.reasonCode) || "VIRA_ACTION_NOT_ALLOWED");
|
|
1313
|
+
if (mode === "enforce" && decision.decision !== "ALLOW") throw new ViraOpenCodeActionError(decision.decision, text(decision.reasonCode) || "VIRA_ACTION_NOT_ALLOWED");
|
|
1312
1314
|
}));
|
|
1313
1315
|
registrations.push(await ctx.tool.hook("execute.after", async (event) => {
|
|
1314
1316
|
const identity = sessionIdentity(event);
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryvira/opencode",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "OpenCode V2 host lifecycle integration for Vira",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"exports": {".": "./dist/index.js"},
|
|
8
8
|
"files": ["dist", "README.md"],
|
|
9
9
|
"scripts": {"build": "node ../../scripts/build-opencode-plugin.mjs", "pack:check": "npm run build && npm pack --dry-run"},
|
|
10
|
-
"dependencies": {"@tryvira/sdk": "0.1.
|
|
10
|
+
"dependencies": {"@tryvira/sdk": "0.1.50"},
|
|
11
11
|
"peerDependencies": {"effect": "^4.0.0"},
|
|
12
12
|
"engines": {"node": ">=20"},
|
|
13
13
|
"license": "MIT"
|