@tryvira/opencode 0.1.16 → 0.1.17
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 +10 -7
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -433,7 +433,8 @@ var ViraClient = class {
|
|
|
433
433
|
body: {
|
|
434
434
|
...input.behaviorPoint ? { behaviorPoint: input.behaviorPoint } : {},
|
|
435
435
|
...input.executionBoundary ? { executionBoundary: input.executionBoundary } : {},
|
|
436
|
-
...input.semanticContext ? { semanticContext: input.semanticContext } : {}
|
|
436
|
+
...input.semanticContext ? { semanticContext: input.semanticContext } : {},
|
|
437
|
+
...input.signalAttestationRefs ? { signalAttestationRefs: input.signalAttestationRefs } : {}
|
|
437
438
|
}
|
|
438
439
|
},
|
|
439
440
|
{
|
|
@@ -482,11 +483,12 @@ var ViraClient = class {
|
|
|
482
483
|
behaviorPoint,
|
|
483
484
|
capsule: firstCapsule,
|
|
484
485
|
...input.requestId ? { requestId: input.requestId } : {},
|
|
485
|
-
...input.sessionId ? { conversationId: input.sessionId } : {}
|
|
486
|
+
...input.sessionId ? { conversationId: input.sessionId } : {},
|
|
487
|
+
...input.signalAttestationRefs ? { signalAttestationRefs: input.signalAttestationRefs } : {}
|
|
486
488
|
},
|
|
487
489
|
idempotencyKey: input.idempotencyKey ? `sdk:runtime:${input.idempotencyKey}` : void 0
|
|
488
490
|
}) : await this.resolveRuntime({
|
|
489
|
-
semanticContext: { taskKey: receipt.taskKey, behaviorPoint, capsule: firstCapsule, ...input.requestId ? { requestId: input.requestId } : {}, ...input.sessionId ? { conversationId: input.sessionId } : {} },
|
|
491
|
+
semanticContext: { taskKey: receipt.taskKey, behaviorPoint, capsule: firstCapsule, ...input.requestId ? { requestId: input.requestId } : {}, ...input.sessionId ? { conversationId: input.sessionId } : {}, ...input.signalAttestationRefs ? { signalAttestationRefs: input.signalAttestationRefs } : {} },
|
|
490
492
|
idempotencyKey: input.idempotencyKey ? `sdk:runtime:${input.idempotencyKey}` : void 0
|
|
491
493
|
});
|
|
492
494
|
return { semantic, runtime };
|
|
@@ -1202,7 +1204,7 @@ function createViraHostRuntime(client, config) {
|
|
|
1202
1204
|
if (mode === "off") return { status: "off" };
|
|
1203
1205
|
if (!capabilities.canInjectContext) return { status: "unavailable", reasonCode: "HOST_CONTEXT_INJECTION_UNSUPPORTED" };
|
|
1204
1206
|
await connectOnce();
|
|
1205
|
-
const semantic = await withTimeout(client.resolveSemanticRuntime({ input: request.input, sessionId: request.sessionId ?? request.conversationId, requestId: request.requestId }), timeoutMs, "SDK_HOST_RESOLVE_TIMEOUT");
|
|
1207
|
+
const semantic = await withTimeout(client.resolveSemanticRuntime({ input: request.input, sessionId: request.sessionId ?? request.conversationId, requestId: request.requestId, signalAttestationRefs: request.signalAttestationRefs }), timeoutMs, "SDK_HOST_RESOLVE_TIMEOUT");
|
|
1206
1208
|
if (!semantic) return { status: "unavailable", reasonCode: "VIRA_SEMANTIC_UNAVAILABLE" };
|
|
1207
1209
|
const semanticBody = bodyOf(semantic.semantic);
|
|
1208
1210
|
const receipt = semanticBody.receipt && typeof semanticBody.receipt === "object" ? semanticBody.receipt : {};
|
|
@@ -1274,7 +1276,7 @@ var errorCode = (error) => {
|
|
|
1274
1276
|
return text(body.code) || text(record(body.error).code) || (error instanceof Error ? error.message : "");
|
|
1275
1277
|
};
|
|
1276
1278
|
async function authorizeWithOneShotCustomerConfirmation(input) {
|
|
1277
|
-
const authorize = (approvalId) => input.client.authorizeHostAction({ executionId: input.executionId, sessionId: input.sessionId, dataVersion: input.dataVersion, scope: input.scope, context: input.context, proposal: input.proposalBody, ...approvalId ? { approval: { approvalId } } : {} });
|
|
1279
|
+
const authorize = (approvalId) => input.client.authorizeHostAction({ executionId: input.executionId, sessionId: input.sessionId, dataVersion: input.dataVersion, scope: input.scope, context: input.context, proposal: input.proposalBody, ...input.signalAttestationRefs?.length ? { signalAttestationRefs: input.signalAttestationRefs } : {}, ...approvalId ? { approval: { approvalId } } : {} });
|
|
1278
1280
|
try {
|
|
1279
1281
|
const response = await authorize(input.approvalId);
|
|
1280
1282
|
const body = record(response?.body);
|
|
@@ -1367,7 +1369,8 @@ var v2Plugin = Plugin.define({
|
|
|
1367
1369
|
const approval = typeof approvalCandidate.approvalId === "string" && approvalCandidate.approvalId.trim() ? { approvalId: approvalCandidate.approvalId.trim() } : void 0;
|
|
1368
1370
|
const dataVersion = text2(bound.context.release_digest);
|
|
1369
1371
|
if (!dataVersion) return { decision: "BLOCK", reasonCode: "RUNTIME_ACTION_DATA_VERSION_UNAVAILABLE" };
|
|
1370
|
-
|
|
1372
|
+
const refs = Array.isArray(bound.context.signal_attestation_refs) ? bound.context.signal_attestation_refs : [];
|
|
1373
|
+
return authorizeWithOneShotCustomerConfirmation({ client, proposal, proposalBody, signalAttestationRefs: refs, executionId: bound.executionId, sessionId: proposal.sessionId ?? proposal.conversationId, dataVersion, scope, context: bound.context, confirmAction: options.confirmAction, approvalId: approval?.approvalId });
|
|
1371
1374
|
}), ...(options.aiSystemId ?? env("VIRA_AI_SYSTEM_ID")) && (options.connectionId ?? env("VIRA_CONNECTION_ID")) ? {} : { connect: { ...scope, name: "OpenCode", systemType: "agent", adapterType: "custom-node", adapterVersion: options.hostVersion ?? ctx.app?.version ?? "unknown", idempotencyKey: "opencode:vira:connect" } } });
|
|
1372
1375
|
let connectedAiSystemId = options.aiSystemId ?? env("VIRA_AI_SYSTEM_ID") ?? "";
|
|
1373
1376
|
let connectedConnectionId = options.connectionId ?? env("VIRA_CONNECTION_ID") ?? "";
|
|
@@ -1381,7 +1384,7 @@ var v2Plugin = Plugin.define({
|
|
|
1381
1384
|
const sessionIdentity = (event) => ({ ...scope, hostName: options.hostName ?? "opencode", hostVersion: options.hostVersion ?? ctx.app?.version ?? "unknown", aiSystemId: required2(connectedAiSystemId, "VIRA_HOST_AI_SYSTEM_REQUIRED"), connectionId: required2(connectedConnectionId, "VIRA_HOST_CONNECTION_REQUIRED"), conversationId: required2(event.conversationId ?? event.sessionID, "VIRA_HOST_SESSION_REQUIRED"), sessionId: text2(event.sessionId ?? event.sessionID ?? event.conversationId) || void 0 });
|
|
1382
1385
|
registrations.push(await ctx.session.hook("context", async (event) => {
|
|
1383
1386
|
const identity = sessionIdentity(event);
|
|
1384
|
-
const result = await runtime.beforeModel({ ...identity, requestId: text2(event.messageID ?? event.requestId) || `opencode:${Date.now()}`, input: required2(lastUserText(event), "VIRA_HOST_MODEL_INPUT_REQUIRED"), traceId: text2(event.traceID), turnId: text2(event.turnID) });
|
|
1387
|
+
const result = await runtime.beforeModel({ ...identity, requestId: text2(event.messageID ?? event.requestId) || `opencode:${Date.now()}`, input: required2(lastUserText(event), "VIRA_HOST_MODEL_INPUT_REQUIRED"), traceId: text2(event.traceID), turnId: text2(event.turnID), signalAttestationRefs: options.signalAttestationRefs });
|
|
1385
1388
|
const responseBody = asRecord(result.response?.body);
|
|
1386
1389
|
const runtimeContext = asRecord(event.viraRuntimeContext ?? responseBody.requestContext ?? responseBody.context);
|
|
1387
1390
|
const executionId = text2(event.executionId ?? responseBody.executionId);
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryvira/opencode",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
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/index.js", "README.md"],
|
|
9
9
|
"scripts": {"build": "node ../../scripts/build-opencode-plugin.mjs", "pack:check": "npm run build && npm pack --dry-run && node ../../scripts/opencode-plugin-smoke.mjs"},
|
|
10
|
-
"dependencies": {"@tryvira/sdk": "0.1.
|
|
10
|
+
"dependencies": {"@tryvira/sdk": "0.1.57"},
|
|
11
11
|
"peerDependencies": {"effect": "^4.0.0"},
|
|
12
12
|
"engines": {"node": ">=20"},
|
|
13
13
|
"license": "MIT"
|