@liberseek/boft-cli-win32-arm64 0.7.4 → 0.7.6
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 +1 -1
- package/THIRD_PARTY_NOTICES.txt +4 -0
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +17934 -0
- package/app/console-web.js +27017 -0
- package/app/desktop-controller.mjs +154 -14
- package/app/host-runtime.mjs +3379 -1152
- package/app/plugins/antigravity/plugin.mjs +355 -74
- package/app/plugins/claude-code/plugin.mjs +2851 -2155
- package/app/plugins/codebuddy/plugin.mjs +436 -95
- package/app/plugins/cursor-cli/manifest.json +1 -1
- package/app/plugins/cursor-cli/plugin.mjs +1144 -497
- package/app/plugins/deepseek-harness/plugin.mjs +1212 -163
- package/app/plugins/grok/plugin.mjs +301 -81
- package/app/plugins/hermes/plugin.mjs +321 -87
- package/app/plugins/kimi-code/plugin.mjs +669 -76
- package/app/plugins/kiro-cli/plugin.mjs +237 -57
- package/app/plugins/muse/plugin.mjs +123 -8
- package/app/plugins/omp/plugin.mjs +470 -147
- package/app/plugins/opencode/plugin.mjs +3611 -208
- package/app/plugins/pi/plugin.mjs +911 -278
- package/app/plugins/qoder/plugin.mjs +407 -48
- package/app/plugins/qoder-cn/plugin.mjs +414 -49
- package/app/plugins/workbuddy/plugin.mjs +126 -8
- package/app/renderer-extension.js +3824 -2314
- package/bin/boft.exe +0 -0
- package/libexec/boft-node-repl.exe +0 -0
- package/libexec/boft-shim.exe +0 -0
- package/libexec/boft-updater.exe +0 -0
- package/licenses/OpenCode-v2-Client-LICENSE.txt +21 -0
- package/package.json +1 -1
|
@@ -8,7 +8,7 @@ var __export = (target, all) => {
|
|
|
8
8
|
// dist/opencode-adapter.js
|
|
9
9
|
import { randomUUID } from "node:crypto";
|
|
10
10
|
import fs4 from "node:fs";
|
|
11
|
-
import
|
|
11
|
+
import path8 from "node:path";
|
|
12
12
|
|
|
13
13
|
// ../../../node_modules/zod/v4/classic/external.js
|
|
14
14
|
var external_exports = {};
|
|
@@ -776,10 +776,10 @@ function mergeDefs(...defs) {
|
|
|
776
776
|
function cloneDef(schema) {
|
|
777
777
|
return mergeDefs(schema._zod.def);
|
|
778
778
|
}
|
|
779
|
-
function getElementAtPath(obj,
|
|
780
|
-
if (!
|
|
779
|
+
function getElementAtPath(obj, path12) {
|
|
780
|
+
if (!path12)
|
|
781
781
|
return obj;
|
|
782
|
-
return
|
|
782
|
+
return path12.reduce((acc, key) => acc?.[key], obj);
|
|
783
783
|
}
|
|
784
784
|
function promiseAllObject(promisesObj) {
|
|
785
785
|
const keys = Object.keys(promisesObj);
|
|
@@ -1188,11 +1188,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
1188
1188
|
}
|
|
1189
1189
|
return false;
|
|
1190
1190
|
}
|
|
1191
|
-
function prefixIssues(
|
|
1191
|
+
function prefixIssues(path12, issues) {
|
|
1192
1192
|
return issues.map((iss) => {
|
|
1193
1193
|
var _a3;
|
|
1194
1194
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
1195
|
-
iss.path.unshift(
|
|
1195
|
+
iss.path.unshift(path12);
|
|
1196
1196
|
return iss;
|
|
1197
1197
|
});
|
|
1198
1198
|
}
|
|
@@ -1339,16 +1339,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1339
1339
|
}
|
|
1340
1340
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
1341
1341
|
const fieldErrors = { _errors: [] };
|
|
1342
|
-
const processError = (error52,
|
|
1342
|
+
const processError = (error52, path12 = []) => {
|
|
1343
1343
|
for (const issue2 of error52.issues) {
|
|
1344
1344
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1345
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1345
|
+
issue2.errors.map((issues) => processError({ issues }, [...path12, ...issue2.path]));
|
|
1346
1346
|
} else if (issue2.code === "invalid_key") {
|
|
1347
|
-
processError({ issues: issue2.issues }, [...
|
|
1347
|
+
processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
|
|
1348
1348
|
} else if (issue2.code === "invalid_element") {
|
|
1349
|
-
processError({ issues: issue2.issues }, [...
|
|
1349
|
+
processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
|
|
1350
1350
|
} else {
|
|
1351
|
-
const fullpath = [...
|
|
1351
|
+
const fullpath = [...path12, ...issue2.path];
|
|
1352
1352
|
if (fullpath.length === 0) {
|
|
1353
1353
|
fieldErrors._errors.push(mapper(issue2));
|
|
1354
1354
|
} else {
|
|
@@ -1375,17 +1375,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1375
1375
|
}
|
|
1376
1376
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
1377
1377
|
const result = { errors: [] };
|
|
1378
|
-
const processError = (error52,
|
|
1378
|
+
const processError = (error52, path12 = []) => {
|
|
1379
1379
|
var _a3, _b;
|
|
1380
1380
|
for (const issue2 of error52.issues) {
|
|
1381
1381
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1382
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1382
|
+
issue2.errors.map((issues) => processError({ issues }, [...path12, ...issue2.path]));
|
|
1383
1383
|
} else if (issue2.code === "invalid_key") {
|
|
1384
|
-
processError({ issues: issue2.issues }, [...
|
|
1384
|
+
processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
|
|
1385
1385
|
} else if (issue2.code === "invalid_element") {
|
|
1386
|
-
processError({ issues: issue2.issues }, [...
|
|
1386
|
+
processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
|
|
1387
1387
|
} else {
|
|
1388
|
-
const fullpath = [...
|
|
1388
|
+
const fullpath = [...path12, ...issue2.path];
|
|
1389
1389
|
if (fullpath.length === 0) {
|
|
1390
1390
|
result.errors.push(mapper(issue2));
|
|
1391
1391
|
continue;
|
|
@@ -1417,8 +1417,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1417
1417
|
}
|
|
1418
1418
|
function toDotPath(_path) {
|
|
1419
1419
|
const segs = [];
|
|
1420
|
-
const
|
|
1421
|
-
for (const seg of
|
|
1420
|
+
const path12 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
1421
|
+
for (const seg of path12) {
|
|
1422
1422
|
if (typeof seg === "number")
|
|
1423
1423
|
segs.push(`[${seg}]`);
|
|
1424
1424
|
else if (typeof seg === "symbol")
|
|
@@ -11788,29 +11788,29 @@ var formatMap = {
|
|
|
11788
11788
|
// do not set
|
|
11789
11789
|
};
|
|
11790
11790
|
var stringProcessor = (schema, ctx, _json, _params) => {
|
|
11791
|
-
const
|
|
11792
|
-
|
|
11791
|
+
const json3 = _json;
|
|
11792
|
+
json3.type = "string";
|
|
11793
11793
|
const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
|
|
11794
11794
|
if (typeof minimum === "number")
|
|
11795
|
-
|
|
11795
|
+
json3.minLength = minimum;
|
|
11796
11796
|
if (typeof maximum === "number")
|
|
11797
|
-
|
|
11797
|
+
json3.maxLength = maximum;
|
|
11798
11798
|
if (format) {
|
|
11799
|
-
|
|
11800
|
-
if (
|
|
11801
|
-
delete
|
|
11799
|
+
json3.format = formatMap[format] ?? format;
|
|
11800
|
+
if (json3.format === "")
|
|
11801
|
+
delete json3.format;
|
|
11802
11802
|
if (format === "time") {
|
|
11803
|
-
delete
|
|
11803
|
+
delete json3.format;
|
|
11804
11804
|
}
|
|
11805
11805
|
}
|
|
11806
11806
|
if (contentEncoding)
|
|
11807
|
-
|
|
11807
|
+
json3.contentEncoding = contentEncoding;
|
|
11808
11808
|
if (patterns && patterns.size > 0) {
|
|
11809
11809
|
const regexes = [...patterns];
|
|
11810
11810
|
if (regexes.length === 1)
|
|
11811
|
-
|
|
11811
|
+
json3.pattern = regexes[0].source;
|
|
11812
11812
|
else if (regexes.length > 1) {
|
|
11813
|
-
|
|
11813
|
+
json3.allOf = [
|
|
11814
11814
|
...regexes.map((regex) => ({
|
|
11815
11815
|
...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
|
|
11816
11816
|
pattern: regex.source
|
|
@@ -11820,40 +11820,40 @@ var stringProcessor = (schema, ctx, _json, _params) => {
|
|
|
11820
11820
|
}
|
|
11821
11821
|
};
|
|
11822
11822
|
var numberProcessor = (schema, ctx, _json, _params) => {
|
|
11823
|
-
const
|
|
11823
|
+
const json3 = _json;
|
|
11824
11824
|
const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
|
|
11825
11825
|
if (typeof format === "string" && format.includes("int"))
|
|
11826
|
-
|
|
11826
|
+
json3.type = "integer";
|
|
11827
11827
|
else
|
|
11828
|
-
|
|
11828
|
+
json3.type = "number";
|
|
11829
11829
|
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
11830
11830
|
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
|
|
11831
11831
|
const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
|
|
11832
11832
|
if (exMin) {
|
|
11833
11833
|
if (legacy) {
|
|
11834
|
-
|
|
11835
|
-
|
|
11834
|
+
json3.minimum = exclusiveMinimum;
|
|
11835
|
+
json3.exclusiveMinimum = true;
|
|
11836
11836
|
} else {
|
|
11837
|
-
|
|
11837
|
+
json3.exclusiveMinimum = exclusiveMinimum;
|
|
11838
11838
|
}
|
|
11839
11839
|
} else if (typeof minimum === "number") {
|
|
11840
|
-
|
|
11840
|
+
json3.minimum = minimum;
|
|
11841
11841
|
}
|
|
11842
11842
|
if (exMax) {
|
|
11843
11843
|
if (legacy) {
|
|
11844
|
-
|
|
11845
|
-
|
|
11844
|
+
json3.maximum = exclusiveMaximum;
|
|
11845
|
+
json3.exclusiveMaximum = true;
|
|
11846
11846
|
} else {
|
|
11847
|
-
|
|
11847
|
+
json3.exclusiveMaximum = exclusiveMaximum;
|
|
11848
11848
|
}
|
|
11849
11849
|
} else if (typeof maximum === "number") {
|
|
11850
|
-
|
|
11850
|
+
json3.maximum = maximum;
|
|
11851
11851
|
}
|
|
11852
11852
|
if (typeof multipleOf === "number")
|
|
11853
|
-
|
|
11853
|
+
json3.multipleOf = multipleOf;
|
|
11854
11854
|
};
|
|
11855
|
-
var booleanProcessor = (_schema, _ctx,
|
|
11856
|
-
|
|
11855
|
+
var booleanProcessor = (_schema, _ctx, json3, _params) => {
|
|
11856
|
+
json3.type = "boolean";
|
|
11857
11857
|
};
|
|
11858
11858
|
var bigintProcessor = (_schema, ctx, _json, _params) => {
|
|
11859
11859
|
if (ctx.unrepresentable === "throw") {
|
|
@@ -11865,13 +11865,13 @@ var symbolProcessor = (_schema, ctx, _json, _params) => {
|
|
|
11865
11865
|
throw new Error("Symbols cannot be represented in JSON Schema");
|
|
11866
11866
|
}
|
|
11867
11867
|
};
|
|
11868
|
-
var nullProcessor = (_schema, ctx,
|
|
11868
|
+
var nullProcessor = (_schema, ctx, json3, _params) => {
|
|
11869
11869
|
if (ctx.target === "openapi-3.0") {
|
|
11870
|
-
|
|
11871
|
-
|
|
11872
|
-
|
|
11870
|
+
json3.type = "string";
|
|
11871
|
+
json3.nullable = true;
|
|
11872
|
+
json3.enum = [null];
|
|
11873
11873
|
} else {
|
|
11874
|
-
|
|
11874
|
+
json3.type = "null";
|
|
11875
11875
|
}
|
|
11876
11876
|
};
|
|
11877
11877
|
var undefinedProcessor = (_schema, ctx, _json, _params) => {
|
|
@@ -11884,8 +11884,8 @@ var voidProcessor = (_schema, ctx, _json, _params) => {
|
|
|
11884
11884
|
throw new Error("Void cannot be represented in JSON Schema");
|
|
11885
11885
|
}
|
|
11886
11886
|
};
|
|
11887
|
-
var neverProcessor = (_schema, _ctx,
|
|
11888
|
-
|
|
11887
|
+
var neverProcessor = (_schema, _ctx, json3, _params) => {
|
|
11888
|
+
json3.not = {};
|
|
11889
11889
|
};
|
|
11890
11890
|
var anyProcessor = (_schema, _ctx, _json, _params) => {
|
|
11891
11891
|
};
|
|
@@ -11896,16 +11896,16 @@ var dateProcessor = (_schema, ctx, _json, _params) => {
|
|
|
11896
11896
|
throw new Error("Date cannot be represented in JSON Schema");
|
|
11897
11897
|
}
|
|
11898
11898
|
};
|
|
11899
|
-
var enumProcessor = (schema, _ctx,
|
|
11899
|
+
var enumProcessor = (schema, _ctx, json3, _params) => {
|
|
11900
11900
|
const def = schema._zod.def;
|
|
11901
11901
|
const values = getEnumValues(def.entries);
|
|
11902
11902
|
if (values.every((v) => typeof v === "number"))
|
|
11903
|
-
|
|
11903
|
+
json3.type = "number";
|
|
11904
11904
|
if (values.every((v) => typeof v === "string"))
|
|
11905
|
-
|
|
11906
|
-
|
|
11905
|
+
json3.type = "string";
|
|
11906
|
+
json3.enum = values;
|
|
11907
11907
|
};
|
|
11908
|
-
var literalProcessor = (schema, ctx,
|
|
11908
|
+
var literalProcessor = (schema, ctx, json3, _params) => {
|
|
11909
11909
|
const def = schema._zod.def;
|
|
11910
11910
|
const vals = [];
|
|
11911
11911
|
for (const val of def.values) {
|
|
@@ -11927,22 +11927,22 @@ var literalProcessor = (schema, ctx, json2, _params) => {
|
|
|
11927
11927
|
if (vals.length === 0) {
|
|
11928
11928
|
} else if (vals.length === 1) {
|
|
11929
11929
|
const val = vals[0];
|
|
11930
|
-
|
|
11930
|
+
json3.type = val === null ? "null" : typeof val;
|
|
11931
11931
|
if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
|
|
11932
|
-
|
|
11932
|
+
json3.enum = [val];
|
|
11933
11933
|
} else {
|
|
11934
|
-
|
|
11934
|
+
json3.const = val;
|
|
11935
11935
|
}
|
|
11936
11936
|
} else {
|
|
11937
11937
|
if (vals.every((v) => typeof v === "number"))
|
|
11938
|
-
|
|
11938
|
+
json3.type = "number";
|
|
11939
11939
|
if (vals.every((v) => typeof v === "string"))
|
|
11940
|
-
|
|
11940
|
+
json3.type = "string";
|
|
11941
11941
|
if (vals.every((v) => typeof v === "boolean"))
|
|
11942
|
-
|
|
11942
|
+
json3.type = "boolean";
|
|
11943
11943
|
if (vals.every((v) => v === null))
|
|
11944
|
-
|
|
11945
|
-
|
|
11944
|
+
json3.type = "null";
|
|
11945
|
+
json3.enum = vals;
|
|
11946
11946
|
}
|
|
11947
11947
|
};
|
|
11948
11948
|
var nanProcessor = (_schema, ctx, _json, _params) => {
|
|
@@ -11950,16 +11950,16 @@ var nanProcessor = (_schema, ctx, _json, _params) => {
|
|
|
11950
11950
|
throw new Error("NaN cannot be represented in JSON Schema");
|
|
11951
11951
|
}
|
|
11952
11952
|
};
|
|
11953
|
-
var templateLiteralProcessor = (schema, _ctx,
|
|
11954
|
-
const _json =
|
|
11953
|
+
var templateLiteralProcessor = (schema, _ctx, json3, _params) => {
|
|
11954
|
+
const _json = json3;
|
|
11955
11955
|
const pattern = schema._zod.pattern;
|
|
11956
11956
|
if (!pattern)
|
|
11957
11957
|
throw new Error("Pattern not found in template literal");
|
|
11958
11958
|
_json.type = "string";
|
|
11959
11959
|
_json.pattern = pattern.source;
|
|
11960
11960
|
};
|
|
11961
|
-
var fileProcessor = (schema, _ctx,
|
|
11962
|
-
const _json =
|
|
11961
|
+
var fileProcessor = (schema, _ctx, json3, _params) => {
|
|
11962
|
+
const _json = json3;
|
|
11963
11963
|
const file2 = {
|
|
11964
11964
|
type: "string",
|
|
11965
11965
|
format: "binary",
|
|
@@ -11982,8 +11982,8 @@ var fileProcessor = (schema, _ctx, json2, _params) => {
|
|
|
11982
11982
|
Object.assign(_json, file2);
|
|
11983
11983
|
}
|
|
11984
11984
|
};
|
|
11985
|
-
var successProcessor = (_schema, _ctx,
|
|
11986
|
-
|
|
11985
|
+
var successProcessor = (_schema, _ctx, json3, _params) => {
|
|
11986
|
+
json3.type = "boolean";
|
|
11987
11987
|
};
|
|
11988
11988
|
var customProcessor = (_schema, ctx, _json, _params) => {
|
|
11989
11989
|
if (ctx.unrepresentable === "throw") {
|
|
@@ -12011,27 +12011,27 @@ var setProcessor = (_schema, ctx, _json, _params) => {
|
|
|
12011
12011
|
}
|
|
12012
12012
|
};
|
|
12013
12013
|
var arrayProcessor = (schema, ctx, _json, params) => {
|
|
12014
|
-
const
|
|
12014
|
+
const json3 = _json;
|
|
12015
12015
|
const def = schema._zod.def;
|
|
12016
12016
|
const { minimum, maximum } = schema._zod.bag;
|
|
12017
12017
|
if (typeof minimum === "number")
|
|
12018
|
-
|
|
12018
|
+
json3.minItems = minimum;
|
|
12019
12019
|
if (typeof maximum === "number")
|
|
12020
|
-
|
|
12021
|
-
|
|
12022
|
-
|
|
12020
|
+
json3.maxItems = maximum;
|
|
12021
|
+
json3.type = "array";
|
|
12022
|
+
json3.items = process2(def.element, ctx, {
|
|
12023
12023
|
...params,
|
|
12024
12024
|
path: [...params.path, "items"]
|
|
12025
12025
|
});
|
|
12026
12026
|
};
|
|
12027
12027
|
var objectProcessor = (schema, ctx, _json, params) => {
|
|
12028
|
-
const
|
|
12028
|
+
const json3 = _json;
|
|
12029
12029
|
const def = schema._zod.def;
|
|
12030
|
-
|
|
12031
|
-
|
|
12030
|
+
json3.type = "object";
|
|
12031
|
+
json3.properties = {};
|
|
12032
12032
|
const shape = def.shape;
|
|
12033
12033
|
for (const key in shape) {
|
|
12034
|
-
|
|
12034
|
+
json3.properties[key] = process2(shape[key], ctx, {
|
|
12035
12035
|
...params,
|
|
12036
12036
|
path: [...params.path, "properties", key]
|
|
12037
12037
|
});
|
|
@@ -12046,21 +12046,21 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
12046
12046
|
}
|
|
12047
12047
|
}));
|
|
12048
12048
|
if (requiredKeys.size > 0) {
|
|
12049
|
-
|
|
12049
|
+
json3.required = Array.from(requiredKeys);
|
|
12050
12050
|
}
|
|
12051
12051
|
if (def.catchall?._zod.def.type === "never") {
|
|
12052
|
-
|
|
12052
|
+
json3.additionalProperties = false;
|
|
12053
12053
|
} else if (!def.catchall) {
|
|
12054
12054
|
if (ctx.io === "output")
|
|
12055
|
-
|
|
12055
|
+
json3.additionalProperties = false;
|
|
12056
12056
|
} else if (def.catchall) {
|
|
12057
|
-
|
|
12057
|
+
json3.additionalProperties = process2(def.catchall, ctx, {
|
|
12058
12058
|
...params,
|
|
12059
12059
|
path: [...params.path, "additionalProperties"]
|
|
12060
12060
|
});
|
|
12061
12061
|
}
|
|
12062
12062
|
};
|
|
12063
|
-
var unionProcessor = (schema, ctx,
|
|
12063
|
+
var unionProcessor = (schema, ctx, json3, params) => {
|
|
12064
12064
|
const def = schema._zod.def;
|
|
12065
12065
|
const isExclusive = def.inclusive === false;
|
|
12066
12066
|
const options = def.options.map((x, i) => process2(x, ctx, {
|
|
@@ -12068,12 +12068,12 @@ var unionProcessor = (schema, ctx, json2, params) => {
|
|
|
12068
12068
|
path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
|
|
12069
12069
|
}));
|
|
12070
12070
|
if (isExclusive) {
|
|
12071
|
-
|
|
12071
|
+
json3.oneOf = options;
|
|
12072
12072
|
} else {
|
|
12073
|
-
|
|
12073
|
+
json3.anyOf = options;
|
|
12074
12074
|
}
|
|
12075
12075
|
};
|
|
12076
|
-
var intersectionProcessor = (schema, ctx,
|
|
12076
|
+
var intersectionProcessor = (schema, ctx, json3, params) => {
|
|
12077
12077
|
const def = schema._zod.def;
|
|
12078
12078
|
const a = process2(def.left, ctx, {
|
|
12079
12079
|
...params,
|
|
@@ -12088,12 +12088,12 @@ var intersectionProcessor = (schema, ctx, json2, params) => {
|
|
|
12088
12088
|
...isSimpleIntersection(a) ? a.allOf : [a],
|
|
12089
12089
|
...isSimpleIntersection(b) ? b.allOf : [b]
|
|
12090
12090
|
];
|
|
12091
|
-
|
|
12091
|
+
json3.allOf = allOf;
|
|
12092
12092
|
};
|
|
12093
12093
|
var tupleProcessor = (schema, ctx, _json, params) => {
|
|
12094
|
-
const
|
|
12094
|
+
const json3 = _json;
|
|
12095
12095
|
const def = schema._zod.def;
|
|
12096
|
-
|
|
12096
|
+
json3.type = "array";
|
|
12097
12097
|
const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
|
|
12098
12098
|
const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
|
|
12099
12099
|
const prefixItems = def.items.map((x, i) => process2(x, ctx, {
|
|
@@ -12105,37 +12105,37 @@ var tupleProcessor = (schema, ctx, _json, params) => {
|
|
|
12105
12105
|
path: [...params.path, restPath, ...ctx.target === "openapi-3.0" ? [def.items.length] : []]
|
|
12106
12106
|
}) : null;
|
|
12107
12107
|
if (ctx.target === "draft-2020-12") {
|
|
12108
|
-
|
|
12108
|
+
json3.prefixItems = prefixItems;
|
|
12109
12109
|
if (rest) {
|
|
12110
|
-
|
|
12110
|
+
json3.items = rest;
|
|
12111
12111
|
}
|
|
12112
12112
|
} else if (ctx.target === "openapi-3.0") {
|
|
12113
|
-
|
|
12113
|
+
json3.items = {
|
|
12114
12114
|
anyOf: prefixItems
|
|
12115
12115
|
};
|
|
12116
12116
|
if (rest) {
|
|
12117
|
-
|
|
12117
|
+
json3.items.anyOf.push(rest);
|
|
12118
12118
|
}
|
|
12119
|
-
|
|
12119
|
+
json3.minItems = prefixItems.length;
|
|
12120
12120
|
if (!rest) {
|
|
12121
|
-
|
|
12121
|
+
json3.maxItems = prefixItems.length;
|
|
12122
12122
|
}
|
|
12123
12123
|
} else {
|
|
12124
|
-
|
|
12124
|
+
json3.items = prefixItems;
|
|
12125
12125
|
if (rest) {
|
|
12126
|
-
|
|
12126
|
+
json3.additionalItems = rest;
|
|
12127
12127
|
}
|
|
12128
12128
|
}
|
|
12129
12129
|
const { minimum, maximum } = schema._zod.bag;
|
|
12130
12130
|
if (typeof minimum === "number")
|
|
12131
|
-
|
|
12131
|
+
json3.minItems = minimum;
|
|
12132
12132
|
if (typeof maximum === "number")
|
|
12133
|
-
|
|
12133
|
+
json3.maxItems = maximum;
|
|
12134
12134
|
};
|
|
12135
12135
|
var recordProcessor = (schema, ctx, _json, params) => {
|
|
12136
|
-
const
|
|
12136
|
+
const json3 = _json;
|
|
12137
12137
|
const def = schema._zod.def;
|
|
12138
|
-
|
|
12138
|
+
json3.type = "object";
|
|
12139
12139
|
const keyType = def.keyType;
|
|
12140
12140
|
const keyBag = keyType._zod.bag;
|
|
12141
12141
|
const patterns = keyBag?.patterns;
|
|
@@ -12144,18 +12144,18 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
12144
12144
|
...params,
|
|
12145
12145
|
path: [...params.path, "patternProperties", "*"]
|
|
12146
12146
|
});
|
|
12147
|
-
|
|
12147
|
+
json3.patternProperties = {};
|
|
12148
12148
|
for (const pattern of patterns) {
|
|
12149
|
-
|
|
12149
|
+
json3.patternProperties[pattern.source] = valueSchema;
|
|
12150
12150
|
}
|
|
12151
12151
|
} else {
|
|
12152
12152
|
if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
|
|
12153
|
-
|
|
12153
|
+
json3.propertyNames = process2(def.keyType, ctx, {
|
|
12154
12154
|
...params,
|
|
12155
12155
|
path: [...params.path, "propertyNames"]
|
|
12156
12156
|
});
|
|
12157
12157
|
}
|
|
12158
|
-
|
|
12158
|
+
json3.additionalProperties = process2(def.valueType, ctx, {
|
|
12159
12159
|
...params,
|
|
12160
12160
|
path: [...params.path, "additionalProperties"]
|
|
12161
12161
|
});
|
|
@@ -12164,19 +12164,19 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
12164
12164
|
if (keyValues) {
|
|
12165
12165
|
const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
|
|
12166
12166
|
if (validKeyValues.length > 0) {
|
|
12167
|
-
|
|
12167
|
+
json3.required = validKeyValues;
|
|
12168
12168
|
}
|
|
12169
12169
|
}
|
|
12170
12170
|
};
|
|
12171
|
-
var nullableProcessor = (schema, ctx,
|
|
12171
|
+
var nullableProcessor = (schema, ctx, json3, params) => {
|
|
12172
12172
|
const def = schema._zod.def;
|
|
12173
12173
|
const inner = process2(def.innerType, ctx, params);
|
|
12174
12174
|
const seen = ctx.seen.get(schema);
|
|
12175
12175
|
if (ctx.target === "openapi-3.0") {
|
|
12176
12176
|
seen.ref = def.innerType;
|
|
12177
|
-
|
|
12177
|
+
json3.nullable = true;
|
|
12178
12178
|
} else {
|
|
12179
|
-
|
|
12179
|
+
json3.anyOf = [inner, { type: "null" }];
|
|
12180
12180
|
}
|
|
12181
12181
|
};
|
|
12182
12182
|
var nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
@@ -12185,22 +12185,22 @@ var nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
|
12185
12185
|
const seen = ctx.seen.get(schema);
|
|
12186
12186
|
seen.ref = def.innerType;
|
|
12187
12187
|
};
|
|
12188
|
-
var defaultProcessor = (schema, ctx,
|
|
12188
|
+
var defaultProcessor = (schema, ctx, json3, params) => {
|
|
12189
12189
|
const def = schema._zod.def;
|
|
12190
12190
|
process2(def.innerType, ctx, params);
|
|
12191
12191
|
const seen = ctx.seen.get(schema);
|
|
12192
12192
|
seen.ref = def.innerType;
|
|
12193
|
-
|
|
12193
|
+
json3.default = JSON.parse(JSON.stringify(def.defaultValue));
|
|
12194
12194
|
};
|
|
12195
|
-
var prefaultProcessor = (schema, ctx,
|
|
12195
|
+
var prefaultProcessor = (schema, ctx, json3, params) => {
|
|
12196
12196
|
const def = schema._zod.def;
|
|
12197
12197
|
process2(def.innerType, ctx, params);
|
|
12198
12198
|
const seen = ctx.seen.get(schema);
|
|
12199
12199
|
seen.ref = def.innerType;
|
|
12200
12200
|
if (ctx.io === "input")
|
|
12201
|
-
|
|
12201
|
+
json3._prefault = JSON.parse(JSON.stringify(def.defaultValue));
|
|
12202
12202
|
};
|
|
12203
|
-
var catchProcessor = (schema, ctx,
|
|
12203
|
+
var catchProcessor = (schema, ctx, json3, params) => {
|
|
12204
12204
|
const def = schema._zod.def;
|
|
12205
12205
|
process2(def.innerType, ctx, params);
|
|
12206
12206
|
const seen = ctx.seen.get(schema);
|
|
@@ -12211,7 +12211,7 @@ var catchProcessor = (schema, ctx, json2, params) => {
|
|
|
12211
12211
|
} catch {
|
|
12212
12212
|
throw new Error("Dynamic catch values are not supported in JSON Schema");
|
|
12213
12213
|
}
|
|
12214
|
-
|
|
12214
|
+
json3.default = catchValue;
|
|
12215
12215
|
};
|
|
12216
12216
|
var pipeProcessor = (schema, ctx, _json, params) => {
|
|
12217
12217
|
const def = schema._zod.def;
|
|
@@ -12221,12 +12221,12 @@ var pipeProcessor = (schema, ctx, _json, params) => {
|
|
|
12221
12221
|
const seen = ctx.seen.get(schema);
|
|
12222
12222
|
seen.ref = innerType;
|
|
12223
12223
|
};
|
|
12224
|
-
var readonlyProcessor = (schema, ctx,
|
|
12224
|
+
var readonlyProcessor = (schema, ctx, json3, params) => {
|
|
12225
12225
|
const def = schema._zod.def;
|
|
12226
12226
|
process2(def.innerType, ctx, params);
|
|
12227
12227
|
const seen = ctx.seen.get(schema);
|
|
12228
12228
|
seen.ref = def.innerType;
|
|
12229
|
-
|
|
12229
|
+
json3.readOnly = true;
|
|
12230
12230
|
};
|
|
12231
12231
|
var promiseProcessor = (schema, ctx, _json, params) => {
|
|
12232
12232
|
const def = schema._zod.def;
|
|
@@ -12870,7 +12870,7 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
12870
12870
|
var _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
|
|
12871
12871
|
$ZodString.init(inst, def);
|
|
12872
12872
|
ZodType.init(inst, def);
|
|
12873
|
-
inst._zod.processJSONSchema = (ctx,
|
|
12873
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => stringProcessor(inst, ctx, json3, params);
|
|
12874
12874
|
const bag = inst._zod.bag;
|
|
12875
12875
|
inst.format = bag.format ?? null;
|
|
12876
12876
|
inst.minLength = bag.minimum ?? null;
|
|
@@ -13141,7 +13141,7 @@ function hash(alg, params) {
|
|
|
13141
13141
|
var ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
|
|
13142
13142
|
$ZodNumber.init(inst, def);
|
|
13143
13143
|
ZodType.init(inst, def);
|
|
13144
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13144
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => numberProcessor(inst, ctx, json3, params);
|
|
13145
13145
|
_installLazyMethods(inst, "ZodNumber", {
|
|
13146
13146
|
gt(value, params) {
|
|
13147
13147
|
return this.check(_gt(value, params));
|
|
@@ -13221,7 +13221,7 @@ function uint32(params) {
|
|
|
13221
13221
|
var ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
|
|
13222
13222
|
$ZodBoolean.init(inst, def);
|
|
13223
13223
|
ZodType.init(inst, def);
|
|
13224
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13224
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => booleanProcessor(inst, ctx, json3, params);
|
|
13225
13225
|
});
|
|
13226
13226
|
function boolean2(params) {
|
|
13227
13227
|
return _boolean(ZodBoolean, params);
|
|
@@ -13229,7 +13229,7 @@ function boolean2(params) {
|
|
|
13229
13229
|
var ZodBigInt = /* @__PURE__ */ $constructor("ZodBigInt", (inst, def) => {
|
|
13230
13230
|
$ZodBigInt.init(inst, def);
|
|
13231
13231
|
ZodType.init(inst, def);
|
|
13232
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13232
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => bigintProcessor(inst, ctx, json3, params);
|
|
13233
13233
|
inst.gte = (value, params) => inst.check(_gte(value, params));
|
|
13234
13234
|
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
13235
13235
|
inst.gt = (value, params) => inst.check(_gt(value, params));
|
|
@@ -13264,7 +13264,7 @@ function uint64(params) {
|
|
|
13264
13264
|
var ZodSymbol = /* @__PURE__ */ $constructor("ZodSymbol", (inst, def) => {
|
|
13265
13265
|
$ZodSymbol.init(inst, def);
|
|
13266
13266
|
ZodType.init(inst, def);
|
|
13267
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13267
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => symbolProcessor(inst, ctx, json3, params);
|
|
13268
13268
|
});
|
|
13269
13269
|
function symbol(params) {
|
|
13270
13270
|
return _symbol(ZodSymbol, params);
|
|
@@ -13272,7 +13272,7 @@ function symbol(params) {
|
|
|
13272
13272
|
var ZodUndefined = /* @__PURE__ */ $constructor("ZodUndefined", (inst, def) => {
|
|
13273
13273
|
$ZodUndefined.init(inst, def);
|
|
13274
13274
|
ZodType.init(inst, def);
|
|
13275
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13275
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => undefinedProcessor(inst, ctx, json3, params);
|
|
13276
13276
|
});
|
|
13277
13277
|
function _undefined3(params) {
|
|
13278
13278
|
return _undefined2(ZodUndefined, params);
|
|
@@ -13280,7 +13280,7 @@ function _undefined3(params) {
|
|
|
13280
13280
|
var ZodNull = /* @__PURE__ */ $constructor("ZodNull", (inst, def) => {
|
|
13281
13281
|
$ZodNull.init(inst, def);
|
|
13282
13282
|
ZodType.init(inst, def);
|
|
13283
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13283
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => nullProcessor(inst, ctx, json3, params);
|
|
13284
13284
|
});
|
|
13285
13285
|
function _null3(params) {
|
|
13286
13286
|
return _null2(ZodNull, params);
|
|
@@ -13288,7 +13288,7 @@ function _null3(params) {
|
|
|
13288
13288
|
var ZodAny = /* @__PURE__ */ $constructor("ZodAny", (inst, def) => {
|
|
13289
13289
|
$ZodAny.init(inst, def);
|
|
13290
13290
|
ZodType.init(inst, def);
|
|
13291
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13291
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => anyProcessor(inst, ctx, json3, params);
|
|
13292
13292
|
});
|
|
13293
13293
|
function any() {
|
|
13294
13294
|
return _any(ZodAny);
|
|
@@ -13296,7 +13296,7 @@ function any() {
|
|
|
13296
13296
|
var ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
|
|
13297
13297
|
$ZodUnknown.init(inst, def);
|
|
13298
13298
|
ZodType.init(inst, def);
|
|
13299
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13299
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => unknownProcessor(inst, ctx, json3, params);
|
|
13300
13300
|
});
|
|
13301
13301
|
function unknown() {
|
|
13302
13302
|
return _unknown(ZodUnknown);
|
|
@@ -13304,7 +13304,7 @@ function unknown() {
|
|
|
13304
13304
|
var ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
|
|
13305
13305
|
$ZodNever.init(inst, def);
|
|
13306
13306
|
ZodType.init(inst, def);
|
|
13307
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13307
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => neverProcessor(inst, ctx, json3, params);
|
|
13308
13308
|
});
|
|
13309
13309
|
function never(params) {
|
|
13310
13310
|
return _never(ZodNever, params);
|
|
@@ -13312,7 +13312,7 @@ function never(params) {
|
|
|
13312
13312
|
var ZodVoid = /* @__PURE__ */ $constructor("ZodVoid", (inst, def) => {
|
|
13313
13313
|
$ZodVoid.init(inst, def);
|
|
13314
13314
|
ZodType.init(inst, def);
|
|
13315
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13315
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => voidProcessor(inst, ctx, json3, params);
|
|
13316
13316
|
});
|
|
13317
13317
|
function _void2(params) {
|
|
13318
13318
|
return _void(ZodVoid, params);
|
|
@@ -13320,7 +13320,7 @@ function _void2(params) {
|
|
|
13320
13320
|
var ZodDate = /* @__PURE__ */ $constructor("ZodDate", (inst, def) => {
|
|
13321
13321
|
$ZodDate.init(inst, def);
|
|
13322
13322
|
ZodType.init(inst, def);
|
|
13323
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13323
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => dateProcessor(inst, ctx, json3, params);
|
|
13324
13324
|
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
13325
13325
|
inst.max = (value, params) => inst.check(_lte(value, params));
|
|
13326
13326
|
const c = inst._zod.bag;
|
|
@@ -13333,7 +13333,7 @@ function date3(params) {
|
|
|
13333
13333
|
var ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
|
|
13334
13334
|
$ZodArray.init(inst, def);
|
|
13335
13335
|
ZodType.init(inst, def);
|
|
13336
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13336
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => arrayProcessor(inst, ctx, json3, params);
|
|
13337
13337
|
inst.element = def.element;
|
|
13338
13338
|
_installLazyMethods(inst, "ZodArray", {
|
|
13339
13339
|
min(n, params) {
|
|
@@ -13363,7 +13363,7 @@ function keyof(schema) {
|
|
|
13363
13363
|
var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
13364
13364
|
$ZodObjectJIT.init(inst, def);
|
|
13365
13365
|
ZodType.init(inst, def);
|
|
13366
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13366
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => objectProcessor(inst, ctx, json3, params);
|
|
13367
13367
|
util_exports.defineLazy(inst, "shape", () => {
|
|
13368
13368
|
return def.shape;
|
|
13369
13369
|
});
|
|
@@ -13436,7 +13436,7 @@ function looseObject(shape, params) {
|
|
|
13436
13436
|
var ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
|
|
13437
13437
|
$ZodUnion.init(inst, def);
|
|
13438
13438
|
ZodType.init(inst, def);
|
|
13439
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13439
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => unionProcessor(inst, ctx, json3, params);
|
|
13440
13440
|
inst.options = def.options;
|
|
13441
13441
|
});
|
|
13442
13442
|
function union(options, params) {
|
|
@@ -13449,7 +13449,7 @@ function union(options, params) {
|
|
|
13449
13449
|
var ZodXor = /* @__PURE__ */ $constructor("ZodXor", (inst, def) => {
|
|
13450
13450
|
ZodUnion.init(inst, def);
|
|
13451
13451
|
$ZodXor.init(inst, def);
|
|
13452
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13452
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => unionProcessor(inst, ctx, json3, params);
|
|
13453
13453
|
inst.options = def.options;
|
|
13454
13454
|
});
|
|
13455
13455
|
function xor(options, params) {
|
|
@@ -13475,7 +13475,7 @@ function discriminatedUnion(discriminator, options, params) {
|
|
|
13475
13475
|
var ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
|
|
13476
13476
|
$ZodIntersection.init(inst, def);
|
|
13477
13477
|
ZodType.init(inst, def);
|
|
13478
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13478
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => intersectionProcessor(inst, ctx, json3, params);
|
|
13479
13479
|
});
|
|
13480
13480
|
function intersection(left, right) {
|
|
13481
13481
|
return new ZodIntersection({
|
|
@@ -13487,7 +13487,7 @@ function intersection(left, right) {
|
|
|
13487
13487
|
var ZodTuple = /* @__PURE__ */ $constructor("ZodTuple", (inst, def) => {
|
|
13488
13488
|
$ZodTuple.init(inst, def);
|
|
13489
13489
|
ZodType.init(inst, def);
|
|
13490
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13490
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => tupleProcessor(inst, ctx, json3, params);
|
|
13491
13491
|
inst.rest = (rest) => inst.clone({
|
|
13492
13492
|
...inst._zod.def,
|
|
13493
13493
|
rest
|
|
@@ -13507,7 +13507,7 @@ function tuple(items, _paramsOrRest, _params) {
|
|
|
13507
13507
|
var ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
|
|
13508
13508
|
$ZodRecord.init(inst, def);
|
|
13509
13509
|
ZodType.init(inst, def);
|
|
13510
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13510
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => recordProcessor(inst, ctx, json3, params);
|
|
13511
13511
|
inst.keyType = def.keyType;
|
|
13512
13512
|
inst.valueType = def.valueType;
|
|
13513
13513
|
});
|
|
@@ -13549,7 +13549,7 @@ function looseRecord(keyType, valueType, params) {
|
|
|
13549
13549
|
var ZodMap = /* @__PURE__ */ $constructor("ZodMap", (inst, def) => {
|
|
13550
13550
|
$ZodMap.init(inst, def);
|
|
13551
13551
|
ZodType.init(inst, def);
|
|
13552
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13552
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => mapProcessor(inst, ctx, json3, params);
|
|
13553
13553
|
inst.keyType = def.keyType;
|
|
13554
13554
|
inst.valueType = def.valueType;
|
|
13555
13555
|
inst.min = (...args) => inst.check(_minSize(...args));
|
|
@@ -13568,7 +13568,7 @@ function map(keyType, valueType, params) {
|
|
|
13568
13568
|
var ZodSet = /* @__PURE__ */ $constructor("ZodSet", (inst, def) => {
|
|
13569
13569
|
$ZodSet.init(inst, def);
|
|
13570
13570
|
ZodType.init(inst, def);
|
|
13571
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13571
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => setProcessor(inst, ctx, json3, params);
|
|
13572
13572
|
inst.min = (...args) => inst.check(_minSize(...args));
|
|
13573
13573
|
inst.nonempty = (params) => inst.check(_minSize(1, params));
|
|
13574
13574
|
inst.max = (...args) => inst.check(_maxSize(...args));
|
|
@@ -13584,7 +13584,7 @@ function set(valueType, params) {
|
|
|
13584
13584
|
var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
13585
13585
|
$ZodEnum.init(inst, def);
|
|
13586
13586
|
ZodType.init(inst, def);
|
|
13587
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13587
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => enumProcessor(inst, ctx, json3, params);
|
|
13588
13588
|
inst.enum = def.entries;
|
|
13589
13589
|
inst.options = Object.values(def.entries);
|
|
13590
13590
|
const keys = new Set(Object.keys(def.entries));
|
|
@@ -13637,7 +13637,7 @@ function nativeEnum(entries, params) {
|
|
|
13637
13637
|
var ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
|
|
13638
13638
|
$ZodLiteral.init(inst, def);
|
|
13639
13639
|
ZodType.init(inst, def);
|
|
13640
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13640
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => literalProcessor(inst, ctx, json3, params);
|
|
13641
13641
|
inst.values = new Set(def.values);
|
|
13642
13642
|
Object.defineProperty(inst, "value", {
|
|
13643
13643
|
get() {
|
|
@@ -13658,7 +13658,7 @@ function literal(value, params) {
|
|
|
13658
13658
|
var ZodFile = /* @__PURE__ */ $constructor("ZodFile", (inst, def) => {
|
|
13659
13659
|
$ZodFile.init(inst, def);
|
|
13660
13660
|
ZodType.init(inst, def);
|
|
13661
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13661
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => fileProcessor(inst, ctx, json3, params);
|
|
13662
13662
|
inst.min = (size, params) => inst.check(_minSize(size, params));
|
|
13663
13663
|
inst.max = (size, params) => inst.check(_maxSize(size, params));
|
|
13664
13664
|
inst.mime = (types, params) => inst.check(_mime(Array.isArray(types) ? types : [types], params));
|
|
@@ -13669,7 +13669,7 @@ function file(params) {
|
|
|
13669
13669
|
var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
|
|
13670
13670
|
$ZodTransform.init(inst, def);
|
|
13671
13671
|
ZodType.init(inst, def);
|
|
13672
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13672
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => transformProcessor(inst, ctx, json3, params);
|
|
13673
13673
|
inst._zod.parse = (payload, _ctx) => {
|
|
13674
13674
|
if (_ctx.direction === "backward") {
|
|
13675
13675
|
throw new $ZodEncodeError(inst.constructor.name);
|
|
@@ -13709,7 +13709,7 @@ function transform(fn) {
|
|
|
13709
13709
|
var ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
|
|
13710
13710
|
$ZodOptional.init(inst, def);
|
|
13711
13711
|
ZodType.init(inst, def);
|
|
13712
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13712
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => optionalProcessor(inst, ctx, json3, params);
|
|
13713
13713
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
13714
13714
|
});
|
|
13715
13715
|
function optional(innerType) {
|
|
@@ -13721,7 +13721,7 @@ function optional(innerType) {
|
|
|
13721
13721
|
var ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
|
|
13722
13722
|
$ZodExactOptional.init(inst, def);
|
|
13723
13723
|
ZodType.init(inst, def);
|
|
13724
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13724
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => optionalProcessor(inst, ctx, json3, params);
|
|
13725
13725
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
13726
13726
|
});
|
|
13727
13727
|
function exactOptional(innerType) {
|
|
@@ -13733,7 +13733,7 @@ function exactOptional(innerType) {
|
|
|
13733
13733
|
var ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
|
|
13734
13734
|
$ZodNullable.init(inst, def);
|
|
13735
13735
|
ZodType.init(inst, def);
|
|
13736
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13736
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => nullableProcessor(inst, ctx, json3, params);
|
|
13737
13737
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
13738
13738
|
});
|
|
13739
13739
|
function nullable(innerType) {
|
|
@@ -13748,7 +13748,7 @@ function nullish2(innerType) {
|
|
|
13748
13748
|
var ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
|
|
13749
13749
|
$ZodDefault.init(inst, def);
|
|
13750
13750
|
ZodType.init(inst, def);
|
|
13751
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13751
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => defaultProcessor(inst, ctx, json3, params);
|
|
13752
13752
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
13753
13753
|
inst.removeDefault = inst.unwrap;
|
|
13754
13754
|
});
|
|
@@ -13764,7 +13764,7 @@ function _default2(innerType, defaultValue) {
|
|
|
13764
13764
|
var ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
|
|
13765
13765
|
$ZodPrefault.init(inst, def);
|
|
13766
13766
|
ZodType.init(inst, def);
|
|
13767
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13767
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => prefaultProcessor(inst, ctx, json3, params);
|
|
13768
13768
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
13769
13769
|
});
|
|
13770
13770
|
function prefault(innerType, defaultValue) {
|
|
@@ -13779,7 +13779,7 @@ function prefault(innerType, defaultValue) {
|
|
|
13779
13779
|
var ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
|
|
13780
13780
|
$ZodNonOptional.init(inst, def);
|
|
13781
13781
|
ZodType.init(inst, def);
|
|
13782
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13782
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => nonoptionalProcessor(inst, ctx, json3, params);
|
|
13783
13783
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
13784
13784
|
});
|
|
13785
13785
|
function nonoptional(innerType, params) {
|
|
@@ -13792,7 +13792,7 @@ function nonoptional(innerType, params) {
|
|
|
13792
13792
|
var ZodSuccess = /* @__PURE__ */ $constructor("ZodSuccess", (inst, def) => {
|
|
13793
13793
|
$ZodSuccess.init(inst, def);
|
|
13794
13794
|
ZodType.init(inst, def);
|
|
13795
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13795
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => successProcessor(inst, ctx, json3, params);
|
|
13796
13796
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
13797
13797
|
});
|
|
13798
13798
|
function success(innerType) {
|
|
@@ -13804,7 +13804,7 @@ function success(innerType) {
|
|
|
13804
13804
|
var ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
|
|
13805
13805
|
$ZodCatch.init(inst, def);
|
|
13806
13806
|
ZodType.init(inst, def);
|
|
13807
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13807
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => catchProcessor(inst, ctx, json3, params);
|
|
13808
13808
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
13809
13809
|
inst.removeCatch = inst.unwrap;
|
|
13810
13810
|
});
|
|
@@ -13818,7 +13818,7 @@ function _catch2(innerType, catchValue) {
|
|
|
13818
13818
|
var ZodNaN = /* @__PURE__ */ $constructor("ZodNaN", (inst, def) => {
|
|
13819
13819
|
$ZodNaN.init(inst, def);
|
|
13820
13820
|
ZodType.init(inst, def);
|
|
13821
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13821
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => nanProcessor(inst, ctx, json3, params);
|
|
13822
13822
|
});
|
|
13823
13823
|
function nan(params) {
|
|
13824
13824
|
return _nan(ZodNaN, params);
|
|
@@ -13826,7 +13826,7 @@ function nan(params) {
|
|
|
13826
13826
|
var ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
|
|
13827
13827
|
$ZodPipe.init(inst, def);
|
|
13828
13828
|
ZodType.init(inst, def);
|
|
13829
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13829
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => pipeProcessor(inst, ctx, json3, params);
|
|
13830
13830
|
inst.in = def.in;
|
|
13831
13831
|
inst.out = def.out;
|
|
13832
13832
|
});
|
|
@@ -13868,7 +13868,7 @@ var ZodPreprocess = /* @__PURE__ */ $constructor("ZodPreprocess", (inst, def) =>
|
|
|
13868
13868
|
var ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
|
|
13869
13869
|
$ZodReadonly.init(inst, def);
|
|
13870
13870
|
ZodType.init(inst, def);
|
|
13871
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13871
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => readonlyProcessor(inst, ctx, json3, params);
|
|
13872
13872
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
13873
13873
|
});
|
|
13874
13874
|
function readonly(innerType) {
|
|
@@ -13880,7 +13880,7 @@ function readonly(innerType) {
|
|
|
13880
13880
|
var ZodTemplateLiteral = /* @__PURE__ */ $constructor("ZodTemplateLiteral", (inst, def) => {
|
|
13881
13881
|
$ZodTemplateLiteral.init(inst, def);
|
|
13882
13882
|
ZodType.init(inst, def);
|
|
13883
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13883
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => templateLiteralProcessor(inst, ctx, json3, params);
|
|
13884
13884
|
});
|
|
13885
13885
|
function templateLiteral(parts, params) {
|
|
13886
13886
|
return new ZodTemplateLiteral({
|
|
@@ -13892,7 +13892,7 @@ function templateLiteral(parts, params) {
|
|
|
13892
13892
|
var ZodLazy = /* @__PURE__ */ $constructor("ZodLazy", (inst, def) => {
|
|
13893
13893
|
$ZodLazy.init(inst, def);
|
|
13894
13894
|
ZodType.init(inst, def);
|
|
13895
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13895
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => lazyProcessor(inst, ctx, json3, params);
|
|
13896
13896
|
inst.unwrap = () => inst._zod.def.getter();
|
|
13897
13897
|
});
|
|
13898
13898
|
function lazy(getter) {
|
|
@@ -13904,7 +13904,7 @@ function lazy(getter) {
|
|
|
13904
13904
|
var ZodPromise = /* @__PURE__ */ $constructor("ZodPromise", (inst, def) => {
|
|
13905
13905
|
$ZodPromise.init(inst, def);
|
|
13906
13906
|
ZodType.init(inst, def);
|
|
13907
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13907
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => promiseProcessor(inst, ctx, json3, params);
|
|
13908
13908
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
13909
13909
|
});
|
|
13910
13910
|
function promise(innerType) {
|
|
@@ -13916,7 +13916,7 @@ function promise(innerType) {
|
|
|
13916
13916
|
var ZodFunction = /* @__PURE__ */ $constructor("ZodFunction", (inst, def) => {
|
|
13917
13917
|
$ZodFunction.init(inst, def);
|
|
13918
13918
|
ZodType.init(inst, def);
|
|
13919
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13919
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => functionProcessor(inst, ctx, json3, params);
|
|
13920
13920
|
});
|
|
13921
13921
|
function _function(params) {
|
|
13922
13922
|
return new ZodFunction({
|
|
@@ -13928,7 +13928,7 @@ function _function(params) {
|
|
|
13928
13928
|
var ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
|
|
13929
13929
|
$ZodCustom.init(inst, def);
|
|
13930
13930
|
ZodType.init(inst, def);
|
|
13931
|
-
inst._zod.processJSONSchema = (ctx,
|
|
13931
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => customProcessor(inst, ctx, json3, params);
|
|
13932
13932
|
});
|
|
13933
13933
|
function check(fn) {
|
|
13934
13934
|
const ch = new $ZodCheck({
|
|
@@ -14110,13 +14110,13 @@ function resolveRef(ref, ctx) {
|
|
|
14110
14110
|
if (!ref.startsWith("#")) {
|
|
14111
14111
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
14112
14112
|
}
|
|
14113
|
-
const
|
|
14114
|
-
if (
|
|
14113
|
+
const path12 = ref.slice(1).split("/").filter(Boolean);
|
|
14114
|
+
if (path12.length === 0) {
|
|
14115
14115
|
return ctx.rootSchema;
|
|
14116
14116
|
}
|
|
14117
14117
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
14118
|
-
if (
|
|
14119
|
-
const key =
|
|
14118
|
+
if (path12[0] === defsKey) {
|
|
14119
|
+
const key = path12[1];
|
|
14120
14120
|
if (!key || !ctx.defs[key]) {
|
|
14121
14121
|
throw new Error(`Reference not found: ${ref}`);
|
|
14122
14122
|
}
|
|
@@ -14579,6 +14579,55 @@ var credentialImportsParamsSchema = external_exports.object({
|
|
|
14579
14579
|
request: credentialImportsRequestSchema
|
|
14580
14580
|
}).strict();
|
|
14581
14581
|
|
|
14582
|
+
// ../../shared-contracts/dist/harness-display-settings.js
|
|
14583
|
+
var harnessDisplayEntriesSchema = external_exports.array(external_exports.strictObject({
|
|
14584
|
+
agent: external_exports.string().min(1).max(128),
|
|
14585
|
+
section: external_exports.enum(["main", "more", "auto"])
|
|
14586
|
+
})).max(256).refine((entries) => new Set(entries.map((entry) => entry.agent)).size === entries.length, "Duplicate Harness IDs");
|
|
14587
|
+
var harnessDisplaySettingsSchema = external_exports.strictObject({
|
|
14588
|
+
entries: harnessDisplayEntriesSchema.nullable()
|
|
14589
|
+
});
|
|
14590
|
+
var harnessDisplayGetSchema = external_exports.strictObject({});
|
|
14591
|
+
var harnessDisplaySetSchema = external_exports.strictObject({
|
|
14592
|
+
entries: harnessDisplayEntriesSchema,
|
|
14593
|
+
/** Import legacy Desktop preferences only if no shared settings exist yet. */
|
|
14594
|
+
initializeOnly: external_exports.boolean().optional()
|
|
14595
|
+
});
|
|
14596
|
+
|
|
14597
|
+
// ../../shared-contracts/dist/console.js
|
|
14598
|
+
var consoleAnnouncementSchema = external_exports.strictObject({
|
|
14599
|
+
title: external_exports.string().trim().min(1).max(200),
|
|
14600
|
+
type: external_exports.enum(["info", "warning", "danger"]),
|
|
14601
|
+
body: external_exports.string().trim().min(1).max(16 * 1024)
|
|
14602
|
+
});
|
|
14603
|
+
var consoleOpenParamsSchema = external_exports.strictObject({});
|
|
14604
|
+
var consoleOpenResultSchema = external_exports.strictObject({
|
|
14605
|
+
/** The console address. */
|
|
14606
|
+
url: external_exports.string().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)
|
|
14607
|
+
});
|
|
14608
|
+
var CONSOLE_HOST_METHODS = Object.freeze([
|
|
14609
|
+
"codexhost/harness/plugins/list",
|
|
14610
|
+
"codexhost/harness/display-settings/get",
|
|
14611
|
+
"codexhost/harness/display-settings/set",
|
|
14612
|
+
"codexhost/harness/inspect",
|
|
14613
|
+
"codexhost/harness/launch-settings/get",
|
|
14614
|
+
"codexhost/harness/launch-settings/set",
|
|
14615
|
+
"codexhost/harness/web-ui/open",
|
|
14616
|
+
"codexhost/harness/accounts/sources",
|
|
14617
|
+
"codexhost/harness/accounts/list",
|
|
14618
|
+
"codexhost/harness/accounts/inspect",
|
|
14619
|
+
"codexhost/harness/credential-imports",
|
|
14620
|
+
"codexhost/harness/session-import/sources",
|
|
14621
|
+
"codexhost/harness/session-import/list",
|
|
14622
|
+
"codexhost/harness/session-import/import",
|
|
14623
|
+
"codexhost/account/list",
|
|
14624
|
+
"codexhost/account/refresh",
|
|
14625
|
+
"codexhost/account/usage/inspect",
|
|
14626
|
+
"codexhost/update/check",
|
|
14627
|
+
"codexhost/update/start",
|
|
14628
|
+
"codexhost/update/status"
|
|
14629
|
+
]);
|
|
14630
|
+
|
|
14582
14631
|
// ../../shared-contracts/dist/version.js
|
|
14583
14632
|
var WORKSPACE_CONTRACT_VERSION = 1;
|
|
14584
14633
|
|
|
@@ -14632,6 +14681,12 @@ var hostTurnIdSchema = opaqueIdSchema.brand();
|
|
|
14632
14681
|
var hostItemIdSchema = opaqueIdSchema.brand();
|
|
14633
14682
|
var hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
14634
14683
|
|
|
14684
|
+
// ../../shared-contracts/dist/manual-compaction.js
|
|
14685
|
+
var threadManualCompactionStartedSchema = external_exports.strictObject({
|
|
14686
|
+
threadId: hostThreadIdSchema,
|
|
14687
|
+
turnId: hostTurnIdSchema
|
|
14688
|
+
});
|
|
14689
|
+
|
|
14635
14690
|
// ../../shared-contracts/dist/thread-usage.js
|
|
14636
14691
|
var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
|
|
14637
14692
|
var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
|
|
@@ -14692,6 +14747,10 @@ var threadUsageSnapshotSchema = external_exports.object({
|
|
|
14692
14747
|
var usagePercentSchema = external_exports.number().finite().min(0).max(100);
|
|
14693
14748
|
var accountCreditsProductUsageSchema = external_exports.object({
|
|
14694
14749
|
product: external_exports.string().min(1),
|
|
14750
|
+
used: external_exports.number().finite().nonnegative().optional(),
|
|
14751
|
+
// Zero is a real empty cap, not an absent field.
|
|
14752
|
+
limit: external_exports.number().finite().nonnegative().optional(),
|
|
14753
|
+
unit: external_exports.string().min(1).max(32).optional(),
|
|
14695
14754
|
usagePercent: usagePercentSchema,
|
|
14696
14755
|
resetsAt: external_exports.string().min(1).optional()
|
|
14697
14756
|
}).strict();
|
|
@@ -14701,11 +14760,14 @@ var accountResetCreditsSchema = external_exports.object({
|
|
|
14701
14760
|
expiresAt: external_exports.array(external_exports.string().min(1)).min(1).max(32).optional()
|
|
14702
14761
|
}).strict();
|
|
14703
14762
|
var accountCreditsSnapshotSchema = external_exports.object({
|
|
14763
|
+
used: external_exports.number().finite().nonnegative().optional(),
|
|
14764
|
+
// Zero is a real empty cap, not an absent field.
|
|
14765
|
+
limit: external_exports.number().finite().nonnegative().optional(),
|
|
14766
|
+
unit: external_exports.string().trim().min(1).max(32).optional(),
|
|
14704
14767
|
/** Native label when the primary limit is scoped to a model or product group. */
|
|
14705
14768
|
label: external_exports.string().min(1).optional(),
|
|
14706
14769
|
usedPercent: usagePercentSchema.optional(),
|
|
14707
14770
|
remaining: external_exports.number().finite().optional(),
|
|
14708
|
-
unit: external_exports.string().trim().min(1).max(32).optional(),
|
|
14709
14771
|
resetsAt: external_exports.string().min(1).optional(),
|
|
14710
14772
|
periodType: external_exports.enum(["weekly", "monthly", "five_hour", "seven_day", "unknown"]),
|
|
14711
14773
|
productUsage: external_exports.array(accountCreditsProductUsageSchema).min(1).optional(),
|
|
@@ -14736,12 +14798,27 @@ var threadUsageInspectionSchema = external_exports.object({
|
|
|
14736
14798
|
}).strict();
|
|
14737
14799
|
|
|
14738
14800
|
// ../../shared-contracts/dist/harness-accounts.js
|
|
14739
|
-
var
|
|
14801
|
+
var accountBalanceSnapshotSchema = external_exports.object({
|
|
14802
|
+
amount: external_exports.number().finite().nonnegative(),
|
|
14803
|
+
/** ISO 4217 code as reported by the Provider, for example `CNY`. */
|
|
14804
|
+
currency: external_exports.string().trim().min(1).max(8),
|
|
14805
|
+
/** Native label when the Harness exposes several Billing Sources. */
|
|
14806
|
+
label: external_exports.string().trim().min(1).max(128).optional()
|
|
14807
|
+
}).strict();
|
|
14808
|
+
var harnessAccountSnapshotObject = external_exports.object({
|
|
14740
14809
|
email: external_exports.string().trim().min(1).max(320).optional(),
|
|
14741
14810
|
label: external_exports.string().trim().min(1).max(256).optional(),
|
|
14742
14811
|
plan: external_exports.string().trim().min(1).max(128).optional(),
|
|
14743
|
-
credits: accountCreditsSnapshotSchema
|
|
14812
|
+
credits: accountCreditsSnapshotSchema.optional(),
|
|
14813
|
+
balance: accountBalanceSnapshotSchema.optional()
|
|
14744
14814
|
}).strict();
|
|
14815
|
+
function requireReportedQuota(schema) {
|
|
14816
|
+
return schema.refine((value) => {
|
|
14817
|
+
const reported = value;
|
|
14818
|
+
return reported.credits !== void 0 || reported.balance !== void 0;
|
|
14819
|
+
}, { message: "Account must report either credits or a balance" });
|
|
14820
|
+
}
|
|
14821
|
+
var harnessAccountSnapshotSchema = requireReportedQuota(harnessAccountSnapshotObject);
|
|
14745
14822
|
var harnessAccountIdentityShape = {
|
|
14746
14823
|
harnessId: harnessIdSchema,
|
|
14747
14824
|
harnessName: external_exports.string().trim().min(1).max(128)
|
|
@@ -14752,11 +14829,13 @@ var harnessAccountSourceListResultSchema = external_exports.object({ sources: ex
|
|
|
14752
14829
|
var harnessAccountInspectParamsSchema = external_exports.object({ harnessId: harnessIdSchema, refresh: external_exports.boolean().optional() }).strict();
|
|
14753
14830
|
var harnessAccountInspectResultSchema = external_exports.object({
|
|
14754
14831
|
...harnessAccountIdentityShape,
|
|
14755
|
-
account: harnessAccountSnapshotSchema.nullable()
|
|
14832
|
+
account: harnessAccountSnapshotSchema.nullable(),
|
|
14833
|
+
/** Every Billing Source from one Harness; `account` remains the first for older clients. */
|
|
14834
|
+
accounts: external_exports.array(harnessAccountSnapshotSchema).max(8).optional()
|
|
14756
14835
|
}).strict();
|
|
14757
14836
|
var harnessAccountListParamsSchema = external_exports.object({ refresh: external_exports.boolean().optional() }).strict();
|
|
14758
14837
|
var harnessAccountListResultSchema = external_exports.object({
|
|
14759
|
-
accounts: external_exports.array(
|
|
14838
|
+
accounts: external_exports.array(requireReportedQuota(harnessAccountSnapshotObject.extend(harnessAccountIdentityShape))).max(128)
|
|
14760
14839
|
}).strict();
|
|
14761
14840
|
|
|
14762
14841
|
// ../../shared-contracts/dist/json-value.js
|
|
@@ -14894,6 +14973,8 @@ var harnessModelSchema = external_exports.object({
|
|
|
14894
14973
|
ref: harnessModelRefSchema,
|
|
14895
14974
|
label: nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH),
|
|
14896
14975
|
resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
|
|
14976
|
+
/** Optional opaque selection for this same Model with priority processing enabled. */
|
|
14977
|
+
fastModel: harnessModelRefSchema.optional(),
|
|
14897
14978
|
supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
|
|
14898
14979
|
}).strict();
|
|
14899
14980
|
var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
|
|
@@ -14926,6 +15007,16 @@ var harnessModelCatalogSchema = external_exports.object({
|
|
|
14926
15007
|
});
|
|
14927
15008
|
}
|
|
14928
15009
|
refs.add(model.ref.id);
|
|
15010
|
+
if (model.fastModel) {
|
|
15011
|
+
if (refs.has(model.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model.fastModel?.id)) {
|
|
15012
|
+
context.addIssue({
|
|
15013
|
+
code: "custom",
|
|
15014
|
+
message: "Fast Model refs must be distinct and unique",
|
|
15015
|
+
path: ["models", index, "fastModel"]
|
|
15016
|
+
});
|
|
15017
|
+
}
|
|
15018
|
+
refs.add(model.fastModel.id);
|
|
15019
|
+
}
|
|
14929
15020
|
const supportedThinkingIds = /* @__PURE__ */ new Set();
|
|
14930
15021
|
for (const [optionIndex, optionId] of (model.supportedThinkingOptionIds ?? []).entries()) {
|
|
14931
15022
|
if (supportedThinkingIds.has(optionId)) {
|
|
@@ -15048,11 +15139,13 @@ var threadThinkingSelectParamsSchema = external_exports.object({
|
|
|
15048
15139
|
thinkingOptionId: harnessThinkingOptionIdSchema
|
|
15049
15140
|
}).strict();
|
|
15050
15141
|
var threadInspectionParamsSchema = external_exports.object({
|
|
15051
|
-
threadId: hostThreadIdSchema
|
|
15142
|
+
threadId: hostThreadIdSchema,
|
|
15143
|
+
includeReferenceCapability: external_exports.boolean().optional()
|
|
15052
15144
|
}).strict();
|
|
15053
15145
|
var codexThreadInspectionSchema = external_exports.object({
|
|
15054
15146
|
owner: external_exports.literal("codex"),
|
|
15055
|
-
locked: external_exports.literal(true)
|
|
15147
|
+
locked: external_exports.literal(true),
|
|
15148
|
+
supportsThreadReferences: external_exports.literal(true).optional()
|
|
15056
15149
|
}).strict();
|
|
15057
15150
|
var externalThreadInspectionSchema = external_exports.object({
|
|
15058
15151
|
owner: external_exports.literal("external"),
|
|
@@ -15180,10 +15273,31 @@ var harnessLaunchSettingsSchema = external_exports.object({
|
|
|
15180
15273
|
restartRequired: external_exports.boolean()
|
|
15181
15274
|
}).strict();
|
|
15182
15275
|
|
|
15276
|
+
// ../../shared-contracts/dist/harness-installation.js
|
|
15277
|
+
var harnessInstallationParamsSchema = external_exports.object({
|
|
15278
|
+
harnessId: harnessIdSchema,
|
|
15279
|
+
action: external_exports.enum(["check", "update"])
|
|
15280
|
+
}).strict();
|
|
15281
|
+
var harnessInstallationStateSchema = external_exports.object({
|
|
15282
|
+
currentVersion: external_exports.string().min(1).max(128),
|
|
15283
|
+
latestVersion: external_exports.string().min(1).max(128),
|
|
15284
|
+
updateAvailable: external_exports.boolean(),
|
|
15285
|
+
canUpdate: external_exports.boolean(),
|
|
15286
|
+
message: external_exports.string().max(2048).optional()
|
|
15287
|
+
}).strict();
|
|
15288
|
+
|
|
15183
15289
|
// ../../shared-contracts/dist/codex-accounts.js
|
|
15184
15290
|
var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
|
|
15185
15291
|
var nonBlankTextSchema3 = external_exports.string().trim().min(1);
|
|
15186
15292
|
var codexAccountAuthKindSchema = external_exports.enum(["api", "chatgpt"]);
|
|
15293
|
+
var codexAccountSiteUrlPattern = /^https?:\/\/(?:\[[0-9a-fA-F:]+\]|[^/\s:@?#]+)(?::\d{1,5})?(?:[/?#][^\s]*)?$/u;
|
|
15294
|
+
function isCodexAccountSiteUrl(value) {
|
|
15295
|
+
return value.length > 0 && value.length <= 2048 && codexAccountSiteUrlPattern.test(value);
|
|
15296
|
+
}
|
|
15297
|
+
var externalUrlOpenParamsSchema = external_exports.object({
|
|
15298
|
+
url: external_exports.string().max(2048).refine(isCodexAccountSiteUrl, "External URL must be http(s)")
|
|
15299
|
+
}).strict();
|
|
15300
|
+
var externalUrlOpenResultSchema = external_exports.object({}).strict();
|
|
15187
15301
|
var codexAccountPlanTypeSchema = external_exports.enum([
|
|
15188
15302
|
"free",
|
|
15189
15303
|
"go",
|
|
@@ -15209,7 +15323,8 @@ var codexAccountSchema = external_exports.object({
|
|
|
15209
15323
|
email: external_exports.string().email().max(320).optional(),
|
|
15210
15324
|
planType: codexAccountPlanTypeSchema.optional(),
|
|
15211
15325
|
authKind: codexAccountAuthKindSchema.optional(),
|
|
15212
|
-
authIdentity: nonBlankTextSchema3.max(256).optional()
|
|
15326
|
+
authIdentity: nonBlankTextSchema3.max(256).optional(),
|
|
15327
|
+
siteUrl: external_exports.string().refine(isCodexAccountSiteUrl, "Account site URL must be http(s)").optional()
|
|
15213
15328
|
}).strict();
|
|
15214
15329
|
var codexAccountPhaseSchema = external_exports.enum(["ready", "unavailable"]);
|
|
15215
15330
|
var codexAccountListResultSchema = external_exports.object({
|
|
@@ -15521,8 +15636,8 @@ function validateHostQuestionResponse(interaction, response) {
|
|
|
15521
15636
|
if (!question.multiple && answers.length > 1) {
|
|
15522
15637
|
return invalidRequest2("Single-choice Question accepts at most one answer");
|
|
15523
15638
|
}
|
|
15524
|
-
const
|
|
15525
|
-
if (!question.allowOther && answers.some((answer) => !
|
|
15639
|
+
const declared2 = new Set(question.options.map(({ value }) => value));
|
|
15640
|
+
if (!question.allowOther && answers.some((answer) => !declared2.has(answer))) {
|
|
15526
15641
|
return invalidRequest2("Question Response contains an undeclared choice");
|
|
15527
15642
|
}
|
|
15528
15643
|
}
|
|
@@ -16107,8 +16222,9 @@ var OpenCodeTransportError = class extends Error {
|
|
|
16107
16222
|
import { randomBytes } from "node:crypto";
|
|
16108
16223
|
import { spawn, spawnSync } from "node:child_process";
|
|
16109
16224
|
import fs2 from "node:fs";
|
|
16110
|
-
import {
|
|
16111
|
-
import
|
|
16225
|
+
import { createServer } from "node:net";
|
|
16226
|
+
import { homedir as homedir2, tmpdir } from "node:os";
|
|
16227
|
+
import path6 from "node:path";
|
|
16112
16228
|
|
|
16113
16229
|
// ../../../node_modules/@opencode-ai/sdk/dist/v2/gen/core/serverSentEvents.gen.js
|
|
16114
16230
|
var createSseClient = ({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url: url2, ...options }) => {
|
|
@@ -16334,7 +16450,7 @@ var serializeObjectParam = ({ allowReserved, explode, name, style, value, valueO
|
|
|
16334
16450
|
|
|
16335
16451
|
// ../../../node_modules/@opencode-ai/sdk/dist/v2/gen/core/utils.gen.js
|
|
16336
16452
|
var PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
16337
|
-
var defaultPathSerializer = ({ path:
|
|
16453
|
+
var defaultPathSerializer = ({ path: path12, url: _url2 }) => {
|
|
16338
16454
|
let url2 = _url2;
|
|
16339
16455
|
const matches = _url2.match(PATH_PARAM_RE);
|
|
16340
16456
|
if (matches) {
|
|
@@ -16353,7 +16469,7 @@ var defaultPathSerializer = ({ path: path7, url: _url2 }) => {
|
|
|
16353
16469
|
name = name.substring(1);
|
|
16354
16470
|
style = "matrix";
|
|
16355
16471
|
}
|
|
16356
|
-
const value =
|
|
16472
|
+
const value = path12[name];
|
|
16357
16473
|
if (value === void 0 || value === null) {
|
|
16358
16474
|
continue;
|
|
16359
16475
|
}
|
|
@@ -16384,11 +16500,11 @@ var defaultPathSerializer = ({ path: path7, url: _url2 }) => {
|
|
|
16384
16500
|
}
|
|
16385
16501
|
return url2;
|
|
16386
16502
|
};
|
|
16387
|
-
var getUrl = ({ baseUrl, path:
|
|
16503
|
+
var getUrl = ({ baseUrl, path: path12, query, querySerializer, url: _url2 }) => {
|
|
16388
16504
|
const pathUrl = _url2.startsWith("/") ? _url2 : `/${_url2}`;
|
|
16389
16505
|
let url2 = (baseUrl ?? "") + pathUrl;
|
|
16390
|
-
if (
|
|
16391
|
-
url2 = defaultPathSerializer({ path:
|
|
16506
|
+
if (path12) {
|
|
16507
|
+
url2 = defaultPathSerializer({ path: path12, url: url2 });
|
|
16392
16508
|
}
|
|
16393
16509
|
let search = query ? querySerializer(query) : "";
|
|
16394
16510
|
if (search.startsWith("?")) {
|
|
@@ -21511,7 +21627,7 @@ function createOpencodeClient(config2) {
|
|
|
21511
21627
|
}
|
|
21512
21628
|
|
|
21513
21629
|
// dist/command.js
|
|
21514
|
-
import
|
|
21630
|
+
import path5 from "node:path";
|
|
21515
21631
|
|
|
21516
21632
|
// ../../harness-discovery/dist/environment.js
|
|
21517
21633
|
import fs from "node:fs";
|
|
@@ -21575,6 +21691,20 @@ function commandInvocation(command, arguments_, environment, platform = process.
|
|
|
21575
21691
|
};
|
|
21576
21692
|
}
|
|
21577
21693
|
|
|
21694
|
+
// ../../harness-discovery/dist/node-runtime.js
|
|
21695
|
+
import path3 from "node:path";
|
|
21696
|
+
function withNodeRuntimeOnPath(environment, runtimeExecutable = process.execPath, platform = process.platform) {
|
|
21697
|
+
const pathKey = Object.keys(environment).find((name) => name.toLowerCase() === "path") ?? "PATH";
|
|
21698
|
+
const delimiter = platform === "win32" ? ";" : ":";
|
|
21699
|
+
const runtimeDirectory = path3.dirname(runtimeExecutable);
|
|
21700
|
+
const directories = (environment[pathKey] ?? "").split(delimiter).filter(Boolean);
|
|
21701
|
+
const equal = platform === "win32" ? (value) => value.toLowerCase() : (value) => value;
|
|
21702
|
+
if (!directories.some((directory) => equal(directory) === equal(runtimeDirectory))) {
|
|
21703
|
+
directories.push(runtimeDirectory);
|
|
21704
|
+
}
|
|
21705
|
+
return { ...environment, [pathKey]: directories.join(delimiter) };
|
|
21706
|
+
}
|
|
21707
|
+
|
|
21578
21708
|
// ../../harness-discovery/dist/resolve.js
|
|
21579
21709
|
import os from "node:os";
|
|
21580
21710
|
|
|
@@ -21738,6 +21868,195 @@ function resolveHarnessExecutable(spec, input, dependencies = {}) {
|
|
|
21738
21868
|
return void 0;
|
|
21739
21869
|
}
|
|
21740
21870
|
|
|
21871
|
+
// ../../harness-discovery/dist/installation.js
|
|
21872
|
+
import { execFile } from "node:child_process";
|
|
21873
|
+
import { homedir } from "node:os";
|
|
21874
|
+
function runInstallationCommand(command, args, environment, timeout = 3e4) {
|
|
21875
|
+
const env = withNodeRuntimeOnPath(environment);
|
|
21876
|
+
const invocation = /\.[cm]?js$/i.test(command) ? commandInvocation(process.execPath, [command, ...args], env) : commandInvocation(command, args, env);
|
|
21877
|
+
return new Promise((resolve, reject) => {
|
|
21878
|
+
const child = execFile(invocation.command, invocation.arguments, {
|
|
21879
|
+
env,
|
|
21880
|
+
cwd: env.HOME ?? env.USERPROFILE ?? homedir(),
|
|
21881
|
+
encoding: "utf8",
|
|
21882
|
+
timeout,
|
|
21883
|
+
killSignal: "SIGKILL",
|
|
21884
|
+
maxBuffer: 1024 * 1024,
|
|
21885
|
+
windowsHide: true,
|
|
21886
|
+
windowsVerbatimArguments: invocation.windowsVerbatimArguments
|
|
21887
|
+
}, (error51, stdout, stderr) => {
|
|
21888
|
+
if (error51)
|
|
21889
|
+
reject(new Error(error51.killed ? "Harness command timed out" : "Harness command failed; check the native installation and retry"));
|
|
21890
|
+
else
|
|
21891
|
+
resolve((stdout || stderr).trim());
|
|
21892
|
+
});
|
|
21893
|
+
child.stdin?.end();
|
|
21894
|
+
});
|
|
21895
|
+
}
|
|
21896
|
+
function installationVersion(value) {
|
|
21897
|
+
if (typeof value !== "string" || !/^v?\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?$/.test(value.trim()))
|
|
21898
|
+
throw new Error("Harness returned an invalid version");
|
|
21899
|
+
return value.trim().replace(/^v/, "");
|
|
21900
|
+
}
|
|
21901
|
+
function versionFromOutput(output) {
|
|
21902
|
+
return installationVersion(output.match(/\b\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?\b/)?.[0]);
|
|
21903
|
+
}
|
|
21904
|
+
function newerInstallationVersion(current, latest) {
|
|
21905
|
+
const a = installationVersion(current).replace(/\+.*/, "");
|
|
21906
|
+
const b = installationVersion(latest).replace(/\+.*/, "");
|
|
21907
|
+
const coreA = a.replace(/-.*/, "").split(".").map(BigInt);
|
|
21908
|
+
const coreB = b.replace(/-.*/, "").split(".").map(BigInt);
|
|
21909
|
+
for (let i = 0; i < Math.max(coreA.length, coreB.length); i++) {
|
|
21910
|
+
if ((coreA[i] ?? 0n) !== (coreB[i] ?? 0n))
|
|
21911
|
+
return (coreB[i] ?? 0n) > (coreA[i] ?? 0n);
|
|
21912
|
+
}
|
|
21913
|
+
const preA = a.includes("-") ? a.slice(a.indexOf("-") + 1).split(".") : [];
|
|
21914
|
+
const preB = b.includes("-") ? b.slice(b.indexOf("-") + 1).split(".") : [];
|
|
21915
|
+
if (!preA.length || !preB.length)
|
|
21916
|
+
return !!preA.length && !preB.length;
|
|
21917
|
+
for (let i = 0; i < Math.max(preA.length, preB.length); i++) {
|
|
21918
|
+
const x = preA[i];
|
|
21919
|
+
const y = preB[i];
|
|
21920
|
+
if (x === y)
|
|
21921
|
+
continue;
|
|
21922
|
+
if (x === void 0 || y === void 0)
|
|
21923
|
+
return x === void 0;
|
|
21924
|
+
const numericX = /^\d+$/.test(x);
|
|
21925
|
+
const numericY = /^\d+$/.test(y);
|
|
21926
|
+
if (numericX && numericY) {
|
|
21927
|
+
if (BigInt(x) === BigInt(y))
|
|
21928
|
+
continue;
|
|
21929
|
+
return BigInt(y) > BigInt(x);
|
|
21930
|
+
}
|
|
21931
|
+
if (numericX !== numericY)
|
|
21932
|
+
return numericX;
|
|
21933
|
+
return y > x;
|
|
21934
|
+
}
|
|
21935
|
+
return false;
|
|
21936
|
+
}
|
|
21937
|
+
function createInstallationManager(options) {
|
|
21938
|
+
let checking;
|
|
21939
|
+
let updating;
|
|
21940
|
+
const check2 = () => checking ??= options.check().finally(() => {
|
|
21941
|
+
checking = void 0;
|
|
21942
|
+
});
|
|
21943
|
+
return (action) => {
|
|
21944
|
+
if (updating)
|
|
21945
|
+
return updating;
|
|
21946
|
+
if (action === "check")
|
|
21947
|
+
return check2();
|
|
21948
|
+
updating = (async () => {
|
|
21949
|
+
const before = await check2();
|
|
21950
|
+
if (!before.updateAvailable)
|
|
21951
|
+
return before;
|
|
21952
|
+
if (!before.canUpdate)
|
|
21953
|
+
throw new Error(before.message ?? "This installation cannot be updated automatically");
|
|
21954
|
+
await options.update(before);
|
|
21955
|
+
const after = await check2();
|
|
21956
|
+
if (after.currentVersion === before.currentVersion)
|
|
21957
|
+
throw new Error("The Harness version did not change; check the native updater and retry");
|
|
21958
|
+
return after;
|
|
21959
|
+
})().finally(() => {
|
|
21960
|
+
updating = void 0;
|
|
21961
|
+
});
|
|
21962
|
+
return updating;
|
|
21963
|
+
};
|
|
21964
|
+
}
|
|
21965
|
+
async function fetchInstallationText(url2) {
|
|
21966
|
+
const request = async () => {
|
|
21967
|
+
const response = await fetch(url2, { signal: AbortSignal.timeout(15e3) });
|
|
21968
|
+
if (!response.ok)
|
|
21969
|
+
throw new Error("Could not check the latest Harness version");
|
|
21970
|
+
return response.text();
|
|
21971
|
+
};
|
|
21972
|
+
try {
|
|
21973
|
+
return await request();
|
|
21974
|
+
} catch (error51) {
|
|
21975
|
+
if (error51 instanceof DOMException && (error51.name === "AbortError" || error51.name === "TimeoutError"))
|
|
21976
|
+
throw error51;
|
|
21977
|
+
return request();
|
|
21978
|
+
}
|
|
21979
|
+
}
|
|
21980
|
+
|
|
21981
|
+
// ../../harness-discovery/dist/npm-installation.js
|
|
21982
|
+
import { readFile, realpath } from "node:fs/promises";
|
|
21983
|
+
import path4 from "node:path";
|
|
21984
|
+
function referencesNpmBin(shim, name, bin) {
|
|
21985
|
+
if (bin.includes(".."))
|
|
21986
|
+
return false;
|
|
21987
|
+
const target = `node_modules/${name}/${bin.replace(/^\.\//, "")}`.toLowerCase();
|
|
21988
|
+
const text = shim.replaceAll("\\", "/").toLowerCase();
|
|
21989
|
+
return text.includes(`%dp0%/${target}"`) || text.includes(`%~dp0/${target}"`);
|
|
21990
|
+
}
|
|
21991
|
+
async function npmInstallation(command, packages, environment) {
|
|
21992
|
+
let selected = await realpath(command);
|
|
21993
|
+
if (process.platform === "win32" && /\.(cmd|bat)$/i.test(selected)) {
|
|
21994
|
+
const shim = (await readFile(selected, "utf8")).replaceAll("\\", "/");
|
|
21995
|
+
const root = path4.dirname(selected);
|
|
21996
|
+
for (const name of packages) {
|
|
21997
|
+
const directory2 = path4.join(root, "node_modules", ...name.split("/"));
|
|
21998
|
+
const metadata = await readFile(path4.join(directory2, "package.json"), "utf8").then((text) => JSON.parse(text)).catch(() => null);
|
|
21999
|
+
const bins = typeof metadata?.bin === "string" ? [metadata.bin] : Object.values(metadata?.bin ?? {});
|
|
22000
|
+
const bin = bins.find((entry) => referencesNpmBin(shim, name, entry));
|
|
22001
|
+
if (bin) {
|
|
22002
|
+
selected = await realpath(path4.join(directory2, bin));
|
|
22003
|
+
break;
|
|
22004
|
+
}
|
|
22005
|
+
}
|
|
22006
|
+
}
|
|
22007
|
+
let directory = path4.dirname(selected);
|
|
22008
|
+
for (let depth = 0; depth < 8; depth++) {
|
|
22009
|
+
const metadata = await readFile(path4.join(directory, "package.json"), "utf8").then((text) => JSON.parse(text)).catch(() => null);
|
|
22010
|
+
if (metadata?.name && packages.includes(metadata.name)) {
|
|
22011
|
+
const name = metadata.name;
|
|
22012
|
+
const currentVersion = installationVersion(metadata.version);
|
|
22013
|
+
const segments = name.split("/");
|
|
22014
|
+
let modules = directory;
|
|
22015
|
+
for (let index = 0; index < segments.length; index++)
|
|
22016
|
+
modules = path4.dirname(modules);
|
|
22017
|
+
const prefix = process.platform === "win32" ? path4.dirname(modules) : path4.dirname(path4.dirname(modules));
|
|
22018
|
+
const globalRoot = process.platform === "win32" ? path4.join(prefix, "node_modules") : path4.join(prefix, "lib", "node_modules");
|
|
22019
|
+
const env = withNodeRuntimeOnPath(environment);
|
|
22020
|
+
const npm = resolveHarnessExecutable({ id: "npm", command: "npm", installRoots: { posix: [], windows: [] } }, { environment: env });
|
|
22021
|
+
let globalInstall = modules === globalRoot;
|
|
22022
|
+
if (process.platform === "win32") {
|
|
22023
|
+
const project = (await Promise.all(["package.json", "package-lock.json", "npm-shrinkwrap.json"].map((file2) => readFile(path4.join(prefix, file2), "utf8").then(() => true, (error51) => error51.code !== "ENOENT")))).some(Boolean);
|
|
22024
|
+
const bins = typeof metadata.bin === "string" ? { [name.split("/").at(-1) ?? name]: metadata.bin } : metadata.bin ?? {};
|
|
22025
|
+
const launchers = await Promise.all(Object.entries(bins).map(async ([bin, entry]) => {
|
|
22026
|
+
if (path4.basename(bin) !== bin || entry.includes(".."))
|
|
22027
|
+
return false;
|
|
22028
|
+
const target = await realpath(path4.join(directory, entry)).catch(() => "");
|
|
22029
|
+
if (target.toLowerCase() !== selected.toLowerCase())
|
|
22030
|
+
return false;
|
|
22031
|
+
const shim = await readFile(path4.join(prefix, `${bin}.cmd`), "utf8").catch(() => "");
|
|
22032
|
+
return referencesNpmBin(shim, name, entry);
|
|
22033
|
+
}));
|
|
22034
|
+
globalInstall = globalInstall && !project && launchers.some(Boolean);
|
|
22035
|
+
}
|
|
22036
|
+
const canUpdate = globalInstall && !!npm;
|
|
22037
|
+
return {
|
|
22038
|
+
prefix,
|
|
22039
|
+
currentVersion,
|
|
22040
|
+
canUpdate,
|
|
22041
|
+
latest: async () => {
|
|
22042
|
+
const data = JSON.parse(await fetchInstallationText(`https://registry.npmjs.org/${encodeURIComponent(name)}/latest`));
|
|
22043
|
+
return installationVersion(data.version);
|
|
22044
|
+
},
|
|
22045
|
+
update: async (version2) => {
|
|
22046
|
+
if (!canUpdate || !npm)
|
|
22047
|
+
throw new Error("Use the original package manager to update this installation");
|
|
22048
|
+
await runInstallationCommand(npm.executable, ["install", "--global", "--prefix", prefix, `${name}@${installationVersion(version2)}`], env, 3e5);
|
|
22049
|
+
}
|
|
22050
|
+
};
|
|
22051
|
+
}
|
|
22052
|
+
const parent = path4.dirname(directory);
|
|
22053
|
+
if (parent === directory)
|
|
22054
|
+
break;
|
|
22055
|
+
directory = parent;
|
|
22056
|
+
}
|
|
22057
|
+
return null;
|
|
22058
|
+
}
|
|
22059
|
+
|
|
21741
22060
|
// dist/command.js
|
|
21742
22061
|
var OpenCodeExecutableError = class extends Error {
|
|
21743
22062
|
code = "OPENCODE_NOT_FOUND";
|
|
@@ -21772,16 +22091,34 @@ function resolveOpenCodeExecutable(input = {}, dependencies = {}) {
|
|
|
21772
22091
|
}, dependencies);
|
|
21773
22092
|
if (!resolution)
|
|
21774
22093
|
throw new OpenCodeExecutableError();
|
|
21775
|
-
return targetPath(platform).isAbsolute(resolution.executable) ? resolution.executable :
|
|
22094
|
+
return targetPath(platform).isAbsolute(resolution.executable) ? resolution.executable : path5.resolve(resolution.executable);
|
|
21776
22095
|
}
|
|
21777
|
-
function openCodeServerInvocation(executable, environment, platform = process.platform) {
|
|
21778
|
-
return commandInvocation(executable, ["serve", "--hostname=127.0.0.1",
|
|
22096
|
+
function openCodeServerInvocation(executable, environment, platform = process.platform, port = 0) {
|
|
22097
|
+
return commandInvocation(executable, ["serve", "--hostname=127.0.0.1", `--port=${port}`], environment, platform);
|
|
21779
22098
|
}
|
|
21780
22099
|
|
|
21781
22100
|
// dist/server-connection.js
|
|
21782
22101
|
var DEFAULT_STARTUP_TIMEOUT_MS = 2e4;
|
|
21783
22102
|
var DEFAULT_CLOSE_TIMEOUT_MS = 3e3;
|
|
22103
|
+
var STARTUP_ATTEMPTS = 3;
|
|
21784
22104
|
var SERVER_USERNAME = "codexhost";
|
|
22105
|
+
function freeLoopbackPort() {
|
|
22106
|
+
return new Promise((resolve, reject) => {
|
|
22107
|
+
const probe = createServer();
|
|
22108
|
+
probe.unref();
|
|
22109
|
+
probe.once("error", reject);
|
|
22110
|
+
probe.listen({ host: "127.0.0.1", port: 0 }, () => {
|
|
22111
|
+
const address = probe.address();
|
|
22112
|
+
const port = typeof address === "object" && address ? address.port : 0;
|
|
22113
|
+
probe.close(() => {
|
|
22114
|
+
if (port)
|
|
22115
|
+
resolve(port);
|
|
22116
|
+
else
|
|
22117
|
+
reject(new Error("Failed to assign an OpenCode Server loopback port"));
|
|
22118
|
+
});
|
|
22119
|
+
});
|
|
22120
|
+
});
|
|
22121
|
+
}
|
|
21785
22122
|
function isRecord2(value) {
|
|
21786
22123
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
21787
22124
|
}
|
|
@@ -21849,9 +22186,9 @@ function signalProcessTree(child, signal) {
|
|
|
21849
22186
|
}
|
|
21850
22187
|
}
|
|
21851
22188
|
function safeOpenCodeServerCwd(environment) {
|
|
21852
|
-
const candidates = [environment.USERPROFILE, environment.HOME,
|
|
22189
|
+
const candidates = [environment.USERPROFILE, environment.HOME, homedir2(), tmpdir()];
|
|
21853
22190
|
for (const candidate of candidates) {
|
|
21854
|
-
if (!candidate || !
|
|
22191
|
+
if (!candidate || !path6.isAbsolute(candidate))
|
|
21855
22192
|
continue;
|
|
21856
22193
|
try {
|
|
21857
22194
|
if (!fs2.statSync(candidate).isDirectory())
|
|
@@ -21903,7 +22240,8 @@ var OpenCodeServerConnection = class {
|
|
|
21903
22240
|
...spawnOptions,
|
|
21904
22241
|
windowsVerbatimArguments: spawnOptions.windowsVerbatimArguments
|
|
21905
22242
|
}),
|
|
21906
|
-
sleep: (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds))
|
|
22243
|
+
sleep: (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds)),
|
|
22244
|
+
assignPort: freeLoopbackPort
|
|
21907
22245
|
}) {
|
|
21908
22246
|
this.#options = options;
|
|
21909
22247
|
this.#environment = options.environment ?? process.env;
|
|
@@ -21959,11 +22297,26 @@ var OpenCodeServerConnection = class {
|
|
|
21959
22297
|
OPENCODE_SERVER_USERNAME: SERVER_USERNAME,
|
|
21960
22298
|
OPENCODE_SERVER_PASSWORD: password
|
|
21961
22299
|
};
|
|
21962
|
-
const invocation = openCodeServerInvocation(executable, environment);
|
|
21963
22300
|
const serverCwd = (this.#dependencies.resolveServerCwd ?? safeOpenCodeServerCwd)(environment);
|
|
21964
22301
|
if (!serverCwd) {
|
|
21965
22302
|
throw new OpenCodeTransportError("unavailable", "OpenCode Server requires a writable startup directory");
|
|
21966
22303
|
}
|
|
22304
|
+
let lastError;
|
|
22305
|
+
for (let attempt = 0; attempt < STARTUP_ATTEMPTS; attempt += 1) {
|
|
22306
|
+
try {
|
|
22307
|
+
return await this.#startAttempt(executable, environment, serverCwd, password);
|
|
22308
|
+
} catch (error51) {
|
|
22309
|
+
lastError = error51;
|
|
22310
|
+
if (!(error51 instanceof OpenCodeTransportError) || error51.code !== "processExited") {
|
|
22311
|
+
throw classifySdkError(error51, "Server startup");
|
|
22312
|
+
}
|
|
22313
|
+
}
|
|
22314
|
+
}
|
|
22315
|
+
throw classifySdkError(lastError, "Server startup");
|
|
22316
|
+
}
|
|
22317
|
+
async #startAttempt(executable, environment, serverCwd, password) {
|
|
22318
|
+
const port = await (this.#dependencies.assignPort ?? freeLoopbackPort)();
|
|
22319
|
+
const invocation = openCodeServerInvocation(executable, environment, process.platform, port);
|
|
21967
22320
|
let child;
|
|
21968
22321
|
try {
|
|
21969
22322
|
child = this.#dependencies.spawn(invocation.command, invocation.arguments, {
|
|
@@ -22024,7 +22377,7 @@ var OpenCodeServerConnection = class {
|
|
|
22024
22377
|
return { baseUrl, authorization };
|
|
22025
22378
|
} catch (error51) {
|
|
22026
22379
|
await this.#stopChild(child).catch(() => void 0);
|
|
22027
|
-
throw
|
|
22380
|
+
throw error51;
|
|
22028
22381
|
}
|
|
22029
22382
|
}
|
|
22030
22383
|
async #stopChild(child) {
|
|
@@ -22284,7 +22637,7 @@ var SdkOpenCodeTransport = class {
|
|
|
22284
22637
|
|
|
22285
22638
|
// dist/file-change-verification.js
|
|
22286
22639
|
import fs3 from "node:fs";
|
|
22287
|
-
import
|
|
22640
|
+
import path7 from "node:path";
|
|
22288
22641
|
function missingPath(error51) {
|
|
22289
22642
|
if (!error51 || typeof error51 !== "object")
|
|
22290
22643
|
return false;
|
|
@@ -22296,33 +22649,33 @@ function hasDotPathSegment(value) {
|
|
|
22296
22649
|
return segments.some((segment) => segment === "." || segment === "..");
|
|
22297
22650
|
}
|
|
22298
22651
|
function canonicalDirectoryPath(value) {
|
|
22299
|
-
let candidate =
|
|
22652
|
+
let candidate = path7.resolve(value);
|
|
22300
22653
|
const missingSegments = [];
|
|
22301
22654
|
for (; ; ) {
|
|
22302
22655
|
try {
|
|
22303
|
-
return
|
|
22656
|
+
return path7.join(fs3.realpathSync.native(candidate), ...missingSegments);
|
|
22304
22657
|
} catch (error51) {
|
|
22305
22658
|
if (!missingPath(error51))
|
|
22306
22659
|
return void 0;
|
|
22307
|
-
const parent =
|
|
22660
|
+
const parent = path7.dirname(candidate);
|
|
22308
22661
|
if (parent === candidate)
|
|
22309
22662
|
return void 0;
|
|
22310
|
-
missingSegments.unshift(
|
|
22663
|
+
missingSegments.unshift(path7.basename(candidate));
|
|
22311
22664
|
candidate = parent;
|
|
22312
22665
|
}
|
|
22313
22666
|
}
|
|
22314
22667
|
}
|
|
22315
22668
|
function canonicalFilePath(value) {
|
|
22316
|
-
const absolute =
|
|
22317
|
-
const parent = canonicalDirectoryPath(
|
|
22318
|
-
return parent ?
|
|
22669
|
+
const absolute = path7.resolve(value);
|
|
22670
|
+
const parent = canonicalDirectoryPath(path7.dirname(absolute));
|
|
22671
|
+
return parent ? path7.join(parent, path7.basename(absolute)) : void 0;
|
|
22319
22672
|
}
|
|
22320
22673
|
function pathIsWithin(root, candidate, allowRoot) {
|
|
22321
|
-
const relative =
|
|
22322
|
-
return allowRoot && relative === "" || relative !== "" && relative !== ".." && !relative.startsWith(`..${
|
|
22674
|
+
const relative = path7.relative(root, candidate);
|
|
22675
|
+
return allowRoot && relative === "" || relative !== "" && relative !== ".." && !relative.startsWith(`..${path7.sep}`) && !path7.isAbsolute(relative);
|
|
22323
22676
|
}
|
|
22324
22677
|
function verifiedOpenCodeWorktree(sessionDirectory, paths) {
|
|
22325
|
-
if (!paths || typeof paths !== "object" || typeof sessionDirectory !== "string" || typeof paths.directory !== "string" || typeof paths.worktree !== "string" || hasDotPathSegment(sessionDirectory) || hasDotPathSegment(paths.directory) || hasDotPathSegment(paths.worktree) || !
|
|
22678
|
+
if (!paths || typeof paths !== "object" || typeof sessionDirectory !== "string" || typeof paths.directory !== "string" || typeof paths.worktree !== "string" || hasDotPathSegment(sessionDirectory) || hasDotPathSegment(paths.directory) || hasDotPathSegment(paths.worktree) || !path7.isAbsolute(sessionDirectory) || !path7.isAbsolute(paths.directory) || !path7.isAbsolute(paths.worktree)) {
|
|
22326
22679
|
return void 0;
|
|
22327
22680
|
}
|
|
22328
22681
|
const session = canonicalDirectoryPath(sessionDirectory);
|
|
@@ -22334,10 +22687,10 @@ function verifiedOpenCodeWorktree(sessionDirectory, paths) {
|
|
|
22334
22687
|
return worktree;
|
|
22335
22688
|
}
|
|
22336
22689
|
function openCodeFileIdentity(file2, worktree) {
|
|
22337
|
-
if (typeof file2 !== "string" || typeof worktree !== "string" || hasDotPathSegment(file2) || hasDotPathSegment(worktree) || !
|
|
22690
|
+
if (typeof file2 !== "string" || typeof worktree !== "string" || hasDotPathSegment(file2) || hasDotPathSegment(worktree) || !path7.isAbsolute(worktree) || !file2 || file2.includes("\0") || file2.includes("\n") || file2.includes("\r")) {
|
|
22338
22691
|
return void 0;
|
|
22339
22692
|
}
|
|
22340
|
-
const candidate = canonicalFilePath(
|
|
22693
|
+
const candidate = canonicalFilePath(path7.isAbsolute(file2) ? file2 : path7.resolve(worktree, file2));
|
|
22341
22694
|
return candidate && pathIsWithin(worktree, candidate, false) ? candidate : void 0;
|
|
22342
22695
|
}
|
|
22343
22696
|
|
|
@@ -22518,6 +22871,11 @@ function semanticHistory(snapshot) {
|
|
|
22518
22871
|
items: turn.items.map(({ item, outcome }) => {
|
|
22519
22872
|
const { itemId: _itemId, ...content } = item;
|
|
22520
22873
|
void _itemId;
|
|
22874
|
+
if (content.type === "fileChange") {
|
|
22875
|
+
const { sourceItemIds: _sourceItemIds, ...change } = content;
|
|
22876
|
+
void _sourceItemIds;
|
|
22877
|
+
return { item: change, outcome };
|
|
22878
|
+
}
|
|
22521
22879
|
return { item: content, outcome };
|
|
22522
22880
|
}),
|
|
22523
22881
|
outcome: turn.outcome,
|
|
@@ -22626,7 +22984,7 @@ function sameCwd(left, right) {
|
|
|
22626
22984
|
try {
|
|
22627
22985
|
return fs4.realpathSync.native(value);
|
|
22628
22986
|
} catch {
|
|
22629
|
-
return
|
|
22987
|
+
return path8.resolve(value);
|
|
22630
22988
|
}
|
|
22631
22989
|
};
|
|
22632
22990
|
return canonical(left) === canonical(right);
|
|
@@ -23980,14 +24338,3059 @@ var OpenCodeAdapter = class {
|
|
|
23980
24338
|
}
|
|
23981
24339
|
};
|
|
23982
24340
|
|
|
23983
|
-
// dist/
|
|
23984
|
-
|
|
23985
|
-
|
|
23986
|
-
|
|
23987
|
-
|
|
23988
|
-
|
|
24341
|
+
// dist/version.js
|
|
24342
|
+
import { execFile as execFile2 } from "node:child_process";
|
|
24343
|
+
import { promisify } from "node:util";
|
|
24344
|
+
function openCodeMajor(version2) {
|
|
24345
|
+
const match = /^(?:opencode\s+)?v?([12])\.\d+\.\d+(?:[-+][\w.-]+)?$/u.exec(version2.trim());
|
|
24346
|
+
if (!match)
|
|
24347
|
+
throw new Error(`Unsupported OpenCode version: ${version2.trim().slice(0, 100)}`);
|
|
24348
|
+
return match[1] === "1" ? 1 : 2;
|
|
24349
|
+
}
|
|
24350
|
+
async function detectOpenCode(options) {
|
|
24351
|
+
const environment = options.environment ?? process.env;
|
|
24352
|
+
const executable = resolveOpenCodeExecutable({
|
|
24353
|
+
...options.command ? { command: options.command } : {},
|
|
23989
24354
|
environment
|
|
23990
24355
|
});
|
|
24356
|
+
const invocation = commandInvocation(executable, ["--version"], environment);
|
|
24357
|
+
const { stdout } = await promisify(execFile2)(invocation.command, invocation.arguments, {
|
|
24358
|
+
env: environment,
|
|
24359
|
+
timeout: options.startupTimeoutMs ?? 2e4,
|
|
24360
|
+
maxBuffer: 16384,
|
|
24361
|
+
windowsHide: true,
|
|
24362
|
+
windowsVerbatimArguments: invocation.windowsVerbatimArguments
|
|
24363
|
+
});
|
|
24364
|
+
return { executable, major: openCodeMajor(stdout) };
|
|
24365
|
+
}
|
|
24366
|
+
|
|
24367
|
+
// dist/v2/adapter.js
|
|
24368
|
+
import fs6 from "node:fs";
|
|
24369
|
+
import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
|
|
24370
|
+
|
|
24371
|
+
// dist/v2/state.js
|
|
24372
|
+
import fs5 from "node:fs";
|
|
24373
|
+
import path9 from "node:path";
|
|
24374
|
+
var harnessId = harnessIdSchema.parse("opencode");
|
|
24375
|
+
function failure(message, code = "nativeFailure") {
|
|
24376
|
+
return {
|
|
24377
|
+
code,
|
|
24378
|
+
message,
|
|
24379
|
+
retryable: ["nativeFailure", "unavailable", "sessionBusy"].includes(code)
|
|
24380
|
+
};
|
|
24381
|
+
}
|
|
24382
|
+
function errorResult(error51) {
|
|
24383
|
+
return {
|
|
24384
|
+
ok: false,
|
|
24385
|
+
error: failure(error51 instanceof Error ? error51.message : String(error51))
|
|
24386
|
+
};
|
|
24387
|
+
}
|
|
24388
|
+
function sameDirectory(left, right) {
|
|
24389
|
+
const canonical = (value) => {
|
|
24390
|
+
try {
|
|
24391
|
+
return fs5.realpathSync(value);
|
|
24392
|
+
} catch {
|
|
24393
|
+
return path9.resolve(value);
|
|
24394
|
+
}
|
|
24395
|
+
};
|
|
24396
|
+
return canonical(left) === canonical(right);
|
|
24397
|
+
}
|
|
24398
|
+
function v2Ref(session, executionPolicy) {
|
|
24399
|
+
return nativeSessionRefSchema.parse({
|
|
24400
|
+
harnessId,
|
|
24401
|
+
nativeSessionId: session.id,
|
|
24402
|
+
formatVersion: 1,
|
|
24403
|
+
locator: { protocol: 2, directory: session.location.directory, executionPolicy }
|
|
24404
|
+
});
|
|
24405
|
+
}
|
|
24406
|
+
function v2Locator(ref) {
|
|
24407
|
+
nativeSessionRefSchema.parse(ref);
|
|
24408
|
+
const locator = ref.locator;
|
|
24409
|
+
if (ref.harnessId !== harnessId || !locator || typeof locator !== "object" || Array.isArray(locator) || locator.protocol !== 2 || typeof locator.directory !== "string" || !locator.directory || locator.executionPolicy !== "default" && locator.executionPolicy !== "unattended-full-access") {
|
|
24410
|
+
throw new Error("This Session requires an OpenCode v2 Native Ref; v1 histories are not migrated by codexhost");
|
|
24411
|
+
}
|
|
24412
|
+
return { directory: locator.directory, executionPolicy: locator.executionPolicy };
|
|
24413
|
+
}
|
|
24414
|
+
function v2Catalog(models, defaultModel) {
|
|
24415
|
+
const enabled = models.filter((model) => model.enabled);
|
|
24416
|
+
const variants = [...new Set(enabled.flatMap((model) => model.variants.map((v) => v.id)))].sort();
|
|
24417
|
+
const ref = (model) => encodeOpenCodeModelRef({ providerID: model.providerID, modelID: model.id });
|
|
24418
|
+
return harnessModelCatalogSchema.parse({
|
|
24419
|
+
models: enabled.map((model) => ({
|
|
24420
|
+
ref: ref(model),
|
|
24421
|
+
label: `${model.providerID} / ${model.name}`,
|
|
24422
|
+
resolvedModelLabel: `${model.providerID}/${model.id}`,
|
|
24423
|
+
supportedThinkingOptionIds: [
|
|
24424
|
+
encodeOpenCodeVariant(void 0),
|
|
24425
|
+
...model.variants.map((v) => encodeOpenCodeVariant(v.id))
|
|
24426
|
+
]
|
|
24427
|
+
})),
|
|
24428
|
+
...defaultModel && enabled.some((m) => ref(m).id === ref(defaultModel).id) ? { defaultModel: ref(defaultModel) } : {},
|
|
24429
|
+
thinkingOptions: [void 0, ...variants].map((v) => ({
|
|
24430
|
+
id: encodeOpenCodeVariant(v),
|
|
24431
|
+
label: v ?? "Default"
|
|
24432
|
+
})),
|
|
24433
|
+
defaultThinkingOptionId: encodeOpenCodeVariant(void 0)
|
|
24434
|
+
});
|
|
24435
|
+
}
|
|
24436
|
+
function v2Permissions(current = [], mode) {
|
|
24437
|
+
const selected = decodeOpenCodePermissionModeId(mode);
|
|
24438
|
+
const rules = current.filter((rule) => !(rule.action === "*" && rule.resource === "*" && ["allow", "ask"].includes(rule.effect)));
|
|
24439
|
+
return selected === "default" ? rules : [...rules, { action: "*", resource: "*", effect: selected }];
|
|
24440
|
+
}
|
|
24441
|
+
function v2State(session, catalog, policy) {
|
|
24442
|
+
const model = session.model ? encodeOpenCodeModelRef({ providerID: session.model.providerID, modelID: session.model.id }) : void 0;
|
|
24443
|
+
const entry = catalog.models.find((candidate) => candidate.ref.id === model?.id);
|
|
24444
|
+
const mode = session.permissions?.findLast((rule) => rule.action === "*" && rule.resource === "*");
|
|
24445
|
+
return {
|
|
24446
|
+
nativeRef: v2Ref(session, policy),
|
|
24447
|
+
...model ? { effectiveModel: model } : {},
|
|
24448
|
+
...entry ? {
|
|
24449
|
+
resolvedModelLabel: entry.resolvedModelLabel ?? entry.label,
|
|
24450
|
+
availableThinkingOptions: catalog.thinkingOptions.filter((v) => entry.supportedThinkingOptionIds?.includes(v.id)),
|
|
24451
|
+
effectiveThinkingOptionId: encodeOpenCodeVariant(session.model?.variant)
|
|
24452
|
+
} : {},
|
|
24453
|
+
effectivePermissionModeId: decodeMode(mode?.effect)
|
|
24454
|
+
};
|
|
24455
|
+
}
|
|
24456
|
+
function decodeMode(effect) {
|
|
24457
|
+
return effect === "allow" || effect === "ask" ? harnessPermissionModeIdSchema.parse(effect) : harnessPermissionModeIdSchema.parse("default");
|
|
24458
|
+
}
|
|
24459
|
+
function v2Usage(session) {
|
|
24460
|
+
const tokens = session.tokens;
|
|
24461
|
+
return parseHostUsage({
|
|
24462
|
+
inputTokens: tokens.input,
|
|
24463
|
+
outputTokens: tokens.output,
|
|
24464
|
+
reasoningOutputTokens: tokens.reasoning,
|
|
24465
|
+
cachedInputTokens: tokens.cache.read,
|
|
24466
|
+
cacheWriteInputTokens: tokens.cache.write,
|
|
24467
|
+
totalCostUsd: session.cost
|
|
24468
|
+
});
|
|
24469
|
+
}
|
|
24470
|
+
|
|
24471
|
+
// dist/v2/catalog.js
|
|
24472
|
+
async function readCatalog(client2, cwd, timeoutMs) {
|
|
24473
|
+
const location = { directory: cwd };
|
|
24474
|
+
const deadline = Date.now() + timeoutMs;
|
|
24475
|
+
const required2 = ["opencode.config.provider", "opencode.config.agent", "opencode.config.policy"];
|
|
24476
|
+
while (true) {
|
|
24477
|
+
const { data: plugins } = await client2.plugin.list({ location });
|
|
24478
|
+
const config2 = required2.map((id) => plugins.find((plugin) => plugin.id === id));
|
|
24479
|
+
const failed = config2.find((plugin) => plugin?.state.status === "failed");
|
|
24480
|
+
if (failed?.state.status === "failed")
|
|
24481
|
+
throw new Error(`OpenCode configuration failed: ${failed.state.error}`);
|
|
24482
|
+
if (config2.every((plugin) => plugin?.state.status === "active"))
|
|
24483
|
+
break;
|
|
24484
|
+
if (Date.now() >= deadline)
|
|
24485
|
+
throw new Error("OpenCode v2 configuration plugins did not become ready");
|
|
24486
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
24487
|
+
}
|
|
24488
|
+
const [models, selected] = await Promise.all([
|
|
24489
|
+
client2.model.list({ location }),
|
|
24490
|
+
client2.model.default({ location })
|
|
24491
|
+
]);
|
|
24492
|
+
return v2Catalog(models.data, selected.data);
|
|
24493
|
+
}
|
|
24494
|
+
|
|
24495
|
+
// dist/v2/connection.js
|
|
24496
|
+
import { spawn as spawn2, spawnSync as spawnSync2 } from "node:child_process";
|
|
24497
|
+
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
24498
|
+
|
|
24499
|
+
// ../../../node_modules/@opencode/client/dist/chunks/service-timing-9rqn6x4v.js
|
|
24500
|
+
var __defProp2 = Object.defineProperty;
|
|
24501
|
+
var __returnValue = (v) => v;
|
|
24502
|
+
function __exportSetter(name, newValue) {
|
|
24503
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
24504
|
+
}
|
|
24505
|
+
var __export2 = (target, all) => {
|
|
24506
|
+
for (var name in all)
|
|
24507
|
+
__defProp2(target, name, {
|
|
24508
|
+
get: all[name],
|
|
24509
|
+
enumerable: true,
|
|
24510
|
+
configurable: true,
|
|
24511
|
+
set: __exportSetter.bind(all, name)
|
|
24512
|
+
});
|
|
24513
|
+
};
|
|
24514
|
+
|
|
24515
|
+
// ../../../node_modules/@opencode/client/dist/chunks/service-timing-frbwqjmf.js
|
|
24516
|
+
var exports_shared_events = {};
|
|
24517
|
+
__export2(exports_shared_events, {
|
|
24518
|
+
SharedEvents: () => exports_shared_events,
|
|
24519
|
+
make: () => make7
|
|
24520
|
+
});
|
|
24521
|
+
function make7(connect) {
|
|
24522
|
+
let current;
|
|
24523
|
+
const capacity = 4096;
|
|
24524
|
+
function stop(connection) {
|
|
24525
|
+
connection.connected = void 0;
|
|
24526
|
+
connection.controller.abort();
|
|
24527
|
+
if (current === connection)
|
|
24528
|
+
current = void 0;
|
|
24529
|
+
}
|
|
24530
|
+
async function run(connection) {
|
|
24531
|
+
let iterator;
|
|
24532
|
+
let completion = {};
|
|
24533
|
+
try {
|
|
24534
|
+
if (connection.controller.signal.aborted)
|
|
24535
|
+
return;
|
|
24536
|
+
iterator = connect(connection.controller.signal, () => {
|
|
24537
|
+
connection.subscribers.forEach((subscriber) => subscriber.activity?.());
|
|
24538
|
+
})[Symbol.asyncIterator]();
|
|
24539
|
+
while (!connection.controller.signal.aborted) {
|
|
24540
|
+
const item = await iterator.next();
|
|
24541
|
+
if (item.done || connection.controller.signal.aborted)
|
|
24542
|
+
break;
|
|
24543
|
+
if (item.value.type === "server.connected")
|
|
24544
|
+
connection.connected = item.value;
|
|
24545
|
+
connection.subscribers.forEach((subscriber) => subscriber.push(item.value));
|
|
24546
|
+
}
|
|
24547
|
+
} catch (error51) {
|
|
24548
|
+
completion = { error: error51 };
|
|
24549
|
+
} finally {
|
|
24550
|
+
stop(connection);
|
|
24551
|
+
try {
|
|
24552
|
+
await iterator?.return?.();
|
|
24553
|
+
} catch (error51) {
|
|
24554
|
+
if (!("error" in completion))
|
|
24555
|
+
completion = { error: error51 };
|
|
24556
|
+
}
|
|
24557
|
+
connection.subscribers.forEach((subscriber) => subscriber.finish(completion));
|
|
24558
|
+
}
|
|
24559
|
+
}
|
|
24560
|
+
return {
|
|
24561
|
+
subscribe(options) {
|
|
24562
|
+
return {
|
|
24563
|
+
[Symbol.asyncIterator]() {
|
|
24564
|
+
const pending = [];
|
|
24565
|
+
const queued = [];
|
|
24566
|
+
let started = false;
|
|
24567
|
+
let completion;
|
|
24568
|
+
let connection;
|
|
24569
|
+
function finish(result, discard = true) {
|
|
24570
|
+
completion = result;
|
|
24571
|
+
if (discard)
|
|
24572
|
+
queued.length = 0;
|
|
24573
|
+
options?.signal?.removeEventListener("abort", abort);
|
|
24574
|
+
if (connection?.subscribers.delete(subscriber) && !connection.subscribers.size)
|
|
24575
|
+
stop(connection);
|
|
24576
|
+
pending.splice(0).forEach((request) => {
|
|
24577
|
+
if ("error" in result)
|
|
24578
|
+
request.reject(result.error);
|
|
24579
|
+
else
|
|
24580
|
+
request.resolve({ done: true, value: void 0 });
|
|
24581
|
+
});
|
|
24582
|
+
}
|
|
24583
|
+
function abort() {
|
|
24584
|
+
finish({});
|
|
24585
|
+
}
|
|
24586
|
+
const subscriber = {
|
|
24587
|
+
activity: options?.onActivity,
|
|
24588
|
+
finish(result) {
|
|
24589
|
+
finish(result, false);
|
|
24590
|
+
},
|
|
24591
|
+
push(value) {
|
|
24592
|
+
if (completion)
|
|
24593
|
+
return;
|
|
24594
|
+
const request = pending.shift();
|
|
24595
|
+
if (request) {
|
|
24596
|
+
request.resolve({ done: false, value });
|
|
24597
|
+
return;
|
|
24598
|
+
}
|
|
24599
|
+
if (queued.length === capacity) {
|
|
24600
|
+
finish({ error: new Error(`Event subscriber exceeded its ${capacity}-event capacity`) });
|
|
24601
|
+
return;
|
|
24602
|
+
}
|
|
24603
|
+
queued.push(value);
|
|
24604
|
+
}
|
|
24605
|
+
};
|
|
24606
|
+
function start() {
|
|
24607
|
+
if (completion)
|
|
24608
|
+
return;
|
|
24609
|
+
const fresh = !current;
|
|
24610
|
+
connection = current ?? {
|
|
24611
|
+
controller: new AbortController(),
|
|
24612
|
+
subscribers: /* @__PURE__ */ new Set()
|
|
24613
|
+
};
|
|
24614
|
+
current = connection;
|
|
24615
|
+
connection.subscribers.add(subscriber);
|
|
24616
|
+
if (connection.connected)
|
|
24617
|
+
subscriber.push(connection.connected);
|
|
24618
|
+
if (fresh)
|
|
24619
|
+
run(connection);
|
|
24620
|
+
}
|
|
24621
|
+
return {
|
|
24622
|
+
next() {
|
|
24623
|
+
const value = queued.shift();
|
|
24624
|
+
if (value)
|
|
24625
|
+
return Promise.resolve({ done: false, value });
|
|
24626
|
+
if (completion) {
|
|
24627
|
+
if ("error" in completion)
|
|
24628
|
+
return Promise.reject(completion.error);
|
|
24629
|
+
return Promise.resolve({ done: true, value: void 0 });
|
|
24630
|
+
}
|
|
24631
|
+
if (options?.signal?.aborted) {
|
|
24632
|
+
abort();
|
|
24633
|
+
return Promise.resolve({ done: true, value: void 0 });
|
|
24634
|
+
}
|
|
24635
|
+
const request = Promise.withResolvers();
|
|
24636
|
+
pending.push(request);
|
|
24637
|
+
if (!started) {
|
|
24638
|
+
started = true;
|
|
24639
|
+
options?.signal?.addEventListener("abort", abort, { once: true });
|
|
24640
|
+
start();
|
|
24641
|
+
}
|
|
24642
|
+
return request.promise;
|
|
24643
|
+
},
|
|
24644
|
+
return() {
|
|
24645
|
+
finish({});
|
|
24646
|
+
return Promise.resolve({ done: true, value: void 0 });
|
|
24647
|
+
}
|
|
24648
|
+
};
|
|
24649
|
+
}
|
|
24650
|
+
};
|
|
24651
|
+
}
|
|
24652
|
+
};
|
|
24653
|
+
}
|
|
24654
|
+
|
|
24655
|
+
// ../../../node_modules/@opencode/client/dist/chunks/service-timing-nwcpakzx.js
|
|
24656
|
+
var ClientError3 = class extends Error {
|
|
24657
|
+
reason;
|
|
24658
|
+
name = "ClientError";
|
|
24659
|
+
constructor(reason, options) {
|
|
24660
|
+
const detail = options?.detail ?? (options?.cause instanceof Error ? options.cause.message : void 0);
|
|
24661
|
+
super(detail ? `${reason}: ${detail}` : reason, options);
|
|
24662
|
+
this.reason = reason;
|
|
24663
|
+
}
|
|
24664
|
+
};
|
|
24665
|
+
|
|
24666
|
+
// ../../../node_modules/@opencode/client/dist/chunks/service-timing-bpdjd9xk.js
|
|
24667
|
+
var exports_client4 = {};
|
|
24668
|
+
__export2(exports_client4, {
|
|
24669
|
+
make: () => make6
|
|
24670
|
+
});
|
|
24671
|
+
var maxSseEventBytes = 16 * 1024 * 1024;
|
|
24672
|
+
function make6(options) {
|
|
24673
|
+
const fetch2 = options.fetch ?? globalThis.fetch;
|
|
24674
|
+
const prepare = (descriptor, requestOptions) => {
|
|
24675
|
+
const baseUrl = new URL(options.baseUrl);
|
|
24676
|
+
if (!baseUrl.pathname.endsWith("/"))
|
|
24677
|
+
baseUrl.pathname += "/";
|
|
24678
|
+
const url2 = new URL(descriptor.path.slice(1), baseUrl);
|
|
24679
|
+
for (const [key, value] of Object.entries(descriptor.query ?? {}))
|
|
24680
|
+
appendQuery(url2.searchParams, key, value);
|
|
24681
|
+
const headers = new Headers(options.headers);
|
|
24682
|
+
for (const [key, value] of Object.entries(descriptor.headers ?? {})) {
|
|
24683
|
+
if (value !== void 0 && value !== null)
|
|
24684
|
+
headers.set(key, String(value));
|
|
24685
|
+
}
|
|
24686
|
+
for (const [key, value] of new Headers(requestOptions?.headers))
|
|
24687
|
+
headers.set(key, value);
|
|
24688
|
+
if (descriptor.body !== void 0 && !headers.has("content-type"))
|
|
24689
|
+
headers.set("content-type", descriptor.binaryBody ? "application/octet-stream" : "application/json");
|
|
24690
|
+
return {
|
|
24691
|
+
url: url2,
|
|
24692
|
+
init: {
|
|
24693
|
+
method: descriptor.method,
|
|
24694
|
+
signal: requestOptions?.signal,
|
|
24695
|
+
headers,
|
|
24696
|
+
body: descriptor.body === void 0 ? void 0 : descriptor.binaryBody ? descriptor.body : JSON.stringify(descriptor.body)
|
|
24697
|
+
}
|
|
24698
|
+
};
|
|
24699
|
+
};
|
|
24700
|
+
const execute = async (descriptor, requestOptions) => {
|
|
24701
|
+
try {
|
|
24702
|
+
const prepared = prepare(descriptor, requestOptions);
|
|
24703
|
+
return await fetch2(prepared.url, prepared.init);
|
|
24704
|
+
} catch (cause) {
|
|
24705
|
+
throw new ClientError3("Transport", { cause });
|
|
24706
|
+
}
|
|
24707
|
+
};
|
|
24708
|
+
const responseError = async (response, descriptor) => {
|
|
24709
|
+
if (descriptor.declaredStatuses.includes(response.status))
|
|
24710
|
+
throw declared(await json2(response));
|
|
24711
|
+
try {
|
|
24712
|
+
await response.body?.cancel();
|
|
24713
|
+
} catch {
|
|
24714
|
+
}
|
|
24715
|
+
throw new ClientError3("UnexpectedStatus", { cause: { status: response.status }, detail: String(response.status) });
|
|
24716
|
+
};
|
|
24717
|
+
const request = async (descriptor, requestOptions) => {
|
|
24718
|
+
const response = await execute(descriptor, requestOptions);
|
|
24719
|
+
if (response.status !== descriptor.successStatus)
|
|
24720
|
+
return responseError(response, descriptor);
|
|
24721
|
+
if (descriptor.binary)
|
|
24722
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
24723
|
+
if (descriptor.empty) {
|
|
24724
|
+
try {
|
|
24725
|
+
await response.body?.cancel();
|
|
24726
|
+
} catch {
|
|
24727
|
+
}
|
|
24728
|
+
return;
|
|
24729
|
+
}
|
|
24730
|
+
return await json2(response);
|
|
24731
|
+
};
|
|
24732
|
+
const sse = (descriptor, requestOptions) => ({
|
|
24733
|
+
async *[Symbol.asyncIterator]() {
|
|
24734
|
+
const response = await execute(descriptor, requestOptions);
|
|
24735
|
+
if (response.status !== descriptor.successStatus)
|
|
24736
|
+
await responseError(response, descriptor);
|
|
24737
|
+
if (!isContentType(response, "text/event-stream")) {
|
|
24738
|
+
try {
|
|
24739
|
+
await response.body?.cancel();
|
|
24740
|
+
} catch {
|
|
24741
|
+
}
|
|
24742
|
+
throw new ClientError3("UnsupportedContentType", { detail: response.headers.get("content-type") });
|
|
24743
|
+
}
|
|
24744
|
+
if (response.body === null)
|
|
24745
|
+
throw new ClientError3("MalformedResponse");
|
|
24746
|
+
const reader = response.body.getReader();
|
|
24747
|
+
const decoder = new TextDecoder();
|
|
24748
|
+
let buffer = "";
|
|
24749
|
+
try {
|
|
24750
|
+
while (true) {
|
|
24751
|
+
let next;
|
|
24752
|
+
try {
|
|
24753
|
+
next = await reader.read();
|
|
24754
|
+
} catch (cause) {
|
|
24755
|
+
throw new ClientError3("Transport", { cause });
|
|
24756
|
+
}
|
|
24757
|
+
if (!next.done)
|
|
24758
|
+
requestOptions?.onActivity?.();
|
|
24759
|
+
buffer += decoder.decode(next.value, { stream: !next.done });
|
|
24760
|
+
if (buffer.length > maxSseEventBytes)
|
|
24761
|
+
throw new ClientError3("SseEventTooLarge");
|
|
24762
|
+
const trailingCarriageReturn = !next.done && buffer.endsWith("\r");
|
|
24763
|
+
if (trailingCarriageReturn)
|
|
24764
|
+
buffer = buffer.slice(0, -1);
|
|
24765
|
+
buffer = buffer.replaceAll(`\r
|
|
24766
|
+
`, `
|
|
24767
|
+
`).replaceAll("\r", `
|
|
24768
|
+
`);
|
|
24769
|
+
if (trailingCarriageReturn)
|
|
24770
|
+
buffer += "\r";
|
|
24771
|
+
if (next.done && buffer !== "")
|
|
24772
|
+
buffer += `
|
|
24773
|
+
|
|
24774
|
+
`;
|
|
24775
|
+
let boundary = buffer.indexOf(`
|
|
24776
|
+
|
|
24777
|
+
`);
|
|
24778
|
+
while (boundary >= 0) {
|
|
24779
|
+
const block = buffer.slice(0, boundary);
|
|
24780
|
+
buffer = buffer.slice(boundary + 2);
|
|
24781
|
+
const data = block.split(`
|
|
24782
|
+
`).flatMap((line) => line.startsWith("data:") ? [line.slice(5).trimStart()] : []).join(`
|
|
24783
|
+
`);
|
|
24784
|
+
if (data !== "") {
|
|
24785
|
+
try {
|
|
24786
|
+
yield JSON.parse(data);
|
|
24787
|
+
} catch (cause) {
|
|
24788
|
+
throw new ClientError3("MalformedResponse", { cause });
|
|
24789
|
+
}
|
|
24790
|
+
}
|
|
24791
|
+
boundary = buffer.indexOf(`
|
|
24792
|
+
|
|
24793
|
+
`);
|
|
24794
|
+
}
|
|
24795
|
+
if (next.done)
|
|
24796
|
+
return;
|
|
24797
|
+
}
|
|
24798
|
+
} finally {
|
|
24799
|
+
try {
|
|
24800
|
+
await reader.cancel();
|
|
24801
|
+
} catch {
|
|
24802
|
+
}
|
|
24803
|
+
reader.releaseLock();
|
|
24804
|
+
}
|
|
24805
|
+
}
|
|
24806
|
+
});
|
|
24807
|
+
return {
|
|
24808
|
+
server: {
|
|
24809
|
+
info: (requestOptions) => request({ method: "GET", path: `/api/info`, successStatus: 200, declaredStatuses: [400, 401], empty: false }, requestOptions)
|
|
24810
|
+
},
|
|
24811
|
+
location: {
|
|
24812
|
+
get: (input, requestOptions) => request({
|
|
24813
|
+
method: "GET",
|
|
24814
|
+
path: `/api/location`,
|
|
24815
|
+
query: { location: input?.["location"] },
|
|
24816
|
+
successStatus: 200,
|
|
24817
|
+
declaredStatuses: [400, 401],
|
|
24818
|
+
empty: false
|
|
24819
|
+
}, requestOptions),
|
|
24820
|
+
reload: (requestOptions) => request({
|
|
24821
|
+
method: "POST",
|
|
24822
|
+
path: `/api/location/reload`,
|
|
24823
|
+
successStatus: 204,
|
|
24824
|
+
declaredStatuses: [400, 401, 503],
|
|
24825
|
+
empty: true
|
|
24826
|
+
}, requestOptions)
|
|
24827
|
+
},
|
|
24828
|
+
agent: {
|
|
24829
|
+
list: (input, requestOptions) => request({
|
|
24830
|
+
method: "GET",
|
|
24831
|
+
path: `/api/agent`,
|
|
24832
|
+
query: { location: input?.["location"] },
|
|
24833
|
+
successStatus: 200,
|
|
24834
|
+
declaredStatuses: [400, 401],
|
|
24835
|
+
empty: false
|
|
24836
|
+
}, requestOptions),
|
|
24837
|
+
get: (input, requestOptions) => request({
|
|
24838
|
+
method: "GET",
|
|
24839
|
+
path: `/api/agent/${encodeURIComponent(input.agentID)}`,
|
|
24840
|
+
query: { location: input["location"] },
|
|
24841
|
+
successStatus: 200,
|
|
24842
|
+
declaredStatuses: [400, 401, 404],
|
|
24843
|
+
empty: false
|
|
24844
|
+
}, requestOptions)
|
|
24845
|
+
},
|
|
24846
|
+
plugin: {
|
|
24847
|
+
list: (input, requestOptions) => request({
|
|
24848
|
+
method: "GET",
|
|
24849
|
+
path: `/api/plugin`,
|
|
24850
|
+
query: { location: input?.["location"] },
|
|
24851
|
+
successStatus: 200,
|
|
24852
|
+
declaredStatuses: [400, 401],
|
|
24853
|
+
empty: false
|
|
24854
|
+
}, requestOptions),
|
|
24855
|
+
check: (input, requestOptions) => request({
|
|
24856
|
+
method: "POST",
|
|
24857
|
+
path: `/api/plugin/check`,
|
|
24858
|
+
query: { location: input?.["location"] },
|
|
24859
|
+
body: { target: input?.["target"] },
|
|
24860
|
+
successStatus: 200,
|
|
24861
|
+
declaredStatuses: [400, 401],
|
|
24862
|
+
empty: false
|
|
24863
|
+
}, requestOptions),
|
|
24864
|
+
update: (input, requestOptions) => request({
|
|
24865
|
+
method: "POST",
|
|
24866
|
+
path: `/api/plugin/update`,
|
|
24867
|
+
query: { location: input["location"] },
|
|
24868
|
+
body: { targets: input["targets"] },
|
|
24869
|
+
successStatus: 204,
|
|
24870
|
+
declaredStatuses: [400, 401, 503],
|
|
24871
|
+
empty: true
|
|
24872
|
+
}, requestOptions)
|
|
24873
|
+
},
|
|
24874
|
+
session: {
|
|
24875
|
+
list: (input, requestOptions) => request({
|
|
24876
|
+
method: "GET",
|
|
24877
|
+
path: `/api/session`,
|
|
24878
|
+
query: {
|
|
24879
|
+
limit: input?.["limit"],
|
|
24880
|
+
order: input?.["order"],
|
|
24881
|
+
search: input?.["search"],
|
|
24882
|
+
parentID: input?.["parentID"],
|
|
24883
|
+
directory: input?.["directory"],
|
|
24884
|
+
project: input?.["project"],
|
|
24885
|
+
subpath: input?.["subpath"],
|
|
24886
|
+
cursor: input?.["cursor"]
|
|
24887
|
+
},
|
|
24888
|
+
successStatus: 200,
|
|
24889
|
+
declaredStatuses: [400, 401],
|
|
24890
|
+
empty: false
|
|
24891
|
+
}, requestOptions),
|
|
24892
|
+
stats: (input, requestOptions) => request({
|
|
24893
|
+
method: "GET",
|
|
24894
|
+
path: `/api/experimental/session/stats`,
|
|
24895
|
+
query: {
|
|
24896
|
+
from: input?.["from"],
|
|
24897
|
+
to: input?.["to"],
|
|
24898
|
+
project: input?.["project"],
|
|
24899
|
+
timezone: input?.["timezone"],
|
|
24900
|
+
tools: input?.["tools"]
|
|
24901
|
+
},
|
|
24902
|
+
successStatus: 200,
|
|
24903
|
+
declaredStatuses: [400, 401],
|
|
24904
|
+
empty: false
|
|
24905
|
+
}, requestOptions).then((value) => value.data),
|
|
24906
|
+
create: (input, requestOptions) => request({
|
|
24907
|
+
method: "POST",
|
|
24908
|
+
path: `/api/session`,
|
|
24909
|
+
body: {
|
|
24910
|
+
id: input?.["id"],
|
|
24911
|
+
title: input?.["title"],
|
|
24912
|
+
agent: input?.["agent"],
|
|
24913
|
+
model: input?.["model"],
|
|
24914
|
+
location: input?.["location"],
|
|
24915
|
+
metadata: input?.["metadata"],
|
|
24916
|
+
permissions: input?.["permissions"]
|
|
24917
|
+
},
|
|
24918
|
+
successStatus: 200,
|
|
24919
|
+
declaredStatuses: [400, 401],
|
|
24920
|
+
empty: false
|
|
24921
|
+
}, requestOptions).then((value) => value.data),
|
|
24922
|
+
import: (input, requestOptions) => request({
|
|
24923
|
+
method: "POST",
|
|
24924
|
+
path: `/api/experimental/session/import`,
|
|
24925
|
+
body: { info: input["info"], messages: input["messages"], location: input["location"] },
|
|
24926
|
+
successStatus: 200,
|
|
24927
|
+
declaredStatuses: [400, 401, 404, 409],
|
|
24928
|
+
empty: false
|
|
24929
|
+
}, requestOptions).then((value) => value.data),
|
|
24930
|
+
export: (input, requestOptions) => request({
|
|
24931
|
+
method: "GET",
|
|
24932
|
+
path: `/api/experimental/session/${encodeURIComponent(input.sessionID)}/export`,
|
|
24933
|
+
query: { sanitize: input["sanitize"] },
|
|
24934
|
+
successStatus: 200,
|
|
24935
|
+
declaredStatuses: [400, 401, 404, 500],
|
|
24936
|
+
empty: false
|
|
24937
|
+
}, requestOptions).then((value) => value.data),
|
|
24938
|
+
active: (requestOptions) => request({
|
|
24939
|
+
method: "GET",
|
|
24940
|
+
path: `/api/session/active`,
|
|
24941
|
+
successStatus: 200,
|
|
24942
|
+
declaredStatuses: [400, 401],
|
|
24943
|
+
empty: false
|
|
24944
|
+
}, requestOptions).then((value) => value.data),
|
|
24945
|
+
get: (input, requestOptions) => request({
|
|
24946
|
+
method: "GET",
|
|
24947
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}`,
|
|
24948
|
+
successStatus: 200,
|
|
24949
|
+
declaredStatuses: [400, 401, 404],
|
|
24950
|
+
empty: false
|
|
24951
|
+
}, requestOptions).then((value) => value.data),
|
|
24952
|
+
remove: (input, requestOptions) => request({
|
|
24953
|
+
method: "DELETE",
|
|
24954
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}`,
|
|
24955
|
+
successStatus: 204,
|
|
24956
|
+
declaredStatuses: [400, 401, 404],
|
|
24957
|
+
empty: true
|
|
24958
|
+
}, requestOptions),
|
|
24959
|
+
fork: (input, requestOptions) => request({
|
|
24960
|
+
method: "POST",
|
|
24961
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/fork`,
|
|
24962
|
+
body: { before: input["before"] },
|
|
24963
|
+
successStatus: 200,
|
|
24964
|
+
declaredStatuses: [400, 401, 404],
|
|
24965
|
+
empty: false
|
|
24966
|
+
}, requestOptions).then((value) => value.data),
|
|
24967
|
+
switchAgent: (input, requestOptions) => request({
|
|
24968
|
+
method: "POST",
|
|
24969
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/agent`,
|
|
24970
|
+
body: { agent: input["agent"] },
|
|
24971
|
+
successStatus: 204,
|
|
24972
|
+
declaredStatuses: [400, 401, 404],
|
|
24973
|
+
empty: true
|
|
24974
|
+
}, requestOptions),
|
|
24975
|
+
switchModel: (input, requestOptions) => request({
|
|
24976
|
+
method: "POST",
|
|
24977
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/model`,
|
|
24978
|
+
body: { model: input["model"] },
|
|
24979
|
+
successStatus: 204,
|
|
24980
|
+
declaredStatuses: [400, 401, 404],
|
|
24981
|
+
empty: true
|
|
24982
|
+
}, requestOptions),
|
|
24983
|
+
update: (input, requestOptions) => request({
|
|
24984
|
+
method: "PATCH",
|
|
24985
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}`,
|
|
24986
|
+
body: { title: input["title"], metadata: input["metadata"], permissions: input["permissions"] },
|
|
24987
|
+
successStatus: 204,
|
|
24988
|
+
declaredStatuses: [400, 401, 404],
|
|
24989
|
+
empty: true
|
|
24990
|
+
}, requestOptions),
|
|
24991
|
+
move: (input, requestOptions) => request({
|
|
24992
|
+
method: "POST",
|
|
24993
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/move`,
|
|
24994
|
+
body: { directory: input["directory"], delivery: input["delivery"] },
|
|
24995
|
+
successStatus: 204,
|
|
24996
|
+
declaredStatuses: [400, 401, 404],
|
|
24997
|
+
empty: true
|
|
24998
|
+
}, requestOptions),
|
|
24999
|
+
prompt: (input, requestOptions) => request({
|
|
25000
|
+
method: "POST",
|
|
25001
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/prompt`,
|
|
25002
|
+
body: {
|
|
25003
|
+
id: input["id"],
|
|
25004
|
+
text: input["text"],
|
|
25005
|
+
files: input["files"],
|
|
25006
|
+
agents: input["agents"],
|
|
25007
|
+
skills: input["skills"],
|
|
25008
|
+
metadata: input["metadata"],
|
|
25009
|
+
delivery: input["delivery"],
|
|
25010
|
+
resume: input["resume"]
|
|
25011
|
+
},
|
|
25012
|
+
successStatus: 200,
|
|
25013
|
+
declaredStatuses: [400, 401, 404, 409],
|
|
25014
|
+
empty: false
|
|
25015
|
+
}, requestOptions).then((value) => value.data),
|
|
25016
|
+
command: (input, requestOptions) => request({
|
|
25017
|
+
method: "POST",
|
|
25018
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/command`,
|
|
25019
|
+
body: {
|
|
25020
|
+
name: input["name"],
|
|
25021
|
+
text: input["text"],
|
|
25022
|
+
files: input["files"],
|
|
25023
|
+
agents: input["agents"],
|
|
25024
|
+
skills: input["skills"],
|
|
25025
|
+
delivery: input["delivery"]
|
|
25026
|
+
},
|
|
25027
|
+
successStatus: 204,
|
|
25028
|
+
declaredStatuses: [400, 401, 404, 500],
|
|
25029
|
+
empty: true
|
|
25030
|
+
}, requestOptions),
|
|
25031
|
+
skill: (input, requestOptions) => request({
|
|
25032
|
+
method: "POST",
|
|
25033
|
+
path: `/api/experimental/session/${encodeURIComponent(input.sessionID)}/skill`,
|
|
25034
|
+
body: { id: input["id"], resume: input["resume"] },
|
|
25035
|
+
successStatus: 204,
|
|
25036
|
+
declaredStatuses: [400, 401, 404],
|
|
25037
|
+
empty: true
|
|
25038
|
+
}, requestOptions),
|
|
25039
|
+
synthetic: (input, requestOptions) => request({
|
|
25040
|
+
method: "POST",
|
|
25041
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/synthetic`,
|
|
25042
|
+
body: {
|
|
25043
|
+
id: input["id"],
|
|
25044
|
+
text: input["text"],
|
|
25045
|
+
description: input["description"],
|
|
25046
|
+
metadata: input["metadata"],
|
|
25047
|
+
delivery: input["delivery"],
|
|
25048
|
+
resume: input["resume"]
|
|
25049
|
+
},
|
|
25050
|
+
successStatus: 200,
|
|
25051
|
+
declaredStatuses: [400, 401, 404, 409],
|
|
25052
|
+
empty: false
|
|
25053
|
+
}, requestOptions).then((value) => value.data),
|
|
25054
|
+
shell: (input, requestOptions) => request({
|
|
25055
|
+
method: "POST",
|
|
25056
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/shell`,
|
|
25057
|
+
body: { id: input["id"], command: input["command"] },
|
|
25058
|
+
successStatus: 204,
|
|
25059
|
+
declaredStatuses: [400, 401, 404],
|
|
25060
|
+
empty: true
|
|
25061
|
+
}, requestOptions),
|
|
25062
|
+
compact: (input, requestOptions) => request({
|
|
25063
|
+
method: "POST",
|
|
25064
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/compact`,
|
|
25065
|
+
body: { id: input["id"], delivery: input["delivery"] },
|
|
25066
|
+
successStatus: 200,
|
|
25067
|
+
declaredStatuses: [400, 401, 404, 409],
|
|
25068
|
+
empty: false
|
|
25069
|
+
}, requestOptions).then((value) => value.data),
|
|
25070
|
+
wait: (input, requestOptions) => request({
|
|
25071
|
+
method: "POST",
|
|
25072
|
+
path: `/api/experimental/session/${encodeURIComponent(input.sessionID)}/wait`,
|
|
25073
|
+
successStatus: 204,
|
|
25074
|
+
declaredStatuses: [400, 401, 404, 503],
|
|
25075
|
+
empty: true
|
|
25076
|
+
}, requestOptions),
|
|
25077
|
+
revert: {
|
|
25078
|
+
stage: (input, requestOptions) => request({
|
|
25079
|
+
method: "POST",
|
|
25080
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/revert/stage`,
|
|
25081
|
+
body: { messageID: input["messageID"], files: input["files"] },
|
|
25082
|
+
successStatus: 200,
|
|
25083
|
+
declaredStatuses: [400, 401, 404, 409, 500],
|
|
25084
|
+
empty: false
|
|
25085
|
+
}, requestOptions).then((value) => value.data),
|
|
25086
|
+
clear: (input, requestOptions) => request({
|
|
25087
|
+
method: "DELETE",
|
|
25088
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/revert`,
|
|
25089
|
+
successStatus: 204,
|
|
25090
|
+
declaredStatuses: [400, 401, 404, 409, 500],
|
|
25091
|
+
empty: true
|
|
25092
|
+
}, requestOptions),
|
|
25093
|
+
commit: (input, requestOptions) => request({
|
|
25094
|
+
method: "POST",
|
|
25095
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/revert/commit`,
|
|
25096
|
+
successStatus: 204,
|
|
25097
|
+
declaredStatuses: [400, 401, 404, 409],
|
|
25098
|
+
empty: true
|
|
25099
|
+
}, requestOptions)
|
|
25100
|
+
},
|
|
25101
|
+
context: (input, requestOptions) => request({
|
|
25102
|
+
method: "GET",
|
|
25103
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/context`,
|
|
25104
|
+
successStatus: 200,
|
|
25105
|
+
declaredStatuses: [400, 401, 404, 500],
|
|
25106
|
+
empty: false
|
|
25107
|
+
}, requestOptions).then((value) => value.data),
|
|
25108
|
+
diff: (input, requestOptions) => request({
|
|
25109
|
+
method: "GET",
|
|
25110
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/diff`,
|
|
25111
|
+
query: { from: input["from"], to: input["to"], context: input["context"] },
|
|
25112
|
+
successStatus: 200,
|
|
25113
|
+
declaredStatuses: [400, 401, 404, 500],
|
|
25114
|
+
empty: false
|
|
25115
|
+
}, requestOptions).then((value) => value.data),
|
|
25116
|
+
inbox: {
|
|
25117
|
+
list: (input, requestOptions) => request({
|
|
25118
|
+
method: "GET",
|
|
25119
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/inbox`,
|
|
25120
|
+
successStatus: 200,
|
|
25121
|
+
declaredStatuses: [400, 401, 404],
|
|
25122
|
+
empty: false
|
|
25123
|
+
}, requestOptions).then((value) => value.data),
|
|
25124
|
+
cancel: (input, requestOptions) => request({
|
|
25125
|
+
method: "DELETE",
|
|
25126
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/inbox/${encodeURIComponent(input.inboxID)}`,
|
|
25127
|
+
successStatus: 204,
|
|
25128
|
+
declaredStatuses: [400, 401, 404],
|
|
25129
|
+
empty: true
|
|
25130
|
+
}, requestOptions),
|
|
25131
|
+
update: (input, requestOptions) => request({
|
|
25132
|
+
method: "PATCH",
|
|
25133
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/inbox/${encodeURIComponent(input.inboxID)}`,
|
|
25134
|
+
body: { delivery: input["delivery"] },
|
|
25135
|
+
successStatus: 204,
|
|
25136
|
+
declaredStatuses: [400, 401, 404, 409],
|
|
25137
|
+
empty: true
|
|
25138
|
+
}, requestOptions)
|
|
25139
|
+
},
|
|
25140
|
+
instructions: {
|
|
25141
|
+
entry: {
|
|
25142
|
+
list: (input, requestOptions) => request({
|
|
25143
|
+
method: "GET",
|
|
25144
|
+
path: `/api/experimental/session/${encodeURIComponent(input.sessionID)}/instructions/entries`,
|
|
25145
|
+
successStatus: 200,
|
|
25146
|
+
declaredStatuses: [400, 401, 404],
|
|
25147
|
+
empty: false
|
|
25148
|
+
}, requestOptions).then((value) => value.data),
|
|
25149
|
+
put: (input, requestOptions) => request({
|
|
25150
|
+
method: "PUT",
|
|
25151
|
+
path: `/api/experimental/session/${encodeURIComponent(input.sessionID)}/instructions/entries/${encodeURIComponent(input.key)}`,
|
|
25152
|
+
body: { value: input["value"] },
|
|
25153
|
+
successStatus: 204,
|
|
25154
|
+
declaredStatuses: [400, 401, 404, 413],
|
|
25155
|
+
empty: true
|
|
25156
|
+
}, requestOptions),
|
|
25157
|
+
remove: (input, requestOptions) => request({
|
|
25158
|
+
method: "DELETE",
|
|
25159
|
+
path: `/api/experimental/session/${encodeURIComponent(input.sessionID)}/instructions/entries/${encodeURIComponent(input.key)}`,
|
|
25160
|
+
successStatus: 204,
|
|
25161
|
+
declaredStatuses: [400, 401, 404],
|
|
25162
|
+
empty: true
|
|
25163
|
+
}, requestOptions)
|
|
25164
|
+
}
|
|
25165
|
+
},
|
|
25166
|
+
generate: (input, requestOptions) => request({
|
|
25167
|
+
method: "POST",
|
|
25168
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/generate`,
|
|
25169
|
+
body: { prompt: input["prompt"] },
|
|
25170
|
+
successStatus: 200,
|
|
25171
|
+
declaredStatuses: [400, 401, 404, 503],
|
|
25172
|
+
empty: false
|
|
25173
|
+
}, requestOptions).then((value) => value.data),
|
|
25174
|
+
log: (input, requestOptions) => sse({
|
|
25175
|
+
method: "GET",
|
|
25176
|
+
path: `/api/experimental/session/${encodeURIComponent(input.sessionID)}/log`,
|
|
25177
|
+
query: { after: input["after"], follow: input["follow"] },
|
|
25178
|
+
successStatus: 200,
|
|
25179
|
+
declaredStatuses: [400, 401, 404],
|
|
25180
|
+
empty: false
|
|
25181
|
+
}, requestOptions),
|
|
25182
|
+
interrupt: (input, requestOptions) => request({
|
|
25183
|
+
method: "POST",
|
|
25184
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/interrupt`,
|
|
25185
|
+
query: { resume: input["resume"] },
|
|
25186
|
+
successStatus: 200,
|
|
25187
|
+
declaredStatuses: [400, 401, 404],
|
|
25188
|
+
empty: false
|
|
25189
|
+
}, requestOptions),
|
|
25190
|
+
background: (input, requestOptions) => request({
|
|
25191
|
+
method: "POST",
|
|
25192
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/background`,
|
|
25193
|
+
successStatus: 204,
|
|
25194
|
+
declaredStatuses: [400, 401, 404],
|
|
25195
|
+
empty: true
|
|
25196
|
+
}, requestOptions),
|
|
25197
|
+
message: {
|
|
25198
|
+
get: (input, requestOptions) => request({
|
|
25199
|
+
method: "GET",
|
|
25200
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/message/${encodeURIComponent(input.messageID)}`,
|
|
25201
|
+
successStatus: 200,
|
|
25202
|
+
declaredStatuses: [400, 401, 404],
|
|
25203
|
+
empty: false
|
|
25204
|
+
}, requestOptions).then((value) => value.data)
|
|
25205
|
+
},
|
|
25206
|
+
form: {
|
|
25207
|
+
list: (input, requestOptions) => request({
|
|
25208
|
+
method: "GET",
|
|
25209
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/form`,
|
|
25210
|
+
successStatus: 200,
|
|
25211
|
+
declaredStatuses: [400, 401, 404],
|
|
25212
|
+
empty: false
|
|
25213
|
+
}, requestOptions).then((value) => value.data),
|
|
25214
|
+
create: (input, requestOptions) => request({
|
|
25215
|
+
method: "POST",
|
|
25216
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/form`,
|
|
25217
|
+
body: { id: input["id"], title: input["title"], metadata: input["metadata"], fields: input["fields"] },
|
|
25218
|
+
successStatus: 200,
|
|
25219
|
+
declaredStatuses: [400, 401, 404, 409],
|
|
25220
|
+
empty: false
|
|
25221
|
+
}, requestOptions).then((value) => value.data),
|
|
25222
|
+
get: (input, requestOptions) => request({
|
|
25223
|
+
method: "GET",
|
|
25224
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/form/${encodeURIComponent(input.formID)}`,
|
|
25225
|
+
successStatus: 200,
|
|
25226
|
+
declaredStatuses: [400, 401, 404],
|
|
25227
|
+
empty: false
|
|
25228
|
+
}, requestOptions).then((value) => value.data),
|
|
25229
|
+
reply: (input, requestOptions) => request({
|
|
25230
|
+
method: "POST",
|
|
25231
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/form/${encodeURIComponent(input.formID)}/reply`,
|
|
25232
|
+
body: { answer: input["answer"] },
|
|
25233
|
+
successStatus: 204,
|
|
25234
|
+
declaredStatuses: [400, 401, 404, 409],
|
|
25235
|
+
empty: true
|
|
25236
|
+
}, requestOptions),
|
|
25237
|
+
cancel: (input, requestOptions) => request({
|
|
25238
|
+
method: "DELETE",
|
|
25239
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/form/${encodeURIComponent(input.formID)}`,
|
|
25240
|
+
successStatus: 204,
|
|
25241
|
+
declaredStatuses: [400, 401, 404, 409],
|
|
25242
|
+
empty: true
|
|
25243
|
+
}, requestOptions)
|
|
25244
|
+
},
|
|
25245
|
+
environment: (input, requestOptions) => request({
|
|
25246
|
+
method: "PUT",
|
|
25247
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/environment`,
|
|
25248
|
+
body: { variables: input["variables"] },
|
|
25249
|
+
successStatus: 204,
|
|
25250
|
+
declaredStatuses: [400, 401, 404],
|
|
25251
|
+
empty: true
|
|
25252
|
+
}, requestOptions),
|
|
25253
|
+
view: (input, requestOptions) => request({
|
|
25254
|
+
method: "POST",
|
|
25255
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/view`,
|
|
25256
|
+
body: { idle: input["idle"] },
|
|
25257
|
+
successStatus: 204,
|
|
25258
|
+
declaredStatuses: [400, 401, 404],
|
|
25259
|
+
empty: true
|
|
25260
|
+
}, requestOptions)
|
|
25261
|
+
},
|
|
25262
|
+
message: {
|
|
25263
|
+
list: (input, requestOptions) => request({
|
|
25264
|
+
method: "GET",
|
|
25265
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/message`,
|
|
25266
|
+
query: { limit: input["limit"], order: input["order"], cursor: input["cursor"], type: input["type"] },
|
|
25267
|
+
successStatus: 200,
|
|
25268
|
+
declaredStatuses: [400, 401, 404, 500],
|
|
25269
|
+
empty: false
|
|
25270
|
+
}, requestOptions)
|
|
25271
|
+
},
|
|
25272
|
+
model: {
|
|
25273
|
+
list: (input, requestOptions) => request({
|
|
25274
|
+
method: "GET",
|
|
25275
|
+
path: `/api/model`,
|
|
25276
|
+
query: { location: input?.["location"] },
|
|
25277
|
+
successStatus: 200,
|
|
25278
|
+
declaredStatuses: [400, 401, 503],
|
|
25279
|
+
empty: false
|
|
25280
|
+
}, requestOptions),
|
|
25281
|
+
default: (input, requestOptions) => request({
|
|
25282
|
+
method: "GET",
|
|
25283
|
+
path: `/api/model/default`,
|
|
25284
|
+
query: { location: input?.["location"] },
|
|
25285
|
+
successStatus: 200,
|
|
25286
|
+
declaredStatuses: [400, 401, 503],
|
|
25287
|
+
empty: false
|
|
25288
|
+
}, requestOptions)
|
|
25289
|
+
},
|
|
25290
|
+
generate: {
|
|
25291
|
+
text: (input, requestOptions) => request({
|
|
25292
|
+
method: "POST",
|
|
25293
|
+
path: `/api/experimental/generate`,
|
|
25294
|
+
body: { prompt: input["prompt"], model: input["model"] },
|
|
25295
|
+
successStatus: 200,
|
|
25296
|
+
declaredStatuses: [400, 401, 503],
|
|
25297
|
+
empty: false
|
|
25298
|
+
}, requestOptions).then((value) => value.data)
|
|
25299
|
+
},
|
|
25300
|
+
provider: {
|
|
25301
|
+
list: (input, requestOptions) => request({
|
|
25302
|
+
method: "GET",
|
|
25303
|
+
path: `/api/provider`,
|
|
25304
|
+
query: { location: input?.["location"] },
|
|
25305
|
+
successStatus: 200,
|
|
25306
|
+
declaredStatuses: [400, 401, 503],
|
|
25307
|
+
empty: false
|
|
25308
|
+
}, requestOptions),
|
|
25309
|
+
get: (input, requestOptions) => request({
|
|
25310
|
+
method: "GET",
|
|
25311
|
+
path: `/api/provider/${encodeURIComponent(input.providerID)}`,
|
|
25312
|
+
query: { location: input["location"] },
|
|
25313
|
+
successStatus: 200,
|
|
25314
|
+
declaredStatuses: [400, 401, 404, 503],
|
|
25315
|
+
empty: false
|
|
25316
|
+
}, requestOptions)
|
|
25317
|
+
},
|
|
25318
|
+
integration: {
|
|
25319
|
+
list: (input, requestOptions) => request({
|
|
25320
|
+
method: "GET",
|
|
25321
|
+
path: `/api/integration`,
|
|
25322
|
+
query: { location: input?.["location"] },
|
|
25323
|
+
successStatus: 200,
|
|
25324
|
+
declaredStatuses: [400, 401],
|
|
25325
|
+
empty: false
|
|
25326
|
+
}, requestOptions),
|
|
25327
|
+
get: (input, requestOptions) => request({
|
|
25328
|
+
method: "GET",
|
|
25329
|
+
path: `/api/integration/${encodeURIComponent(input.integrationID)}`,
|
|
25330
|
+
query: { location: input["location"] },
|
|
25331
|
+
successStatus: 200,
|
|
25332
|
+
declaredStatuses: [400, 401, 404],
|
|
25333
|
+
empty: false
|
|
25334
|
+
}, requestOptions),
|
|
25335
|
+
wellknown: {
|
|
25336
|
+
add: (input, requestOptions) => request({
|
|
25337
|
+
method: "POST",
|
|
25338
|
+
path: `/api/experimental/integration/wellknown`,
|
|
25339
|
+
query: { location: input["location"] },
|
|
25340
|
+
body: { url: input["url"] },
|
|
25341
|
+
successStatus: 204,
|
|
25342
|
+
declaredStatuses: [400, 401],
|
|
25343
|
+
empty: true
|
|
25344
|
+
}, requestOptions)
|
|
25345
|
+
},
|
|
25346
|
+
connect: {
|
|
25347
|
+
key: (input, requestOptions) => request({
|
|
25348
|
+
method: "POST",
|
|
25349
|
+
path: `/api/integration/${encodeURIComponent(input.integrationID)}/connect/key`,
|
|
25350
|
+
query: { location: input["location"] },
|
|
25351
|
+
body: { key: input["key"], answer: input["answer"], label: input["label"] },
|
|
25352
|
+
successStatus: 204,
|
|
25353
|
+
declaredStatuses: [400, 401, 404],
|
|
25354
|
+
empty: true
|
|
25355
|
+
}, requestOptions)
|
|
25356
|
+
},
|
|
25357
|
+
oauth: {
|
|
25358
|
+
connect: (input, requestOptions) => request({
|
|
25359
|
+
method: "POST",
|
|
25360
|
+
path: `/api/integration/${encodeURIComponent(input.integrationID)}/connect/oauth`,
|
|
25361
|
+
query: { location: input["location"] },
|
|
25362
|
+
body: { methodID: input["methodID"], answer: input["answer"], label: input["label"] },
|
|
25363
|
+
successStatus: 200,
|
|
25364
|
+
declaredStatuses: [400, 401],
|
|
25365
|
+
empty: false
|
|
25366
|
+
}, requestOptions),
|
|
25367
|
+
status: (input, requestOptions) => request({
|
|
25368
|
+
method: "GET",
|
|
25369
|
+
path: `/api/integration/${encodeURIComponent(input.integrationID)}/connect/oauth/${encodeURIComponent(input.attemptID)}`,
|
|
25370
|
+
query: { location: input["location"] },
|
|
25371
|
+
successStatus: 200,
|
|
25372
|
+
declaredStatuses: [400, 401, 404],
|
|
25373
|
+
empty: false
|
|
25374
|
+
}, requestOptions),
|
|
25375
|
+
complete: (input, requestOptions) => request({
|
|
25376
|
+
method: "POST",
|
|
25377
|
+
path: `/api/integration/${encodeURIComponent(input.integrationID)}/connect/oauth/${encodeURIComponent(input.attemptID)}/complete`,
|
|
25378
|
+
query: { location: input["location"] },
|
|
25379
|
+
body: { code: input["code"] },
|
|
25380
|
+
successStatus: 204,
|
|
25381
|
+
declaredStatuses: [400, 401, 404],
|
|
25382
|
+
empty: true
|
|
25383
|
+
}, requestOptions),
|
|
25384
|
+
cancel: (input, requestOptions) => request({
|
|
25385
|
+
method: "DELETE",
|
|
25386
|
+
path: `/api/integration/${encodeURIComponent(input.integrationID)}/connect/oauth/${encodeURIComponent(input.attemptID)}`,
|
|
25387
|
+
query: { location: input["location"] },
|
|
25388
|
+
successStatus: 204,
|
|
25389
|
+
declaredStatuses: [400, 401],
|
|
25390
|
+
empty: true
|
|
25391
|
+
}, requestOptions)
|
|
25392
|
+
},
|
|
25393
|
+
command: {
|
|
25394
|
+
connect: (input, requestOptions) => request({
|
|
25395
|
+
method: "POST",
|
|
25396
|
+
path: `/api/integration/${encodeURIComponent(input.integrationID)}/connect/command`,
|
|
25397
|
+
query: { location: input["location"] },
|
|
25398
|
+
body: { methodID: input["methodID"], label: input["label"] },
|
|
25399
|
+
successStatus: 200,
|
|
25400
|
+
declaredStatuses: [400, 401, 404],
|
|
25401
|
+
empty: false
|
|
25402
|
+
}, requestOptions),
|
|
25403
|
+
status: (input, requestOptions) => request({
|
|
25404
|
+
method: "GET",
|
|
25405
|
+
path: `/api/integration/${encodeURIComponent(input.integrationID)}/connect/command/${encodeURIComponent(input.attemptID)}`,
|
|
25406
|
+
query: { location: input["location"] },
|
|
25407
|
+
successStatus: 200,
|
|
25408
|
+
declaredStatuses: [400, 401, 404],
|
|
25409
|
+
empty: false
|
|
25410
|
+
}, requestOptions),
|
|
25411
|
+
cancel: (input, requestOptions) => request({
|
|
25412
|
+
method: "DELETE",
|
|
25413
|
+
path: `/api/integration/${encodeURIComponent(input.integrationID)}/connect/command/${encodeURIComponent(input.attemptID)}`,
|
|
25414
|
+
query: { location: input["location"] },
|
|
25415
|
+
successStatus: 204,
|
|
25416
|
+
declaredStatuses: [400, 401],
|
|
25417
|
+
empty: true
|
|
25418
|
+
}, requestOptions)
|
|
25419
|
+
}
|
|
25420
|
+
},
|
|
25421
|
+
mcp: {
|
|
25422
|
+
list: (input, requestOptions) => request({
|
|
25423
|
+
method: "GET",
|
|
25424
|
+
path: `/api/mcp`,
|
|
25425
|
+
query: { location: input?.["location"] },
|
|
25426
|
+
successStatus: 200,
|
|
25427
|
+
declaredStatuses: [400, 401],
|
|
25428
|
+
empty: false
|
|
25429
|
+
}, requestOptions),
|
|
25430
|
+
add: (input, requestOptions) => request({
|
|
25431
|
+
method: "PUT",
|
|
25432
|
+
path: `/api/experimental/mcp/${encodeURIComponent(input.server)}`,
|
|
25433
|
+
query: { location: input["location"] },
|
|
25434
|
+
body: { config: input["config"] },
|
|
25435
|
+
successStatus: 204,
|
|
25436
|
+
declaredStatuses: [400, 401],
|
|
25437
|
+
empty: true
|
|
25438
|
+
}, requestOptions),
|
|
25439
|
+
remove: (input, requestOptions) => request({
|
|
25440
|
+
method: "DELETE",
|
|
25441
|
+
path: `/api/experimental/mcp/${encodeURIComponent(input.server)}`,
|
|
25442
|
+
query: { location: input["location"] },
|
|
25443
|
+
successStatus: 204,
|
|
25444
|
+
declaredStatuses: [400, 401, 404],
|
|
25445
|
+
empty: true
|
|
25446
|
+
}, requestOptions),
|
|
25447
|
+
connect: (input, requestOptions) => request({
|
|
25448
|
+
method: "POST",
|
|
25449
|
+
path: `/api/experimental/mcp/${encodeURIComponent(input.server)}/connect`,
|
|
25450
|
+
query: { location: input["location"] },
|
|
25451
|
+
successStatus: 204,
|
|
25452
|
+
declaredStatuses: [400, 401, 404],
|
|
25453
|
+
empty: true
|
|
25454
|
+
}, requestOptions),
|
|
25455
|
+
disconnect: (input, requestOptions) => request({
|
|
25456
|
+
method: "POST",
|
|
25457
|
+
path: `/api/experimental/mcp/${encodeURIComponent(input.server)}/disconnect`,
|
|
25458
|
+
query: { location: input["location"] },
|
|
25459
|
+
successStatus: 204,
|
|
25460
|
+
declaredStatuses: [400, 401, 404],
|
|
25461
|
+
empty: true
|
|
25462
|
+
}, requestOptions),
|
|
25463
|
+
resource: {
|
|
25464
|
+
catalog: (input, requestOptions) => request({
|
|
25465
|
+
method: "GET",
|
|
25466
|
+
path: `/api/mcp/resource`,
|
|
25467
|
+
query: { location: input?.["location"] },
|
|
25468
|
+
successStatus: 200,
|
|
25469
|
+
declaredStatuses: [400, 401],
|
|
25470
|
+
empty: false
|
|
25471
|
+
}, requestOptions)
|
|
25472
|
+
}
|
|
25473
|
+
},
|
|
25474
|
+
credential: {
|
|
25475
|
+
update: (input, requestOptions) => request({
|
|
25476
|
+
method: "PATCH",
|
|
25477
|
+
path: `/api/credential/${encodeURIComponent(input.credentialID)}`,
|
|
25478
|
+
body: { label: input["label"] },
|
|
25479
|
+
successStatus: 204,
|
|
25480
|
+
declaredStatuses: [400, 401],
|
|
25481
|
+
empty: true
|
|
25482
|
+
}, requestOptions),
|
|
25483
|
+
activate: (input, requestOptions) => request({
|
|
25484
|
+
method: "POST",
|
|
25485
|
+
path: `/api/credential/${encodeURIComponent(input.credentialID)}/activate`,
|
|
25486
|
+
successStatus: 204,
|
|
25487
|
+
declaredStatuses: [400, 401],
|
|
25488
|
+
empty: true
|
|
25489
|
+
}, requestOptions),
|
|
25490
|
+
remove: (input, requestOptions) => request({
|
|
25491
|
+
method: "DELETE",
|
|
25492
|
+
path: `/api/credential/${encodeURIComponent(input.credentialID)}`,
|
|
25493
|
+
successStatus: 204,
|
|
25494
|
+
declaredStatuses: [400, 401],
|
|
25495
|
+
empty: true
|
|
25496
|
+
}, requestOptions)
|
|
25497
|
+
},
|
|
25498
|
+
project: {
|
|
25499
|
+
list: (requestOptions) => request({ method: "GET", path: `/api/project`, successStatus: 200, declaredStatuses: [400, 401], empty: false }, requestOptions),
|
|
25500
|
+
update: (input, requestOptions) => request({
|
|
25501
|
+
method: "PATCH",
|
|
25502
|
+
path: `/api/project/${encodeURIComponent(input.projectID)}`,
|
|
25503
|
+
body: {
|
|
25504
|
+
canonical: input["canonical"],
|
|
25505
|
+
name: input["name"],
|
|
25506
|
+
icon: input["icon"],
|
|
25507
|
+
commands: input["commands"]
|
|
25508
|
+
},
|
|
25509
|
+
successStatus: 200,
|
|
25510
|
+
declaredStatuses: [400, 401, 404],
|
|
25511
|
+
empty: false
|
|
25512
|
+
}, requestOptions)
|
|
25513
|
+
},
|
|
25514
|
+
form: {
|
|
25515
|
+
list: (input, requestOptions) => request({
|
|
25516
|
+
method: "GET",
|
|
25517
|
+
path: `/api/form`,
|
|
25518
|
+
query: { location: input?.["location"] },
|
|
25519
|
+
successStatus: 200,
|
|
25520
|
+
declaredStatuses: [400, 401],
|
|
25521
|
+
empty: false
|
|
25522
|
+
}, requestOptions)
|
|
25523
|
+
},
|
|
25524
|
+
permission: {
|
|
25525
|
+
request: {
|
|
25526
|
+
list: (input, requestOptions) => request({
|
|
25527
|
+
method: "GET",
|
|
25528
|
+
path: `/api/permission/request`,
|
|
25529
|
+
query: { location: input?.["location"] },
|
|
25530
|
+
successStatus: 200,
|
|
25531
|
+
declaredStatuses: [400, 401],
|
|
25532
|
+
empty: false
|
|
25533
|
+
}, requestOptions)
|
|
25534
|
+
},
|
|
25535
|
+
saved: {
|
|
25536
|
+
list: (input, requestOptions) => request({
|
|
25537
|
+
method: "GET",
|
|
25538
|
+
path: `/api/permission/saved`,
|
|
25539
|
+
query: { projectID: input?.["projectID"] },
|
|
25540
|
+
successStatus: 200,
|
|
25541
|
+
declaredStatuses: [400, 401],
|
|
25542
|
+
empty: false
|
|
25543
|
+
}, requestOptions).then((value) => value.data),
|
|
25544
|
+
remove: (input, requestOptions) => request({
|
|
25545
|
+
method: "DELETE",
|
|
25546
|
+
path: `/api/permission/saved/${encodeURIComponent(input.id)}`,
|
|
25547
|
+
successStatus: 204,
|
|
25548
|
+
declaredStatuses: [400, 401],
|
|
25549
|
+
empty: true
|
|
25550
|
+
}, requestOptions)
|
|
25551
|
+
},
|
|
25552
|
+
create: (input, requestOptions) => request({
|
|
25553
|
+
method: "POST",
|
|
25554
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/permission`,
|
|
25555
|
+
body: {
|
|
25556
|
+
id: input["id"],
|
|
25557
|
+
action: input["action"],
|
|
25558
|
+
resources: input["resources"],
|
|
25559
|
+
save: input["save"],
|
|
25560
|
+
metadata: input["metadata"],
|
|
25561
|
+
source: input["source"],
|
|
25562
|
+
agent: input["agent"]
|
|
25563
|
+
},
|
|
25564
|
+
successStatus: 200,
|
|
25565
|
+
declaredStatuses: [400, 401, 404],
|
|
25566
|
+
empty: false
|
|
25567
|
+
}, requestOptions).then((value) => value.data),
|
|
25568
|
+
list: (input, requestOptions) => request({
|
|
25569
|
+
method: "GET",
|
|
25570
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/permission`,
|
|
25571
|
+
successStatus: 200,
|
|
25572
|
+
declaredStatuses: [400, 401, 404],
|
|
25573
|
+
empty: false
|
|
25574
|
+
}, requestOptions).then((value) => value.data),
|
|
25575
|
+
get: (input, requestOptions) => request({
|
|
25576
|
+
method: "GET",
|
|
25577
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/permission/${encodeURIComponent(input.requestID)}`,
|
|
25578
|
+
successStatus: 200,
|
|
25579
|
+
declaredStatuses: [400, 401, 404],
|
|
25580
|
+
empty: false
|
|
25581
|
+
}, requestOptions).then((value) => value.data),
|
|
25582
|
+
reply: (input, requestOptions) => request({
|
|
25583
|
+
method: "POST",
|
|
25584
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/permission/${encodeURIComponent(input.requestID)}/reply`,
|
|
25585
|
+
body: { decision: input["decision"], message: input["message"] },
|
|
25586
|
+
successStatus: 204,
|
|
25587
|
+
declaredStatuses: [400, 401, 404],
|
|
25588
|
+
empty: true
|
|
25589
|
+
}, requestOptions)
|
|
25590
|
+
},
|
|
25591
|
+
file: {
|
|
25592
|
+
read: (input, requestOptions) => request({
|
|
25593
|
+
method: "GET",
|
|
25594
|
+
path: `/api/fs/read/${encodePath(input.path)}`,
|
|
25595
|
+
query: { location: input["location"] },
|
|
25596
|
+
successStatus: 200,
|
|
25597
|
+
declaredStatuses: [400, 401, 404],
|
|
25598
|
+
empty: false,
|
|
25599
|
+
binary: true
|
|
25600
|
+
}, requestOptions),
|
|
25601
|
+
list: (input, requestOptions) => request({
|
|
25602
|
+
method: "GET",
|
|
25603
|
+
path: `/api/fs/list`,
|
|
25604
|
+
query: { location: input?.["location"], path: input?.["path"] },
|
|
25605
|
+
successStatus: 200,
|
|
25606
|
+
declaredStatuses: [400, 401],
|
|
25607
|
+
empty: false
|
|
25608
|
+
}, requestOptions),
|
|
25609
|
+
find: (input, requestOptions) => request({
|
|
25610
|
+
method: "GET",
|
|
25611
|
+
path: `/api/fs/find`,
|
|
25612
|
+
query: { location: input["location"], query: input["query"], type: input["type"], limit: input["limit"] },
|
|
25613
|
+
successStatus: 200,
|
|
25614
|
+
declaredStatuses: [400, 401],
|
|
25615
|
+
empty: false
|
|
25616
|
+
}, requestOptions),
|
|
25617
|
+
write: (input, requestOptions) => request({
|
|
25618
|
+
method: "POST",
|
|
25619
|
+
path: `/api/experimental/fs/write`,
|
|
25620
|
+
query: { location: input["location"], path: input["path"] },
|
|
25621
|
+
body: input["payload"],
|
|
25622
|
+
successStatus: 200,
|
|
25623
|
+
declaredStatuses: [400, 401],
|
|
25624
|
+
empty: false,
|
|
25625
|
+
binaryBody: true
|
|
25626
|
+
}, requestOptions)
|
|
25627
|
+
},
|
|
25628
|
+
command: {
|
|
25629
|
+
list: (input, requestOptions) => request({
|
|
25630
|
+
method: "GET",
|
|
25631
|
+
path: `/api/command`,
|
|
25632
|
+
query: { location: input?.["location"] },
|
|
25633
|
+
successStatus: 200,
|
|
25634
|
+
declaredStatuses: [400, 401],
|
|
25635
|
+
empty: false
|
|
25636
|
+
}, requestOptions)
|
|
25637
|
+
},
|
|
25638
|
+
skill: {
|
|
25639
|
+
list: (input, requestOptions) => request({
|
|
25640
|
+
method: "GET",
|
|
25641
|
+
path: `/api/skill`,
|
|
25642
|
+
query: { location: input?.["location"] },
|
|
25643
|
+
successStatus: 200,
|
|
25644
|
+
declaredStatuses: [400, 401],
|
|
25645
|
+
empty: false
|
|
25646
|
+
}, requestOptions)
|
|
25647
|
+
},
|
|
25648
|
+
rpc: {
|
|
25649
|
+
call: (input, requestOptions) => request({
|
|
25650
|
+
method: "POST",
|
|
25651
|
+
path: `/api/rpc/${encodeURIComponent(input.rpcID)}/${encodeURIComponent(input.method)}`,
|
|
25652
|
+
query: { location: input["location"] },
|
|
25653
|
+
body: { input: input["input"] },
|
|
25654
|
+
successStatus: 200,
|
|
25655
|
+
declaredStatuses: [400, 401, 500],
|
|
25656
|
+
empty: false
|
|
25657
|
+
}, requestOptions)
|
|
25658
|
+
},
|
|
25659
|
+
event: {
|
|
25660
|
+
subscribe: (requestOptions) => sse({ method: "GET", path: `/api/event`, successStatus: 200, declaredStatuses: [400, 401], empty: false }, requestOptions)
|
|
25661
|
+
},
|
|
25662
|
+
pty: {
|
|
25663
|
+
list: (input, requestOptions) => request({
|
|
25664
|
+
method: "GET",
|
|
25665
|
+
path: `/api/pty`,
|
|
25666
|
+
query: { location: input?.["location"] },
|
|
25667
|
+
successStatus: 200,
|
|
25668
|
+
declaredStatuses: [400, 401],
|
|
25669
|
+
empty: false
|
|
25670
|
+
}, requestOptions),
|
|
25671
|
+
create: (input, requestOptions) => request({
|
|
25672
|
+
method: "POST",
|
|
25673
|
+
path: `/api/pty`,
|
|
25674
|
+
query: { location: input?.["location"] },
|
|
25675
|
+
body: {
|
|
25676
|
+
command: input?.["command"],
|
|
25677
|
+
args: input?.["args"],
|
|
25678
|
+
cwd: input?.["cwd"],
|
|
25679
|
+
title: input?.["title"],
|
|
25680
|
+
env: input?.["env"]
|
|
25681
|
+
},
|
|
25682
|
+
successStatus: 200,
|
|
25683
|
+
declaredStatuses: [400, 401],
|
|
25684
|
+
empty: false
|
|
25685
|
+
}, requestOptions),
|
|
25686
|
+
get: (input, requestOptions) => request({
|
|
25687
|
+
method: "GET",
|
|
25688
|
+
path: `/api/pty/${encodeURIComponent(input.ptyID)}`,
|
|
25689
|
+
query: { location: input["location"] },
|
|
25690
|
+
successStatus: 200,
|
|
25691
|
+
declaredStatuses: [400, 401, 404],
|
|
25692
|
+
empty: false
|
|
25693
|
+
}, requestOptions),
|
|
25694
|
+
update: (input, requestOptions) => request({
|
|
25695
|
+
method: "PUT",
|
|
25696
|
+
path: `/api/pty/${encodeURIComponent(input.ptyID)}`,
|
|
25697
|
+
query: { location: input["location"] },
|
|
25698
|
+
body: { title: input["title"], size: input["size"] },
|
|
25699
|
+
successStatus: 200,
|
|
25700
|
+
declaredStatuses: [400, 401, 404],
|
|
25701
|
+
empty: false
|
|
25702
|
+
}, requestOptions),
|
|
25703
|
+
remove: (input, requestOptions) => request({
|
|
25704
|
+
method: "DELETE",
|
|
25705
|
+
path: `/api/pty/${encodeURIComponent(input.ptyID)}`,
|
|
25706
|
+
query: { location: input["location"] },
|
|
25707
|
+
successStatus: 204,
|
|
25708
|
+
declaredStatuses: [400, 401, 404],
|
|
25709
|
+
empty: true
|
|
25710
|
+
}, requestOptions),
|
|
25711
|
+
connect: {
|
|
25712
|
+
token: (input, requestOptions) => request({
|
|
25713
|
+
method: "POST",
|
|
25714
|
+
path: `/api/pty/${encodeURIComponent(input.ptyID)}/connect-token`,
|
|
25715
|
+
query: { location: input["location"] },
|
|
25716
|
+
headers: { "x-opencode-ticket": input["x-opencode-ticket"] },
|
|
25717
|
+
successStatus: 200,
|
|
25718
|
+
declaredStatuses: [400, 401, 403, 404],
|
|
25719
|
+
empty: false
|
|
25720
|
+
}, requestOptions)
|
|
25721
|
+
}
|
|
25722
|
+
},
|
|
25723
|
+
experimental: {
|
|
25724
|
+
persistentPty: {
|
|
25725
|
+
read: (input, requestOptions) => request({
|
|
25726
|
+
method: "GET",
|
|
25727
|
+
path: `/api/experimental/session/${encodeURIComponent(input.sessionID)}/terminal/read`,
|
|
25728
|
+
query: { lines: input["lines"] },
|
|
25729
|
+
successStatus: 200,
|
|
25730
|
+
declaredStatuses: [400, 401, 503],
|
|
25731
|
+
empty: false
|
|
25732
|
+
}, requestOptions).then((value) => value.data),
|
|
25733
|
+
list: (input, requestOptions) => request({
|
|
25734
|
+
method: "GET",
|
|
25735
|
+
path: `/api/experimental/session/${encodeURIComponent(input.sessionID)}/terminal`,
|
|
25736
|
+
successStatus: 200,
|
|
25737
|
+
declaredStatuses: [400, 401, 503],
|
|
25738
|
+
empty: false
|
|
25739
|
+
}, requestOptions).then((value) => value.data),
|
|
25740
|
+
create: (input, requestOptions) => request({
|
|
25741
|
+
method: "POST",
|
|
25742
|
+
path: `/api/experimental/session/${encodeURIComponent(input.sessionID)}/terminal`,
|
|
25743
|
+
body: {
|
|
25744
|
+
command: input["command"],
|
|
25745
|
+
args: input["args"],
|
|
25746
|
+
cwd: input["cwd"],
|
|
25747
|
+
title: input["title"],
|
|
25748
|
+
env: input["env"],
|
|
25749
|
+
size: input["size"]
|
|
25750
|
+
},
|
|
25751
|
+
successStatus: 200,
|
|
25752
|
+
declaredStatuses: [400, 401, 503],
|
|
25753
|
+
empty: false
|
|
25754
|
+
}, requestOptions).then((value) => value.data),
|
|
25755
|
+
shutdown: (requestOptions) => request({
|
|
25756
|
+
method: "POST",
|
|
25757
|
+
path: `/api/experimental/persistent-pty/shutdown`,
|
|
25758
|
+
successStatus: 204,
|
|
25759
|
+
declaredStatuses: [400, 401, 503],
|
|
25760
|
+
empty: true
|
|
25761
|
+
}, requestOptions),
|
|
25762
|
+
handoff: (requestOptions) => request({
|
|
25763
|
+
method: "POST",
|
|
25764
|
+
path: `/api/experimental/persistent-pty/handoff`,
|
|
25765
|
+
successStatus: 200,
|
|
25766
|
+
declaredStatuses: [400, 401, 503],
|
|
25767
|
+
empty: false
|
|
25768
|
+
}, requestOptions),
|
|
25769
|
+
get: (input, requestOptions) => request({
|
|
25770
|
+
method: "GET",
|
|
25771
|
+
path: `/api/experimental/persistent-pty/${encodeURIComponent(input.ptyID)}`,
|
|
25772
|
+
successStatus: 200,
|
|
25773
|
+
declaredStatuses: [400, 401, 404, 503],
|
|
25774
|
+
empty: false
|
|
25775
|
+
}, requestOptions).then((value) => value.data),
|
|
25776
|
+
update: (input, requestOptions) => request({
|
|
25777
|
+
method: "PUT",
|
|
25778
|
+
path: `/api/experimental/persistent-pty/${encodeURIComponent(input.ptyID)}`,
|
|
25779
|
+
body: { attachmentID: input["attachmentID"], size: input["size"] },
|
|
25780
|
+
successStatus: 200,
|
|
25781
|
+
declaredStatuses: [400, 401, 404, 503],
|
|
25782
|
+
empty: false
|
|
25783
|
+
}, requestOptions).then((value) => value.data),
|
|
25784
|
+
snapshot: (input, requestOptions) => request({
|
|
25785
|
+
method: "GET",
|
|
25786
|
+
path: `/api/experimental/persistent-pty/${encodeURIComponent(input.ptyID)}/snapshot`,
|
|
25787
|
+
successStatus: 200,
|
|
25788
|
+
declaredStatuses: [400, 401, 404, 503],
|
|
25789
|
+
empty: false
|
|
25790
|
+
}, requestOptions).then((value) => value.data),
|
|
25791
|
+
remove: (input, requestOptions) => request({
|
|
25792
|
+
method: "DELETE",
|
|
25793
|
+
path: `/api/experimental/persistent-pty/${encodeURIComponent(input.ptyID)}`,
|
|
25794
|
+
successStatus: 204,
|
|
25795
|
+
declaredStatuses: [400, 401, 404, 503],
|
|
25796
|
+
empty: true
|
|
25797
|
+
}, requestOptions),
|
|
25798
|
+
connectToken: (input, requestOptions) => request({
|
|
25799
|
+
method: "POST",
|
|
25800
|
+
path: `/api/experimental/persistent-pty/${encodeURIComponent(input.ptyID)}/connect-token`,
|
|
25801
|
+
headers: { "x-opencode-ticket": input["x-opencode-ticket"] },
|
|
25802
|
+
successStatus: 200,
|
|
25803
|
+
declaredStatuses: [400, 401, 403, 404, 503],
|
|
25804
|
+
empty: false
|
|
25805
|
+
}, requestOptions).then((value) => value.data)
|
|
25806
|
+
}
|
|
25807
|
+
},
|
|
25808
|
+
shell: {
|
|
25809
|
+
list: (input, requestOptions) => request({
|
|
25810
|
+
method: "GET",
|
|
25811
|
+
path: `/api/shell`,
|
|
25812
|
+
query: { location: input?.["location"] },
|
|
25813
|
+
successStatus: 200,
|
|
25814
|
+
declaredStatuses: [400, 401],
|
|
25815
|
+
empty: false
|
|
25816
|
+
}, requestOptions),
|
|
25817
|
+
create: (input, requestOptions) => request({
|
|
25818
|
+
method: "POST",
|
|
25819
|
+
path: `/api/shell`,
|
|
25820
|
+
query: { location: input["location"] },
|
|
25821
|
+
body: {
|
|
25822
|
+
command: input["command"],
|
|
25823
|
+
cwd: input["cwd"],
|
|
25824
|
+
timeout: input["timeout"],
|
|
25825
|
+
metadata: input["metadata"]
|
|
25826
|
+
},
|
|
25827
|
+
successStatus: 200,
|
|
25828
|
+
declaredStatuses: [400, 401],
|
|
25829
|
+
empty: false
|
|
25830
|
+
}, requestOptions),
|
|
25831
|
+
get: (input, requestOptions) => request({
|
|
25832
|
+
method: "GET",
|
|
25833
|
+
path: `/api/shell/${encodeURIComponent(input.id)}`,
|
|
25834
|
+
query: { location: input["location"] },
|
|
25835
|
+
successStatus: 200,
|
|
25836
|
+
declaredStatuses: [400, 401, 404],
|
|
25837
|
+
empty: false
|
|
25838
|
+
}, requestOptions),
|
|
25839
|
+
output: (input, requestOptions) => request({
|
|
25840
|
+
method: "GET",
|
|
25841
|
+
path: `/api/shell/${encodeURIComponent(input.id)}/output`,
|
|
25842
|
+
query: { location: input["location"], cursor: input["cursor"], limit: input["limit"] },
|
|
25843
|
+
successStatus: 200,
|
|
25844
|
+
declaredStatuses: [400, 401, 404],
|
|
25845
|
+
empty: false
|
|
25846
|
+
}, requestOptions),
|
|
25847
|
+
remove: (input, requestOptions) => request({
|
|
25848
|
+
method: "DELETE",
|
|
25849
|
+
path: `/api/shell/${encodeURIComponent(input.id)}`,
|
|
25850
|
+
query: { location: input["location"] },
|
|
25851
|
+
successStatus: 204,
|
|
25852
|
+
declaredStatuses: [400, 401],
|
|
25853
|
+
empty: true
|
|
25854
|
+
}, requestOptions)
|
|
25855
|
+
},
|
|
25856
|
+
reference: {
|
|
25857
|
+
list: (input, requestOptions) => request({
|
|
25858
|
+
method: "GET",
|
|
25859
|
+
path: `/api/reference`,
|
|
25860
|
+
query: { location: input?.["location"] },
|
|
25861
|
+
successStatus: 200,
|
|
25862
|
+
declaredStatuses: [400, 401],
|
|
25863
|
+
empty: false
|
|
25864
|
+
}, requestOptions)
|
|
25865
|
+
},
|
|
25866
|
+
worktree: {
|
|
25867
|
+
list: (input, requestOptions) => request({
|
|
25868
|
+
method: "GET",
|
|
25869
|
+
path: `/api/worktree`,
|
|
25870
|
+
query: { projectID: input["projectID"] },
|
|
25871
|
+
successStatus: 200,
|
|
25872
|
+
declaredStatuses: [400, 401, 404],
|
|
25873
|
+
empty: false
|
|
25874
|
+
}, requestOptions),
|
|
25875
|
+
create: (input, requestOptions) => request({
|
|
25876
|
+
method: "POST",
|
|
25877
|
+
path: `/api/worktree`,
|
|
25878
|
+
body: {
|
|
25879
|
+
projectID: input["projectID"],
|
|
25880
|
+
from: input["from"],
|
|
25881
|
+
branch: input["branch"],
|
|
25882
|
+
directory: input["directory"],
|
|
25883
|
+
name: input["name"]
|
|
25884
|
+
},
|
|
25885
|
+
successStatus: 200,
|
|
25886
|
+
declaredStatuses: [400, 401, 404],
|
|
25887
|
+
empty: false
|
|
25888
|
+
}, requestOptions),
|
|
25889
|
+
remove: (input, requestOptions) => request({
|
|
25890
|
+
method: "DELETE",
|
|
25891
|
+
path: `/api/worktree`,
|
|
25892
|
+
body: { projectID: input["projectID"], directory: input["directory"], force: input["force"] },
|
|
25893
|
+
successStatus: 204,
|
|
25894
|
+
declaredStatuses: [400, 401, 404],
|
|
25895
|
+
empty: true
|
|
25896
|
+
}, requestOptions),
|
|
25897
|
+
refresh: (input, requestOptions) => request({
|
|
25898
|
+
method: "POST",
|
|
25899
|
+
path: `/api/worktree/refresh`,
|
|
25900
|
+
body: { projectID: input["projectID"] },
|
|
25901
|
+
successStatus: 204,
|
|
25902
|
+
declaredStatuses: [400, 401, 404],
|
|
25903
|
+
empty: true
|
|
25904
|
+
}, requestOptions)
|
|
25905
|
+
},
|
|
25906
|
+
vcs: {
|
|
25907
|
+
get: (input, requestOptions) => request({
|
|
25908
|
+
method: "GET",
|
|
25909
|
+
path: `/api/vcs`,
|
|
25910
|
+
query: { location: input?.["location"] },
|
|
25911
|
+
successStatus: 200,
|
|
25912
|
+
declaredStatuses: [400, 401],
|
|
25913
|
+
empty: false
|
|
25914
|
+
}, requestOptions),
|
|
25915
|
+
base: (input, requestOptions) => request({
|
|
25916
|
+
method: "GET",
|
|
25917
|
+
path: `/api/vcs/base`,
|
|
25918
|
+
query: { location: input?.["location"] },
|
|
25919
|
+
successStatus: 200,
|
|
25920
|
+
declaredStatuses: [400, 401, 503],
|
|
25921
|
+
empty: false
|
|
25922
|
+
}, requestOptions),
|
|
25923
|
+
status: (input, requestOptions) => request({
|
|
25924
|
+
method: "GET",
|
|
25925
|
+
path: `/api/vcs/status`,
|
|
25926
|
+
query: { location: input?.["location"] },
|
|
25927
|
+
successStatus: 200,
|
|
25928
|
+
declaredStatuses: [400, 401],
|
|
25929
|
+
empty: false
|
|
25930
|
+
}, requestOptions),
|
|
25931
|
+
branch: {
|
|
25932
|
+
list: (input, requestOptions) => request({
|
|
25933
|
+
method: "GET",
|
|
25934
|
+
path: `/api/vcs/branch`,
|
|
25935
|
+
query: { location: input?.["location"], search: input?.["search"], limit: input?.["limit"] },
|
|
25936
|
+
successStatus: 200,
|
|
25937
|
+
declaredStatuses: [400, 401],
|
|
25938
|
+
empty: false
|
|
25939
|
+
}, requestOptions)
|
|
25940
|
+
},
|
|
25941
|
+
diff: (input, requestOptions) => request({
|
|
25942
|
+
method: "GET",
|
|
25943
|
+
path: `/api/vcs/diff`,
|
|
25944
|
+
query: { location: input["location"], mode: input["mode"], base: input["base"], context: input["context"] },
|
|
25945
|
+
successStatus: 200,
|
|
25946
|
+
declaredStatuses: [400, 401, 503],
|
|
25947
|
+
empty: false
|
|
25948
|
+
}, requestOptions)
|
|
25949
|
+
},
|
|
25950
|
+
debug: {
|
|
25951
|
+
location: {
|
|
25952
|
+
list: (requestOptions) => request({
|
|
25953
|
+
method: "GET",
|
|
25954
|
+
path: `/api/debug/location`,
|
|
25955
|
+
successStatus: 200,
|
|
25956
|
+
declaredStatuses: [400, 401],
|
|
25957
|
+
empty: false
|
|
25958
|
+
}, requestOptions),
|
|
25959
|
+
evict: (input, requestOptions) => request({
|
|
25960
|
+
method: "DELETE",
|
|
25961
|
+
path: `/api/debug/location`,
|
|
25962
|
+
query: { location: input?.["location"] },
|
|
25963
|
+
successStatus: 204,
|
|
25964
|
+
declaredStatuses: [400, 401],
|
|
25965
|
+
empty: true
|
|
25966
|
+
}, requestOptions)
|
|
25967
|
+
}
|
|
25968
|
+
},
|
|
25969
|
+
migration: {
|
|
25970
|
+
v1: {
|
|
25971
|
+
status: (requestOptions) => request({
|
|
25972
|
+
method: "GET",
|
|
25973
|
+
path: `/api/experimental/migration/v1`,
|
|
25974
|
+
successStatus: 200,
|
|
25975
|
+
declaredStatuses: [400, 401],
|
|
25976
|
+
empty: false
|
|
25977
|
+
}, requestOptions)
|
|
25978
|
+
}
|
|
25979
|
+
},
|
|
25980
|
+
websearch: {
|
|
25981
|
+
providers: (input, requestOptions) => request({
|
|
25982
|
+
method: "GET",
|
|
25983
|
+
path: `/api/websearch/provider`,
|
|
25984
|
+
query: { location: input?.["location"] },
|
|
25985
|
+
successStatus: 200,
|
|
25986
|
+
declaredStatuses: [400, 401, 503],
|
|
25987
|
+
empty: false
|
|
25988
|
+
}, requestOptions),
|
|
25989
|
+
query: (input, requestOptions) => request({
|
|
25990
|
+
method: "POST",
|
|
25991
|
+
path: `/api/websearch`,
|
|
25992
|
+
query: { location: input["location"] },
|
|
25993
|
+
body: { query: input["query"], providerID: input["providerID"] },
|
|
25994
|
+
successStatus: 200,
|
|
25995
|
+
declaredStatuses: [400, 401, 503],
|
|
25996
|
+
empty: false
|
|
25997
|
+
}, requestOptions)
|
|
25998
|
+
},
|
|
25999
|
+
config: {
|
|
26000
|
+
get: (input, requestOptions) => request({
|
|
26001
|
+
method: "GET",
|
|
26002
|
+
path: `/api/config`,
|
|
26003
|
+
query: { location: input?.["location"] },
|
|
26004
|
+
successStatus: 200,
|
|
26005
|
+
declaredStatuses: [400, 401],
|
|
26006
|
+
empty: false
|
|
26007
|
+
}, requestOptions),
|
|
26008
|
+
shells: (requestOptions) => request({ method: "GET", path: `/api/config/shell`, successStatus: 200, declaredStatuses: [400, 401], empty: false }, requestOptions),
|
|
26009
|
+
update: (input, requestOptions) => request({
|
|
26010
|
+
method: "PATCH",
|
|
26011
|
+
path: `/api/experimental/config`,
|
|
26012
|
+
body: { shell: input["shell"] },
|
|
26013
|
+
successStatus: 204,
|
|
26014
|
+
declaredStatuses: [400, 401],
|
|
26015
|
+
empty: true
|
|
26016
|
+
}, requestOptions)
|
|
26017
|
+
}
|
|
26018
|
+
};
|
|
26019
|
+
}
|
|
26020
|
+
function encodePath(value) {
|
|
26021
|
+
return value.split("/").map(encodeURIComponent).join("/");
|
|
26022
|
+
}
|
|
26023
|
+
function appendQuery(params, key, value) {
|
|
26024
|
+
if (value === void 0)
|
|
26025
|
+
return;
|
|
26026
|
+
if (value === null) {
|
|
26027
|
+
params.append(key, "null");
|
|
26028
|
+
return;
|
|
26029
|
+
}
|
|
26030
|
+
if (Array.isArray(value)) {
|
|
26031
|
+
for (const item of value)
|
|
26032
|
+
appendQuery(params, key, item);
|
|
26033
|
+
return;
|
|
26034
|
+
}
|
|
26035
|
+
if (typeof value === "object") {
|
|
26036
|
+
for (const [child, item] of Object.entries(value))
|
|
26037
|
+
appendQuery(params, `${key}[${child}]`, item);
|
|
26038
|
+
return;
|
|
26039
|
+
}
|
|
26040
|
+
params.append(key, String(value));
|
|
26041
|
+
}
|
|
26042
|
+
async function json2(response) {
|
|
26043
|
+
if (!isContentType(response, "application/json") && !response.headers.get("content-type")?.includes("+json")) {
|
|
26044
|
+
try {
|
|
26045
|
+
await response.body?.cancel();
|
|
26046
|
+
} catch {
|
|
26047
|
+
}
|
|
26048
|
+
throw new ClientError3("UnsupportedContentType", { detail: response.headers.get("content-type") });
|
|
26049
|
+
}
|
|
26050
|
+
let text;
|
|
26051
|
+
try {
|
|
26052
|
+
text = await response.text();
|
|
26053
|
+
} catch (cause) {
|
|
26054
|
+
throw new ClientError3("Transport", { cause });
|
|
26055
|
+
}
|
|
26056
|
+
if (text === "")
|
|
26057
|
+
throw new ClientError3("MalformedResponse");
|
|
26058
|
+
try {
|
|
26059
|
+
return JSON.parse(text);
|
|
26060
|
+
} catch (cause) {
|
|
26061
|
+
throw new ClientError3("MalformedResponse", { cause });
|
|
26062
|
+
}
|
|
26063
|
+
}
|
|
26064
|
+
function declared(body) {
|
|
26065
|
+
const error51 = Object.assign(new Error(body.message ?? body.data?.message), body);
|
|
26066
|
+
if (body._tag)
|
|
26067
|
+
error51.name = body._tag;
|
|
26068
|
+
return error51;
|
|
26069
|
+
}
|
|
26070
|
+
function isContentType(response, expected) {
|
|
26071
|
+
return response.headers.get("content-type")?.split(";", 1)[0]?.trim().toLowerCase() === expected;
|
|
26072
|
+
}
|
|
26073
|
+
|
|
26074
|
+
// ../../../node_modules/@opencode/client/dist/chunks/service-timing-4tveyqeh.js
|
|
26075
|
+
var isRpcError2 = (value) => typeof value === "object" && value !== null && "_tag" in value && value["_tag"] === "RpcError";
|
|
26076
|
+
var isRpcInternalError2 = (value) => typeof value === "object" && value !== null && "_tag" in value && value["_tag"] === "RpcInternalError";
|
|
26077
|
+
|
|
26078
|
+
// ../../../node_modules/@opencode/client/dist/chunks/service-timing-1tbj6z39.js
|
|
26079
|
+
function makeRpc2(raw, events) {
|
|
26080
|
+
return (definition) => {
|
|
26081
|
+
const subscribe = (name, options) => {
|
|
26082
|
+
if (!Object.hasOwn(definition.events, name))
|
|
26083
|
+
throw new Error(`Unknown RPC event: ${definition.id}.${name}`);
|
|
26084
|
+
const type = eventType(definition, name);
|
|
26085
|
+
return {
|
|
26086
|
+
[Symbol.asyncIterator]() {
|
|
26087
|
+
const controller = new AbortController();
|
|
26088
|
+
const signal = options?.signal ? AbortSignal.any([controller.signal, options.signal]) : controller.signal;
|
|
26089
|
+
const iterator = (async function* () {
|
|
26090
|
+
try {
|
|
26091
|
+
for await (const published of events.subscribe({ signal })) {
|
|
26092
|
+
if (signal.aborted)
|
|
26093
|
+
return;
|
|
26094
|
+
if (published.type !== type)
|
|
26095
|
+
continue;
|
|
26096
|
+
yield published;
|
|
26097
|
+
}
|
|
26098
|
+
} catch (error51) {
|
|
26099
|
+
if (!signal.aborted)
|
|
26100
|
+
throw error51;
|
|
26101
|
+
} finally {
|
|
26102
|
+
controller.abort();
|
|
26103
|
+
}
|
|
26104
|
+
})();
|
|
26105
|
+
return {
|
|
26106
|
+
next: () => iterator.next(),
|
|
26107
|
+
return: () => {
|
|
26108
|
+
controller.abort();
|
|
26109
|
+
return iterator.return();
|
|
26110
|
+
}
|
|
26111
|
+
};
|
|
26112
|
+
}
|
|
26113
|
+
};
|
|
26114
|
+
};
|
|
26115
|
+
return Object.assign(Object.fromEntries(Object.keys(definition.methods).map((name) => [
|
|
26116
|
+
name,
|
|
26117
|
+
async (input, options) => {
|
|
26118
|
+
try {
|
|
26119
|
+
const result = await raw.rpc.call({
|
|
26120
|
+
rpcID: definition.id,
|
|
26121
|
+
method: name,
|
|
26122
|
+
input,
|
|
26123
|
+
location: options?.location
|
|
26124
|
+
}, { signal: options?.signal, headers: options?.headers });
|
|
26125
|
+
return result.output;
|
|
26126
|
+
} catch (error51) {
|
|
26127
|
+
if (!isRpcError2(error51) && !isRpcInternalError2(error51))
|
|
26128
|
+
throw error51;
|
|
26129
|
+
throw error51.data === void 0 ? { type: error51.type, message: error51.message } : { type: error51.type, message: error51.message, data: error51.data };
|
|
26130
|
+
}
|
|
26131
|
+
}
|
|
26132
|
+
])), {
|
|
26133
|
+
events: {
|
|
26134
|
+
subscribe,
|
|
26135
|
+
on: (name, handler, options) => {
|
|
26136
|
+
const controller = new AbortController();
|
|
26137
|
+
const signal = options?.signal ? AbortSignal.any([controller.signal, options.signal]) : controller.signal;
|
|
26138
|
+
const source = subscribe(name, { signal });
|
|
26139
|
+
(async () => {
|
|
26140
|
+
for await (const event of source)
|
|
26141
|
+
await handler(event);
|
|
26142
|
+
})().catch((error51) => console.error(error51));
|
|
26143
|
+
return () => controller.abort();
|
|
26144
|
+
}
|
|
26145
|
+
}
|
|
26146
|
+
});
|
|
26147
|
+
};
|
|
26148
|
+
}
|
|
26149
|
+
function eventType(definition, name) {
|
|
26150
|
+
return `rpc.${definition.id}.${name}`;
|
|
26151
|
+
}
|
|
26152
|
+
|
|
26153
|
+
// ../../../node_modules/@opencode/client/dist/chunks/service-timing-2twkm0vy.js
|
|
26154
|
+
var exports_client3 = {};
|
|
26155
|
+
__export2(exports_client3, {
|
|
26156
|
+
OpenCode: () => exports_client3,
|
|
26157
|
+
make: () => make5
|
|
26158
|
+
});
|
|
26159
|
+
function make5(options) {
|
|
26160
|
+
const raw = make6(options);
|
|
26161
|
+
const events = make7((signal, onActivity) => raw.event.subscribe({ signal, onActivity }));
|
|
26162
|
+
return {
|
|
26163
|
+
...raw,
|
|
26164
|
+
rpc: Object.assign(makeRpc2(raw, events), raw.rpc),
|
|
26165
|
+
event: events
|
|
26166
|
+
};
|
|
26167
|
+
}
|
|
26168
|
+
|
|
26169
|
+
// dist/v2/connection.js
|
|
26170
|
+
var V2Connection = class {
|
|
26171
|
+
options;
|
|
26172
|
+
cwd;
|
|
26173
|
+
#child;
|
|
26174
|
+
#starting;
|
|
26175
|
+
#closing;
|
|
26176
|
+
#abort = new AbortController();
|
|
26177
|
+
#stderr = "";
|
|
26178
|
+
constructor(options, cwd) {
|
|
26179
|
+
this.options = options;
|
|
26180
|
+
this.cwd = cwd;
|
|
26181
|
+
}
|
|
26182
|
+
get stderrTail() {
|
|
26183
|
+
return this.#stderr;
|
|
26184
|
+
}
|
|
26185
|
+
client() {
|
|
26186
|
+
if (this.#closing)
|
|
26187
|
+
return Promise.reject(new Error("OpenCode v2 connection is closed"));
|
|
26188
|
+
return this.#starting ??= this.#start();
|
|
26189
|
+
}
|
|
26190
|
+
async #start() {
|
|
26191
|
+
const password = randomBytes2(32).toString("base64url");
|
|
26192
|
+
const env = {
|
|
26193
|
+
...this.options.environment ?? process.env,
|
|
26194
|
+
OPENCODE_PASSWORD: password,
|
|
26195
|
+
OPENCODE_SERVER_PASSWORD: password
|
|
26196
|
+
};
|
|
26197
|
+
const executable = resolveOpenCodeExecutable({
|
|
26198
|
+
...this.options.command ? { command: this.options.command } : {},
|
|
26199
|
+
environment: env
|
|
26200
|
+
});
|
|
26201
|
+
const invocation = openCodeServerInvocation(executable, env);
|
|
26202
|
+
const child = spawn2(invocation.command, invocation.arguments, {
|
|
26203
|
+
env,
|
|
26204
|
+
cwd: this.cwd,
|
|
26205
|
+
stdio: "pipe",
|
|
26206
|
+
detached: process.platform !== "win32",
|
|
26207
|
+
windowsHide: true,
|
|
26208
|
+
windowsVerbatimArguments: invocation.windowsVerbatimArguments
|
|
26209
|
+
});
|
|
26210
|
+
this.#child = child;
|
|
26211
|
+
child.stderr.on("data", (chunk) => {
|
|
26212
|
+
this.#stderr = sanitizeDiagnosticTail(this.#stderr + chunk.toString());
|
|
26213
|
+
});
|
|
26214
|
+
try {
|
|
26215
|
+
const baseUrl = await new Promise((resolve, reject) => {
|
|
26216
|
+
let output = "";
|
|
26217
|
+
const timer = setTimeout(() => finish(new Error("OpenCode v2 server startup timed out")), this.options.startupTimeoutMs ?? 2e4);
|
|
26218
|
+
const abort = () => finish(new Error("OpenCode v2 connection closed during startup"));
|
|
26219
|
+
const finish = (error51, url2) => {
|
|
26220
|
+
clearTimeout(timer);
|
|
26221
|
+
this.#abort.signal.removeEventListener("abort", abort);
|
|
26222
|
+
if (error51)
|
|
26223
|
+
reject(error51);
|
|
26224
|
+
else if (url2)
|
|
26225
|
+
resolve(url2);
|
|
26226
|
+
};
|
|
26227
|
+
this.#abort.signal.addEventListener("abort", abort, { once: true });
|
|
26228
|
+
child.once("error", (error51) => finish(error51));
|
|
26229
|
+
child.once("exit", (code, signal) => finish(new Error(`OpenCode v2 server exited (${signal ?? code})`)));
|
|
26230
|
+
child.stdout.on("data", (chunk) => {
|
|
26231
|
+
output += chunk.toString();
|
|
26232
|
+
const lines = output.split(/\r?\n/u);
|
|
26233
|
+
output = (lines.pop() ?? "").slice(-8192);
|
|
26234
|
+
for (const line of lines) {
|
|
26235
|
+
const url2 = /^server listening on (http:\/\/127\.0\.0\.1:\d+)\s*$/u.exec(line)?.[1];
|
|
26236
|
+
if (url2)
|
|
26237
|
+
finish(void 0, url2);
|
|
26238
|
+
}
|
|
26239
|
+
});
|
|
26240
|
+
});
|
|
26241
|
+
const client2 = exports_client3.make({
|
|
26242
|
+
baseUrl,
|
|
26243
|
+
headers: {
|
|
26244
|
+
Authorization: `Basic ${Buffer.from(`opencode:${password}`).toString("base64")}`
|
|
26245
|
+
},
|
|
26246
|
+
fetch: (request, init) => {
|
|
26247
|
+
const signal = AbortSignal.any([
|
|
26248
|
+
this.#abort.signal,
|
|
26249
|
+
...init?.signal ? [init.signal] : [],
|
|
26250
|
+
// Event streams keep their caller-owned lifetime; ordinary requests are bounded.
|
|
26251
|
+
...(request instanceof Request ? request.url : String(request)).includes("/event") ? [] : [AbortSignal.timeout(this.options.commandTimeoutMs ?? 2e4)]
|
|
26252
|
+
]);
|
|
26253
|
+
return fetch(request, { ...init, signal });
|
|
26254
|
+
}
|
|
26255
|
+
});
|
|
26256
|
+
const info = await client2.server.info();
|
|
26257
|
+
if (!/^2\./u.test(info.version))
|
|
26258
|
+
throw new Error(`Expected OpenCode v2 server, received ${info.version}`);
|
|
26259
|
+
return client2;
|
|
26260
|
+
} catch (error51) {
|
|
26261
|
+
await this.#stop();
|
|
26262
|
+
throw error51;
|
|
26263
|
+
}
|
|
26264
|
+
}
|
|
26265
|
+
close() {
|
|
26266
|
+
return this.#closing ??= (async () => {
|
|
26267
|
+
this.#abort.abort();
|
|
26268
|
+
await this.#stop();
|
|
26269
|
+
await this.#starting?.catch(() => void 0);
|
|
26270
|
+
})();
|
|
26271
|
+
}
|
|
26272
|
+
async #stop() {
|
|
26273
|
+
const child = this.#child;
|
|
26274
|
+
if (!child?.pid)
|
|
26275
|
+
return;
|
|
26276
|
+
const pid = child.pid;
|
|
26277
|
+
const kill = (signal) => {
|
|
26278
|
+
try {
|
|
26279
|
+
if (process.platform === "win32")
|
|
26280
|
+
spawnSync2("taskkill.exe", ["/pid", String(child.pid), "/t", "/f"], {
|
|
26281
|
+
windowsHide: true,
|
|
26282
|
+
stdio: "ignore"
|
|
26283
|
+
});
|
|
26284
|
+
else
|
|
26285
|
+
process.kill(-pid, signal);
|
|
26286
|
+
} catch {
|
|
26287
|
+
}
|
|
26288
|
+
};
|
|
26289
|
+
if (child.exitCode === null && child.signalCode === null) {
|
|
26290
|
+
await new Promise((resolve) => {
|
|
26291
|
+
const timer = setTimeout(() => {
|
|
26292
|
+
kill("SIGKILL");
|
|
26293
|
+
resolve();
|
|
26294
|
+
}, this.options.closeTimeoutMs ?? 3e3);
|
|
26295
|
+
child.once("exit", () => {
|
|
26296
|
+
clearTimeout(timer);
|
|
26297
|
+
resolve();
|
|
26298
|
+
});
|
|
26299
|
+
kill("SIGTERM");
|
|
26300
|
+
});
|
|
26301
|
+
}
|
|
26302
|
+
if (this.#child === child)
|
|
26303
|
+
this.#child = void 0;
|
|
26304
|
+
}
|
|
26305
|
+
};
|
|
26306
|
+
|
|
26307
|
+
// dist/v2/history.js
|
|
26308
|
+
import path10 from "node:path";
|
|
26309
|
+
async function readMessages(client2, sessionID) {
|
|
26310
|
+
const messages = [];
|
|
26311
|
+
let cursor;
|
|
26312
|
+
const seen = /* @__PURE__ */ new Set();
|
|
26313
|
+
do {
|
|
26314
|
+
const page = await client2.message.list({
|
|
26315
|
+
sessionID,
|
|
26316
|
+
...cursor ? { cursor } : { order: "asc", limit: 100 }
|
|
26317
|
+
});
|
|
26318
|
+
messages.push(...page.data);
|
|
26319
|
+
cursor = page.cursor.next ?? void 0;
|
|
26320
|
+
if (cursor && seen.has(cursor))
|
|
26321
|
+
throw new Error("OpenCode v2 transcript pagination did not advance");
|
|
26322
|
+
if (cursor)
|
|
26323
|
+
seen.add(cursor);
|
|
26324
|
+
} while (cursor);
|
|
26325
|
+
return messages;
|
|
26326
|
+
}
|
|
26327
|
+
var contentId = (messageID, index) => hostItemIdSchema.parse(`${messageID}:${index}`);
|
|
26328
|
+
function assistantItems2(message, limit) {
|
|
26329
|
+
return message.content.map((part, index) => {
|
|
26330
|
+
const itemId2 = contentId(message.id, index);
|
|
26331
|
+
if (part.type === "text" || part.type === "reasoning") {
|
|
26332
|
+
return {
|
|
26333
|
+
item: {
|
|
26334
|
+
type: part.type === "text" ? "agentMessage" : "reasoning",
|
|
26335
|
+
itemId: itemId2,
|
|
26336
|
+
text: part.text
|
|
26337
|
+
},
|
|
26338
|
+
outcome: message.error ? { status: "failed", error: failure(message.error.message) } : { status: "succeeded" }
|
|
26339
|
+
};
|
|
26340
|
+
}
|
|
26341
|
+
const state = part.state;
|
|
26342
|
+
const text = "content" in state ? state.content?.map((p) => p.type === "text" ? p.text : `[File: ${p.uri}]`).join("\n") : void 0;
|
|
26343
|
+
return {
|
|
26344
|
+
item: {
|
|
26345
|
+
type: "toolExecution",
|
|
26346
|
+
itemId: itemId2,
|
|
26347
|
+
toolName: part.name,
|
|
26348
|
+
namespace: "opencode",
|
|
26349
|
+
arguments: typeof state.input === "string" ? state.input : state.input,
|
|
26350
|
+
...text ? {
|
|
26351
|
+
output: {
|
|
26352
|
+
content: [{ type: "text", text: text.slice(0, limit) }],
|
|
26353
|
+
...text.length > limit ? { truncated: true } : {}
|
|
26354
|
+
}
|
|
26355
|
+
} : {}
|
|
26356
|
+
},
|
|
26357
|
+
outcome: state.status === "error" ? { status: "failed", error: failure(state.error.message) } : state.status === "completed" ? { status: "succeeded" } : { status: "cancelled", reason: "Native Tool did not complete" }
|
|
26358
|
+
};
|
|
26359
|
+
});
|
|
26360
|
+
}
|
|
26361
|
+
function projectHistory(session, messages, limit) {
|
|
26362
|
+
if (session.revert)
|
|
26363
|
+
throw new Error("Clear the staged OpenCode v2 revert before using this Session in codexhost");
|
|
26364
|
+
const turns = [];
|
|
26365
|
+
let turn;
|
|
26366
|
+
for (const message of messages) {
|
|
26367
|
+
if (message.type === "user" && turn) {
|
|
26368
|
+
turn.input.push({ type: "text", text: message.text });
|
|
26369
|
+
} else if (message.type === "user" || message.type === "compaction" && message.reason === "manual" && !turn) {
|
|
26370
|
+
turn = {
|
|
26371
|
+
nativeTurnRef: nativeTurnRefSchema.parse({
|
|
26372
|
+
harnessId,
|
|
26373
|
+
nativeSessionId: session.id,
|
|
26374
|
+
nativeTurnKey: message.id,
|
|
26375
|
+
formatVersion: 1
|
|
26376
|
+
}),
|
|
26377
|
+
input: message.type === "user" ? [{ type: "text", text: message.text }] : [],
|
|
26378
|
+
items: [],
|
|
26379
|
+
outcome: { status: "unknown", reason: "OpenCode execution has no durable terminal" },
|
|
26380
|
+
startedAtMs: message.time.created
|
|
26381
|
+
};
|
|
26382
|
+
turns.push(turn);
|
|
26383
|
+
}
|
|
26384
|
+
if (!turn)
|
|
26385
|
+
continue;
|
|
26386
|
+
if (message.type === "assistant") {
|
|
26387
|
+
turn.items.push(...assistantItems2(message, limit));
|
|
26388
|
+
turn.model = encodeOpenCodeModelRef({
|
|
26389
|
+
providerID: message.model.providerID,
|
|
26390
|
+
modelID: message.model.id
|
|
26391
|
+
});
|
|
26392
|
+
} else if (message.type === "compaction") {
|
|
26393
|
+
turn.items.push({
|
|
26394
|
+
item: { type: "contextCompaction", itemId: hostItemIdSchema.parse(message.id) },
|
|
26395
|
+
outcome: message.status === "failed" ? { status: "failed", error: failure(message.error.message) } : message.status === "completed" ? { status: "succeeded" } : { status: "cancelled", reason: "Compaction is incomplete" }
|
|
26396
|
+
});
|
|
26397
|
+
} else if (message.type === "shell") {
|
|
26398
|
+
turn.items.push({
|
|
26399
|
+
item: {
|
|
26400
|
+
type: "commandExecution",
|
|
26401
|
+
itemId: hostItemIdSchema.parse(message.id),
|
|
26402
|
+
command: message.command,
|
|
26403
|
+
...message.output ? {
|
|
26404
|
+
output: message.output.output.slice(0, limit),
|
|
26405
|
+
outputTruncated: message.output.truncated || message.output.output.length > limit
|
|
26406
|
+
} : {},
|
|
26407
|
+
...typeof message.exit === "number" ? { exitCode: message.exit } : {}
|
|
26408
|
+
},
|
|
26409
|
+
outcome: message.status === "killed" ? { status: "cancelled" } : message.exit === 0 ? { status: "succeeded" } : {
|
|
26410
|
+
status: "failed",
|
|
26411
|
+
error: failure(`Shell ${message.status}, exit ${message.exit ?? "unknown"}`)
|
|
26412
|
+
}
|
|
26413
|
+
});
|
|
26414
|
+
} else if (message.type === "idle") {
|
|
26415
|
+
turn.outcome = message.outcome === "interrupted" ? { status: "cancelled" } : message.outcome === "failed" ? { status: "failed", error: failure("OpenCode v2 execution failed") } : { status: "succeeded" };
|
|
26416
|
+
turn.completedAtMs = message.time.created;
|
|
26417
|
+
turn.checkpoint = nativeCheckpointRefSchema.parse({
|
|
26418
|
+
harnessId,
|
|
26419
|
+
nativeSessionId: session.id,
|
|
26420
|
+
checkpointId: message.id,
|
|
26421
|
+
locator: { protocol: 2, userMessageID: turn.nativeTurnRef.nativeTurnKey },
|
|
26422
|
+
formatVersion: 1
|
|
26423
|
+
});
|
|
26424
|
+
turn = void 0;
|
|
26425
|
+
}
|
|
26426
|
+
}
|
|
26427
|
+
return { turns };
|
|
26428
|
+
}
|
|
26429
|
+
function fileChanges(session, turn, diffs) {
|
|
26430
|
+
if (!diffs.length)
|
|
26431
|
+
return void 0;
|
|
26432
|
+
const changes = diffs.map((diff) => {
|
|
26433
|
+
const absolute = path10.resolve(session.location.directory, diff.file);
|
|
26434
|
+
const relative = path10.relative(session.location.directory, absolute);
|
|
26435
|
+
if (relative.startsWith(`..${path10.sep}`) || relative === ".." || path10.isAbsolute(relative))
|
|
26436
|
+
throw new Error("OpenCode v2 diff escaped the Session directory");
|
|
26437
|
+
return {
|
|
26438
|
+
path: absolute,
|
|
26439
|
+
kind: diff.status === "added" ? "add" : diff.status === "deleted" ? "delete" : "update",
|
|
26440
|
+
unifiedDiff: diff.patch
|
|
26441
|
+
};
|
|
26442
|
+
});
|
|
26443
|
+
return {
|
|
26444
|
+
item: {
|
|
26445
|
+
type: "fileChange",
|
|
26446
|
+
itemId: hostItemIdSchema.parse(`${turn.nativeTurnRef.nativeTurnKey}:diff`),
|
|
26447
|
+
changes
|
|
26448
|
+
},
|
|
26449
|
+
outcome: { status: "succeeded" }
|
|
26450
|
+
};
|
|
26451
|
+
}
|
|
26452
|
+
async function readHistory(client2, session, limit) {
|
|
26453
|
+
const messages = await readMessages(client2, session.id);
|
|
26454
|
+
const snapshot = projectHistory(session, messages, limit);
|
|
26455
|
+
for (const turn of snapshot.turns) {
|
|
26456
|
+
if (!turn.checkpoint)
|
|
26457
|
+
continue;
|
|
26458
|
+
const first = messages.findIndex((m) => m.id === turn.nativeTurnRef.nativeTurnKey);
|
|
26459
|
+
const last = messages.findIndex((m) => m.id === turn.checkpoint?.checkpointId);
|
|
26460
|
+
if (!messages.slice(first, last).some((m) => m.type === "assistant" && m.snapshot?.files?.length))
|
|
26461
|
+
continue;
|
|
26462
|
+
const diffs = await client2.session.diff({
|
|
26463
|
+
sessionID: session.id,
|
|
26464
|
+
from: turn.nativeTurnRef.nativeTurnKey
|
|
26465
|
+
});
|
|
26466
|
+
const item = fileChanges(session, turn, diffs);
|
|
26467
|
+
if (item)
|
|
26468
|
+
turn.items.push(item);
|
|
26469
|
+
}
|
|
26470
|
+
return { messages, snapshot };
|
|
26471
|
+
}
|
|
26472
|
+
function terminalItemOutcome(outcome) {
|
|
26473
|
+
return outcome.status === "unknown" ? { status: "failed", error: failure(outcome.reason, "protocolError") } : outcome;
|
|
26474
|
+
}
|
|
26475
|
+
|
|
26476
|
+
// dist/v2/interactions.js
|
|
26477
|
+
function permissionInteraction(request, turnId) {
|
|
26478
|
+
return {
|
|
26479
|
+
request,
|
|
26480
|
+
interaction: {
|
|
26481
|
+
type: "approval",
|
|
26482
|
+
interactionId: hostInteractionIdSchema.parse(`oc2-permission:${request.id}`),
|
|
26483
|
+
turnId,
|
|
26484
|
+
title: request.action,
|
|
26485
|
+
description: request.message ?? request.resources.join("\n"),
|
|
26486
|
+
subject: { type: "nativeAction" },
|
|
26487
|
+
actions: [
|
|
26488
|
+
{ id: "once", label: "Allow once", effect: "allowOnce" },
|
|
26489
|
+
{ id: "reject", label: "Deny", effect: "deny" }
|
|
26490
|
+
]
|
|
26491
|
+
}
|
|
26492
|
+
};
|
|
26493
|
+
}
|
|
26494
|
+
function formInteraction(form, turnId) {
|
|
26495
|
+
const questions = form.fields.map((field) => {
|
|
26496
|
+
if (field.type === "external" || field.hidden || field.when?.length) {
|
|
26497
|
+
throw new Error("OpenCode v2 external, hidden or conditional form fields require its native UI");
|
|
26498
|
+
}
|
|
26499
|
+
const base = {
|
|
26500
|
+
id: field.key,
|
|
26501
|
+
prompt: [field.title, field.description].filter(Boolean).join("\n") || field.key,
|
|
26502
|
+
optional: !field.required
|
|
26503
|
+
};
|
|
26504
|
+
if (field.type === "boolean")
|
|
26505
|
+
return {
|
|
26506
|
+
...base,
|
|
26507
|
+
type: "choice",
|
|
26508
|
+
multiple: false,
|
|
26509
|
+
allowOther: false,
|
|
26510
|
+
options: [
|
|
26511
|
+
{ value: "true", label: "Yes" },
|
|
26512
|
+
{ value: "false", label: "No" }
|
|
26513
|
+
]
|
|
26514
|
+
};
|
|
26515
|
+
if (field.type === "multiselect" || field.type === "string" && field.options?.length) {
|
|
26516
|
+
return {
|
|
26517
|
+
...base,
|
|
26518
|
+
type: "choice",
|
|
26519
|
+
multiple: field.type === "multiselect",
|
|
26520
|
+
allowOther: field.custom ?? false,
|
|
26521
|
+
options: field.options ?? []
|
|
26522
|
+
};
|
|
26523
|
+
}
|
|
26524
|
+
return {
|
|
26525
|
+
...base,
|
|
26526
|
+
type: "text",
|
|
26527
|
+
multiline: field.type === "string",
|
|
26528
|
+
secret: false,
|
|
26529
|
+
...field.type === "string" && field.placeholder ? { placeholder: field.placeholder } : {},
|
|
26530
|
+
...field.default !== void 0 ? { prefill: String(field.default) } : {}
|
|
26531
|
+
};
|
|
26532
|
+
});
|
|
26533
|
+
return {
|
|
26534
|
+
form,
|
|
26535
|
+
interaction: {
|
|
26536
|
+
type: "question",
|
|
26537
|
+
interactionId: hostInteractionIdSchema.parse(`oc2-form:${form.id}`),
|
|
26538
|
+
turnId,
|
|
26539
|
+
title: form.title,
|
|
26540
|
+
questions
|
|
26541
|
+
}
|
|
26542
|
+
};
|
|
26543
|
+
}
|
|
26544
|
+
async function replyInteraction(client2, pending, command) {
|
|
26545
|
+
if (pending.interaction.type === "approval" && pending.request) {
|
|
26546
|
+
if (command.response.type !== "approval")
|
|
26547
|
+
throw new Error("Expected OpenCode approval decision");
|
|
26548
|
+
const validation2 = validateHostApprovalResponse(pending.interaction, command.response);
|
|
26549
|
+
if (validation2)
|
|
26550
|
+
throw new Error(validation2.message);
|
|
26551
|
+
if (command.response.type !== "approval" || !["once", "reject"].includes(command.response.actionId))
|
|
26552
|
+
throw new Error("Invalid OpenCode approval decision");
|
|
26553
|
+
await client2.permission.reply({
|
|
26554
|
+
sessionID: pending.request.sessionID,
|
|
26555
|
+
requestID: pending.request.id,
|
|
26556
|
+
decision: command.response.actionId === "once" ? "once" : "reject"
|
|
26557
|
+
});
|
|
26558
|
+
return;
|
|
26559
|
+
}
|
|
26560
|
+
if (pending.interaction.type !== "question" || !pending.form)
|
|
26561
|
+
throw new Error("Invalid OpenCode interaction");
|
|
26562
|
+
if (command.response.type !== "question")
|
|
26563
|
+
throw new Error("Expected OpenCode form answer");
|
|
26564
|
+
const validation = validateHostQuestionResponse(pending.interaction, command.response);
|
|
26565
|
+
if (validation)
|
|
26566
|
+
throw new Error(validation.message);
|
|
26567
|
+
const form = pending.form;
|
|
26568
|
+
if (command.response.cancelled) {
|
|
26569
|
+
await client2.session.form.cancel({ sessionID: form.sessionID, formID: form.id });
|
|
26570
|
+
return;
|
|
26571
|
+
}
|
|
26572
|
+
const answer = {};
|
|
26573
|
+
for (const field of form.fields) {
|
|
26574
|
+
const values = command.response.answers[field.key] ?? [];
|
|
26575
|
+
if (!values.length)
|
|
26576
|
+
continue;
|
|
26577
|
+
const value = values[0];
|
|
26578
|
+
if (value === void 0)
|
|
26579
|
+
continue;
|
|
26580
|
+
if (field.type === "multiselect")
|
|
26581
|
+
answer[field.key] = values;
|
|
26582
|
+
else if (field.type === "boolean")
|
|
26583
|
+
answer[field.key] = value === "true";
|
|
26584
|
+
else if (field.type === "number" || field.type === "integer") {
|
|
26585
|
+
const number4 = Number(value);
|
|
26586
|
+
if (!value.trim() || !Number.isFinite(number4) || field.type === "integer" && !Number.isInteger(number4))
|
|
26587
|
+
throw new Error(`Invalid number for ${field.key}`);
|
|
26588
|
+
answer[field.key] = number4;
|
|
26589
|
+
} else
|
|
26590
|
+
answer[field.key] = value;
|
|
26591
|
+
}
|
|
26592
|
+
await client2.session.form.reply({ sessionID: form.sessionID, formID: form.id, answer });
|
|
26593
|
+
}
|
|
26594
|
+
|
|
26595
|
+
// dist/v2/session.js
|
|
26596
|
+
function v2Capabilities(catalog) {
|
|
26597
|
+
return {
|
|
26598
|
+
configuration: {
|
|
26599
|
+
selectModel: catalog.models.length > 0,
|
|
26600
|
+
selectThinkingOption: catalog.thinkingOptions.length > 1,
|
|
26601
|
+
selectPermissionMode: true,
|
|
26602
|
+
permissionModeScope: "live"
|
|
26603
|
+
},
|
|
26604
|
+
history: { fork: true, forkAcrossCwd: false, rollbackLastTurn: true }
|
|
26605
|
+
};
|
|
26606
|
+
}
|
|
26607
|
+
var V2Session = class {
|
|
26608
|
+
client;
|
|
26609
|
+
connection;
|
|
26610
|
+
info;
|
|
26611
|
+
catalog;
|
|
26612
|
+
policy;
|
|
26613
|
+
limit;
|
|
26614
|
+
onClosed;
|
|
26615
|
+
harnessId = harnessId;
|
|
26616
|
+
capabilities;
|
|
26617
|
+
initialState;
|
|
26618
|
+
initialUsage;
|
|
26619
|
+
commands;
|
|
26620
|
+
#channel = new HarnessOutputChannel();
|
|
26621
|
+
outputs = this.#channel.outputs;
|
|
26622
|
+
#abort = new AbortController();
|
|
26623
|
+
#active;
|
|
26624
|
+
#closed = false;
|
|
26625
|
+
#closePromise;
|
|
26626
|
+
#pump;
|
|
26627
|
+
#reconciling;
|
|
26628
|
+
#timer;
|
|
26629
|
+
#configuring = false;
|
|
26630
|
+
constructor(client2, connection, info, catalog, policy, limit, onClosed) {
|
|
26631
|
+
this.client = client2;
|
|
26632
|
+
this.connection = connection;
|
|
26633
|
+
this.info = info;
|
|
26634
|
+
this.catalog = catalog;
|
|
26635
|
+
this.policy = policy;
|
|
26636
|
+
this.limit = limit;
|
|
26637
|
+
this.onClosed = onClosed;
|
|
26638
|
+
this.initialState = v2State(info, catalog, policy);
|
|
26639
|
+
this.initialUsage = v2Usage(info);
|
|
26640
|
+
this.capabilities = v2Capabilities(catalog);
|
|
26641
|
+
this.commands = {
|
|
26642
|
+
list: async () => ({ ok: true, value: openCodeCommandCatalog }),
|
|
26643
|
+
execute: async (command) => {
|
|
26644
|
+
if (command.commandId !== "opencode.compact" || Object.keys(command.arguments ?? {}).length)
|
|
26645
|
+
return { ok: false, error: failure("Unsupported OpenCode command", "unsupported") };
|
|
26646
|
+
return this.#start({ type: "turn.start", turnId: command.turnId, input: [] }, true);
|
|
26647
|
+
}
|
|
26648
|
+
};
|
|
26649
|
+
}
|
|
26650
|
+
async start() {
|
|
26651
|
+
await new Promise((resolve, reject) => {
|
|
26652
|
+
const timer = setTimeout(() => reject(new Error("OpenCode v2 event subscription timed out")), this.connection.options.startupTimeoutMs ?? 2e4);
|
|
26653
|
+
this.#pump = (async () => {
|
|
26654
|
+
try {
|
|
26655
|
+
for await (const event of this.client.event.subscribe({ signal: this.#abort.signal })) {
|
|
26656
|
+
if (this.#abort.signal.aborted)
|
|
26657
|
+
break;
|
|
26658
|
+
if (event.type === "server.connected") {
|
|
26659
|
+
clearTimeout(timer);
|
|
26660
|
+
resolve();
|
|
26661
|
+
}
|
|
26662
|
+
this.#onEvent(event);
|
|
26663
|
+
}
|
|
26664
|
+
if (!this.#abort.signal.aborted)
|
|
26665
|
+
throw new Error("OpenCode v2 event stream disconnected");
|
|
26666
|
+
} catch (error51) {
|
|
26667
|
+
clearTimeout(timer);
|
|
26668
|
+
reject(error51);
|
|
26669
|
+
if (!this.#closed)
|
|
26670
|
+
await this.#fault(failure(error51 instanceof Error ? error51.message : String(error51), "processExited"));
|
|
26671
|
+
}
|
|
26672
|
+
})();
|
|
26673
|
+
});
|
|
26674
|
+
this.#timer = setInterval(() => {
|
|
26675
|
+
void this.#refresh();
|
|
26676
|
+
}, 400);
|
|
26677
|
+
}
|
|
26678
|
+
async readSnapshot() {
|
|
26679
|
+
if (this.#closed)
|
|
26680
|
+
return { ok: false, error: failure("OpenCode Session is closed", "invalidState") };
|
|
26681
|
+
if (this.#active || this.#configuring)
|
|
26682
|
+
return { ok: false, error: failure("OpenCode Session is busy", "sessionBusy") };
|
|
26683
|
+
try {
|
|
26684
|
+
this.info = await this.client.session.get({ sessionID: this.info.id });
|
|
26685
|
+
const { snapshot } = await readHistory(this.client, this.info, this.limit);
|
|
26686
|
+
return {
|
|
26687
|
+
ok: true,
|
|
26688
|
+
value: { ...snapshot, state: v2State(this.info, this.catalog, this.policy) }
|
|
26689
|
+
};
|
|
26690
|
+
} catch (error51) {
|
|
26691
|
+
return errorResult(error51);
|
|
26692
|
+
}
|
|
26693
|
+
}
|
|
26694
|
+
async execute(command) {
|
|
26695
|
+
if (this.#closed)
|
|
26696
|
+
return { ok: false, error: failure("OpenCode Session is closed", "invalidState") };
|
|
26697
|
+
if (command.type === "turn.start")
|
|
26698
|
+
return this.#start(command, false);
|
|
26699
|
+
if (command.type === "turn.cancel") {
|
|
26700
|
+
const active = this.#active;
|
|
26701
|
+
if (!active?.admitted || active.turnId !== command.turnId)
|
|
26702
|
+
return { ok: false, error: failure("No matching OpenCode Turn", "invalidState") };
|
|
26703
|
+
try {
|
|
26704
|
+
await this.client.session.interrupt({ sessionID: this.info.id, resume: false });
|
|
26705
|
+
await this.#refresh();
|
|
26706
|
+
return { ok: true, value: { cancellationRequested: true } };
|
|
26707
|
+
} catch (error51) {
|
|
26708
|
+
return errorResult(error51);
|
|
26709
|
+
}
|
|
26710
|
+
}
|
|
26711
|
+
if (command.type === "interaction.respond") {
|
|
26712
|
+
const active = this.#active;
|
|
26713
|
+
const pending = active?.interactions.get(command.interactionId);
|
|
26714
|
+
if (!active || !pending || active.replying.has(command.interactionId))
|
|
26715
|
+
return {
|
|
26716
|
+
ok: false,
|
|
26717
|
+
error: failure("OpenCode interaction is no longer pending", "invalidState")
|
|
26718
|
+
};
|
|
26719
|
+
active.replying.add(command.interactionId);
|
|
26720
|
+
try {
|
|
26721
|
+
await replyInteraction(this.client, pending, command);
|
|
26722
|
+
this.#closeInteraction(active, command.interactionId, command.response.type === "question" && command.response.cancelled ? "cancelled" : "responded");
|
|
26723
|
+
return { ok: true, value: { accepted: true } };
|
|
26724
|
+
} catch (error51) {
|
|
26725
|
+
return errorResult(error51);
|
|
26726
|
+
} finally {
|
|
26727
|
+
active.replying.delete(command.interactionId);
|
|
26728
|
+
}
|
|
26729
|
+
}
|
|
26730
|
+
if (this.#active || this.#configuring)
|
|
26731
|
+
return { ok: false, error: failure("OpenCode Session is busy", "sessionBusy") };
|
|
26732
|
+
this.#configuring = true;
|
|
26733
|
+
try {
|
|
26734
|
+
if ((await this.client.session.active())[this.info.id])
|
|
26735
|
+
throw new Error("OpenCode Session is running");
|
|
26736
|
+
if (command.type === "permissionMode.select") {
|
|
26737
|
+
await this.client.session.update({
|
|
26738
|
+
sessionID: this.info.id,
|
|
26739
|
+
permissions: v2Permissions(this.info.permissions, command.permissionModeId)
|
|
26740
|
+
});
|
|
26741
|
+
} else {
|
|
26742
|
+
let model = this.info.model;
|
|
26743
|
+
if (command.type === "model.select") {
|
|
26744
|
+
if (!this.catalog.models.some((m) => m.ref.id === command.model.id))
|
|
26745
|
+
throw new Error("OpenCode Model is not available");
|
|
26746
|
+
const decoded = decodeOpenCodeModelRef(command.model);
|
|
26747
|
+
model = { providerID: decoded.providerID, id: decoded.modelID };
|
|
26748
|
+
} else {
|
|
26749
|
+
if (!model)
|
|
26750
|
+
throw new Error("Select a Model before a Thinking option");
|
|
26751
|
+
const state = v2State(this.info, this.catalog, this.policy);
|
|
26752
|
+
if (!state.availableThinkingOptions?.some((v) => v.id === command.thinkingOptionId))
|
|
26753
|
+
throw new Error("Thinking option is unavailable for this Model");
|
|
26754
|
+
const variant = decodeOpenCodeVariant(command.thinkingOptionId);
|
|
26755
|
+
model = { providerID: model.providerID, id: model.id, ...variant ? { variant } : {} };
|
|
26756
|
+
}
|
|
26757
|
+
await this.client.session.switchModel({ sessionID: this.info.id, model });
|
|
26758
|
+
}
|
|
26759
|
+
this.info = await this.client.session.get({ sessionID: this.info.id });
|
|
26760
|
+
this.#emit({
|
|
26761
|
+
type: "session.state.changed",
|
|
26762
|
+
state: v2State(this.info, this.catalog, this.policy)
|
|
26763
|
+
});
|
|
26764
|
+
return { ok: true, value: { completed: true } };
|
|
26765
|
+
} catch (error51) {
|
|
26766
|
+
return errorResult(error51);
|
|
26767
|
+
} finally {
|
|
26768
|
+
this.#configuring = false;
|
|
26769
|
+
}
|
|
26770
|
+
}
|
|
26771
|
+
async #start(command, compact) {
|
|
26772
|
+
if (this.#closed || this.#active || this.#configuring)
|
|
26773
|
+
return {
|
|
26774
|
+
ok: false,
|
|
26775
|
+
error: failure("OpenCode Session is closed or busy", this.#closed ? "invalidState" : "sessionBusy")
|
|
26776
|
+
};
|
|
26777
|
+
const text = command.input.filter((part) => part.type === "text").map((part) => part.text).join("\n");
|
|
26778
|
+
if (!compact && !text.trim())
|
|
26779
|
+
return { ok: false, error: failure("OpenCode requires text input", "invalidRequest") };
|
|
26780
|
+
let resolve;
|
|
26781
|
+
const done = new Promise((r) => {
|
|
26782
|
+
resolve = r;
|
|
26783
|
+
});
|
|
26784
|
+
const active = {
|
|
26785
|
+
turnId: command.turnId,
|
|
26786
|
+
compact,
|
|
26787
|
+
admitted: false,
|
|
26788
|
+
baseline: /* @__PURE__ */ new Set(),
|
|
26789
|
+
live: /* @__PURE__ */ new Map(),
|
|
26790
|
+
assistants: /* @__PURE__ */ new Set(),
|
|
26791
|
+
transient: /* @__PURE__ */ new Map(),
|
|
26792
|
+
interactions: /* @__PURE__ */ new Map(),
|
|
26793
|
+
replying: /* @__PURE__ */ new Set(),
|
|
26794
|
+
settledInteractions: /* @__PURE__ */ new Set(),
|
|
26795
|
+
done,
|
|
26796
|
+
resolve
|
|
26797
|
+
};
|
|
26798
|
+
this.#active = active;
|
|
26799
|
+
let attempted = false;
|
|
26800
|
+
try {
|
|
26801
|
+
if ((await this.client.session.active())[this.info.id])
|
|
26802
|
+
throw new Error("OpenCode Session is already running");
|
|
26803
|
+
this.info = await this.client.session.get({ sessionID: this.info.id });
|
|
26804
|
+
const before = await readHistory(this.client, this.info, this.limit);
|
|
26805
|
+
if (before.snapshot.turns.some((turn) => turn.outcome.status === "unknown"))
|
|
26806
|
+
throw new Error("OpenCode history contains an incomplete execution");
|
|
26807
|
+
active.baseline = new Set(before.snapshot.turns.map((t) => t.nativeTurnRef.nativeTurnKey));
|
|
26808
|
+
attempted = true;
|
|
26809
|
+
if (compact)
|
|
26810
|
+
await this.client.session.compact({ sessionID: this.info.id });
|
|
26811
|
+
else
|
|
26812
|
+
await this.client.session.prompt({
|
|
26813
|
+
sessionID: this.info.id,
|
|
26814
|
+
text,
|
|
26815
|
+
delivery: "queue",
|
|
26816
|
+
metadata: { "codexhost.turnId": active.turnId }
|
|
26817
|
+
});
|
|
26818
|
+
if (this.#closed) {
|
|
26819
|
+
await this.client.session.interrupt({ sessionID: this.info.id, resume: false });
|
|
26820
|
+
throw new Error("OpenCode Session closed during admission");
|
|
26821
|
+
}
|
|
26822
|
+
active.admitted = true;
|
|
26823
|
+
this.#emit({ type: "turn.started", turnId: active.turnId });
|
|
26824
|
+
for (const item of active.transient.values())
|
|
26825
|
+
this.#projectItem(active, { item, outcome: { status: "succeeded" } }, false);
|
|
26826
|
+
void this.#refresh();
|
|
26827
|
+
return { ok: true, value: { turnId: active.turnId } };
|
|
26828
|
+
} catch (error51) {
|
|
26829
|
+
if (attempted)
|
|
26830
|
+
await this.client.session.interrupt({ sessionID: this.info.id, resume: false }).catch((interruptError) => this.#fault(errorResult(interruptError).error));
|
|
26831
|
+
if (this.#active === active)
|
|
26832
|
+
this.#active = void 0;
|
|
26833
|
+
active.resolve();
|
|
26834
|
+
return errorResult(error51);
|
|
26835
|
+
}
|
|
26836
|
+
}
|
|
26837
|
+
#onEvent(event) {
|
|
26838
|
+
const active = this.#active;
|
|
26839
|
+
if (!active || !("data" in event) || !("sessionID" in event.data) || event.data.sessionID !== this.info.id)
|
|
26840
|
+
return;
|
|
26841
|
+
if (event.type === "session.step.started")
|
|
26842
|
+
active.assistants.add(event.data.assistantMessageID);
|
|
26843
|
+
if ((event.type === "session.text.delta" || event.type === "session.reasoning.delta") && active.assistants.has(event.data.assistantMessageID)) {
|
|
26844
|
+
const itemId2 = contentId(event.data.assistantMessageID, event.data.ordinal);
|
|
26845
|
+
const type = event.type === "session.text.delta" ? "agentMessage" : "reasoning";
|
|
26846
|
+
const previous = active.transient.get(itemId2);
|
|
26847
|
+
const item = {
|
|
26848
|
+
type,
|
|
26849
|
+
itemId: itemId2,
|
|
26850
|
+
text: (previous?.text ?? "") + event.data.delta
|
|
26851
|
+
};
|
|
26852
|
+
active.transient.set(itemId2, item);
|
|
26853
|
+
if (active.admitted)
|
|
26854
|
+
this.#projectItem(active, { item, outcome: { status: "succeeded" } }, false);
|
|
26855
|
+
}
|
|
26856
|
+
if (!event.type.endsWith(".delta"))
|
|
26857
|
+
void this.#refresh();
|
|
26858
|
+
}
|
|
26859
|
+
#refresh() {
|
|
26860
|
+
if (this.#closed || !this.#active?.admitted)
|
|
26861
|
+
return Promise.resolve();
|
|
26862
|
+
return this.#reconciling ??= this.#reconcile().catch(async (error51) => {
|
|
26863
|
+
await this.#fault(failure(error51 instanceof Error ? error51.message : String(error51), "protocolError"));
|
|
26864
|
+
}).finally(() => {
|
|
26865
|
+
this.#reconciling = void 0;
|
|
26866
|
+
});
|
|
26867
|
+
}
|
|
26868
|
+
async #reconcile() {
|
|
26869
|
+
const active = this.#active;
|
|
26870
|
+
if (!active?.admitted)
|
|
26871
|
+
return;
|
|
26872
|
+
const info = await this.client.session.get({ sessionID: this.info.id });
|
|
26873
|
+
const { snapshot, messages } = await readHistory(this.client, info, this.limit);
|
|
26874
|
+
if (this.#active !== active || this.#closed)
|
|
26875
|
+
return;
|
|
26876
|
+
this.info = info;
|
|
26877
|
+
const turns = snapshot.turns.filter((t) => !active.baseline.has(t.nativeTurnRef.nativeTurnKey));
|
|
26878
|
+
if (turns.length > 1)
|
|
26879
|
+
throw new Error("Concurrent native prompts cannot be assigned to one Host Turn");
|
|
26880
|
+
const turn = turns[0];
|
|
26881
|
+
if (turn) {
|
|
26882
|
+
const prompt = messages.find((message) => message.id === turn.nativeTurnRef.nativeTurnKey);
|
|
26883
|
+
if (active.compact ? turn.input.length !== 0 : prompt?.type !== "user" || prompt.metadata?.["codexhost.turnId"] !== active.turnId || turn.input.length !== 1)
|
|
26884
|
+
throw new Error("Concurrent native input cannot be assigned to this Host Turn");
|
|
26885
|
+
const terminal = turn.outcome.status !== "unknown";
|
|
26886
|
+
for (const item of turn.items)
|
|
26887
|
+
this.#projectItem(active, item, terminal, turn.outcome.status === "cancelled" || turn.outcome.status === "failed");
|
|
26888
|
+
if (terminal) {
|
|
26889
|
+
if ((await this.client.session.active())[info.id])
|
|
26890
|
+
return;
|
|
26891
|
+
if (this.#active === active)
|
|
26892
|
+
this.#finish(active, turn);
|
|
26893
|
+
return;
|
|
26894
|
+
}
|
|
26895
|
+
}
|
|
26896
|
+
const [permissions, forms] = await Promise.all([
|
|
26897
|
+
this.client.permission.list({ sessionID: info.id }),
|
|
26898
|
+
this.client.session.form.list({ sessionID: info.id })
|
|
26899
|
+
]);
|
|
26900
|
+
if (this.#active !== active || this.#closed)
|
|
26901
|
+
return;
|
|
26902
|
+
const current = /* @__PURE__ */ new Map();
|
|
26903
|
+
for (const request of permissions) {
|
|
26904
|
+
const pending = permissionInteraction(request, active.turnId);
|
|
26905
|
+
current.set(pending.interaction.interactionId, pending);
|
|
26906
|
+
}
|
|
26907
|
+
for (const form of forms) {
|
|
26908
|
+
const pending = formInteraction(form, active.turnId);
|
|
26909
|
+
current.set(pending.interaction.interactionId, pending);
|
|
26910
|
+
}
|
|
26911
|
+
for (const [id, pending] of current)
|
|
26912
|
+
if (!active.interactions.has(id) && !active.settledInteractions.has(id)) {
|
|
26913
|
+
active.interactions.set(id, pending);
|
|
26914
|
+
this.#channel.emit({ kind: "interaction", interaction: pending.interaction });
|
|
26915
|
+
}
|
|
26916
|
+
for (const id of active.interactions.keys())
|
|
26917
|
+
if (!current.has(id) && !active.replying.has(id))
|
|
26918
|
+
this.#closeInteraction(active, id, "expired");
|
|
26919
|
+
}
|
|
26920
|
+
#projectItem(active, snapshot, terminal, interrupted = false) {
|
|
26921
|
+
const item = snapshot.item;
|
|
26922
|
+
const old = active.live.get(item.itemId);
|
|
26923
|
+
if (!old) {
|
|
26924
|
+
active.live.set(item.itemId, item);
|
|
26925
|
+
this.#emit({ type: "item.started", turnId: active.turnId, item });
|
|
26926
|
+
return;
|
|
26927
|
+
}
|
|
26928
|
+
if ((item.type === "agentMessage" || item.type === "reasoning") && "text" in old) {
|
|
26929
|
+
if (old.text.startsWith(item.text) && !terminal)
|
|
26930
|
+
return;
|
|
26931
|
+
if (terminal && interrupted && old.text.startsWith(item.text)) {
|
|
26932
|
+
active.live.set(item.itemId, item);
|
|
26933
|
+
return;
|
|
26934
|
+
}
|
|
26935
|
+
if (!item.text.startsWith(old.text))
|
|
26936
|
+
throw new Error("OpenCode v2 streamed text differs from durable history");
|
|
26937
|
+
const delta = item.text.slice(old.text.length);
|
|
26938
|
+
if (delta)
|
|
26939
|
+
this.#emit({
|
|
26940
|
+
type: "item.updated",
|
|
26941
|
+
turnId: active.turnId,
|
|
26942
|
+
itemId: item.itemId,
|
|
26943
|
+
update: { type: "text.append", text: delta }
|
|
26944
|
+
});
|
|
26945
|
+
} else if (item.type === "toolExecution" && item.output && JSON.stringify(item) !== JSON.stringify(old)) {
|
|
26946
|
+
this.#emit({
|
|
26947
|
+
type: "item.updated",
|
|
26948
|
+
turnId: active.turnId,
|
|
26949
|
+
itemId: item.itemId,
|
|
26950
|
+
update: { type: "output.replace", output: item.output }
|
|
26951
|
+
});
|
|
26952
|
+
}
|
|
26953
|
+
active.live.set(item.itemId, item);
|
|
26954
|
+
}
|
|
26955
|
+
#finish(active, turn) {
|
|
26956
|
+
if (this.#active !== active || turn.outcome.status === "unknown")
|
|
26957
|
+
return;
|
|
26958
|
+
for (const id of active.interactions.keys())
|
|
26959
|
+
this.#closeInteraction(active, id, "cancelled");
|
|
26960
|
+
for (const [id, item] of active.live) {
|
|
26961
|
+
const snapshot = turn.items.find((entry) => entry.item.itemId === id) ?? {
|
|
26962
|
+
item,
|
|
26963
|
+
outcome: terminalItemOutcome(turn.outcome)
|
|
26964
|
+
};
|
|
26965
|
+
this.#emit({ type: "item.completed", turnId: active.turnId, snapshot });
|
|
26966
|
+
}
|
|
26967
|
+
this.#emit({
|
|
26968
|
+
type: "session.state.changed",
|
|
26969
|
+
state: v2State(this.info, this.catalog, this.policy)
|
|
26970
|
+
});
|
|
26971
|
+
this.#emit({
|
|
26972
|
+
type: "session.usage.changed",
|
|
26973
|
+
usage: v2Usage(this.info),
|
|
26974
|
+
observedForTurnId: active.turnId
|
|
26975
|
+
});
|
|
26976
|
+
this.#active = void 0;
|
|
26977
|
+
this.#emit({
|
|
26978
|
+
type: "turn.completed",
|
|
26979
|
+
turnId: active.turnId,
|
|
26980
|
+
nativeTurnRef: turn.nativeTurnRef,
|
|
26981
|
+
outcome: { ...turn.outcome, ...turn.checkpoint ? { checkpoint: turn.checkpoint } : {} }
|
|
26982
|
+
});
|
|
26983
|
+
active.resolve();
|
|
26984
|
+
}
|
|
26985
|
+
#closeInteraction(active, id, reason) {
|
|
26986
|
+
const pending = active.interactions.get(id);
|
|
26987
|
+
if (!pending)
|
|
26988
|
+
return;
|
|
26989
|
+
active.interactions.delete(id);
|
|
26990
|
+
active.settledInteractions.add(id);
|
|
26991
|
+
this.#emit({
|
|
26992
|
+
type: "interaction.closed",
|
|
26993
|
+
interactionId: pending.interaction.interactionId,
|
|
26994
|
+
turnId: active.turnId,
|
|
26995
|
+
reason
|
|
26996
|
+
});
|
|
26997
|
+
}
|
|
26998
|
+
#emit(event) {
|
|
26999
|
+
this.#channel.emit({ kind: "event", event });
|
|
27000
|
+
}
|
|
27001
|
+
async #fault(error51) {
|
|
27002
|
+
if (this.#closed)
|
|
27003
|
+
return;
|
|
27004
|
+
this.#closed = true;
|
|
27005
|
+
if (this.#timer)
|
|
27006
|
+
clearInterval(this.#timer);
|
|
27007
|
+
this.#abort.abort();
|
|
27008
|
+
const active = this.#active;
|
|
27009
|
+
if (active?.admitted) {
|
|
27010
|
+
for (const id of active.interactions.keys())
|
|
27011
|
+
this.#closeInteraction(active, id, "cancelled");
|
|
27012
|
+
for (const item of active.live.values())
|
|
27013
|
+
this.#emit({
|
|
27014
|
+
type: "item.completed",
|
|
27015
|
+
turnId: active.turnId,
|
|
27016
|
+
snapshot: { item, outcome: { status: "failed", error: error51 } }
|
|
27017
|
+
});
|
|
27018
|
+
this.#emit({
|
|
27019
|
+
type: "turn.completed",
|
|
27020
|
+
turnId: active.turnId,
|
|
27021
|
+
outcome: { status: "failed", error: error51 }
|
|
27022
|
+
});
|
|
27023
|
+
}
|
|
27024
|
+
this.#active = void 0;
|
|
27025
|
+
active?.resolve();
|
|
27026
|
+
this.#emit({ type: "session.faulted", error: error51 });
|
|
27027
|
+
this.#channel.end();
|
|
27028
|
+
await this.client.session.interrupt({ sessionID: this.info.id, resume: false }).catch(() => void 0);
|
|
27029
|
+
await this.connection.close();
|
|
27030
|
+
this.onClosed();
|
|
27031
|
+
}
|
|
27032
|
+
close() {
|
|
27033
|
+
return this.#closePromise ??= (async () => {
|
|
27034
|
+
const active = this.#active;
|
|
27035
|
+
if (active?.admitted && !this.#closed) {
|
|
27036
|
+
await this.client.session.interrupt({ sessionID: this.info.id, resume: false }).catch(() => void 0);
|
|
27037
|
+
await this.#refresh();
|
|
27038
|
+
if (this.#active) {
|
|
27039
|
+
let timer;
|
|
27040
|
+
await Promise.race([
|
|
27041
|
+
active.done,
|
|
27042
|
+
new Promise((resolve) => {
|
|
27043
|
+
timer = setTimeout(resolve, this.connection.options.closeTimeoutMs ?? 3e3);
|
|
27044
|
+
})
|
|
27045
|
+
]).finally(() => {
|
|
27046
|
+
if (timer)
|
|
27047
|
+
clearTimeout(timer);
|
|
27048
|
+
});
|
|
27049
|
+
}
|
|
27050
|
+
if (this.#active)
|
|
27051
|
+
await this.#fault(failure("OpenCode Session closed before native completion was confirmed", "processExited"));
|
|
27052
|
+
}
|
|
27053
|
+
this.#closed = true;
|
|
27054
|
+
if (this.#timer)
|
|
27055
|
+
clearInterval(this.#timer);
|
|
27056
|
+
this.#abort.abort();
|
|
27057
|
+
await this.connection.close();
|
|
27058
|
+
await this.#pump;
|
|
27059
|
+
this.#channel.end();
|
|
27060
|
+
this.onClosed();
|
|
27061
|
+
})();
|
|
27062
|
+
}
|
|
27063
|
+
};
|
|
27064
|
+
|
|
27065
|
+
// dist/v2/adapter.js
|
|
27066
|
+
var V2Adapter = class {
|
|
27067
|
+
options;
|
|
27068
|
+
harnessId = harnessId;
|
|
27069
|
+
commandCatalog = openCodeCommandCatalog;
|
|
27070
|
+
#connections = /* @__PURE__ */ new Set();
|
|
27071
|
+
#sessions = /* @__PURE__ */ new Set();
|
|
27072
|
+
#closed = false;
|
|
27073
|
+
constructor(options) {
|
|
27074
|
+
this.options = options;
|
|
27075
|
+
}
|
|
27076
|
+
async #catalog(client2, cwd) {
|
|
27077
|
+
return readCatalog(client2, cwd, this.options.startupTimeoutMs ?? 2e4);
|
|
27078
|
+
}
|
|
27079
|
+
async inspect(input = {}) {
|
|
27080
|
+
const cwd = input.cwd ?? process.cwd();
|
|
27081
|
+
const connection = new V2Connection(this.options, cwd);
|
|
27082
|
+
this.#connections.add(connection);
|
|
27083
|
+
try {
|
|
27084
|
+
if (this.#closed)
|
|
27085
|
+
throw new Error("OpenCode Adapter is closed");
|
|
27086
|
+
const client2 = await connection.client();
|
|
27087
|
+
const catalog = await this.#catalog(client2, cwd);
|
|
27088
|
+
return {
|
|
27089
|
+
status: "ready",
|
|
27090
|
+
catalog,
|
|
27091
|
+
capabilities: v2Capabilities(catalog),
|
|
27092
|
+
permissionModes: OPENCODE_PERMISSION_MODE_CATALOG
|
|
27093
|
+
};
|
|
27094
|
+
} catch (error51) {
|
|
27095
|
+
return {
|
|
27096
|
+
status: "error",
|
|
27097
|
+
error: {
|
|
27098
|
+
...errorResult(error51).error,
|
|
27099
|
+
...connection.stderrTail ? { stderrTail: connection.stderrTail } : {}
|
|
27100
|
+
}
|
|
27101
|
+
};
|
|
27102
|
+
} finally {
|
|
27103
|
+
await connection.close();
|
|
27104
|
+
this.#connections.delete(connection);
|
|
27105
|
+
}
|
|
27106
|
+
}
|
|
27107
|
+
async open(input) {
|
|
27108
|
+
try {
|
|
27109
|
+
input = { ...input, cwd: fs6.realpathSync(input.cwd) };
|
|
27110
|
+
} catch (error51) {
|
|
27111
|
+
return errorResult(error51);
|
|
27112
|
+
}
|
|
27113
|
+
const connection = new V2Connection({
|
|
27114
|
+
...this.options,
|
|
27115
|
+
environment: { ...this.options.environment ?? process.env, ...input.environment }
|
|
27116
|
+
}, input.cwd);
|
|
27117
|
+
this.#connections.add(connection);
|
|
27118
|
+
let created;
|
|
27119
|
+
let client2;
|
|
27120
|
+
try {
|
|
27121
|
+
if (this.#closed)
|
|
27122
|
+
throw new Error("OpenCode Adapter is closed");
|
|
27123
|
+
if (!input.cwd)
|
|
27124
|
+
throw new Error("OpenCode requires a working directory");
|
|
27125
|
+
let policy = input.kind === "create" ? input.executionPolicy ?? "default" : "default";
|
|
27126
|
+
if (input.kind !== "create") {
|
|
27127
|
+
const locator = v2Locator(input.kind === "resume" ? input.nativeRef : input.sourceRef);
|
|
27128
|
+
if (!sameDirectory(locator.directory, input.cwd))
|
|
27129
|
+
throw new Error("OpenCode cannot resume or derive a Session across directories");
|
|
27130
|
+
policy = locator.executionPolicy;
|
|
27131
|
+
}
|
|
27132
|
+
client2 = await connection.client();
|
|
27133
|
+
const catalog = await this.#catalog(client2, input.cwd);
|
|
27134
|
+
let info;
|
|
27135
|
+
if (input.kind === "create") {
|
|
27136
|
+
const model = selectedModel(input, catalog);
|
|
27137
|
+
info = await client2.session.create({
|
|
27138
|
+
location: { directory: input.cwd },
|
|
27139
|
+
...model ? { model } : {},
|
|
27140
|
+
permissions: v2Permissions([], input.permissionModeId ?? harnessPermissionModeIdSchema.parse(policy === "unattended-full-access" ? "allow" : "default"))
|
|
27141
|
+
});
|
|
27142
|
+
created = info.id;
|
|
27143
|
+
} else {
|
|
27144
|
+
const ref = input.kind === "resume" ? input.nativeRef : input.sourceRef;
|
|
27145
|
+
info = await client2.session.get({ sessionID: ref.nativeSessionId });
|
|
27146
|
+
if (info.id !== ref.nativeSessionId || !sameDirectory(info.location.directory, input.cwd))
|
|
27147
|
+
throw new Error("OpenCode returned a different Native Session or directory");
|
|
27148
|
+
if ((await client2.session.active())[info.id])
|
|
27149
|
+
throw new Error("OpenCode Session is already running");
|
|
27150
|
+
const source = await readHistory(client2, info, this.options.toolOutputLimit ?? 64e3);
|
|
27151
|
+
if (source.snapshot.turns.some((turn) => turn.outcome.status === "unknown"))
|
|
27152
|
+
throw new Error("OpenCode history contains an incomplete execution");
|
|
27153
|
+
if (input.kind !== "resume") {
|
|
27154
|
+
const parent = info;
|
|
27155
|
+
const turns = source.snapshot.turns;
|
|
27156
|
+
let count;
|
|
27157
|
+
if (input.kind === "rollbackLastTurn") {
|
|
27158
|
+
if (!turns.length)
|
|
27159
|
+
throw new Error("OpenCode history is empty");
|
|
27160
|
+
count = turns.length - 1;
|
|
27161
|
+
} else {
|
|
27162
|
+
if (input.checkpoint.harnessId !== harnessId || input.checkpoint.nativeSessionId !== info.id)
|
|
27163
|
+
throw new Error("Checkpoint belongs to another Session");
|
|
27164
|
+
count = turns.findIndex((turn) => turn.checkpoint?.checkpointId === input.checkpoint.checkpointId) + 1;
|
|
27165
|
+
if (!count || JSON.stringify(turns[count - 1]?.checkpoint) !== JSON.stringify(input.checkpoint))
|
|
27166
|
+
throw new Error("OpenCode checkpoint does not match native history");
|
|
27167
|
+
}
|
|
27168
|
+
const before = turns[count]?.nativeTurnRef.nativeTurnKey;
|
|
27169
|
+
info = await client2.session.fork({ sessionID: parent.id, ...before ? { before } : {} });
|
|
27170
|
+
if (info.id === parent.id)
|
|
27171
|
+
throw new Error("OpenCode fork returned its source Session");
|
|
27172
|
+
created = info.id;
|
|
27173
|
+
if (!sameDirectory(info.location.directory, parent.location.directory))
|
|
27174
|
+
throw new Error("OpenCode fork changed directory");
|
|
27175
|
+
await client2.session.update({
|
|
27176
|
+
sessionID: info.id,
|
|
27177
|
+
permissions: parent.permissions ?? []
|
|
27178
|
+
});
|
|
27179
|
+
if (parent.model)
|
|
27180
|
+
await client2.session.switchModel({ sessionID: info.id, model: parent.model });
|
|
27181
|
+
info = await client2.session.get({ sessionID: info.id });
|
|
27182
|
+
const derived = await readHistory(client2, info, this.options.toolOutputLimit ?? 64e3);
|
|
27183
|
+
if (historyContent(derived.snapshot, false) !== historyContent({ turns: turns.slice(0, count) }, false))
|
|
27184
|
+
throw new Error("OpenCode fork did not preserve the exact history prefix");
|
|
27185
|
+
if (!isDeepStrictEqual2(info.permissions ?? [], parent.permissions ?? []) || !isDeepStrictEqual2(info.model, parent.model))
|
|
27186
|
+
throw new Error("OpenCode fork did not preserve the current configuration");
|
|
27187
|
+
const currentParent = await client2.session.get({ sessionID: parent.id });
|
|
27188
|
+
if (!isDeepStrictEqual2(currentParent.model, parent.model) || !isDeepStrictEqual2(currentParent.permissions, parent.permissions) || !sameDirectory(currentParent.location.directory, parent.location.directory))
|
|
27189
|
+
throw new Error("OpenCode source configuration changed during derivation");
|
|
27190
|
+
const unchanged = await readHistory(client2, currentParent, this.options.toolOutputLimit ?? 64e3);
|
|
27191
|
+
if (historyContent(unchanged.snapshot) !== historyContent(source.snapshot))
|
|
27192
|
+
throw new Error("OpenCode source history changed during derivation");
|
|
27193
|
+
}
|
|
27194
|
+
}
|
|
27195
|
+
if (this.#closed)
|
|
27196
|
+
throw new Error("OpenCode Adapter closed during Session open");
|
|
27197
|
+
const session = new V2Session(client2, connection, info, catalog, policy, this.options.toolOutputLimit ?? 64e3, () => {
|
|
27198
|
+
this.#sessions.delete(session);
|
|
27199
|
+
this.#connections.delete(connection);
|
|
27200
|
+
});
|
|
27201
|
+
this.#sessions.add(session);
|
|
27202
|
+
try {
|
|
27203
|
+
await session.start();
|
|
27204
|
+
} catch (error51) {
|
|
27205
|
+
await session.close();
|
|
27206
|
+
throw error51;
|
|
27207
|
+
}
|
|
27208
|
+
return { ok: true, value: session };
|
|
27209
|
+
} catch (error51) {
|
|
27210
|
+
if (created && client2)
|
|
27211
|
+
await client2.session.remove({ sessionID: created }).catch(() => void 0);
|
|
27212
|
+
await connection.close();
|
|
27213
|
+
this.#connections.delete(connection);
|
|
27214
|
+
return errorResult(error51);
|
|
27215
|
+
}
|
|
27216
|
+
}
|
|
27217
|
+
async close() {
|
|
27218
|
+
this.#closed = true;
|
|
27219
|
+
await Promise.all([...this.#sessions].map((session) => session.close()));
|
|
27220
|
+
await Promise.all([...this.#connections].map((connection) => connection.close()));
|
|
27221
|
+
this.#sessions.clear();
|
|
27222
|
+
this.#connections.clear();
|
|
27223
|
+
}
|
|
27224
|
+
};
|
|
27225
|
+
function selectedModel(input, catalog) {
|
|
27226
|
+
const selected = input.model ?? catalog.defaultModel;
|
|
27227
|
+
if (!selected) {
|
|
27228
|
+
if (input.thinkingOptionId)
|
|
27229
|
+
throw new Error("Thinking selection requires a Model");
|
|
27230
|
+
return void 0;
|
|
27231
|
+
}
|
|
27232
|
+
const entry = catalog.models.find((model2) => model2.ref.id === selected.id);
|
|
27233
|
+
if (!entry)
|
|
27234
|
+
throw new Error("OpenCode Model is not available");
|
|
27235
|
+
if (input.thinkingOptionId && !entry.supportedThinkingOptionIds?.includes(input.thinkingOptionId))
|
|
27236
|
+
throw new Error("OpenCode Thinking option is not available for this Model");
|
|
27237
|
+
const model = decodeOpenCodeModelRef(selected);
|
|
27238
|
+
const variant = input.thinkingOptionId ? decodeOpenCodeVariant(input.thinkingOptionId) : void 0;
|
|
27239
|
+
return { providerID: model.providerID, id: model.modelID, ...variant ? { variant } : {} };
|
|
27240
|
+
}
|
|
27241
|
+
function historyContent(snapshot, identities = true) {
|
|
27242
|
+
return JSON.stringify(snapshot.turns.map((turn) => ({
|
|
27243
|
+
...identities ? { key: turn.nativeTurnRef.nativeTurnKey } : {},
|
|
27244
|
+
input: turn.input,
|
|
27245
|
+
model: turn.model,
|
|
27246
|
+
checkpoint: Boolean(turn.checkpoint),
|
|
27247
|
+
items: identities ? turn.items : turn.items.map(({ item, ...rest }) => ({
|
|
27248
|
+
...rest,
|
|
27249
|
+
item: { ...item, itemId: void 0 }
|
|
27250
|
+
})),
|
|
27251
|
+
outcome: turn.outcome
|
|
27252
|
+
})));
|
|
27253
|
+
}
|
|
27254
|
+
|
|
27255
|
+
// dist/versioned-adapter.js
|
|
27256
|
+
var OpenCodeAdapter2 = class {
|
|
27257
|
+
options;
|
|
27258
|
+
dependencies;
|
|
27259
|
+
harnessId = harnessId;
|
|
27260
|
+
commandCatalog = openCodeCommandCatalog;
|
|
27261
|
+
#adapters = /* @__PURE__ */ new Set();
|
|
27262
|
+
#closed = false;
|
|
27263
|
+
constructor(options = {}, dependencies) {
|
|
27264
|
+
this.options = options;
|
|
27265
|
+
this.dependencies = dependencies;
|
|
27266
|
+
}
|
|
27267
|
+
async #select(environment, input) {
|
|
27268
|
+
if (this.#closed)
|
|
27269
|
+
throw new Error("OpenCode Adapter is closed");
|
|
27270
|
+
const options = {
|
|
27271
|
+
...this.options,
|
|
27272
|
+
environment: { ...this.options.environment ?? process.env, ...environment }
|
|
27273
|
+
};
|
|
27274
|
+
const detected = this.dependencies ? { executable: options.command, major: 1 } : await detectOpenCode(options);
|
|
27275
|
+
if (this.#closed)
|
|
27276
|
+
throw new Error("OpenCode Adapter closed during version detection");
|
|
27277
|
+
if (input && input.kind !== "create") {
|
|
27278
|
+
const ref = input.kind === "resume" ? input.nativeRef : input.sourceRef;
|
|
27279
|
+
const locator = ref.locator;
|
|
27280
|
+
const nativeMajor = locator && typeof locator === "object" && !Array.isArray(locator) && locator.protocol === 2 ? 2 : 1;
|
|
27281
|
+
if (nativeMajor !== detected.major)
|
|
27282
|
+
throw new Error(`This OpenCode Session requires v${nativeMajor}; selected CLI is v${detected.major}. Select the matching installation with CODEXHOST_OPENCODE_COMMAND. codexhost does not migrate histories.`);
|
|
27283
|
+
}
|
|
27284
|
+
const pinned = { ...options, ...detected.executable ? { command: detected.executable } : {} };
|
|
27285
|
+
const adapter = detected.major === 2 ? new V2Adapter(pinned) : new OpenCodeAdapter(pinned, this.dependencies);
|
|
27286
|
+
this.#adapters.add(adapter);
|
|
27287
|
+
return adapter;
|
|
27288
|
+
}
|
|
27289
|
+
async inspect(input = {}) {
|
|
27290
|
+
let adapter;
|
|
27291
|
+
try {
|
|
27292
|
+
adapter = await this.#select();
|
|
27293
|
+
return await adapter.inspect(input);
|
|
27294
|
+
} catch (error51) {
|
|
27295
|
+
return {
|
|
27296
|
+
status: error51 instanceof OpenCodeExecutableError ? "notInstalled" : "error",
|
|
27297
|
+
error: normalize(error51)
|
|
27298
|
+
};
|
|
27299
|
+
} finally {
|
|
27300
|
+
if (adapter) {
|
|
27301
|
+
await adapter.close();
|
|
27302
|
+
this.#adapters.delete(adapter);
|
|
27303
|
+
}
|
|
27304
|
+
}
|
|
27305
|
+
}
|
|
27306
|
+
async open(input) {
|
|
27307
|
+
let adapter;
|
|
27308
|
+
try {
|
|
27309
|
+
adapter = await this.#select(input.environment, input);
|
|
27310
|
+
const result = await adapter.open(input);
|
|
27311
|
+
if (!result.ok) {
|
|
27312
|
+
await adapter.close();
|
|
27313
|
+
this.#adapters.delete(adapter);
|
|
27314
|
+
}
|
|
27315
|
+
if (result.ok) {
|
|
27316
|
+
const owner = adapter;
|
|
27317
|
+
const close = result.value.close.bind(result.value);
|
|
27318
|
+
result.value.close = async () => {
|
|
27319
|
+
await close();
|
|
27320
|
+
this.#adapters.delete(owner);
|
|
27321
|
+
};
|
|
27322
|
+
}
|
|
27323
|
+
return result;
|
|
27324
|
+
} catch (error51) {
|
|
27325
|
+
if (adapter) {
|
|
27326
|
+
await adapter.close();
|
|
27327
|
+
this.#adapters.delete(adapter);
|
|
27328
|
+
}
|
|
27329
|
+
return { ok: false, error: normalize(error51) };
|
|
27330
|
+
}
|
|
27331
|
+
}
|
|
27332
|
+
async close() {
|
|
27333
|
+
this.#closed = true;
|
|
27334
|
+
await Promise.all([...this.#adapters].map((adapter) => adapter.close()));
|
|
27335
|
+
this.#adapters.clear();
|
|
27336
|
+
}
|
|
27337
|
+
};
|
|
27338
|
+
function normalize(error51) {
|
|
27339
|
+
return failure(error51 instanceof Error ? error51.message : String(error51), error51 instanceof OpenCodeExecutableError ? "notInstalled" : "unavailable");
|
|
27340
|
+
}
|
|
27341
|
+
|
|
27342
|
+
// dist/installation.js
|
|
27343
|
+
import { realpath as realpath2 } from "node:fs/promises";
|
|
27344
|
+
import { homedir as homedir3 } from "node:os";
|
|
27345
|
+
import path11 from "node:path";
|
|
27346
|
+
function createOpenCodeInstallation(environment, command) {
|
|
27347
|
+
let update;
|
|
27348
|
+
return createInstallationManager({
|
|
27349
|
+
async check() {
|
|
27350
|
+
const executable = resolveOpenCodeExecutable({
|
|
27351
|
+
environment,
|
|
27352
|
+
...command ? { command } : {}
|
|
27353
|
+
});
|
|
27354
|
+
const currentVersion = versionFromOutput(await runInstallationCommand(executable, ["--version"], environment));
|
|
27355
|
+
const npm = await npmInstallation(executable, ["opencode-ai"], environment);
|
|
27356
|
+
let latestVersion;
|
|
27357
|
+
let canUpdate;
|
|
27358
|
+
if (npm) {
|
|
27359
|
+
latestVersion = await npm.latest();
|
|
27360
|
+
canUpdate = npm.canUpdate;
|
|
27361
|
+
update = npm.update;
|
|
27362
|
+
} else {
|
|
27363
|
+
const release = JSON.parse(await fetchInstallationText("https://api.github.com/repos/anomalyco/opencode/releases/latest"));
|
|
27364
|
+
latestVersion = installationVersion(release.tag_name);
|
|
27365
|
+
const home = environment.HOME ?? environment.USERPROFILE ?? homedir3();
|
|
27366
|
+
const standard = path11.join(home, ".opencode", "bin", process.platform === "win32" ? "opencode.exe" : "opencode");
|
|
27367
|
+
canUpdate = process.platform !== "win32" && path11.resolve(executable) === standard && await realpath2(executable) === standard;
|
|
27368
|
+
update = async (version2) => {
|
|
27369
|
+
await runInstallationCommand(executable, ["upgrade", version2, "--method", "curl"], environment, 3e5);
|
|
27370
|
+
};
|
|
27371
|
+
}
|
|
27372
|
+
return {
|
|
27373
|
+
currentVersion,
|
|
27374
|
+
latestVersion,
|
|
27375
|
+
updateAvailable: newerInstallationVersion(currentVersion, latestVersion),
|
|
27376
|
+
canUpdate,
|
|
27377
|
+
...!canUpdate ? { message: "Use the original package manager to update this OpenCode installation." } : {}
|
|
27378
|
+
};
|
|
27379
|
+
},
|
|
27380
|
+
async update(state) {
|
|
27381
|
+
await update(state.latestVersion);
|
|
27382
|
+
}
|
|
27383
|
+
});
|
|
27384
|
+
}
|
|
27385
|
+
|
|
27386
|
+
// dist/plugin.js
|
|
27387
|
+
var OPENCODE_COMMAND_ENV = "CODEXHOST_OPENCODE_COMMAND";
|
|
27388
|
+
function createHarnessAdapter(context) {
|
|
27389
|
+
const environment = { ...context.environment };
|
|
27390
|
+
return Object.assign(new OpenCodeAdapter2({
|
|
27391
|
+
...environment[OPENCODE_COMMAND_ENV] ? { command: environment[OPENCODE_COMMAND_ENV] } : {},
|
|
27392
|
+
environment
|
|
27393
|
+
}), { installation: createOpenCodeInstallation(environment, environment[OPENCODE_COMMAND_ENV]) });
|
|
23991
27394
|
}
|
|
23992
27395
|
export {
|
|
23993
27396
|
OPENCODE_COMMAND_ENV,
|