@xemahq/worker-runtime-opencode 0.5.4 → 0.7.0
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.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -3
- package/dist/index.js.map +1 -1
- package/dist/lib/compaction-policy.d.ts +17 -0
- package/dist/lib/compaction-policy.d.ts.map +1 -0
- package/dist/lib/compaction-policy.js +38 -0
- package/dist/lib/compaction-policy.js.map +1 -0
- package/dist/lib/factory.d.ts +2 -2
- package/dist/lib/factory.d.ts.map +1 -1
- package/dist/lib/factory.js +3 -3
- package/dist/lib/factory.js.map +1 -1
- package/dist/lib/opencode-worker-runtime.d.ts +4 -2
- package/dist/lib/opencode-worker-runtime.d.ts.map +1 -1
- package/dist/lib/opencode-worker-runtime.js +13 -5
- package/dist/lib/opencode-worker-runtime.js.map +1 -1
- package/dist/lib/runtime-profile-compiler.d.ts +3 -0
- package/dist/lib/runtime-profile-compiler.d.ts.map +1 -0
- package/dist/lib/runtime-profile-compiler.js +117 -0
- package/dist/lib/runtime-profile-compiler.js.map +1 -0
- package/dist/lib/runtime-profile.d.ts +22 -0
- package/dist/lib/runtime-profile.d.ts.map +1 -0
- package/dist/lib/runtime-profile.js +98 -0
- package/dist/lib/runtime-profile.js.map +1 -0
- package/dist/lib/session-bundle.js +2 -2
- package/dist/lib/session-bundle.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { OpencodeWorkerRuntimeAdapter, OPENCODE_CONNECTOR_KIND, type OpencodePodSpec, } from './lib/opencode-worker-runtime';
|
|
2
|
+
export { createOpencodeWorkerRuntimeAdapter } from './lib/factory';
|
|
3
|
+
export { compileOpencodeRuntimeProfile } from './lib/runtime-profile-compiler';
|
|
4
|
+
export { buildOpenCodeCompaction, deriveOpenCodeCompaction, deriveOpenCodeCompactionReserve, type OpenCodeCompactionConfig, } from './lib/compaction-policy';
|
|
5
|
+
export { OPENCODE_RUNTIME_PROFILE_SETTING_DEFAULTS, resolveOpencodeRuntimeProfileSettings, type OpencodeAuthoredRuntimeProfileSettings, } from './lib/runtime-profile';
|
|
6
|
+
export { OPENCODE_NATIVE_PERMISSION_REFS, OpencodeRuntimeProfileSchema, type OpencodeNativePermissionRef, type OpencodeRuntimeProfileSettings, } from './lib/runtime-profile';
|
|
3
7
|
export { buildOpencodeSessionBundle, computeSessionBindingRevision, computeStaticBundleFingerprint, decodeOpencodeSessionBundle, type OpencodeBundleSubAgent, type OpencodeSessionBundlePayload, } from './lib/session-bundle';
|
|
4
8
|
export type { BundleCallerContext, OpencodeRuntimeConfig, WorkerRef, } from './lib/worker-ref';
|
|
5
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EACL,4BAA4B,EAC5B,uBAAuB,EACvB,KAAK,eAAe,GACrB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,kCAAkC,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,+BAA+B,EAC/B,KAAK,wBAAwB,GAC9B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,yCAAyC,EACzC,qCAAqC,EACrC,KAAK,sCAAsC,GAC5C,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,+BAA+B,EAC/B,4BAA4B,EAC5B,KAAK,2BAA2B,EAChC,KAAK,8BAA8B,GACpC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,EAC7B,8BAA8B,EAC9B,2BAA2B,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,4BAA4B,GAClC,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,mBAAmB,EACnB,qBAAqB,EACrB,SAAS,GACV,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decodeOpencodeSessionBundle = exports.computeStaticBundleFingerprint = exports.computeSessionBindingRevision = exports.buildOpencodeSessionBundle = exports.
|
|
3
|
+
exports.decodeOpencodeSessionBundle = exports.computeStaticBundleFingerprint = exports.computeSessionBindingRevision = exports.buildOpencodeSessionBundle = exports.OpencodeRuntimeProfileSchema = exports.OPENCODE_NATIVE_PERMISSION_REFS = exports.resolveOpencodeRuntimeProfileSettings = exports.OPENCODE_RUNTIME_PROFILE_SETTING_DEFAULTS = exports.deriveOpenCodeCompactionReserve = exports.deriveOpenCodeCompaction = exports.buildOpenCodeCompaction = exports.compileOpencodeRuntimeProfile = exports.createOpencodeWorkerRuntimeAdapter = exports.OPENCODE_CONNECTOR_KIND = exports.OpencodeWorkerRuntimeAdapter = void 0;
|
|
4
4
|
var opencode_worker_runtime_1 = require("./lib/opencode-worker-runtime");
|
|
5
|
-
Object.defineProperty(exports, "
|
|
5
|
+
Object.defineProperty(exports, "OpencodeWorkerRuntimeAdapter", { enumerable: true, get: function () { return opencode_worker_runtime_1.OpencodeWorkerRuntimeAdapter; } });
|
|
6
6
|
Object.defineProperty(exports, "OPENCODE_CONNECTOR_KIND", { enumerable: true, get: function () { return opencode_worker_runtime_1.OPENCODE_CONNECTOR_KIND; } });
|
|
7
7
|
var factory_1 = require("./lib/factory");
|
|
8
|
-
Object.defineProperty(exports, "
|
|
8
|
+
Object.defineProperty(exports, "createOpencodeWorkerRuntimeAdapter", { enumerable: true, get: function () { return factory_1.createOpencodeWorkerRuntimeAdapter; } });
|
|
9
|
+
var runtime_profile_compiler_1 = require("./lib/runtime-profile-compiler");
|
|
10
|
+
Object.defineProperty(exports, "compileOpencodeRuntimeProfile", { enumerable: true, get: function () { return runtime_profile_compiler_1.compileOpencodeRuntimeProfile; } });
|
|
11
|
+
var compaction_policy_1 = require("./lib/compaction-policy");
|
|
12
|
+
Object.defineProperty(exports, "buildOpenCodeCompaction", { enumerable: true, get: function () { return compaction_policy_1.buildOpenCodeCompaction; } });
|
|
13
|
+
Object.defineProperty(exports, "deriveOpenCodeCompaction", { enumerable: true, get: function () { return compaction_policy_1.deriveOpenCodeCompaction; } });
|
|
14
|
+
Object.defineProperty(exports, "deriveOpenCodeCompactionReserve", { enumerable: true, get: function () { return compaction_policy_1.deriveOpenCodeCompactionReserve; } });
|
|
15
|
+
var runtime_profile_1 = require("./lib/runtime-profile");
|
|
16
|
+
Object.defineProperty(exports, "OPENCODE_RUNTIME_PROFILE_SETTING_DEFAULTS", { enumerable: true, get: function () { return runtime_profile_1.OPENCODE_RUNTIME_PROFILE_SETTING_DEFAULTS; } });
|
|
17
|
+
Object.defineProperty(exports, "resolveOpencodeRuntimeProfileSettings", { enumerable: true, get: function () { return runtime_profile_1.resolveOpencodeRuntimeProfileSettings; } });
|
|
18
|
+
var runtime_profile_2 = require("./lib/runtime-profile");
|
|
19
|
+
Object.defineProperty(exports, "OPENCODE_NATIVE_PERMISSION_REFS", { enumerable: true, get: function () { return runtime_profile_2.OPENCODE_NATIVE_PERMISSION_REFS; } });
|
|
20
|
+
Object.defineProperty(exports, "OpencodeRuntimeProfileSchema", { enumerable: true, get: function () { return runtime_profile_2.OpencodeRuntimeProfileSchema; } });
|
|
9
21
|
var session_bundle_1 = require("./lib/session-bundle");
|
|
10
22
|
Object.defineProperty(exports, "buildOpencodeSessionBundle", { enumerable: true, get: function () { return session_bundle_1.buildOpencodeSessionBundle; } });
|
|
11
23
|
Object.defineProperty(exports, "computeSessionBindingRevision", { enumerable: true, get: function () { return session_bundle_1.computeSessionBindingRevision; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AASA,yEAIuC;AAHrC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AASA,yEAIuC;AAHrC,uIAAA,4BAA4B,OAAA;AAC5B,kIAAA,uBAAuB,OAAA;AAGzB,yCAAmE;AAA1D,6HAAA,kCAAkC,OAAA;AAC3C,2EAA+E;AAAtE,yIAAA,6BAA6B,OAAA;AACtC,6DAKiC;AAJ/B,4HAAA,uBAAuB,OAAA;AACvB,6HAAA,wBAAwB,OAAA;AACxB,oIAAA,+BAA+B,OAAA;AAGjC,yDAI+B;AAH7B,4IAAA,yCAAyC,OAAA;AACzC,wIAAA,qCAAqC,OAAA;AAGvC,yDAK+B;AAJ7B,kIAAA,+BAA+B,OAAA;AAC/B,+HAAA,4BAA4B,OAAA;AAI9B,uDAO8B;AAN5B,4HAAA,0BAA0B,OAAA;AAC1B,+HAAA,6BAA6B,OAAA;AAC7B,gIAAA,8BAA8B,OAAA;AAC9B,6HAAA,2BAA2B,OAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface OpenCodeCompactionConfig {
|
|
2
|
+
readonly auto: boolean;
|
|
3
|
+
readonly prune: boolean;
|
|
4
|
+
readonly reserved: number;
|
|
5
|
+
}
|
|
6
|
+
export declare function deriveOpenCodeCompactionReserve(opts: {
|
|
7
|
+
contextWindow?: number | null | undefined;
|
|
8
|
+
}): number;
|
|
9
|
+
export declare function buildOpenCodeCompaction(opts: {
|
|
10
|
+
readonly auto: boolean;
|
|
11
|
+
readonly prune: boolean;
|
|
12
|
+
readonly contextWindow?: number | null | undefined;
|
|
13
|
+
}): OpenCodeCompactionConfig;
|
|
14
|
+
export declare function deriveOpenCodeCompaction(opts: {
|
|
15
|
+
contextWindow?: number | null | undefined;
|
|
16
|
+
}): OpenCodeCompactionConfig;
|
|
17
|
+
//# sourceMappingURL=compaction-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compaction-policy.d.ts","sourceRoot":"","sources":["../../src/lib/compaction-policy.ts"],"names":[],"mappings":"AAcA,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAmED,wBAAgB,+BAA+B,CAAC,IAAI,EAAE;IACpD,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CAC3C,GAAG,MAAM,CAcT;AAUD,wBAAgB,uBAAuB,CAAC,IAAI,EAAE;IAC5C,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CACpD,GAAG,wBAAwB,CAQ3B;AAeD,wBAAgB,wBAAwB,CAAC,IAAI,EAAE;IAC7C,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CAC3C,GAAG,wBAAwB,CAO3B"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deriveOpenCodeCompactionReserve = deriveOpenCodeCompactionReserve;
|
|
4
|
+
exports.buildOpenCodeCompaction = buildOpenCodeCompaction;
|
|
5
|
+
exports.deriveOpenCodeCompaction = deriveOpenCodeCompaction;
|
|
6
|
+
const runtime_profile_1 = require("./runtime-profile");
|
|
7
|
+
const COMPACTION_RESERVE_FRACTION = 0.35;
|
|
8
|
+
const COMPACTION_RESERVE_MIN_TOKENS = 16_000;
|
|
9
|
+
const COMPACTION_RESERVE_MAX_TOKENS = 96_000;
|
|
10
|
+
const COMPACTION_RESERVE_MAX_FRACTION = 0.5;
|
|
11
|
+
const COMPACTION_RESERVE_DEFAULT_TOKENS = 80_000;
|
|
12
|
+
function deriveOpenCodeCompactionReserve(opts) {
|
|
13
|
+
const window = opts.contextWindow;
|
|
14
|
+
if (typeof window !== 'number' || !Number.isFinite(window) || window <= 0) {
|
|
15
|
+
return COMPACTION_RESERVE_DEFAULT_TOKENS;
|
|
16
|
+
}
|
|
17
|
+
const proportional = Math.round(window * COMPACTION_RESERVE_FRACTION);
|
|
18
|
+
const ceilingByFraction = Math.floor(window * COMPACTION_RESERVE_MAX_FRACTION);
|
|
19
|
+
return Math.min(Math.max(proportional, COMPACTION_RESERVE_MIN_TOKENS), COMPACTION_RESERVE_MAX_TOKENS, ceilingByFraction);
|
|
20
|
+
}
|
|
21
|
+
function buildOpenCodeCompaction(opts) {
|
|
22
|
+
return {
|
|
23
|
+
auto: opts.auto,
|
|
24
|
+
prune: opts.prune,
|
|
25
|
+
reserved: deriveOpenCodeCompactionReserve({
|
|
26
|
+
contextWindow: opts.contextWindow,
|
|
27
|
+
}),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function deriveOpenCodeCompaction(opts) {
|
|
31
|
+
const defaults = runtime_profile_1.OPENCODE_RUNTIME_PROFILE_SETTING_DEFAULTS.compaction;
|
|
32
|
+
return buildOpenCodeCompaction({
|
|
33
|
+
auto: defaults.auto,
|
|
34
|
+
prune: defaults.prune,
|
|
35
|
+
contextWindow: opts.contextWindow,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=compaction-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compaction-policy.js","sourceRoot":"","sources":["../../src/lib/compaction-policy.ts"],"names":[],"mappings":";;AAqFA,0EAgBC;AAUD,0DAYC;AAeD,4DAS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AC"}
|
package/dist/lib/factory.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OpencodeWorkerRuntimeAdapter } from './opencode-worker-runtime';
|
|
2
2
|
import type { OpencodeRuntimeConfig } from './worker-ref';
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function createOpencodeWorkerRuntimeAdapter(config: OpencodeRuntimeConfig): OpencodeWorkerRuntimeAdapter;
|
|
4
4
|
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/lib/factory.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/lib/factory.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAQ1D,wBAAgB,kCAAkC,CAChD,MAAM,EAAE,qBAAqB,GAC5B,4BAA4B,CAG9B"}
|
package/dist/lib/factory.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createOpencodeWorkerRuntimeAdapter = createOpencodeWorkerRuntimeAdapter;
|
|
4
4
|
const opencode_worker_runtime_1 = require("./opencode-worker-runtime");
|
|
5
|
-
function
|
|
5
|
+
function createOpencodeWorkerRuntimeAdapter(config) {
|
|
6
6
|
validate(config);
|
|
7
|
-
return new opencode_worker_runtime_1.
|
|
7
|
+
return new opencode_worker_runtime_1.OpencodeWorkerRuntimeAdapter(config);
|
|
8
8
|
}
|
|
9
9
|
function validate(config) {
|
|
10
10
|
const ref = config.workerRef;
|
package/dist/lib/factory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src/lib/factory.ts"],"names":[],"mappings":";;AAkBA,
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src/lib/factory.ts"],"names":[],"mappings":";;AAkBA,gFAKC;AAdD,uEAAyE;AASzE,SAAgB,kCAAkC,CAChD,MAA6B;IAE7B,QAAQ,CAAC,MAAM,CAAC,CAAC;IACjB,OAAO,IAAI,sDAA4B,CAAC,MAAM,CAAC,CAAC;AAClD,CAAC;AAED,SAAS,QAAQ,CAAC,MAA6B;IAC7C,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC;IAC7B,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC3E,CAAC;IACD,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,EAAE,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;IAClF,CAAC;IACD,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;IACD,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;IAC/E,CAAC;IACD,IAAI,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,EAAE,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC,CAAC;IACrF,CAAC;IACD,IAAI,CAAC,GAAG,CAAC,qBAAqB,CAAC,IAAI,EAAE,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;IACxF,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAC7B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;AACH,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WorkerRuntimeKind, type BuildBundleInput, type BuildPodSpecInput, type SessionBundle, type
|
|
1
|
+
import { WorkerRuntimeKind, type BuildBundleInput, type BuildPodSpecInput, type RuntimeProfileCompilationContext, type RuntimeProfileContent, type RuntimeProfileProjection, type RuntimeProfileSchema, type SessionBundle, type WorkerRuntimeAdapter, type WorkerRuntimeCapabilityBits } from '@xemahq/kernel-contracts/worker-runtime';
|
|
2
2
|
import type { AbstractMount } from '@xemahq/kernel-contracts/workspace-storage';
|
|
3
3
|
import type { OpencodeRuntimeConfig } from './worker-ref';
|
|
4
4
|
export declare const OPENCODE_CONNECTOR_KIND = "opencode-default";
|
|
@@ -14,7 +14,7 @@ export interface OpencodePodSpec {
|
|
|
14
14
|
};
|
|
15
15
|
readonly requestedCapabilities: BuildPodSpecInput['capabilities'];
|
|
16
16
|
}
|
|
17
|
-
export declare class
|
|
17
|
+
export declare class OpencodeWorkerRuntimeAdapter implements WorkerRuntimeAdapter {
|
|
18
18
|
readonly kind = WorkerRuntimeKind.Opencode;
|
|
19
19
|
readonly capabilities: WorkerRuntimeCapabilityBits;
|
|
20
20
|
readonly connectorKindRequired = "opencode-default";
|
|
@@ -22,6 +22,8 @@ export declare class OpencodeWorkerRuntime implements WorkerRuntime {
|
|
|
22
22
|
private workerRef;
|
|
23
23
|
private caller;
|
|
24
24
|
constructor(config: OpencodeRuntimeConfig);
|
|
25
|
+
runtimeProfileSchema(): RuntimeProfileSchema;
|
|
26
|
+
compileProfile(profile: RuntimeProfileContent, resolvedComposition: RuntimeProfileCompilationContext): RuntimeProfileProjection;
|
|
25
27
|
buildPodSpec(input: BuildPodSpecInput): Promise<OpencodePodSpec>;
|
|
26
28
|
buildSessionBundle(input: BuildBundleInput): Promise<SessionBundle>;
|
|
27
29
|
applySessionBundle(bundle: SessionBundle): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opencode-worker-runtime.d.ts","sourceRoot":"","sources":["../../src/lib/opencode-worker-runtime.ts"],"names":[],"mappings":"AAYA,OAAO,EAEL,iBAAiB,EACjB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,
|
|
1
|
+
{"version":3,"file":"opencode-worker-runtime.d.ts","sourceRoot":"","sources":["../../src/lib/opencode-worker-runtime.ts"],"names":[],"mappings":"AAYA,OAAO,EAEL,iBAAiB,EACjB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,gCAAgC,EACrC,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,2BAA2B,EACjC,MAAM,yCAAyC,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAC;AAOhF,OAAO,KAAK,EAAE,qBAAqB,EAAa,MAAM,cAAc,CAAC;AAcrE,eAAO,MAAM,uBAAuB,qBAAqB,CAAC;AAmC1D,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAC;IACxC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC/C,QAAQ,CAAC,MAAM,EAAE,SAAS,aAAa,EAAE,CAAC;IAC1C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAMzB,QAAQ,CAAC,YAAY,CAAC,EAAE;QACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;KACpC,CAAC;IACF,QAAQ,CAAC,qBAAqB,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAC;CACnE;AAOD,qBAAa,4BAA6B,YAAW,oBAAoB;IACvE,QAAQ,CAAC,IAAI,8BAA8B;IAC3C,QAAQ,CAAC,YAAY,8BAAyB;IAC9C,QAAQ,CAAC,qBAAqB,sBAA2B;IACzD,QAAQ,CAAC,uBAAuB,QAAQ;IAExC,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,MAAM,CAAkC;gBAEpC,MAAM,EAAE,qBAAqB;IAKzC,oBAAoB,IAAI,oBAAoB;IAI5C,cAAc,CACZ,OAAO,EAAE,qBAAqB,EAC9B,mBAAmB,EAAE,gCAAgC,GACpD,wBAAwB;IAU3B,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC;IAwB1D,kBAAkB,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC;IA0BnE,kBAAkB,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IA8DxD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA4BtB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAe7B,OAAO,CAAC,WAAW;CAcpB"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.OpencodeWorkerRuntimeAdapter = exports.OPENCODE_CONNECTOR_KIND = void 0;
|
|
4
4
|
const worker_runtime_1 = require("@xemahq/kernel-contracts/worker-runtime");
|
|
5
5
|
const session_bundle_1 = require("./session-bundle");
|
|
6
|
+
const runtime_profile_compiler_1 = require("./runtime-profile-compiler");
|
|
7
|
+
const runtime_profile_1 = require("./runtime-profile");
|
|
6
8
|
exports.OPENCODE_CONNECTOR_KIND = 'opencode-default';
|
|
7
9
|
const APPLY_SESSION_BUNDLE_TIMEOUT_MS = 120_000;
|
|
8
10
|
const OPENCODE_CAPABILITIES = {
|
|
@@ -20,7 +22,7 @@ const OPENCODE_CAPABILITIES = {
|
|
|
20
22
|
gatewayAttributedCalls: true,
|
|
21
23
|
llmEndpointOverride: true,
|
|
22
24
|
};
|
|
23
|
-
class
|
|
25
|
+
class OpencodeWorkerRuntimeAdapter {
|
|
24
26
|
kind = worker_runtime_1.WorkerRuntimeKind.Opencode;
|
|
25
27
|
capabilities = OPENCODE_CAPABILITIES;
|
|
26
28
|
connectorKindRequired = exports.OPENCODE_CONNECTOR_KIND;
|
|
@@ -31,6 +33,12 @@ class OpencodeWorkerRuntime {
|
|
|
31
33
|
this.workerRef = config.workerRef;
|
|
32
34
|
this.caller = config.caller;
|
|
33
35
|
}
|
|
36
|
+
runtimeProfileSchema() {
|
|
37
|
+
return runtime_profile_1.OpencodeRuntimeProfileSchema;
|
|
38
|
+
}
|
|
39
|
+
compileProfile(profile, resolvedComposition) {
|
|
40
|
+
return (0, runtime_profile_compiler_1.compileOpencodeRuntimeProfile)(profile, resolvedComposition);
|
|
41
|
+
}
|
|
34
42
|
buildPodSpec(input) {
|
|
35
43
|
const spec = {
|
|
36
44
|
runtimeKind: this.kind,
|
|
@@ -95,7 +103,7 @@ class OpencodeWorkerRuntime {
|
|
|
95
103
|
});
|
|
96
104
|
if (!response.ok) {
|
|
97
105
|
const text = await safeReadText(response);
|
|
98
|
-
throw new Error(`
|
|
106
|
+
throw new Error(`OpencodeWorkerRuntimeAdapter.pause failed: HTTP ${response.status} from ${url} — ${text}`);
|
|
99
107
|
}
|
|
100
108
|
}
|
|
101
109
|
async resume() {
|
|
@@ -107,7 +115,7 @@ class OpencodeWorkerRuntime {
|
|
|
107
115
|
});
|
|
108
116
|
if (!response.ok) {
|
|
109
117
|
const text = await safeReadText(response);
|
|
110
|
-
throw new Error(`
|
|
118
|
+
throw new Error(`OpencodeWorkerRuntimeAdapter.resume failed: HTTP ${response.status} from ${url} — ${text}`);
|
|
111
119
|
}
|
|
112
120
|
}
|
|
113
121
|
authHeaders() {
|
|
@@ -118,7 +126,7 @@ class OpencodeWorkerRuntime {
|
|
|
118
126
|
};
|
|
119
127
|
}
|
|
120
128
|
}
|
|
121
|
-
exports.
|
|
129
|
+
exports.OpencodeWorkerRuntimeAdapter = OpencodeWorkerRuntimeAdapter;
|
|
122
130
|
function assertApplyResponseOk(parsed, payload) {
|
|
123
131
|
if (parsed.unchanged === true)
|
|
124
132
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opencode-worker-runtime.js","sourceRoot":"","sources":["../../src/lib/opencode-worker-runtime.ts"],"names":[],"mappings":";;;AAYA,
|
|
1
|
+
{"version":3,"file":"opencode-worker-runtime.js","sourceRoot":"","sources":["../../src/lib/opencode-worker-runtime.ts"],"names":[],"mappings":";;;AAYA,4EAYiD;AAGjD,qDAI0B;AAE1B,yEAA2E;AAC3E,uDAAiE;AAYpD,QAAA,uBAAuB,GAAG,kBAAkB,CAAC;AAW1D,MAAM,+BAA+B,GAAG,OAAO,CAAC;AAEhD,MAAM,qBAAqB,GAAgC;IACzD,MAAM,EAAE,IAAI;IACZ,YAAY,EAAE,IAAI;IAClB,WAAW,EAAE,IAAI;IACjB,YAAY,EAAE,IAAI;IAClB,KAAK,EAAE;QACL,yBAAQ,CAAC,iBAAiB;QAC1B,yBAAQ,CAAC,gBAAgB;QACzB,yBAAQ,CAAC,WAAW;QACpB,yBAAQ,CAAC,YAAY;KACtB;IACD,iBAAiB,EAAE,IAAI;IACvB,sBAAsB,EAAE,IAAI;IAC5B,mBAAmB,EAAE,IA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,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAClE,MAAM,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC;IAC9D,OAAO,GAAG,WAAW,GAAG,YAAY,EAAE,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type RuntimeProfileCompilationContext, type RuntimeProfileContent, type RuntimeProfileProjection } from '@xemahq/kernel-contracts/worker-runtime';
|
|
2
|
+
export declare function compileOpencodeRuntimeProfile(inputProfile: RuntimeProfileContent, resolvedComposition: RuntimeProfileCompilationContext): RuntimeProfileProjection;
|
|
3
|
+
//# sourceMappingURL=runtime-profile-compiler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-profile-compiler.d.ts","sourceRoot":"","sources":["../../src/lib/runtime-profile-compiler.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,KAAK,gCAAgC,EACrC,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAC9B,MAAM,yCAAyC,CAAC;AAqBjD,wBAAgB,6BAA6B,CAC3C,YAAY,EAAE,qBAAqB,EACnC,mBAAmB,EAAE,gCAAgC,GACpD,wBAAwB,CA+D1B"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compileOpencodeRuntimeProfile = compileOpencodeRuntimeProfile;
|
|
4
|
+
const content_address_1 = require("@xemahq/kernel-contracts/content-address");
|
|
5
|
+
const worker_runtime_1 = require("@xemahq/kernel-contracts/worker-runtime");
|
|
6
|
+
const compaction_policy_1 = require("./compaction-policy");
|
|
7
|
+
const runtime_profile_1 = require("./runtime-profile");
|
|
8
|
+
function compileOpencodeRuntimeProfile(inputProfile, resolvedComposition) {
|
|
9
|
+
const profile = runtime_profile_1.OpencodeRuntimeProfileSchema.parse(inputProfile);
|
|
10
|
+
assertCompositionProfile(profile, resolvedComposition);
|
|
11
|
+
const settings = (0, runtime_profile_1.resolveOpencodeRuntimeProfileSettings)(profile.settings);
|
|
12
|
+
const contextWindow = parsePrimaryContextWindow(resolvedComposition);
|
|
13
|
+
const restriction = parseNativeToolRestriction(resolvedComposition);
|
|
14
|
+
const authoredDecisions = new Map(profile.nativePermissionPolicy.entries.map((entry) => [
|
|
15
|
+
entry.nativeToolRef,
|
|
16
|
+
entry.decision,
|
|
17
|
+
]));
|
|
18
|
+
const permission = {
|
|
19
|
+
'*': worker_runtime_1.NativePermissionDecision.Deny,
|
|
20
|
+
};
|
|
21
|
+
for (const nativeToolRef of runtime_profile_1.OPENCODE_NATIVE_PERMISSION_REFS) {
|
|
22
|
+
const authored = authoredDecisions.get(nativeToolRef) ?? worker_runtime_1.NativePermissionDecision.Deny;
|
|
23
|
+
permission[nativeToolRef] =
|
|
24
|
+
restriction === undefined || restriction.has(nativeToolRef)
|
|
25
|
+
? authored
|
|
26
|
+
: worker_runtime_1.NativePermissionDecision.Deny;
|
|
27
|
+
}
|
|
28
|
+
return (0, content_address_1.deepFreezeCanonicalJson)({
|
|
29
|
+
schemaVersion: 1,
|
|
30
|
+
runtimeKind: worker_runtime_1.WorkerRuntimeKind.Opencode,
|
|
31
|
+
config: {
|
|
32
|
+
$schema: 'https://opencode.ai/config.json',
|
|
33
|
+
autoupdate: false,
|
|
34
|
+
share: 'disabled',
|
|
35
|
+
snapshot: settings.snapshot,
|
|
36
|
+
permission,
|
|
37
|
+
compaction: (0, compaction_policy_1.buildOpenCodeCompaction)({
|
|
38
|
+
auto: settings.compaction.auto,
|
|
39
|
+
prune: settings.compaction.prune,
|
|
40
|
+
contextWindow,
|
|
41
|
+
}),
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function parsePrimaryContextWindow(resolvedComposition) {
|
|
46
|
+
if (!isRecord(resolvedComposition)) {
|
|
47
|
+
throw new TypeError('Resolved composition must be an object.');
|
|
48
|
+
}
|
|
49
|
+
const modelResolution = resolvedComposition.modelResolution;
|
|
50
|
+
if (!isRecord(modelResolution)) {
|
|
51
|
+
throw new TypeError('Resolved composition must contain a modelResolution object.');
|
|
52
|
+
}
|
|
53
|
+
if (!Object.hasOwn(modelResolution, 'contextWindow')) {
|
|
54
|
+
throw new TypeError('Resolved composition modelResolution must declare contextWindow.');
|
|
55
|
+
}
|
|
56
|
+
const contextWindow = modelResolution.contextWindow;
|
|
57
|
+
if (contextWindow === null) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
if (typeof contextWindow !== 'number' || !Number.isFinite(contextWindow)) {
|
|
61
|
+
throw new TypeError('Resolved composition modelResolution.contextWindow must be a finite number or null.');
|
|
62
|
+
}
|
|
63
|
+
return contextWindow;
|
|
64
|
+
}
|
|
65
|
+
function assertCompositionProfile(profile, resolvedComposition) {
|
|
66
|
+
if (!isRecord(resolvedComposition)) {
|
|
67
|
+
throw new TypeError('Resolved composition must be an object.');
|
|
68
|
+
}
|
|
69
|
+
if (Object.hasOwn(resolvedComposition, 'runtimeProjection')) {
|
|
70
|
+
throw new TypeError('Profile compilation requires the pre-projection resolved composition.');
|
|
71
|
+
}
|
|
72
|
+
if (!Object.hasOwn(resolvedComposition, 'runtimeProfile')) {
|
|
73
|
+
throw new TypeError('Resolved composition must contain its materialized runtimeProfile.');
|
|
74
|
+
}
|
|
75
|
+
const compositionProfile = runtime_profile_1.OpencodeRuntimeProfileSchema.parse(resolvedComposition.runtimeProfile);
|
|
76
|
+
if ((0, content_address_1.canonicalJsonStringify)(profile) !==
|
|
77
|
+
(0, content_address_1.canonicalJsonStringify)(compositionProfile)) {
|
|
78
|
+
throw new TypeError('Compiler profile must exactly match resolvedComposition.runtimeProfile.');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function parseNativeToolRestriction(resolvedComposition) {
|
|
82
|
+
if (!isRecord(resolvedComposition)) {
|
|
83
|
+
throw new TypeError('Resolved composition must be an object.');
|
|
84
|
+
}
|
|
85
|
+
const effectiveOverlay = resolvedComposition.effectiveOverlay;
|
|
86
|
+
if (!isRecord(effectiveOverlay)) {
|
|
87
|
+
throw new TypeError('Resolved composition must contain an effectiveOverlay object.');
|
|
88
|
+
}
|
|
89
|
+
const restriction = effectiveOverlay.nativeToolRestriction;
|
|
90
|
+
if (restriction === undefined) {
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
if (!isRecord(restriction) || restriction.kind !== 'allow-only') {
|
|
94
|
+
throw new TypeError('effectiveOverlay.nativeToolRestriction must use kind "allow-only".');
|
|
95
|
+
}
|
|
96
|
+
if (!Array.isArray(restriction.nativeToolRefs)) {
|
|
97
|
+
throw new TypeError('effectiveOverlay.nativeToolRestriction.nativeToolRefs must be an array.');
|
|
98
|
+
}
|
|
99
|
+
let previous;
|
|
100
|
+
const refs = new Set();
|
|
101
|
+
for (const ref of restriction.nativeToolRefs) {
|
|
102
|
+
if (typeof ref !== 'string' || !(0, runtime_profile_1.isOpencodeNativePermissionRef)(ref)) {
|
|
103
|
+
throw new TypeError(`Unsupported OpenCode native permission restriction ref "${String(ref)}". ` +
|
|
104
|
+
'Xema capabilities and MCP tools are not OpenCode native permissions.');
|
|
105
|
+
}
|
|
106
|
+
if (previous !== undefined && ref <= previous) {
|
|
107
|
+
throw new TypeError('effectiveOverlay.nativeToolRestriction.nativeToolRefs must be unique and sorted.');
|
|
108
|
+
}
|
|
109
|
+
previous = ref;
|
|
110
|
+
refs.add(ref);
|
|
111
|
+
}
|
|
112
|
+
return refs;
|
|
113
|
+
}
|
|
114
|
+
function isRecord(value) {
|
|
115
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=runtime-profile-compiler.js.map
|
|
@@ -0,0 +1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CAAC;IACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,SAAS,CACjB,yEAAyE,CAC1E,CAAC;IACJ,CAAC;IAED,IAAI,QAA4B,CAAC;IACjC,MAAM,IAAI,GAAG,IAAI,GAAG,EAA+B,CAAC;IACpD,KAAK,MAAM,GAAG,IAAI,WAAW,CAAC,cAAc,EAAE,CAAC;QAC7C,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,IAAA,+CAA6B,EAAC,GAAG,CAAC,EAAE,CAAC;YACnE,MAAM,IAAI,SAAS,CACjB,2DAA2D,MAAM,CAAC,GAAG,CAAC,KAAK;gBACzE,sEAAsE,CACzE,CAAC;QACJ,CAAC;QACD,IAAI,QAAQ,KAAK,SAAS,IAAI,GAAG,IAAI,QAAQ,EAAE,CAAC;YAC9C,MAAM,IAAI,SAAS,CACjB,kFAAkF,CACnF,CAAC;QACJ,CAAC;QACD,QAAQ,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type RuntimeProfileSchema } from '@xemahq/kernel-contracts/worker-runtime';
|
|
2
|
+
export declare const OPENCODE_NATIVE_PERMISSION_REFS: readonly ["bash", "doom_loop", "edit", "glob", "grep", "lsp", "question", "read", "skill", "task", "todowrite", "webfetch", "websearch"];
|
|
3
|
+
export type OpencodeNativePermissionRef = (typeof OPENCODE_NATIVE_PERMISSION_REFS)[number];
|
|
4
|
+
export interface OpencodeRuntimeProfileSettings {
|
|
5
|
+
readonly snapshot: boolean;
|
|
6
|
+
readonly compaction: {
|
|
7
|
+
readonly auto: boolean;
|
|
8
|
+
readonly prune: boolean;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export interface OpencodeAuthoredRuntimeProfileSettings {
|
|
12
|
+
readonly snapshot?: boolean;
|
|
13
|
+
readonly compaction?: {
|
|
14
|
+
readonly auto?: boolean;
|
|
15
|
+
readonly prune?: boolean;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export declare const OPENCODE_RUNTIME_PROFILE_SETTING_DEFAULTS: OpencodeRuntimeProfileSettings;
|
|
19
|
+
export declare function resolveOpencodeRuntimeProfileSettings(authored: OpencodeAuthoredRuntimeProfileSettings): OpencodeRuntimeProfileSettings;
|
|
20
|
+
export declare function isOpencodeNativePermissionRef(value: string): value is OpencodeNativePermissionRef;
|
|
21
|
+
export declare const OpencodeRuntimeProfileSchema: RuntimeProfileSchema;
|
|
22
|
+
//# sourceMappingURL=runtime-profile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-profile.d.ts","sourceRoot":"","sources":["../../src/lib/runtime-profile.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,yCAAyC,CAAC;AAWjD,eAAO,MAAM,+BAA+B,0IAclC,CAAC;AAEX,MAAM,MAAM,2BAA2B,GACrC,CAAC,OAAO,+BAA+B,CAAC,CAAC,MAAM,CAAC,CAAC;AASnD,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE;QACnB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;QACvB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;KACzB,CAAC;CACH;AA4CD,MAAM,WAAW,sCAAsC;IACrD,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,UAAU,CAAC,EAAE;QACpB,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;QACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;KAC1B,CAAC;CACH;AAiBD,eAAO,MAAM,yCAAyC,EAAE,8BAIpD,CAAC;AAcL,wBAAgB,qCAAqC,CACnD,QAAQ,EAAE,sCAAsC,GAC/C,8BAA8B,CAShC;AAQD,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,MAAM,GACZ,KAAK,IAAI,2BAA2B,CAEtC;AA2DD,eAAO,MAAM,4BAA4B,EAAE,oBAyBvC,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OpencodeRuntimeProfileSchema = exports.OPENCODE_RUNTIME_PROFILE_SETTING_DEFAULTS = exports.OPENCODE_NATIVE_PERMISSION_REFS = void 0;
|
|
4
|
+
exports.resolveOpencodeRuntimeProfileSettings = resolveOpencodeRuntimeProfileSettings;
|
|
5
|
+
exports.isOpencodeNativePermissionRef = isOpencodeNativePermissionRef;
|
|
6
|
+
const worker_runtime_1 = require("@xemahq/kernel-contracts/worker-runtime");
|
|
7
|
+
exports.OPENCODE_NATIVE_PERMISSION_REFS = [
|
|
8
|
+
'bash',
|
|
9
|
+
'doom_loop',
|
|
10
|
+
'edit',
|
|
11
|
+
'glob',
|
|
12
|
+
'grep',
|
|
13
|
+
'lsp',
|
|
14
|
+
'question',
|
|
15
|
+
'read',
|
|
16
|
+
'skill',
|
|
17
|
+
'task',
|
|
18
|
+
'todowrite',
|
|
19
|
+
'webfetch',
|
|
20
|
+
'websearch',
|
|
21
|
+
];
|
|
22
|
+
exports.OPENCODE_RUNTIME_PROFILE_SETTING_DEFAULTS = Object.freeze({
|
|
23
|
+
snapshot: true,
|
|
24
|
+
compaction: Object.freeze({ auto: true, prune: true }),
|
|
25
|
+
});
|
|
26
|
+
function resolveOpencodeRuntimeProfileSettings(authored) {
|
|
27
|
+
const defaults = exports.OPENCODE_RUNTIME_PROFILE_SETTING_DEFAULTS;
|
|
28
|
+
return {
|
|
29
|
+
snapshot: authored.snapshot ?? defaults.snapshot,
|
|
30
|
+
compaction: {
|
|
31
|
+
auto: authored.compaction?.auto ?? defaults.compaction.auto,
|
|
32
|
+
prune: authored.compaction?.prune ?? defaults.compaction.prune,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const SETTINGS_KEYS = ['compaction', 'snapshot'];
|
|
37
|
+
const COMPACTION_KEYS = ['auto', 'prune'];
|
|
38
|
+
const NATIVE_PERMISSION_REF_SET = new Set(exports.OPENCODE_NATIVE_PERMISSION_REFS);
|
|
39
|
+
function isOpencodeNativePermissionRef(value) {
|
|
40
|
+
return NATIVE_PERMISSION_REF_SET.has(value);
|
|
41
|
+
}
|
|
42
|
+
exports.OpencodeRuntimeProfileSchema = worker_runtime_1.RuntimeProfileContentSchema.superRefine((profile, context) => {
|
|
43
|
+
if (profile.runtimeKind !== worker_runtime_1.WorkerRuntimeKind.Opencode) {
|
|
44
|
+
addIssue(context, ['runtimeKind'], `OpenCode adapter requires runtimeKind "${worker_runtime_1.WorkerRuntimeKind.Opencode}".`);
|
|
45
|
+
}
|
|
46
|
+
addSettingsIssues(profile.settings, context);
|
|
47
|
+
for (let index = 0; index < profile.nativePermissionPolicy.entries.length; index += 1) {
|
|
48
|
+
const entry = profile.nativePermissionPolicy.entries[index];
|
|
49
|
+
if (entry !== undefined &&
|
|
50
|
+
!isOpencodeNativePermissionRef(entry.nativeToolRef)) {
|
|
51
|
+
addIssue(context, ['nativePermissionPolicy', 'entries', index, 'nativeToolRef'], `Unsupported OpenCode native permission ref "${entry.nativeToolRef}". ` +
|
|
52
|
+
'Xema capabilities and MCP tools are not OpenCode native permissions.');
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
function addSettingsIssues(settings, context) {
|
|
57
|
+
addUnknownKeyIssues(settings, SETTINGS_KEYS, ['settings'], context);
|
|
58
|
+
if (Object.hasOwn(settings, 'snapshot') && typeof settings.snapshot !== 'boolean') {
|
|
59
|
+
addIssue(context, ['settings', 'snapshot'], 'snapshot must be a boolean.');
|
|
60
|
+
}
|
|
61
|
+
if (!Object.hasOwn(settings, 'compaction')) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (!isRecord(settings.compaction)) {
|
|
65
|
+
addIssue(context, ['settings', 'compaction'], 'compaction must be an object.');
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const compaction = settings.compaction;
|
|
69
|
+
addUnknownKeyIssues(compaction, COMPACTION_KEYS, ['settings', 'compaction'], context, RETIRED_COMPACTION_KEYS);
|
|
70
|
+
for (const key of ['auto', 'prune']) {
|
|
71
|
+
if (Object.hasOwn(compaction, key) && typeof compaction[key] !== 'boolean') {
|
|
72
|
+
addIssue(context, ['settings', 'compaction', key], `${key} must be a boolean.`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const RETIRED_COMPACTION_KEYS = {
|
|
77
|
+
reservedTokens: 'reservedTokens is no longer authored: the compaction reserve is derived per session ' +
|
|
78
|
+
"from the primary model's context window, which a profile author cannot know. Remove the key.",
|
|
79
|
+
};
|
|
80
|
+
function addUnknownKeyIssues(value, expectedKeys, path, context, retiredKeys = {}) {
|
|
81
|
+
const expected = new Set(expectedKeys);
|
|
82
|
+
for (const key of Object.keys(value)) {
|
|
83
|
+
if (expected.has(key)) {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const retired = Object.hasOwn(retiredKeys, key)
|
|
87
|
+
? retiredKeys[key]
|
|
88
|
+
: undefined;
|
|
89
|
+
addIssue(context, [...path, key], retired ?? `Unknown OpenCode setting "${key}".`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function addIssue(context, path, message) {
|
|
93
|
+
context.addIssue({ code: 'custom', path: [...path], message });
|
|
94
|
+
}
|
|
95
|
+
function isRecord(value) {
|
|
96
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=runtime-profile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-profile.js","sourceRoot":"","sources":["../../src/lib/runtime-profile.ts"],"names":[],"mappings":";;;AAoIA,sFAWC;AAQD,sEAIC;AA3JD,4EAIiD;AAWpC,QAAA,+BAA+B,GAAG;IAC7C,MAAM;IACN,WAAW;IACX,MAAM;IACN,MAAM;IACN,MAAM;IACN,KAAK;IACL,UAAU;IACV,MAAM;IACN,OAAO;IACP,MAAM;IACN,WAAW;IACX,UAAU;IACV,WAAW;CACH,CAAC;AAqFE,QAAA,yCAAyC,GACpD,MAAM,CAAC,MAAM,CAAC;IACZ,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;CACvD,CAAC,CAAC;AAcL,SAAgB,qCAAqC,CACnD,QAAgD;IAEhD,MAAM,QAAQ,GAAG,iDAAyC,CAAC;IAC3D,OAAO;QACL,QAAQ,EAAE,QAAQ,CAAC,QAAQ,IAAI,QAAQ,CAAC,QAAQ;QAChD,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ,CAAC,UAAU,EAAE,IAAI,IAAI,QAAQ,CAAC,UAAU,CAAC,IAAI;YAC3D,KAAK,EAAE,QAAQ,CAAC,UAAU,EAAE,KAAK,IAAI,QAAQ,CAAC,UAAU,CAAC,KAAK;SAC/D;KACF,CAAC;AACJ,CAAC;AAED,MAAM,aAAa,GAAG,CAAC,YAAY,EAAE,UAAU,CAAU,CAAC;AAC1D,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,OAAO,CAAU,CAAC;AACnD,MAAM,yBAAyB,GAAwB,IAAI,GAAG,CAC5D,uCAA+B,CAChC,CAAC;AAEF,S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S;QACX,CAAC;QACD,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC;YAC7C,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC;YAClB,CAAC,CAAC,SAAS,CAAC;QACd,QAAQ,CACN,OAAO,EACP,CAAC,GAAG,IAAI,EAAE,GAAG,CAAC,EACd,OAAO,IAAI,6BAA6B,GAAG,IAAI,CAChD,CAAC;IACJ,CAAC;AACH,CAAC;AAUD,SAAS,QAAQ,CACf,OAA0B,EAC1B,IAAkC,EAClC,OAAe;IAEf,OAAO,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;AACjE,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -35,8 +35,8 @@ function buildOpencodeSessionBundle(input, allocationId, caller, bindingEpoch, w
|
|
|
35
35
|
if (!Number.isSafeInteger(bindingEpoch) || bindingEpoch < 1) {
|
|
36
36
|
throw new Error('bindingEpoch must be a positive safe integer.');
|
|
37
37
|
}
|
|
38
|
-
const runtimeConfigBase64 = input.runtimeConfigBase64
|
|
39
|
-
if (
|
|
38
|
+
const runtimeConfigBase64 = input.runtimeConfigBase64;
|
|
39
|
+
if (runtimeConfigBase64 === undefined || runtimeConfigBase64.length === 0) {
|
|
40
40
|
throw new Error('BuildBundleInput.runtimeConfigBase64 is required by the opencode runtime — the workspace-proxy bundle handler treats an empty config as a 400.');
|
|
41
41
|
}
|
|
42
42
|
const staticFingerprint = computeStaticBundleFingerprint(input);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-bundle.js","sourceRoot":"","sources":["../../src/lib/session-bundle.ts"],"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yCAAyC,CAClL,CAAC;IACJ,CAAC;IACD,OAAO,MAAsC,CAAC;AAChD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xemahq/worker-runtime-opencode",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Opencode WorkerRuntime driver — wraps the workspace-proxy control-session handshake and the opencode SSE event stream behind the kernel WorkerRuntime contract.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Neuralchowder Inc. <developer@xema.dev> (https://xema.dev)",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"prettier": "3.6.2",
|
|
28
28
|
"ts-jest": "^29.4.9",
|
|
29
29
|
"typescript": "5.9.3",
|
|
30
|
-
"@xemahq/kernel-contracts": "^
|
|
30
|
+
"@xemahq/kernel-contracts": "^29.2.0"
|
|
31
31
|
},
|
|
32
32
|
"exports": {
|
|
33
33
|
".": {
|