@codexhost/cli-darwin-x64 0.10.2 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/THIRD_PARTY_NOTICES.txt +4 -0
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +17959 -0
- package/app/console-web.js +25950 -0
- package/app/desktop-controller.mjs +154 -14
- package/app/host-runtime.mjs +3176 -1070
- package/app/plugins/antigravity/plugin.mjs +345 -72
- package/app/plugins/claude-code/plugin.mjs +2153 -1465
- package/app/plugins/codebuddy/plugin.mjs +426 -93
- package/app/plugins/cursor-cli/manifest.json +1 -1
- package/app/plugins/cursor-cli/plugin.mjs +1134 -495
- package/app/plugins/deepseek-harness/plugin.mjs +604 -36
- package/app/plugins/grok/plugin.mjs +290 -78
- package/app/plugins/hermes/plugin.mjs +311 -85
- package/app/plugins/kimi-code/plugin.mjs +659 -74
- package/app/plugins/kiro-cli/plugin.mjs +227 -55
- package/app/plugins/omp/plugin.mjs +300 -45
- package/app/plugins/opencode/plugin.mjs +3600 -206
- package/app/plugins/pi/plugin.mjs +897 -275
- package/app/plugins/qoder/plugin.mjs +397 -46
- package/app/plugins/qoder-cn/plugin.mjs +404 -47
- package/app/plugins/workbuddy/plugin.mjs +116 -6
- package/app/renderer-extension.js +2303 -1200
- package/bin/codexhost +0 -0
- package/libexec/codexhost-shim +0 -0
- package/libexec/codexhost-updater +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,6 +14760,10 @@ 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().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,
|
|
@@ -14720,12 +14783,27 @@ var threadUsageInspectionSchema = external_exports.object({
|
|
|
14720
14783
|
}).strict();
|
|
14721
14784
|
|
|
14722
14785
|
// ../../shared-contracts/dist/harness-accounts.js
|
|
14723
|
-
var
|
|
14786
|
+
var accountBalanceSnapshotSchema = external_exports.object({
|
|
14787
|
+
amount: external_exports.number().finite().nonnegative(),
|
|
14788
|
+
/** ISO 4217 code as reported by the Provider, for example `CNY`. */
|
|
14789
|
+
currency: external_exports.string().trim().min(1).max(8),
|
|
14790
|
+
/** Native label when the Harness exposes several Billing Sources. */
|
|
14791
|
+
label: external_exports.string().trim().min(1).max(128).optional()
|
|
14792
|
+
}).strict();
|
|
14793
|
+
var harnessAccountSnapshotObject = external_exports.object({
|
|
14724
14794
|
email: external_exports.string().trim().min(1).max(320).optional(),
|
|
14725
14795
|
label: external_exports.string().trim().min(1).max(256).optional(),
|
|
14726
14796
|
plan: external_exports.string().trim().min(1).max(128).optional(),
|
|
14727
|
-
credits: accountCreditsSnapshotSchema
|
|
14797
|
+
credits: accountCreditsSnapshotSchema.optional(),
|
|
14798
|
+
balance: accountBalanceSnapshotSchema.optional()
|
|
14728
14799
|
}).strict();
|
|
14800
|
+
function requireReportedQuota(schema) {
|
|
14801
|
+
return schema.refine((value) => {
|
|
14802
|
+
const reported = value;
|
|
14803
|
+
return reported.credits !== void 0 || reported.balance !== void 0;
|
|
14804
|
+
}, { message: "Account must report either credits or a balance" });
|
|
14805
|
+
}
|
|
14806
|
+
var harnessAccountSnapshotSchema = requireReportedQuota(harnessAccountSnapshotObject);
|
|
14729
14807
|
var harnessAccountIdentityShape = {
|
|
14730
14808
|
harnessId: harnessIdSchema,
|
|
14731
14809
|
harnessName: external_exports.string().trim().min(1).max(128)
|
|
@@ -14736,11 +14814,13 @@ var harnessAccountSourceListResultSchema = external_exports.object({ sources: ex
|
|
|
14736
14814
|
var harnessAccountInspectParamsSchema = external_exports.object({ harnessId: harnessIdSchema, refresh: external_exports.boolean().optional() }).strict();
|
|
14737
14815
|
var harnessAccountInspectResultSchema = external_exports.object({
|
|
14738
14816
|
...harnessAccountIdentityShape,
|
|
14739
|
-
account: harnessAccountSnapshotSchema.nullable()
|
|
14817
|
+
account: harnessAccountSnapshotSchema.nullable(),
|
|
14818
|
+
/** Every Billing Source from one Harness; `account` remains the first for older clients. */
|
|
14819
|
+
accounts: external_exports.array(harnessAccountSnapshotSchema).max(8).optional()
|
|
14740
14820
|
}).strict();
|
|
14741
14821
|
var harnessAccountListParamsSchema = external_exports.object({ refresh: external_exports.boolean().optional() }).strict();
|
|
14742
14822
|
var harnessAccountListResultSchema = external_exports.object({
|
|
14743
|
-
accounts: external_exports.array(
|
|
14823
|
+
accounts: external_exports.array(requireReportedQuota(harnessAccountSnapshotObject.extend(harnessAccountIdentityShape))).max(128)
|
|
14744
14824
|
}).strict();
|
|
14745
14825
|
|
|
14746
14826
|
// ../../shared-contracts/dist/json-value.js
|
|
@@ -14878,6 +14958,8 @@ var harnessModelSchema = external_exports.object({
|
|
|
14878
14958
|
ref: harnessModelRefSchema,
|
|
14879
14959
|
label: nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH),
|
|
14880
14960
|
resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
|
|
14961
|
+
/** Optional opaque selection for this same Model with priority processing enabled. */
|
|
14962
|
+
fastModel: harnessModelRefSchema.optional(),
|
|
14881
14963
|
supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
|
|
14882
14964
|
}).strict();
|
|
14883
14965
|
var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
|
|
@@ -14910,6 +14992,16 @@ var harnessModelCatalogSchema = external_exports.object({
|
|
|
14910
14992
|
});
|
|
14911
14993
|
}
|
|
14912
14994
|
refs.add(model.ref.id);
|
|
14995
|
+
if (model.fastModel) {
|
|
14996
|
+
if (refs.has(model.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model.fastModel?.id)) {
|
|
14997
|
+
context.addIssue({
|
|
14998
|
+
code: "custom",
|
|
14999
|
+
message: "Fast Model refs must be distinct and unique",
|
|
15000
|
+
path: ["models", index, "fastModel"]
|
|
15001
|
+
});
|
|
15002
|
+
}
|
|
15003
|
+
refs.add(model.fastModel.id);
|
|
15004
|
+
}
|
|
14913
15005
|
const supportedThinkingIds = /* @__PURE__ */ new Set();
|
|
14914
15006
|
for (const [optionIndex, optionId] of (model.supportedThinkingOptionIds ?? []).entries()) {
|
|
14915
15007
|
if (supportedThinkingIds.has(optionId)) {
|
|
@@ -15029,11 +15121,13 @@ var threadThinkingSelectParamsSchema = external_exports.object({
|
|
|
15029
15121
|
thinkingOptionId: harnessThinkingOptionIdSchema
|
|
15030
15122
|
}).strict();
|
|
15031
15123
|
var threadInspectionParamsSchema = external_exports.object({
|
|
15032
|
-
threadId: hostThreadIdSchema
|
|
15124
|
+
threadId: hostThreadIdSchema,
|
|
15125
|
+
includeReferenceCapability: external_exports.boolean().optional()
|
|
15033
15126
|
}).strict();
|
|
15034
15127
|
var codexThreadInspectionSchema = external_exports.object({
|
|
15035
15128
|
owner: external_exports.literal("codex"),
|
|
15036
|
-
locked: external_exports.literal(true)
|
|
15129
|
+
locked: external_exports.literal(true),
|
|
15130
|
+
supportsThreadReferences: external_exports.literal(true).optional()
|
|
15037
15131
|
}).strict();
|
|
15038
15132
|
var externalThreadInspectionSchema = external_exports.object({
|
|
15039
15133
|
owner: external_exports.literal("external"),
|
|
@@ -15159,6 +15253,19 @@ var harnessLaunchSettingsSchema = external_exports.object({
|
|
|
15159
15253
|
restartRequired: external_exports.boolean()
|
|
15160
15254
|
}).strict();
|
|
15161
15255
|
|
|
15256
|
+
// ../../shared-contracts/dist/harness-installation.js
|
|
15257
|
+
var harnessInstallationParamsSchema = external_exports.object({
|
|
15258
|
+
harnessId: harnessIdSchema,
|
|
15259
|
+
action: external_exports.enum(["check", "update"])
|
|
15260
|
+
}).strict();
|
|
15261
|
+
var harnessInstallationStateSchema = external_exports.object({
|
|
15262
|
+
currentVersion: external_exports.string().min(1).max(128),
|
|
15263
|
+
latestVersion: external_exports.string().min(1).max(128),
|
|
15264
|
+
updateAvailable: external_exports.boolean(),
|
|
15265
|
+
canUpdate: external_exports.boolean(),
|
|
15266
|
+
message: external_exports.string().max(2048).optional()
|
|
15267
|
+
}).strict();
|
|
15268
|
+
|
|
15162
15269
|
// ../../shared-contracts/dist/codex-accounts.js
|
|
15163
15270
|
var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
|
|
15164
15271
|
var nonBlankTextSchema3 = external_exports.string().trim().min(1);
|
|
@@ -15497,8 +15604,8 @@ function validateHostQuestionResponse(interaction, response) {
|
|
|
15497
15604
|
if (!question.multiple && answers.length > 1) {
|
|
15498
15605
|
return invalidRequest2("Single-choice Question accepts at most one answer");
|
|
15499
15606
|
}
|
|
15500
|
-
const
|
|
15501
|
-
if (!question.allowOther && answers.some((answer) => !
|
|
15607
|
+
const declared2 = new Set(question.options.map(({ value }) => value));
|
|
15608
|
+
if (!question.allowOther && answers.some((answer) => !declared2.has(answer))) {
|
|
15502
15609
|
return invalidRequest2("Question Response contains an undeclared choice");
|
|
15503
15610
|
}
|
|
15504
15611
|
}
|
|
@@ -16077,8 +16184,9 @@ var OpenCodeTransportError = class extends Error {
|
|
|
16077
16184
|
import { randomBytes } from "node:crypto";
|
|
16078
16185
|
import { spawn, spawnSync } from "node:child_process";
|
|
16079
16186
|
import fs2 from "node:fs";
|
|
16080
|
-
import {
|
|
16081
|
-
import
|
|
16187
|
+
import { createServer } from "node:net";
|
|
16188
|
+
import { homedir as homedir2, tmpdir } from "node:os";
|
|
16189
|
+
import path6 from "node:path";
|
|
16082
16190
|
|
|
16083
16191
|
// ../../../node_modules/@opencode-ai/sdk/dist/v2/gen/core/serverSentEvents.gen.js
|
|
16084
16192
|
var createSseClient = ({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url: url2, ...options }) => {
|
|
@@ -16304,7 +16412,7 @@ var serializeObjectParam = ({ allowReserved, explode, name, style, value, valueO
|
|
|
16304
16412
|
|
|
16305
16413
|
// ../../../node_modules/@opencode-ai/sdk/dist/v2/gen/core/utils.gen.js
|
|
16306
16414
|
var PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
16307
|
-
var defaultPathSerializer = ({ path:
|
|
16415
|
+
var defaultPathSerializer = ({ path: path12, url: _url2 }) => {
|
|
16308
16416
|
let url2 = _url2;
|
|
16309
16417
|
const matches = _url2.match(PATH_PARAM_RE);
|
|
16310
16418
|
if (matches) {
|
|
@@ -16323,7 +16431,7 @@ var defaultPathSerializer = ({ path: path7, url: _url2 }) => {
|
|
|
16323
16431
|
name = name.substring(1);
|
|
16324
16432
|
style = "matrix";
|
|
16325
16433
|
}
|
|
16326
|
-
const value =
|
|
16434
|
+
const value = path12[name];
|
|
16327
16435
|
if (value === void 0 || value === null) {
|
|
16328
16436
|
continue;
|
|
16329
16437
|
}
|
|
@@ -16354,11 +16462,11 @@ var defaultPathSerializer = ({ path: path7, url: _url2 }) => {
|
|
|
16354
16462
|
}
|
|
16355
16463
|
return url2;
|
|
16356
16464
|
};
|
|
16357
|
-
var getUrl = ({ baseUrl, path:
|
|
16465
|
+
var getUrl = ({ baseUrl, path: path12, query, querySerializer, url: _url2 }) => {
|
|
16358
16466
|
const pathUrl = _url2.startsWith("/") ? _url2 : `/${_url2}`;
|
|
16359
16467
|
let url2 = (baseUrl ?? "") + pathUrl;
|
|
16360
|
-
if (
|
|
16361
|
-
url2 = defaultPathSerializer({ path:
|
|
16468
|
+
if (path12) {
|
|
16469
|
+
url2 = defaultPathSerializer({ path: path12, url: url2 });
|
|
16362
16470
|
}
|
|
16363
16471
|
let search = query ? querySerializer(query) : "";
|
|
16364
16472
|
if (search.startsWith("?")) {
|
|
@@ -21481,7 +21589,7 @@ function createOpencodeClient(config2) {
|
|
|
21481
21589
|
}
|
|
21482
21590
|
|
|
21483
21591
|
// dist/command.js
|
|
21484
|
-
import
|
|
21592
|
+
import path5 from "node:path";
|
|
21485
21593
|
|
|
21486
21594
|
// ../../harness-discovery/dist/environment.js
|
|
21487
21595
|
import fs from "node:fs";
|
|
@@ -21545,6 +21653,20 @@ function commandInvocation(command, arguments_, environment, platform = process.
|
|
|
21545
21653
|
};
|
|
21546
21654
|
}
|
|
21547
21655
|
|
|
21656
|
+
// ../../harness-discovery/dist/node-runtime.js
|
|
21657
|
+
import path3 from "node:path";
|
|
21658
|
+
function withNodeRuntimeOnPath(environment, runtimeExecutable = process.execPath, platform = process.platform) {
|
|
21659
|
+
const pathKey = Object.keys(environment).find((name) => name.toLowerCase() === "path") ?? "PATH";
|
|
21660
|
+
const delimiter = platform === "win32" ? ";" : ":";
|
|
21661
|
+
const runtimeDirectory = path3.dirname(runtimeExecutable);
|
|
21662
|
+
const directories = (environment[pathKey] ?? "").split(delimiter).filter(Boolean);
|
|
21663
|
+
const equal = platform === "win32" ? (value) => value.toLowerCase() : (value) => value;
|
|
21664
|
+
if (!directories.some((directory) => equal(directory) === equal(runtimeDirectory))) {
|
|
21665
|
+
directories.push(runtimeDirectory);
|
|
21666
|
+
}
|
|
21667
|
+
return { ...environment, [pathKey]: directories.join(delimiter) };
|
|
21668
|
+
}
|
|
21669
|
+
|
|
21548
21670
|
// ../../harness-discovery/dist/resolve.js
|
|
21549
21671
|
import os from "node:os";
|
|
21550
21672
|
|
|
@@ -21708,6 +21830,195 @@ function resolveHarnessExecutable(spec, input, dependencies = {}) {
|
|
|
21708
21830
|
return void 0;
|
|
21709
21831
|
}
|
|
21710
21832
|
|
|
21833
|
+
// ../../harness-discovery/dist/installation.js
|
|
21834
|
+
import { execFile } from "node:child_process";
|
|
21835
|
+
import { homedir } from "node:os";
|
|
21836
|
+
function runInstallationCommand(command, args, environment, timeout = 3e4) {
|
|
21837
|
+
const env = withNodeRuntimeOnPath(environment);
|
|
21838
|
+
const invocation = /\.[cm]?js$/i.test(command) ? commandInvocation(process.execPath, [command, ...args], env) : commandInvocation(command, args, env);
|
|
21839
|
+
return new Promise((resolve, reject) => {
|
|
21840
|
+
const child = execFile(invocation.command, invocation.arguments, {
|
|
21841
|
+
env,
|
|
21842
|
+
cwd: env.HOME ?? env.USERPROFILE ?? homedir(),
|
|
21843
|
+
encoding: "utf8",
|
|
21844
|
+
timeout,
|
|
21845
|
+
killSignal: "SIGKILL",
|
|
21846
|
+
maxBuffer: 1024 * 1024,
|
|
21847
|
+
windowsHide: true,
|
|
21848
|
+
windowsVerbatimArguments: invocation.windowsVerbatimArguments
|
|
21849
|
+
}, (error51, stdout, stderr) => {
|
|
21850
|
+
if (error51)
|
|
21851
|
+
reject(new Error(error51.killed ? "Harness command timed out" : "Harness command failed; check the native installation and retry"));
|
|
21852
|
+
else
|
|
21853
|
+
resolve((stdout || stderr).trim());
|
|
21854
|
+
});
|
|
21855
|
+
child.stdin?.end();
|
|
21856
|
+
});
|
|
21857
|
+
}
|
|
21858
|
+
function installationVersion(value) {
|
|
21859
|
+
if (typeof value !== "string" || !/^v?\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?$/.test(value.trim()))
|
|
21860
|
+
throw new Error("Harness returned an invalid version");
|
|
21861
|
+
return value.trim().replace(/^v/, "");
|
|
21862
|
+
}
|
|
21863
|
+
function versionFromOutput(output) {
|
|
21864
|
+
return installationVersion(output.match(/\b\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?\b/)?.[0]);
|
|
21865
|
+
}
|
|
21866
|
+
function newerInstallationVersion(current, latest) {
|
|
21867
|
+
const a = installationVersion(current).replace(/\+.*/, "");
|
|
21868
|
+
const b = installationVersion(latest).replace(/\+.*/, "");
|
|
21869
|
+
const coreA = a.replace(/-.*/, "").split(".").map(BigInt);
|
|
21870
|
+
const coreB = b.replace(/-.*/, "").split(".").map(BigInt);
|
|
21871
|
+
for (let i = 0; i < Math.max(coreA.length, coreB.length); i++) {
|
|
21872
|
+
if ((coreA[i] ?? 0n) !== (coreB[i] ?? 0n))
|
|
21873
|
+
return (coreB[i] ?? 0n) > (coreA[i] ?? 0n);
|
|
21874
|
+
}
|
|
21875
|
+
const preA = a.includes("-") ? a.slice(a.indexOf("-") + 1).split(".") : [];
|
|
21876
|
+
const preB = b.includes("-") ? b.slice(b.indexOf("-") + 1).split(".") : [];
|
|
21877
|
+
if (!preA.length || !preB.length)
|
|
21878
|
+
return !!preA.length && !preB.length;
|
|
21879
|
+
for (let i = 0; i < Math.max(preA.length, preB.length); i++) {
|
|
21880
|
+
const x = preA[i];
|
|
21881
|
+
const y = preB[i];
|
|
21882
|
+
if (x === y)
|
|
21883
|
+
continue;
|
|
21884
|
+
if (x === void 0 || y === void 0)
|
|
21885
|
+
return x === void 0;
|
|
21886
|
+
const numericX = /^\d+$/.test(x);
|
|
21887
|
+
const numericY = /^\d+$/.test(y);
|
|
21888
|
+
if (numericX && numericY) {
|
|
21889
|
+
if (BigInt(x) === BigInt(y))
|
|
21890
|
+
continue;
|
|
21891
|
+
return BigInt(y) > BigInt(x);
|
|
21892
|
+
}
|
|
21893
|
+
if (numericX !== numericY)
|
|
21894
|
+
return numericX;
|
|
21895
|
+
return y > x;
|
|
21896
|
+
}
|
|
21897
|
+
return false;
|
|
21898
|
+
}
|
|
21899
|
+
function createInstallationManager(options) {
|
|
21900
|
+
let checking;
|
|
21901
|
+
let updating;
|
|
21902
|
+
const check2 = () => checking ??= options.check().finally(() => {
|
|
21903
|
+
checking = void 0;
|
|
21904
|
+
});
|
|
21905
|
+
return (action) => {
|
|
21906
|
+
if (updating)
|
|
21907
|
+
return updating;
|
|
21908
|
+
if (action === "check")
|
|
21909
|
+
return check2();
|
|
21910
|
+
updating = (async () => {
|
|
21911
|
+
const before = await check2();
|
|
21912
|
+
if (!before.updateAvailable)
|
|
21913
|
+
return before;
|
|
21914
|
+
if (!before.canUpdate)
|
|
21915
|
+
throw new Error(before.message ?? "This installation cannot be updated automatically");
|
|
21916
|
+
await options.update(before);
|
|
21917
|
+
const after = await check2();
|
|
21918
|
+
if (after.currentVersion === before.currentVersion)
|
|
21919
|
+
throw new Error("The Harness version did not change; check the native updater and retry");
|
|
21920
|
+
return after;
|
|
21921
|
+
})().finally(() => {
|
|
21922
|
+
updating = void 0;
|
|
21923
|
+
});
|
|
21924
|
+
return updating;
|
|
21925
|
+
};
|
|
21926
|
+
}
|
|
21927
|
+
async function fetchInstallationText(url2) {
|
|
21928
|
+
const request = async () => {
|
|
21929
|
+
const response = await fetch(url2, { signal: AbortSignal.timeout(15e3) });
|
|
21930
|
+
if (!response.ok)
|
|
21931
|
+
throw new Error("Could not check the latest Harness version");
|
|
21932
|
+
return response.text();
|
|
21933
|
+
};
|
|
21934
|
+
try {
|
|
21935
|
+
return await request();
|
|
21936
|
+
} catch (error51) {
|
|
21937
|
+
if (error51 instanceof DOMException && (error51.name === "AbortError" || error51.name === "TimeoutError"))
|
|
21938
|
+
throw error51;
|
|
21939
|
+
return request();
|
|
21940
|
+
}
|
|
21941
|
+
}
|
|
21942
|
+
|
|
21943
|
+
// ../../harness-discovery/dist/npm-installation.js
|
|
21944
|
+
import { readFile, realpath } from "node:fs/promises";
|
|
21945
|
+
import path4 from "node:path";
|
|
21946
|
+
function referencesNpmBin(shim, name, bin) {
|
|
21947
|
+
if (bin.includes(".."))
|
|
21948
|
+
return false;
|
|
21949
|
+
const target = `node_modules/${name}/${bin.replace(/^\.\//, "")}`.toLowerCase();
|
|
21950
|
+
const text = shim.replaceAll("\\", "/").toLowerCase();
|
|
21951
|
+
return text.includes(`%dp0%/${target}"`) || text.includes(`%~dp0/${target}"`);
|
|
21952
|
+
}
|
|
21953
|
+
async function npmInstallation(command, packages, environment) {
|
|
21954
|
+
let selected = await realpath(command);
|
|
21955
|
+
if (process.platform === "win32" && /\.(cmd|bat)$/i.test(selected)) {
|
|
21956
|
+
const shim = (await readFile(selected, "utf8")).replaceAll("\\", "/");
|
|
21957
|
+
const root = path4.dirname(selected);
|
|
21958
|
+
for (const name of packages) {
|
|
21959
|
+
const directory2 = path4.join(root, "node_modules", ...name.split("/"));
|
|
21960
|
+
const metadata = await readFile(path4.join(directory2, "package.json"), "utf8").then((text) => JSON.parse(text)).catch(() => null);
|
|
21961
|
+
const bins = typeof metadata?.bin === "string" ? [metadata.bin] : Object.values(metadata?.bin ?? {});
|
|
21962
|
+
const bin = bins.find((entry) => referencesNpmBin(shim, name, entry));
|
|
21963
|
+
if (bin) {
|
|
21964
|
+
selected = await realpath(path4.join(directory2, bin));
|
|
21965
|
+
break;
|
|
21966
|
+
}
|
|
21967
|
+
}
|
|
21968
|
+
}
|
|
21969
|
+
let directory = path4.dirname(selected);
|
|
21970
|
+
for (let depth = 0; depth < 8; depth++) {
|
|
21971
|
+
const metadata = await readFile(path4.join(directory, "package.json"), "utf8").then((text) => JSON.parse(text)).catch(() => null);
|
|
21972
|
+
if (metadata?.name && packages.includes(metadata.name)) {
|
|
21973
|
+
const name = metadata.name;
|
|
21974
|
+
const currentVersion = installationVersion(metadata.version);
|
|
21975
|
+
const segments = name.split("/");
|
|
21976
|
+
let modules = directory;
|
|
21977
|
+
for (let index = 0; index < segments.length; index++)
|
|
21978
|
+
modules = path4.dirname(modules);
|
|
21979
|
+
const prefix = process.platform === "win32" ? path4.dirname(modules) : path4.dirname(path4.dirname(modules));
|
|
21980
|
+
const globalRoot = process.platform === "win32" ? path4.join(prefix, "node_modules") : path4.join(prefix, "lib", "node_modules");
|
|
21981
|
+
const env = withNodeRuntimeOnPath(environment);
|
|
21982
|
+
const npm = resolveHarnessExecutable({ id: "npm", command: "npm", installRoots: { posix: [], windows: [] } }, { environment: env });
|
|
21983
|
+
let globalInstall = modules === globalRoot;
|
|
21984
|
+
if (process.platform === "win32") {
|
|
21985
|
+
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);
|
|
21986
|
+
const bins = typeof metadata.bin === "string" ? { [name.split("/").at(-1) ?? name]: metadata.bin } : metadata.bin ?? {};
|
|
21987
|
+
const launchers = await Promise.all(Object.entries(bins).map(async ([bin, entry]) => {
|
|
21988
|
+
if (path4.basename(bin) !== bin || entry.includes(".."))
|
|
21989
|
+
return false;
|
|
21990
|
+
const target = await realpath(path4.join(directory, entry)).catch(() => "");
|
|
21991
|
+
if (target.toLowerCase() !== selected.toLowerCase())
|
|
21992
|
+
return false;
|
|
21993
|
+
const shim = await readFile(path4.join(prefix, `${bin}.cmd`), "utf8").catch(() => "");
|
|
21994
|
+
return referencesNpmBin(shim, name, entry);
|
|
21995
|
+
}));
|
|
21996
|
+
globalInstall = globalInstall && !project && launchers.some(Boolean);
|
|
21997
|
+
}
|
|
21998
|
+
const canUpdate = globalInstall && !!npm;
|
|
21999
|
+
return {
|
|
22000
|
+
prefix,
|
|
22001
|
+
currentVersion,
|
|
22002
|
+
canUpdate,
|
|
22003
|
+
latest: async () => {
|
|
22004
|
+
const data = JSON.parse(await fetchInstallationText(`https://registry.npmjs.org/${encodeURIComponent(name)}/latest`));
|
|
22005
|
+
return installationVersion(data.version);
|
|
22006
|
+
},
|
|
22007
|
+
update: async (version2) => {
|
|
22008
|
+
if (!canUpdate || !npm)
|
|
22009
|
+
throw new Error("Use the original package manager to update this installation");
|
|
22010
|
+
await runInstallationCommand(npm.executable, ["install", "--global", "--prefix", prefix, `${name}@${installationVersion(version2)}`], env, 3e5);
|
|
22011
|
+
}
|
|
22012
|
+
};
|
|
22013
|
+
}
|
|
22014
|
+
const parent = path4.dirname(directory);
|
|
22015
|
+
if (parent === directory)
|
|
22016
|
+
break;
|
|
22017
|
+
directory = parent;
|
|
22018
|
+
}
|
|
22019
|
+
return null;
|
|
22020
|
+
}
|
|
22021
|
+
|
|
21711
22022
|
// dist/command.js
|
|
21712
22023
|
var OpenCodeExecutableError = class extends Error {
|
|
21713
22024
|
code = "OPENCODE_NOT_FOUND";
|
|
@@ -21742,16 +22053,34 @@ function resolveOpenCodeExecutable(input = {}, dependencies = {}) {
|
|
|
21742
22053
|
}, dependencies);
|
|
21743
22054
|
if (!resolution)
|
|
21744
22055
|
throw new OpenCodeExecutableError();
|
|
21745
|
-
return targetPath(platform).isAbsolute(resolution.executable) ? resolution.executable :
|
|
22056
|
+
return targetPath(platform).isAbsolute(resolution.executable) ? resolution.executable : path5.resolve(resolution.executable);
|
|
21746
22057
|
}
|
|
21747
|
-
function openCodeServerInvocation(executable, environment, platform = process.platform) {
|
|
21748
|
-
return commandInvocation(executable, ["serve", "--hostname=127.0.0.1",
|
|
22058
|
+
function openCodeServerInvocation(executable, environment, platform = process.platform, port = 0) {
|
|
22059
|
+
return commandInvocation(executable, ["serve", "--hostname=127.0.0.1", `--port=${port}`], environment, platform);
|
|
21749
22060
|
}
|
|
21750
22061
|
|
|
21751
22062
|
// dist/server-connection.js
|
|
21752
22063
|
var DEFAULT_STARTUP_TIMEOUT_MS = 2e4;
|
|
21753
22064
|
var DEFAULT_CLOSE_TIMEOUT_MS = 3e3;
|
|
22065
|
+
var STARTUP_ATTEMPTS = 3;
|
|
21754
22066
|
var SERVER_USERNAME = "codexhost";
|
|
22067
|
+
function freeLoopbackPort() {
|
|
22068
|
+
return new Promise((resolve, reject) => {
|
|
22069
|
+
const probe = createServer();
|
|
22070
|
+
probe.unref();
|
|
22071
|
+
probe.once("error", reject);
|
|
22072
|
+
probe.listen({ host: "127.0.0.1", port: 0 }, () => {
|
|
22073
|
+
const address = probe.address();
|
|
22074
|
+
const port = typeof address === "object" && address ? address.port : 0;
|
|
22075
|
+
probe.close(() => {
|
|
22076
|
+
if (port)
|
|
22077
|
+
resolve(port);
|
|
22078
|
+
else
|
|
22079
|
+
reject(new Error("Failed to assign an OpenCode Server loopback port"));
|
|
22080
|
+
});
|
|
22081
|
+
});
|
|
22082
|
+
});
|
|
22083
|
+
}
|
|
21755
22084
|
function isRecord2(value) {
|
|
21756
22085
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
21757
22086
|
}
|
|
@@ -21819,9 +22148,9 @@ function signalProcessTree(child, signal) {
|
|
|
21819
22148
|
}
|
|
21820
22149
|
}
|
|
21821
22150
|
function safeOpenCodeServerCwd(environment) {
|
|
21822
|
-
const candidates = [environment.USERPROFILE, environment.HOME,
|
|
22151
|
+
const candidates = [environment.USERPROFILE, environment.HOME, homedir2(), tmpdir()];
|
|
21823
22152
|
for (const candidate of candidates) {
|
|
21824
|
-
if (!candidate || !
|
|
22153
|
+
if (!candidate || !path6.isAbsolute(candidate))
|
|
21825
22154
|
continue;
|
|
21826
22155
|
try {
|
|
21827
22156
|
if (!fs2.statSync(candidate).isDirectory())
|
|
@@ -21873,7 +22202,8 @@ var OpenCodeServerConnection = class {
|
|
|
21873
22202
|
...spawnOptions,
|
|
21874
22203
|
windowsVerbatimArguments: spawnOptions.windowsVerbatimArguments
|
|
21875
22204
|
}),
|
|
21876
|
-
sleep: (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds))
|
|
22205
|
+
sleep: (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds)),
|
|
22206
|
+
assignPort: freeLoopbackPort
|
|
21877
22207
|
}) {
|
|
21878
22208
|
this.#options = options;
|
|
21879
22209
|
this.#environment = options.environment ?? process.env;
|
|
@@ -21929,11 +22259,26 @@ var OpenCodeServerConnection = class {
|
|
|
21929
22259
|
OPENCODE_SERVER_USERNAME: SERVER_USERNAME,
|
|
21930
22260
|
OPENCODE_SERVER_PASSWORD: password
|
|
21931
22261
|
};
|
|
21932
|
-
const invocation = openCodeServerInvocation(executable, environment);
|
|
21933
22262
|
const serverCwd = (this.#dependencies.resolveServerCwd ?? safeOpenCodeServerCwd)(environment);
|
|
21934
22263
|
if (!serverCwd) {
|
|
21935
22264
|
throw new OpenCodeTransportError("unavailable", "OpenCode Server requires a writable startup directory");
|
|
21936
22265
|
}
|
|
22266
|
+
let lastError;
|
|
22267
|
+
for (let attempt = 0; attempt < STARTUP_ATTEMPTS; attempt += 1) {
|
|
22268
|
+
try {
|
|
22269
|
+
return await this.#startAttempt(executable, environment, serverCwd, password);
|
|
22270
|
+
} catch (error51) {
|
|
22271
|
+
lastError = error51;
|
|
22272
|
+
if (!(error51 instanceof OpenCodeTransportError) || error51.code !== "processExited") {
|
|
22273
|
+
throw classifySdkError(error51, "Server startup");
|
|
22274
|
+
}
|
|
22275
|
+
}
|
|
22276
|
+
}
|
|
22277
|
+
throw classifySdkError(lastError, "Server startup");
|
|
22278
|
+
}
|
|
22279
|
+
async #startAttempt(executable, environment, serverCwd, password) {
|
|
22280
|
+
const port = await (this.#dependencies.assignPort ?? freeLoopbackPort)();
|
|
22281
|
+
const invocation = openCodeServerInvocation(executable, environment, process.platform, port);
|
|
21937
22282
|
let child;
|
|
21938
22283
|
try {
|
|
21939
22284
|
child = this.#dependencies.spawn(invocation.command, invocation.arguments, {
|
|
@@ -21994,7 +22339,7 @@ var OpenCodeServerConnection = class {
|
|
|
21994
22339
|
return { baseUrl, authorization };
|
|
21995
22340
|
} catch (error51) {
|
|
21996
22341
|
await this.#stopChild(child).catch(() => void 0);
|
|
21997
|
-
throw
|
|
22342
|
+
throw error51;
|
|
21998
22343
|
}
|
|
21999
22344
|
}
|
|
22000
22345
|
async #stopChild(child) {
|
|
@@ -22254,7 +22599,7 @@ var SdkOpenCodeTransport = class {
|
|
|
22254
22599
|
|
|
22255
22600
|
// dist/file-change-verification.js
|
|
22256
22601
|
import fs3 from "node:fs";
|
|
22257
|
-
import
|
|
22602
|
+
import path7 from "node:path";
|
|
22258
22603
|
function missingPath(error51) {
|
|
22259
22604
|
if (!error51 || typeof error51 !== "object")
|
|
22260
22605
|
return false;
|
|
@@ -22266,33 +22611,33 @@ function hasDotPathSegment(value) {
|
|
|
22266
22611
|
return segments.some((segment) => segment === "." || segment === "..");
|
|
22267
22612
|
}
|
|
22268
22613
|
function canonicalDirectoryPath(value) {
|
|
22269
|
-
let candidate =
|
|
22614
|
+
let candidate = path7.resolve(value);
|
|
22270
22615
|
const missingSegments = [];
|
|
22271
22616
|
for (; ; ) {
|
|
22272
22617
|
try {
|
|
22273
|
-
return
|
|
22618
|
+
return path7.join(fs3.realpathSync.native(candidate), ...missingSegments);
|
|
22274
22619
|
} catch (error51) {
|
|
22275
22620
|
if (!missingPath(error51))
|
|
22276
22621
|
return void 0;
|
|
22277
|
-
const parent =
|
|
22622
|
+
const parent = path7.dirname(candidate);
|
|
22278
22623
|
if (parent === candidate)
|
|
22279
22624
|
return void 0;
|
|
22280
|
-
missingSegments.unshift(
|
|
22625
|
+
missingSegments.unshift(path7.basename(candidate));
|
|
22281
22626
|
candidate = parent;
|
|
22282
22627
|
}
|
|
22283
22628
|
}
|
|
22284
22629
|
}
|
|
22285
22630
|
function canonicalFilePath(value) {
|
|
22286
|
-
const absolute =
|
|
22287
|
-
const parent = canonicalDirectoryPath(
|
|
22288
|
-
return parent ?
|
|
22631
|
+
const absolute = path7.resolve(value);
|
|
22632
|
+
const parent = canonicalDirectoryPath(path7.dirname(absolute));
|
|
22633
|
+
return parent ? path7.join(parent, path7.basename(absolute)) : void 0;
|
|
22289
22634
|
}
|
|
22290
22635
|
function pathIsWithin(root, candidate, allowRoot) {
|
|
22291
|
-
const relative =
|
|
22292
|
-
return allowRoot && relative === "" || relative !== "" && relative !== ".." && !relative.startsWith(`..${
|
|
22636
|
+
const relative = path7.relative(root, candidate);
|
|
22637
|
+
return allowRoot && relative === "" || relative !== "" && relative !== ".." && !relative.startsWith(`..${path7.sep}`) && !path7.isAbsolute(relative);
|
|
22293
22638
|
}
|
|
22294
22639
|
function verifiedOpenCodeWorktree(sessionDirectory, paths) {
|
|
22295
|
-
if (!paths || typeof paths !== "object" || typeof sessionDirectory !== "string" || typeof paths.directory !== "string" || typeof paths.worktree !== "string" || hasDotPathSegment(sessionDirectory) || hasDotPathSegment(paths.directory) || hasDotPathSegment(paths.worktree) || !
|
|
22640
|
+
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)) {
|
|
22296
22641
|
return void 0;
|
|
22297
22642
|
}
|
|
22298
22643
|
const session = canonicalDirectoryPath(sessionDirectory);
|
|
@@ -22304,10 +22649,10 @@ function verifiedOpenCodeWorktree(sessionDirectory, paths) {
|
|
|
22304
22649
|
return worktree;
|
|
22305
22650
|
}
|
|
22306
22651
|
function openCodeFileIdentity(file2, worktree) {
|
|
22307
|
-
if (typeof file2 !== "string" || typeof worktree !== "string" || hasDotPathSegment(file2) || hasDotPathSegment(worktree) || !
|
|
22652
|
+
if (typeof file2 !== "string" || typeof worktree !== "string" || hasDotPathSegment(file2) || hasDotPathSegment(worktree) || !path7.isAbsolute(worktree) || !file2 || file2.includes("\0") || file2.includes("\n") || file2.includes("\r")) {
|
|
22308
22653
|
return void 0;
|
|
22309
22654
|
}
|
|
22310
|
-
const candidate = canonicalFilePath(
|
|
22655
|
+
const candidate = canonicalFilePath(path7.isAbsolute(file2) ? file2 : path7.resolve(worktree, file2));
|
|
22311
22656
|
return candidate && pathIsWithin(worktree, candidate, false) ? candidate : void 0;
|
|
22312
22657
|
}
|
|
22313
22658
|
|
|
@@ -22489,6 +22834,11 @@ function semanticHistory(snapshot) {
|
|
|
22489
22834
|
items: turn.items.map(({ item, outcome }) => {
|
|
22490
22835
|
const { itemId: _itemId, ...content } = item;
|
|
22491
22836
|
void _itemId;
|
|
22837
|
+
if (content.type === "fileChange") {
|
|
22838
|
+
const { sourceItemIds: _sourceItemIds, ...change } = content;
|
|
22839
|
+
void _sourceItemIds;
|
|
22840
|
+
return { item: change, outcome };
|
|
22841
|
+
}
|
|
22492
22842
|
return { item: content, outcome };
|
|
22493
22843
|
}),
|
|
22494
22844
|
outcome: turn.outcome,
|
|
@@ -22597,7 +22947,7 @@ function sameCwd(left, right) {
|
|
|
22597
22947
|
try {
|
|
22598
22948
|
return fs4.realpathSync.native(value);
|
|
22599
22949
|
} catch {
|
|
22600
|
-
return
|
|
22950
|
+
return path8.resolve(value);
|
|
22601
22951
|
}
|
|
22602
22952
|
};
|
|
22603
22953
|
return canonical(left) === canonical(right);
|
|
@@ -23946,14 +24296,3058 @@ var OpenCodeAdapter = class {
|
|
|
23946
24296
|
}
|
|
23947
24297
|
};
|
|
23948
24298
|
|
|
23949
|
-
// dist/
|
|
23950
|
-
|
|
23951
|
-
|
|
23952
|
-
|
|
23953
|
-
|
|
23954
|
-
|
|
24299
|
+
// dist/version.js
|
|
24300
|
+
import { execFile as execFile2 } from "node:child_process";
|
|
24301
|
+
import { promisify } from "node:util";
|
|
24302
|
+
function openCodeMajor(version2) {
|
|
24303
|
+
const match = /^(?:opencode\s+)?v?([12])\.\d+\.\d+(?:[-+][\w.-]+)?$/u.exec(version2.trim());
|
|
24304
|
+
if (!match)
|
|
24305
|
+
throw new Error(`Unsupported OpenCode version: ${version2.trim().slice(0, 100)}`);
|
|
24306
|
+
return match[1] === "1" ? 1 : 2;
|
|
24307
|
+
}
|
|
24308
|
+
async function detectOpenCode(options) {
|
|
24309
|
+
const environment = options.environment ?? process.env;
|
|
24310
|
+
const executable = resolveOpenCodeExecutable({
|
|
24311
|
+
...options.command ? { command: options.command } : {},
|
|
23955
24312
|
environment
|
|
23956
24313
|
});
|
|
24314
|
+
const invocation = commandInvocation(executable, ["--version"], environment);
|
|
24315
|
+
const { stdout } = await promisify(execFile2)(invocation.command, invocation.arguments, {
|
|
24316
|
+
env: environment,
|
|
24317
|
+
timeout: options.startupTimeoutMs ?? 2e4,
|
|
24318
|
+
maxBuffer: 16384,
|
|
24319
|
+
windowsHide: true,
|
|
24320
|
+
windowsVerbatimArguments: invocation.windowsVerbatimArguments
|
|
24321
|
+
});
|
|
24322
|
+
return { executable, major: openCodeMajor(stdout) };
|
|
24323
|
+
}
|
|
24324
|
+
|
|
24325
|
+
// dist/v2/adapter.js
|
|
24326
|
+
import fs6 from "node:fs";
|
|
24327
|
+
import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
|
|
24328
|
+
|
|
24329
|
+
// dist/v2/state.js
|
|
24330
|
+
import fs5 from "node:fs";
|
|
24331
|
+
import path9 from "node:path";
|
|
24332
|
+
var harnessId = harnessIdSchema.parse("opencode");
|
|
24333
|
+
function failure(message, code = "nativeFailure") {
|
|
24334
|
+
return {
|
|
24335
|
+
code,
|
|
24336
|
+
message,
|
|
24337
|
+
retryable: ["nativeFailure", "unavailable", "sessionBusy"].includes(code)
|
|
24338
|
+
};
|
|
24339
|
+
}
|
|
24340
|
+
function errorResult(error51) {
|
|
24341
|
+
return {
|
|
24342
|
+
ok: false,
|
|
24343
|
+
error: failure(error51 instanceof Error ? error51.message : String(error51))
|
|
24344
|
+
};
|
|
24345
|
+
}
|
|
24346
|
+
function sameDirectory(left, right) {
|
|
24347
|
+
const canonical = (value) => {
|
|
24348
|
+
try {
|
|
24349
|
+
return fs5.realpathSync(value);
|
|
24350
|
+
} catch {
|
|
24351
|
+
return path9.resolve(value);
|
|
24352
|
+
}
|
|
24353
|
+
};
|
|
24354
|
+
return canonical(left) === canonical(right);
|
|
24355
|
+
}
|
|
24356
|
+
function v2Ref(session, executionPolicy) {
|
|
24357
|
+
return nativeSessionRefSchema.parse({
|
|
24358
|
+
harnessId,
|
|
24359
|
+
nativeSessionId: session.id,
|
|
24360
|
+
formatVersion: 1,
|
|
24361
|
+
locator: { protocol: 2, directory: session.location.directory, executionPolicy }
|
|
24362
|
+
});
|
|
24363
|
+
}
|
|
24364
|
+
function v2Locator(ref) {
|
|
24365
|
+
nativeSessionRefSchema.parse(ref);
|
|
24366
|
+
const locator = ref.locator;
|
|
24367
|
+
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") {
|
|
24368
|
+
throw new Error("This Session requires an OpenCode v2 Native Ref; v1 histories are not migrated by codexhost");
|
|
24369
|
+
}
|
|
24370
|
+
return { directory: locator.directory, executionPolicy: locator.executionPolicy };
|
|
24371
|
+
}
|
|
24372
|
+
function v2Catalog(models, defaultModel) {
|
|
24373
|
+
const enabled = models.filter((model) => model.enabled);
|
|
24374
|
+
const variants = [...new Set(enabled.flatMap((model) => model.variants.map((v) => v.id)))].sort();
|
|
24375
|
+
const ref = (model) => encodeOpenCodeModelRef({ providerID: model.providerID, modelID: model.id });
|
|
24376
|
+
return harnessModelCatalogSchema.parse({
|
|
24377
|
+
models: enabled.map((model) => ({
|
|
24378
|
+
ref: ref(model),
|
|
24379
|
+
label: `${model.providerID} / ${model.name}`,
|
|
24380
|
+
resolvedModelLabel: `${model.providerID}/${model.id}`,
|
|
24381
|
+
supportedThinkingOptionIds: [
|
|
24382
|
+
encodeOpenCodeVariant(void 0),
|
|
24383
|
+
...model.variants.map((v) => encodeOpenCodeVariant(v.id))
|
|
24384
|
+
]
|
|
24385
|
+
})),
|
|
24386
|
+
...defaultModel && enabled.some((m) => ref(m).id === ref(defaultModel).id) ? { defaultModel: ref(defaultModel) } : {},
|
|
24387
|
+
thinkingOptions: [void 0, ...variants].map((v) => ({
|
|
24388
|
+
id: encodeOpenCodeVariant(v),
|
|
24389
|
+
label: v ?? "Default"
|
|
24390
|
+
})),
|
|
24391
|
+
defaultThinkingOptionId: encodeOpenCodeVariant(void 0)
|
|
24392
|
+
});
|
|
24393
|
+
}
|
|
24394
|
+
function v2Permissions(current = [], mode) {
|
|
24395
|
+
const selected = decodeOpenCodePermissionModeId(mode);
|
|
24396
|
+
const rules = current.filter((rule) => !(rule.action === "*" && rule.resource === "*" && ["allow", "ask"].includes(rule.effect)));
|
|
24397
|
+
return selected === "default" ? rules : [...rules, { action: "*", resource: "*", effect: selected }];
|
|
24398
|
+
}
|
|
24399
|
+
function v2State(session, catalog, policy) {
|
|
24400
|
+
const model = session.model ? encodeOpenCodeModelRef({ providerID: session.model.providerID, modelID: session.model.id }) : void 0;
|
|
24401
|
+
const entry = catalog.models.find((candidate) => candidate.ref.id === model?.id);
|
|
24402
|
+
const mode = session.permissions?.findLast((rule) => rule.action === "*" && rule.resource === "*");
|
|
24403
|
+
return {
|
|
24404
|
+
nativeRef: v2Ref(session, policy),
|
|
24405
|
+
...model ? { effectiveModel: model } : {},
|
|
24406
|
+
...entry ? {
|
|
24407
|
+
resolvedModelLabel: entry.resolvedModelLabel ?? entry.label,
|
|
24408
|
+
availableThinkingOptions: catalog.thinkingOptions.filter((v) => entry.supportedThinkingOptionIds?.includes(v.id)),
|
|
24409
|
+
effectiveThinkingOptionId: encodeOpenCodeVariant(session.model?.variant)
|
|
24410
|
+
} : {},
|
|
24411
|
+
effectivePermissionModeId: decodeMode(mode?.effect)
|
|
24412
|
+
};
|
|
24413
|
+
}
|
|
24414
|
+
function decodeMode(effect) {
|
|
24415
|
+
return effect === "allow" || effect === "ask" ? harnessPermissionModeIdSchema.parse(effect) : harnessPermissionModeIdSchema.parse("default");
|
|
24416
|
+
}
|
|
24417
|
+
function v2Usage(session) {
|
|
24418
|
+
const tokens = session.tokens;
|
|
24419
|
+
return parseHostUsage({
|
|
24420
|
+
inputTokens: tokens.input,
|
|
24421
|
+
outputTokens: tokens.output,
|
|
24422
|
+
reasoningOutputTokens: tokens.reasoning,
|
|
24423
|
+
cachedInputTokens: tokens.cache.read,
|
|
24424
|
+
cacheWriteInputTokens: tokens.cache.write,
|
|
24425
|
+
totalCostUsd: session.cost
|
|
24426
|
+
});
|
|
24427
|
+
}
|
|
24428
|
+
|
|
24429
|
+
// dist/v2/catalog.js
|
|
24430
|
+
async function readCatalog(client2, cwd, timeoutMs) {
|
|
24431
|
+
const location = { directory: cwd };
|
|
24432
|
+
const deadline = Date.now() + timeoutMs;
|
|
24433
|
+
const required2 = ["opencode.config.provider", "opencode.config.agent", "opencode.config.policy"];
|
|
24434
|
+
while (true) {
|
|
24435
|
+
const { data: plugins } = await client2.plugin.list({ location });
|
|
24436
|
+
const config2 = required2.map((id) => plugins.find((plugin) => plugin.id === id));
|
|
24437
|
+
const failed = config2.find((plugin) => plugin?.state.status === "failed");
|
|
24438
|
+
if (failed?.state.status === "failed")
|
|
24439
|
+
throw new Error(`OpenCode configuration failed: ${failed.state.error}`);
|
|
24440
|
+
if (config2.every((plugin) => plugin?.state.status === "active"))
|
|
24441
|
+
break;
|
|
24442
|
+
if (Date.now() >= deadline)
|
|
24443
|
+
throw new Error("OpenCode v2 configuration plugins did not become ready");
|
|
24444
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
24445
|
+
}
|
|
24446
|
+
const [models, selected] = await Promise.all([
|
|
24447
|
+
client2.model.list({ location }),
|
|
24448
|
+
client2.model.default({ location })
|
|
24449
|
+
]);
|
|
24450
|
+
return v2Catalog(models.data, selected.data);
|
|
24451
|
+
}
|
|
24452
|
+
|
|
24453
|
+
// dist/v2/connection.js
|
|
24454
|
+
import { spawn as spawn2, spawnSync as spawnSync2 } from "node:child_process";
|
|
24455
|
+
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
24456
|
+
|
|
24457
|
+
// ../../../node_modules/@opencode/client/dist/chunks/service-timing-9rqn6x4v.js
|
|
24458
|
+
var __defProp2 = Object.defineProperty;
|
|
24459
|
+
var __returnValue = (v) => v;
|
|
24460
|
+
function __exportSetter(name, newValue) {
|
|
24461
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
24462
|
+
}
|
|
24463
|
+
var __export2 = (target, all) => {
|
|
24464
|
+
for (var name in all)
|
|
24465
|
+
__defProp2(target, name, {
|
|
24466
|
+
get: all[name],
|
|
24467
|
+
enumerable: true,
|
|
24468
|
+
configurable: true,
|
|
24469
|
+
set: __exportSetter.bind(all, name)
|
|
24470
|
+
});
|
|
24471
|
+
};
|
|
24472
|
+
|
|
24473
|
+
// ../../../node_modules/@opencode/client/dist/chunks/service-timing-frbwqjmf.js
|
|
24474
|
+
var exports_shared_events = {};
|
|
24475
|
+
__export2(exports_shared_events, {
|
|
24476
|
+
SharedEvents: () => exports_shared_events,
|
|
24477
|
+
make: () => make7
|
|
24478
|
+
});
|
|
24479
|
+
function make7(connect) {
|
|
24480
|
+
let current;
|
|
24481
|
+
const capacity = 4096;
|
|
24482
|
+
function stop(connection) {
|
|
24483
|
+
connection.connected = void 0;
|
|
24484
|
+
connection.controller.abort();
|
|
24485
|
+
if (current === connection)
|
|
24486
|
+
current = void 0;
|
|
24487
|
+
}
|
|
24488
|
+
async function run(connection) {
|
|
24489
|
+
let iterator;
|
|
24490
|
+
let completion = {};
|
|
24491
|
+
try {
|
|
24492
|
+
if (connection.controller.signal.aborted)
|
|
24493
|
+
return;
|
|
24494
|
+
iterator = connect(connection.controller.signal, () => {
|
|
24495
|
+
connection.subscribers.forEach((subscriber) => subscriber.activity?.());
|
|
24496
|
+
})[Symbol.asyncIterator]();
|
|
24497
|
+
while (!connection.controller.signal.aborted) {
|
|
24498
|
+
const item = await iterator.next();
|
|
24499
|
+
if (item.done || connection.controller.signal.aborted)
|
|
24500
|
+
break;
|
|
24501
|
+
if (item.value.type === "server.connected")
|
|
24502
|
+
connection.connected = item.value;
|
|
24503
|
+
connection.subscribers.forEach((subscriber) => subscriber.push(item.value));
|
|
24504
|
+
}
|
|
24505
|
+
} catch (error51) {
|
|
24506
|
+
completion = { error: error51 };
|
|
24507
|
+
} finally {
|
|
24508
|
+
stop(connection);
|
|
24509
|
+
try {
|
|
24510
|
+
await iterator?.return?.();
|
|
24511
|
+
} catch (error51) {
|
|
24512
|
+
if (!("error" in completion))
|
|
24513
|
+
completion = { error: error51 };
|
|
24514
|
+
}
|
|
24515
|
+
connection.subscribers.forEach((subscriber) => subscriber.finish(completion));
|
|
24516
|
+
}
|
|
24517
|
+
}
|
|
24518
|
+
return {
|
|
24519
|
+
subscribe(options) {
|
|
24520
|
+
return {
|
|
24521
|
+
[Symbol.asyncIterator]() {
|
|
24522
|
+
const pending = [];
|
|
24523
|
+
const queued = [];
|
|
24524
|
+
let started = false;
|
|
24525
|
+
let completion;
|
|
24526
|
+
let connection;
|
|
24527
|
+
function finish(result, discard = true) {
|
|
24528
|
+
completion = result;
|
|
24529
|
+
if (discard)
|
|
24530
|
+
queued.length = 0;
|
|
24531
|
+
options?.signal?.removeEventListener("abort", abort);
|
|
24532
|
+
if (connection?.subscribers.delete(subscriber) && !connection.subscribers.size)
|
|
24533
|
+
stop(connection);
|
|
24534
|
+
pending.splice(0).forEach((request) => {
|
|
24535
|
+
if ("error" in result)
|
|
24536
|
+
request.reject(result.error);
|
|
24537
|
+
else
|
|
24538
|
+
request.resolve({ done: true, value: void 0 });
|
|
24539
|
+
});
|
|
24540
|
+
}
|
|
24541
|
+
function abort() {
|
|
24542
|
+
finish({});
|
|
24543
|
+
}
|
|
24544
|
+
const subscriber = {
|
|
24545
|
+
activity: options?.onActivity,
|
|
24546
|
+
finish(result) {
|
|
24547
|
+
finish(result, false);
|
|
24548
|
+
},
|
|
24549
|
+
push(value) {
|
|
24550
|
+
if (completion)
|
|
24551
|
+
return;
|
|
24552
|
+
const request = pending.shift();
|
|
24553
|
+
if (request) {
|
|
24554
|
+
request.resolve({ done: false, value });
|
|
24555
|
+
return;
|
|
24556
|
+
}
|
|
24557
|
+
if (queued.length === capacity) {
|
|
24558
|
+
finish({ error: new Error(`Event subscriber exceeded its ${capacity}-event capacity`) });
|
|
24559
|
+
return;
|
|
24560
|
+
}
|
|
24561
|
+
queued.push(value);
|
|
24562
|
+
}
|
|
24563
|
+
};
|
|
24564
|
+
function start() {
|
|
24565
|
+
if (completion)
|
|
24566
|
+
return;
|
|
24567
|
+
const fresh = !current;
|
|
24568
|
+
connection = current ?? {
|
|
24569
|
+
controller: new AbortController(),
|
|
24570
|
+
subscribers: /* @__PURE__ */ new Set()
|
|
24571
|
+
};
|
|
24572
|
+
current = connection;
|
|
24573
|
+
connection.subscribers.add(subscriber);
|
|
24574
|
+
if (connection.connected)
|
|
24575
|
+
subscriber.push(connection.connected);
|
|
24576
|
+
if (fresh)
|
|
24577
|
+
run(connection);
|
|
24578
|
+
}
|
|
24579
|
+
return {
|
|
24580
|
+
next() {
|
|
24581
|
+
const value = queued.shift();
|
|
24582
|
+
if (value)
|
|
24583
|
+
return Promise.resolve({ done: false, value });
|
|
24584
|
+
if (completion) {
|
|
24585
|
+
if ("error" in completion)
|
|
24586
|
+
return Promise.reject(completion.error);
|
|
24587
|
+
return Promise.resolve({ done: true, value: void 0 });
|
|
24588
|
+
}
|
|
24589
|
+
if (options?.signal?.aborted) {
|
|
24590
|
+
abort();
|
|
24591
|
+
return Promise.resolve({ done: true, value: void 0 });
|
|
24592
|
+
}
|
|
24593
|
+
const request = Promise.withResolvers();
|
|
24594
|
+
pending.push(request);
|
|
24595
|
+
if (!started) {
|
|
24596
|
+
started = true;
|
|
24597
|
+
options?.signal?.addEventListener("abort", abort, { once: true });
|
|
24598
|
+
start();
|
|
24599
|
+
}
|
|
24600
|
+
return request.promise;
|
|
24601
|
+
},
|
|
24602
|
+
return() {
|
|
24603
|
+
finish({});
|
|
24604
|
+
return Promise.resolve({ done: true, value: void 0 });
|
|
24605
|
+
}
|
|
24606
|
+
};
|
|
24607
|
+
}
|
|
24608
|
+
};
|
|
24609
|
+
}
|
|
24610
|
+
};
|
|
24611
|
+
}
|
|
24612
|
+
|
|
24613
|
+
// ../../../node_modules/@opencode/client/dist/chunks/service-timing-nwcpakzx.js
|
|
24614
|
+
var ClientError3 = class extends Error {
|
|
24615
|
+
reason;
|
|
24616
|
+
name = "ClientError";
|
|
24617
|
+
constructor(reason, options) {
|
|
24618
|
+
const detail = options?.detail ?? (options?.cause instanceof Error ? options.cause.message : void 0);
|
|
24619
|
+
super(detail ? `${reason}: ${detail}` : reason, options);
|
|
24620
|
+
this.reason = reason;
|
|
24621
|
+
}
|
|
24622
|
+
};
|
|
24623
|
+
|
|
24624
|
+
// ../../../node_modules/@opencode/client/dist/chunks/service-timing-bpdjd9xk.js
|
|
24625
|
+
var exports_client4 = {};
|
|
24626
|
+
__export2(exports_client4, {
|
|
24627
|
+
make: () => make6
|
|
24628
|
+
});
|
|
24629
|
+
var maxSseEventBytes = 16 * 1024 * 1024;
|
|
24630
|
+
function make6(options) {
|
|
24631
|
+
const fetch2 = options.fetch ?? globalThis.fetch;
|
|
24632
|
+
const prepare = (descriptor, requestOptions) => {
|
|
24633
|
+
const baseUrl = new URL(options.baseUrl);
|
|
24634
|
+
if (!baseUrl.pathname.endsWith("/"))
|
|
24635
|
+
baseUrl.pathname += "/";
|
|
24636
|
+
const url2 = new URL(descriptor.path.slice(1), baseUrl);
|
|
24637
|
+
for (const [key, value] of Object.entries(descriptor.query ?? {}))
|
|
24638
|
+
appendQuery(url2.searchParams, key, value);
|
|
24639
|
+
const headers = new Headers(options.headers);
|
|
24640
|
+
for (const [key, value] of Object.entries(descriptor.headers ?? {})) {
|
|
24641
|
+
if (value !== void 0 && value !== null)
|
|
24642
|
+
headers.set(key, String(value));
|
|
24643
|
+
}
|
|
24644
|
+
for (const [key, value] of new Headers(requestOptions?.headers))
|
|
24645
|
+
headers.set(key, value);
|
|
24646
|
+
if (descriptor.body !== void 0 && !headers.has("content-type"))
|
|
24647
|
+
headers.set("content-type", descriptor.binaryBody ? "application/octet-stream" : "application/json");
|
|
24648
|
+
return {
|
|
24649
|
+
url: url2,
|
|
24650
|
+
init: {
|
|
24651
|
+
method: descriptor.method,
|
|
24652
|
+
signal: requestOptions?.signal,
|
|
24653
|
+
headers,
|
|
24654
|
+
body: descriptor.body === void 0 ? void 0 : descriptor.binaryBody ? descriptor.body : JSON.stringify(descriptor.body)
|
|
24655
|
+
}
|
|
24656
|
+
};
|
|
24657
|
+
};
|
|
24658
|
+
const execute = async (descriptor, requestOptions) => {
|
|
24659
|
+
try {
|
|
24660
|
+
const prepared = prepare(descriptor, requestOptions);
|
|
24661
|
+
return await fetch2(prepared.url, prepared.init);
|
|
24662
|
+
} catch (cause) {
|
|
24663
|
+
throw new ClientError3("Transport", { cause });
|
|
24664
|
+
}
|
|
24665
|
+
};
|
|
24666
|
+
const responseError = async (response, descriptor) => {
|
|
24667
|
+
if (descriptor.declaredStatuses.includes(response.status))
|
|
24668
|
+
throw declared(await json2(response));
|
|
24669
|
+
try {
|
|
24670
|
+
await response.body?.cancel();
|
|
24671
|
+
} catch {
|
|
24672
|
+
}
|
|
24673
|
+
throw new ClientError3("UnexpectedStatus", { cause: { status: response.status }, detail: String(response.status) });
|
|
24674
|
+
};
|
|
24675
|
+
const request = async (descriptor, requestOptions) => {
|
|
24676
|
+
const response = await execute(descriptor, requestOptions);
|
|
24677
|
+
if (response.status !== descriptor.successStatus)
|
|
24678
|
+
return responseError(response, descriptor);
|
|
24679
|
+
if (descriptor.binary)
|
|
24680
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
24681
|
+
if (descriptor.empty) {
|
|
24682
|
+
try {
|
|
24683
|
+
await response.body?.cancel();
|
|
24684
|
+
} catch {
|
|
24685
|
+
}
|
|
24686
|
+
return;
|
|
24687
|
+
}
|
|
24688
|
+
return await json2(response);
|
|
24689
|
+
};
|
|
24690
|
+
const sse = (descriptor, requestOptions) => ({
|
|
24691
|
+
async *[Symbol.asyncIterator]() {
|
|
24692
|
+
const response = await execute(descriptor, requestOptions);
|
|
24693
|
+
if (response.status !== descriptor.successStatus)
|
|
24694
|
+
await responseError(response, descriptor);
|
|
24695
|
+
if (!isContentType(response, "text/event-stream")) {
|
|
24696
|
+
try {
|
|
24697
|
+
await response.body?.cancel();
|
|
24698
|
+
} catch {
|
|
24699
|
+
}
|
|
24700
|
+
throw new ClientError3("UnsupportedContentType", { detail: response.headers.get("content-type") });
|
|
24701
|
+
}
|
|
24702
|
+
if (response.body === null)
|
|
24703
|
+
throw new ClientError3("MalformedResponse");
|
|
24704
|
+
const reader = response.body.getReader();
|
|
24705
|
+
const decoder = new TextDecoder();
|
|
24706
|
+
let buffer = "";
|
|
24707
|
+
try {
|
|
24708
|
+
while (true) {
|
|
24709
|
+
let next;
|
|
24710
|
+
try {
|
|
24711
|
+
next = await reader.read();
|
|
24712
|
+
} catch (cause) {
|
|
24713
|
+
throw new ClientError3("Transport", { cause });
|
|
24714
|
+
}
|
|
24715
|
+
if (!next.done)
|
|
24716
|
+
requestOptions?.onActivity?.();
|
|
24717
|
+
buffer += decoder.decode(next.value, { stream: !next.done });
|
|
24718
|
+
if (buffer.length > maxSseEventBytes)
|
|
24719
|
+
throw new ClientError3("SseEventTooLarge");
|
|
24720
|
+
const trailingCarriageReturn = !next.done && buffer.endsWith("\r");
|
|
24721
|
+
if (trailingCarriageReturn)
|
|
24722
|
+
buffer = buffer.slice(0, -1);
|
|
24723
|
+
buffer = buffer.replaceAll(`\r
|
|
24724
|
+
`, `
|
|
24725
|
+
`).replaceAll("\r", `
|
|
24726
|
+
`);
|
|
24727
|
+
if (trailingCarriageReturn)
|
|
24728
|
+
buffer += "\r";
|
|
24729
|
+
if (next.done && buffer !== "")
|
|
24730
|
+
buffer += `
|
|
24731
|
+
|
|
24732
|
+
`;
|
|
24733
|
+
let boundary = buffer.indexOf(`
|
|
24734
|
+
|
|
24735
|
+
`);
|
|
24736
|
+
while (boundary >= 0) {
|
|
24737
|
+
const block = buffer.slice(0, boundary);
|
|
24738
|
+
buffer = buffer.slice(boundary + 2);
|
|
24739
|
+
const data = block.split(`
|
|
24740
|
+
`).flatMap((line) => line.startsWith("data:") ? [line.slice(5).trimStart()] : []).join(`
|
|
24741
|
+
`);
|
|
24742
|
+
if (data !== "") {
|
|
24743
|
+
try {
|
|
24744
|
+
yield JSON.parse(data);
|
|
24745
|
+
} catch (cause) {
|
|
24746
|
+
throw new ClientError3("MalformedResponse", { cause });
|
|
24747
|
+
}
|
|
24748
|
+
}
|
|
24749
|
+
boundary = buffer.indexOf(`
|
|
24750
|
+
|
|
24751
|
+
`);
|
|
24752
|
+
}
|
|
24753
|
+
if (next.done)
|
|
24754
|
+
return;
|
|
24755
|
+
}
|
|
24756
|
+
} finally {
|
|
24757
|
+
try {
|
|
24758
|
+
await reader.cancel();
|
|
24759
|
+
} catch {
|
|
24760
|
+
}
|
|
24761
|
+
reader.releaseLock();
|
|
24762
|
+
}
|
|
24763
|
+
}
|
|
24764
|
+
});
|
|
24765
|
+
return {
|
|
24766
|
+
server: {
|
|
24767
|
+
info: (requestOptions) => request({ method: "GET", path: `/api/info`, successStatus: 200, declaredStatuses: [400, 401], empty: false }, requestOptions)
|
|
24768
|
+
},
|
|
24769
|
+
location: {
|
|
24770
|
+
get: (input, requestOptions) => request({
|
|
24771
|
+
method: "GET",
|
|
24772
|
+
path: `/api/location`,
|
|
24773
|
+
query: { location: input?.["location"] },
|
|
24774
|
+
successStatus: 200,
|
|
24775
|
+
declaredStatuses: [400, 401],
|
|
24776
|
+
empty: false
|
|
24777
|
+
}, requestOptions),
|
|
24778
|
+
reload: (requestOptions) => request({
|
|
24779
|
+
method: "POST",
|
|
24780
|
+
path: `/api/location/reload`,
|
|
24781
|
+
successStatus: 204,
|
|
24782
|
+
declaredStatuses: [400, 401, 503],
|
|
24783
|
+
empty: true
|
|
24784
|
+
}, requestOptions)
|
|
24785
|
+
},
|
|
24786
|
+
agent: {
|
|
24787
|
+
list: (input, requestOptions) => request({
|
|
24788
|
+
method: "GET",
|
|
24789
|
+
path: `/api/agent`,
|
|
24790
|
+
query: { location: input?.["location"] },
|
|
24791
|
+
successStatus: 200,
|
|
24792
|
+
declaredStatuses: [400, 401],
|
|
24793
|
+
empty: false
|
|
24794
|
+
}, requestOptions),
|
|
24795
|
+
get: (input, requestOptions) => request({
|
|
24796
|
+
method: "GET",
|
|
24797
|
+
path: `/api/agent/${encodeURIComponent(input.agentID)}`,
|
|
24798
|
+
query: { location: input["location"] },
|
|
24799
|
+
successStatus: 200,
|
|
24800
|
+
declaredStatuses: [400, 401, 404],
|
|
24801
|
+
empty: false
|
|
24802
|
+
}, requestOptions)
|
|
24803
|
+
},
|
|
24804
|
+
plugin: {
|
|
24805
|
+
list: (input, requestOptions) => request({
|
|
24806
|
+
method: "GET",
|
|
24807
|
+
path: `/api/plugin`,
|
|
24808
|
+
query: { location: input?.["location"] },
|
|
24809
|
+
successStatus: 200,
|
|
24810
|
+
declaredStatuses: [400, 401],
|
|
24811
|
+
empty: false
|
|
24812
|
+
}, requestOptions),
|
|
24813
|
+
check: (input, requestOptions) => request({
|
|
24814
|
+
method: "POST",
|
|
24815
|
+
path: `/api/plugin/check`,
|
|
24816
|
+
query: { location: input?.["location"] },
|
|
24817
|
+
body: { target: input?.["target"] },
|
|
24818
|
+
successStatus: 200,
|
|
24819
|
+
declaredStatuses: [400, 401],
|
|
24820
|
+
empty: false
|
|
24821
|
+
}, requestOptions),
|
|
24822
|
+
update: (input, requestOptions) => request({
|
|
24823
|
+
method: "POST",
|
|
24824
|
+
path: `/api/plugin/update`,
|
|
24825
|
+
query: { location: input["location"] },
|
|
24826
|
+
body: { targets: input["targets"] },
|
|
24827
|
+
successStatus: 204,
|
|
24828
|
+
declaredStatuses: [400, 401, 503],
|
|
24829
|
+
empty: true
|
|
24830
|
+
}, requestOptions)
|
|
24831
|
+
},
|
|
24832
|
+
session: {
|
|
24833
|
+
list: (input, requestOptions) => request({
|
|
24834
|
+
method: "GET",
|
|
24835
|
+
path: `/api/session`,
|
|
24836
|
+
query: {
|
|
24837
|
+
limit: input?.["limit"],
|
|
24838
|
+
order: input?.["order"],
|
|
24839
|
+
search: input?.["search"],
|
|
24840
|
+
parentID: input?.["parentID"],
|
|
24841
|
+
directory: input?.["directory"],
|
|
24842
|
+
project: input?.["project"],
|
|
24843
|
+
subpath: input?.["subpath"],
|
|
24844
|
+
cursor: input?.["cursor"]
|
|
24845
|
+
},
|
|
24846
|
+
successStatus: 200,
|
|
24847
|
+
declaredStatuses: [400, 401],
|
|
24848
|
+
empty: false
|
|
24849
|
+
}, requestOptions),
|
|
24850
|
+
stats: (input, requestOptions) => request({
|
|
24851
|
+
method: "GET",
|
|
24852
|
+
path: `/api/experimental/session/stats`,
|
|
24853
|
+
query: {
|
|
24854
|
+
from: input?.["from"],
|
|
24855
|
+
to: input?.["to"],
|
|
24856
|
+
project: input?.["project"],
|
|
24857
|
+
timezone: input?.["timezone"],
|
|
24858
|
+
tools: input?.["tools"]
|
|
24859
|
+
},
|
|
24860
|
+
successStatus: 200,
|
|
24861
|
+
declaredStatuses: [400, 401],
|
|
24862
|
+
empty: false
|
|
24863
|
+
}, requestOptions).then((value) => value.data),
|
|
24864
|
+
create: (input, requestOptions) => request({
|
|
24865
|
+
method: "POST",
|
|
24866
|
+
path: `/api/session`,
|
|
24867
|
+
body: {
|
|
24868
|
+
id: input?.["id"],
|
|
24869
|
+
title: input?.["title"],
|
|
24870
|
+
agent: input?.["agent"],
|
|
24871
|
+
model: input?.["model"],
|
|
24872
|
+
location: input?.["location"],
|
|
24873
|
+
metadata: input?.["metadata"],
|
|
24874
|
+
permissions: input?.["permissions"]
|
|
24875
|
+
},
|
|
24876
|
+
successStatus: 200,
|
|
24877
|
+
declaredStatuses: [400, 401],
|
|
24878
|
+
empty: false
|
|
24879
|
+
}, requestOptions).then((value) => value.data),
|
|
24880
|
+
import: (input, requestOptions) => request({
|
|
24881
|
+
method: "POST",
|
|
24882
|
+
path: `/api/experimental/session/import`,
|
|
24883
|
+
body: { info: input["info"], messages: input["messages"], location: input["location"] },
|
|
24884
|
+
successStatus: 200,
|
|
24885
|
+
declaredStatuses: [400, 401, 404, 409],
|
|
24886
|
+
empty: false
|
|
24887
|
+
}, requestOptions).then((value) => value.data),
|
|
24888
|
+
export: (input, requestOptions) => request({
|
|
24889
|
+
method: "GET",
|
|
24890
|
+
path: `/api/experimental/session/${encodeURIComponent(input.sessionID)}/export`,
|
|
24891
|
+
query: { sanitize: input["sanitize"] },
|
|
24892
|
+
successStatus: 200,
|
|
24893
|
+
declaredStatuses: [400, 401, 404, 500],
|
|
24894
|
+
empty: false
|
|
24895
|
+
}, requestOptions).then((value) => value.data),
|
|
24896
|
+
active: (requestOptions) => request({
|
|
24897
|
+
method: "GET",
|
|
24898
|
+
path: `/api/session/active`,
|
|
24899
|
+
successStatus: 200,
|
|
24900
|
+
declaredStatuses: [400, 401],
|
|
24901
|
+
empty: false
|
|
24902
|
+
}, requestOptions).then((value) => value.data),
|
|
24903
|
+
get: (input, requestOptions) => request({
|
|
24904
|
+
method: "GET",
|
|
24905
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}`,
|
|
24906
|
+
successStatus: 200,
|
|
24907
|
+
declaredStatuses: [400, 401, 404],
|
|
24908
|
+
empty: false
|
|
24909
|
+
}, requestOptions).then((value) => value.data),
|
|
24910
|
+
remove: (input, requestOptions) => request({
|
|
24911
|
+
method: "DELETE",
|
|
24912
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}`,
|
|
24913
|
+
successStatus: 204,
|
|
24914
|
+
declaredStatuses: [400, 401, 404],
|
|
24915
|
+
empty: true
|
|
24916
|
+
}, requestOptions),
|
|
24917
|
+
fork: (input, requestOptions) => request({
|
|
24918
|
+
method: "POST",
|
|
24919
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/fork`,
|
|
24920
|
+
body: { before: input["before"] },
|
|
24921
|
+
successStatus: 200,
|
|
24922
|
+
declaredStatuses: [400, 401, 404],
|
|
24923
|
+
empty: false
|
|
24924
|
+
}, requestOptions).then((value) => value.data),
|
|
24925
|
+
switchAgent: (input, requestOptions) => request({
|
|
24926
|
+
method: "POST",
|
|
24927
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/agent`,
|
|
24928
|
+
body: { agent: input["agent"] },
|
|
24929
|
+
successStatus: 204,
|
|
24930
|
+
declaredStatuses: [400, 401, 404],
|
|
24931
|
+
empty: true
|
|
24932
|
+
}, requestOptions),
|
|
24933
|
+
switchModel: (input, requestOptions) => request({
|
|
24934
|
+
method: "POST",
|
|
24935
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/model`,
|
|
24936
|
+
body: { model: input["model"] },
|
|
24937
|
+
successStatus: 204,
|
|
24938
|
+
declaredStatuses: [400, 401, 404],
|
|
24939
|
+
empty: true
|
|
24940
|
+
}, requestOptions),
|
|
24941
|
+
update: (input, requestOptions) => request({
|
|
24942
|
+
method: "PATCH",
|
|
24943
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}`,
|
|
24944
|
+
body: { title: input["title"], metadata: input["metadata"], permissions: input["permissions"] },
|
|
24945
|
+
successStatus: 204,
|
|
24946
|
+
declaredStatuses: [400, 401, 404],
|
|
24947
|
+
empty: true
|
|
24948
|
+
}, requestOptions),
|
|
24949
|
+
move: (input, requestOptions) => request({
|
|
24950
|
+
method: "POST",
|
|
24951
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/move`,
|
|
24952
|
+
body: { directory: input["directory"], delivery: input["delivery"] },
|
|
24953
|
+
successStatus: 204,
|
|
24954
|
+
declaredStatuses: [400, 401, 404],
|
|
24955
|
+
empty: true
|
|
24956
|
+
}, requestOptions),
|
|
24957
|
+
prompt: (input, requestOptions) => request({
|
|
24958
|
+
method: "POST",
|
|
24959
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/prompt`,
|
|
24960
|
+
body: {
|
|
24961
|
+
id: input["id"],
|
|
24962
|
+
text: input["text"],
|
|
24963
|
+
files: input["files"],
|
|
24964
|
+
agents: input["agents"],
|
|
24965
|
+
skills: input["skills"],
|
|
24966
|
+
metadata: input["metadata"],
|
|
24967
|
+
delivery: input["delivery"],
|
|
24968
|
+
resume: input["resume"]
|
|
24969
|
+
},
|
|
24970
|
+
successStatus: 200,
|
|
24971
|
+
declaredStatuses: [400, 401, 404, 409],
|
|
24972
|
+
empty: false
|
|
24973
|
+
}, requestOptions).then((value) => value.data),
|
|
24974
|
+
command: (input, requestOptions) => request({
|
|
24975
|
+
method: "POST",
|
|
24976
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/command`,
|
|
24977
|
+
body: {
|
|
24978
|
+
name: input["name"],
|
|
24979
|
+
text: input["text"],
|
|
24980
|
+
files: input["files"],
|
|
24981
|
+
agents: input["agents"],
|
|
24982
|
+
skills: input["skills"],
|
|
24983
|
+
delivery: input["delivery"]
|
|
24984
|
+
},
|
|
24985
|
+
successStatus: 204,
|
|
24986
|
+
declaredStatuses: [400, 401, 404, 500],
|
|
24987
|
+
empty: true
|
|
24988
|
+
}, requestOptions),
|
|
24989
|
+
skill: (input, requestOptions) => request({
|
|
24990
|
+
method: "POST",
|
|
24991
|
+
path: `/api/experimental/session/${encodeURIComponent(input.sessionID)}/skill`,
|
|
24992
|
+
body: { id: input["id"], resume: input["resume"] },
|
|
24993
|
+
successStatus: 204,
|
|
24994
|
+
declaredStatuses: [400, 401, 404],
|
|
24995
|
+
empty: true
|
|
24996
|
+
}, requestOptions),
|
|
24997
|
+
synthetic: (input, requestOptions) => request({
|
|
24998
|
+
method: "POST",
|
|
24999
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/synthetic`,
|
|
25000
|
+
body: {
|
|
25001
|
+
id: input["id"],
|
|
25002
|
+
text: input["text"],
|
|
25003
|
+
description: input["description"],
|
|
25004
|
+
metadata: input["metadata"],
|
|
25005
|
+
delivery: input["delivery"],
|
|
25006
|
+
resume: input["resume"]
|
|
25007
|
+
},
|
|
25008
|
+
successStatus: 200,
|
|
25009
|
+
declaredStatuses: [400, 401, 404, 409],
|
|
25010
|
+
empty: false
|
|
25011
|
+
}, requestOptions).then((value) => value.data),
|
|
25012
|
+
shell: (input, requestOptions) => request({
|
|
25013
|
+
method: "POST",
|
|
25014
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/shell`,
|
|
25015
|
+
body: { id: input["id"], command: input["command"] },
|
|
25016
|
+
successStatus: 204,
|
|
25017
|
+
declaredStatuses: [400, 401, 404],
|
|
25018
|
+
empty: true
|
|
25019
|
+
}, requestOptions),
|
|
25020
|
+
compact: (input, requestOptions) => request({
|
|
25021
|
+
method: "POST",
|
|
25022
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/compact`,
|
|
25023
|
+
body: { id: input["id"], delivery: input["delivery"] },
|
|
25024
|
+
successStatus: 200,
|
|
25025
|
+
declaredStatuses: [400, 401, 404, 409],
|
|
25026
|
+
empty: false
|
|
25027
|
+
}, requestOptions).then((value) => value.data),
|
|
25028
|
+
wait: (input, requestOptions) => request({
|
|
25029
|
+
method: "POST",
|
|
25030
|
+
path: `/api/experimental/session/${encodeURIComponent(input.sessionID)}/wait`,
|
|
25031
|
+
successStatus: 204,
|
|
25032
|
+
declaredStatuses: [400, 401, 404, 503],
|
|
25033
|
+
empty: true
|
|
25034
|
+
}, requestOptions),
|
|
25035
|
+
revert: {
|
|
25036
|
+
stage: (input, requestOptions) => request({
|
|
25037
|
+
method: "POST",
|
|
25038
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/revert/stage`,
|
|
25039
|
+
body: { messageID: input["messageID"], files: input["files"] },
|
|
25040
|
+
successStatus: 200,
|
|
25041
|
+
declaredStatuses: [400, 401, 404, 409, 500],
|
|
25042
|
+
empty: false
|
|
25043
|
+
}, requestOptions).then((value) => value.data),
|
|
25044
|
+
clear: (input, requestOptions) => request({
|
|
25045
|
+
method: "DELETE",
|
|
25046
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/revert`,
|
|
25047
|
+
successStatus: 204,
|
|
25048
|
+
declaredStatuses: [400, 401, 404, 409, 500],
|
|
25049
|
+
empty: true
|
|
25050
|
+
}, requestOptions),
|
|
25051
|
+
commit: (input, requestOptions) => request({
|
|
25052
|
+
method: "POST",
|
|
25053
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/revert/commit`,
|
|
25054
|
+
successStatus: 204,
|
|
25055
|
+
declaredStatuses: [400, 401, 404, 409],
|
|
25056
|
+
empty: true
|
|
25057
|
+
}, requestOptions)
|
|
25058
|
+
},
|
|
25059
|
+
context: (input, requestOptions) => request({
|
|
25060
|
+
method: "GET",
|
|
25061
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/context`,
|
|
25062
|
+
successStatus: 200,
|
|
25063
|
+
declaredStatuses: [400, 401, 404, 500],
|
|
25064
|
+
empty: false
|
|
25065
|
+
}, requestOptions).then((value) => value.data),
|
|
25066
|
+
diff: (input, requestOptions) => request({
|
|
25067
|
+
method: "GET",
|
|
25068
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/diff`,
|
|
25069
|
+
query: { from: input["from"], to: input["to"], context: input["context"] },
|
|
25070
|
+
successStatus: 200,
|
|
25071
|
+
declaredStatuses: [400, 401, 404, 500],
|
|
25072
|
+
empty: false
|
|
25073
|
+
}, requestOptions).then((value) => value.data),
|
|
25074
|
+
inbox: {
|
|
25075
|
+
list: (input, requestOptions) => request({
|
|
25076
|
+
method: "GET",
|
|
25077
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/inbox`,
|
|
25078
|
+
successStatus: 200,
|
|
25079
|
+
declaredStatuses: [400, 401, 404],
|
|
25080
|
+
empty: false
|
|
25081
|
+
}, requestOptions).then((value) => value.data),
|
|
25082
|
+
cancel: (input, requestOptions) => request({
|
|
25083
|
+
method: "DELETE",
|
|
25084
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/inbox/${encodeURIComponent(input.inboxID)}`,
|
|
25085
|
+
successStatus: 204,
|
|
25086
|
+
declaredStatuses: [400, 401, 404],
|
|
25087
|
+
empty: true
|
|
25088
|
+
}, requestOptions),
|
|
25089
|
+
update: (input, requestOptions) => request({
|
|
25090
|
+
method: "PATCH",
|
|
25091
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/inbox/${encodeURIComponent(input.inboxID)}`,
|
|
25092
|
+
body: { delivery: input["delivery"] },
|
|
25093
|
+
successStatus: 204,
|
|
25094
|
+
declaredStatuses: [400, 401, 404, 409],
|
|
25095
|
+
empty: true
|
|
25096
|
+
}, requestOptions)
|
|
25097
|
+
},
|
|
25098
|
+
instructions: {
|
|
25099
|
+
entry: {
|
|
25100
|
+
list: (input, requestOptions) => request({
|
|
25101
|
+
method: "GET",
|
|
25102
|
+
path: `/api/experimental/session/${encodeURIComponent(input.sessionID)}/instructions/entries`,
|
|
25103
|
+
successStatus: 200,
|
|
25104
|
+
declaredStatuses: [400, 401, 404],
|
|
25105
|
+
empty: false
|
|
25106
|
+
}, requestOptions).then((value) => value.data),
|
|
25107
|
+
put: (input, requestOptions) => request({
|
|
25108
|
+
method: "PUT",
|
|
25109
|
+
path: `/api/experimental/session/${encodeURIComponent(input.sessionID)}/instructions/entries/${encodeURIComponent(input.key)}`,
|
|
25110
|
+
body: { value: input["value"] },
|
|
25111
|
+
successStatus: 204,
|
|
25112
|
+
declaredStatuses: [400, 401, 404, 413],
|
|
25113
|
+
empty: true
|
|
25114
|
+
}, requestOptions),
|
|
25115
|
+
remove: (input, requestOptions) => request({
|
|
25116
|
+
method: "DELETE",
|
|
25117
|
+
path: `/api/experimental/session/${encodeURIComponent(input.sessionID)}/instructions/entries/${encodeURIComponent(input.key)}`,
|
|
25118
|
+
successStatus: 204,
|
|
25119
|
+
declaredStatuses: [400, 401, 404],
|
|
25120
|
+
empty: true
|
|
25121
|
+
}, requestOptions)
|
|
25122
|
+
}
|
|
25123
|
+
},
|
|
25124
|
+
generate: (input, requestOptions) => request({
|
|
25125
|
+
method: "POST",
|
|
25126
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/generate`,
|
|
25127
|
+
body: { prompt: input["prompt"] },
|
|
25128
|
+
successStatus: 200,
|
|
25129
|
+
declaredStatuses: [400, 401, 404, 503],
|
|
25130
|
+
empty: false
|
|
25131
|
+
}, requestOptions).then((value) => value.data),
|
|
25132
|
+
log: (input, requestOptions) => sse({
|
|
25133
|
+
method: "GET",
|
|
25134
|
+
path: `/api/experimental/session/${encodeURIComponent(input.sessionID)}/log`,
|
|
25135
|
+
query: { after: input["after"], follow: input["follow"] },
|
|
25136
|
+
successStatus: 200,
|
|
25137
|
+
declaredStatuses: [400, 401, 404],
|
|
25138
|
+
empty: false
|
|
25139
|
+
}, requestOptions),
|
|
25140
|
+
interrupt: (input, requestOptions) => request({
|
|
25141
|
+
method: "POST",
|
|
25142
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/interrupt`,
|
|
25143
|
+
query: { resume: input["resume"] },
|
|
25144
|
+
successStatus: 200,
|
|
25145
|
+
declaredStatuses: [400, 401, 404],
|
|
25146
|
+
empty: false
|
|
25147
|
+
}, requestOptions),
|
|
25148
|
+
background: (input, requestOptions) => request({
|
|
25149
|
+
method: "POST",
|
|
25150
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/background`,
|
|
25151
|
+
successStatus: 204,
|
|
25152
|
+
declaredStatuses: [400, 401, 404],
|
|
25153
|
+
empty: true
|
|
25154
|
+
}, requestOptions),
|
|
25155
|
+
message: {
|
|
25156
|
+
get: (input, requestOptions) => request({
|
|
25157
|
+
method: "GET",
|
|
25158
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/message/${encodeURIComponent(input.messageID)}`,
|
|
25159
|
+
successStatus: 200,
|
|
25160
|
+
declaredStatuses: [400, 401, 404],
|
|
25161
|
+
empty: false
|
|
25162
|
+
}, requestOptions).then((value) => value.data)
|
|
25163
|
+
},
|
|
25164
|
+
form: {
|
|
25165
|
+
list: (input, requestOptions) => request({
|
|
25166
|
+
method: "GET",
|
|
25167
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/form`,
|
|
25168
|
+
successStatus: 200,
|
|
25169
|
+
declaredStatuses: [400, 401, 404],
|
|
25170
|
+
empty: false
|
|
25171
|
+
}, requestOptions).then((value) => value.data),
|
|
25172
|
+
create: (input, requestOptions) => request({
|
|
25173
|
+
method: "POST",
|
|
25174
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/form`,
|
|
25175
|
+
body: { id: input["id"], title: input["title"], metadata: input["metadata"], fields: input["fields"] },
|
|
25176
|
+
successStatus: 200,
|
|
25177
|
+
declaredStatuses: [400, 401, 404, 409],
|
|
25178
|
+
empty: false
|
|
25179
|
+
}, requestOptions).then((value) => value.data),
|
|
25180
|
+
get: (input, requestOptions) => request({
|
|
25181
|
+
method: "GET",
|
|
25182
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/form/${encodeURIComponent(input.formID)}`,
|
|
25183
|
+
successStatus: 200,
|
|
25184
|
+
declaredStatuses: [400, 401, 404],
|
|
25185
|
+
empty: false
|
|
25186
|
+
}, requestOptions).then((value) => value.data),
|
|
25187
|
+
reply: (input, requestOptions) => request({
|
|
25188
|
+
method: "POST",
|
|
25189
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/form/${encodeURIComponent(input.formID)}/reply`,
|
|
25190
|
+
body: { answer: input["answer"] },
|
|
25191
|
+
successStatus: 204,
|
|
25192
|
+
declaredStatuses: [400, 401, 404, 409],
|
|
25193
|
+
empty: true
|
|
25194
|
+
}, requestOptions),
|
|
25195
|
+
cancel: (input, requestOptions) => request({
|
|
25196
|
+
method: "DELETE",
|
|
25197
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/form/${encodeURIComponent(input.formID)}`,
|
|
25198
|
+
successStatus: 204,
|
|
25199
|
+
declaredStatuses: [400, 401, 404, 409],
|
|
25200
|
+
empty: true
|
|
25201
|
+
}, requestOptions)
|
|
25202
|
+
},
|
|
25203
|
+
environment: (input, requestOptions) => request({
|
|
25204
|
+
method: "PUT",
|
|
25205
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/environment`,
|
|
25206
|
+
body: { variables: input["variables"] },
|
|
25207
|
+
successStatus: 204,
|
|
25208
|
+
declaredStatuses: [400, 401, 404],
|
|
25209
|
+
empty: true
|
|
25210
|
+
}, requestOptions),
|
|
25211
|
+
view: (input, requestOptions) => request({
|
|
25212
|
+
method: "POST",
|
|
25213
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/view`,
|
|
25214
|
+
body: { idle: input["idle"] },
|
|
25215
|
+
successStatus: 204,
|
|
25216
|
+
declaredStatuses: [400, 401, 404],
|
|
25217
|
+
empty: true
|
|
25218
|
+
}, requestOptions)
|
|
25219
|
+
},
|
|
25220
|
+
message: {
|
|
25221
|
+
list: (input, requestOptions) => request({
|
|
25222
|
+
method: "GET",
|
|
25223
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/message`,
|
|
25224
|
+
query: { limit: input["limit"], order: input["order"], cursor: input["cursor"], type: input["type"] },
|
|
25225
|
+
successStatus: 200,
|
|
25226
|
+
declaredStatuses: [400, 401, 404, 500],
|
|
25227
|
+
empty: false
|
|
25228
|
+
}, requestOptions)
|
|
25229
|
+
},
|
|
25230
|
+
model: {
|
|
25231
|
+
list: (input, requestOptions) => request({
|
|
25232
|
+
method: "GET",
|
|
25233
|
+
path: `/api/model`,
|
|
25234
|
+
query: { location: input?.["location"] },
|
|
25235
|
+
successStatus: 200,
|
|
25236
|
+
declaredStatuses: [400, 401, 503],
|
|
25237
|
+
empty: false
|
|
25238
|
+
}, requestOptions),
|
|
25239
|
+
default: (input, requestOptions) => request({
|
|
25240
|
+
method: "GET",
|
|
25241
|
+
path: `/api/model/default`,
|
|
25242
|
+
query: { location: input?.["location"] },
|
|
25243
|
+
successStatus: 200,
|
|
25244
|
+
declaredStatuses: [400, 401, 503],
|
|
25245
|
+
empty: false
|
|
25246
|
+
}, requestOptions)
|
|
25247
|
+
},
|
|
25248
|
+
generate: {
|
|
25249
|
+
text: (input, requestOptions) => request({
|
|
25250
|
+
method: "POST",
|
|
25251
|
+
path: `/api/experimental/generate`,
|
|
25252
|
+
body: { prompt: input["prompt"], model: input["model"] },
|
|
25253
|
+
successStatus: 200,
|
|
25254
|
+
declaredStatuses: [400, 401, 503],
|
|
25255
|
+
empty: false
|
|
25256
|
+
}, requestOptions).then((value) => value.data)
|
|
25257
|
+
},
|
|
25258
|
+
provider: {
|
|
25259
|
+
list: (input, requestOptions) => request({
|
|
25260
|
+
method: "GET",
|
|
25261
|
+
path: `/api/provider`,
|
|
25262
|
+
query: { location: input?.["location"] },
|
|
25263
|
+
successStatus: 200,
|
|
25264
|
+
declaredStatuses: [400, 401, 503],
|
|
25265
|
+
empty: false
|
|
25266
|
+
}, requestOptions),
|
|
25267
|
+
get: (input, requestOptions) => request({
|
|
25268
|
+
method: "GET",
|
|
25269
|
+
path: `/api/provider/${encodeURIComponent(input.providerID)}`,
|
|
25270
|
+
query: { location: input["location"] },
|
|
25271
|
+
successStatus: 200,
|
|
25272
|
+
declaredStatuses: [400, 401, 404, 503],
|
|
25273
|
+
empty: false
|
|
25274
|
+
}, requestOptions)
|
|
25275
|
+
},
|
|
25276
|
+
integration: {
|
|
25277
|
+
list: (input, requestOptions) => request({
|
|
25278
|
+
method: "GET",
|
|
25279
|
+
path: `/api/integration`,
|
|
25280
|
+
query: { location: input?.["location"] },
|
|
25281
|
+
successStatus: 200,
|
|
25282
|
+
declaredStatuses: [400, 401],
|
|
25283
|
+
empty: false
|
|
25284
|
+
}, requestOptions),
|
|
25285
|
+
get: (input, requestOptions) => request({
|
|
25286
|
+
method: "GET",
|
|
25287
|
+
path: `/api/integration/${encodeURIComponent(input.integrationID)}`,
|
|
25288
|
+
query: { location: input["location"] },
|
|
25289
|
+
successStatus: 200,
|
|
25290
|
+
declaredStatuses: [400, 401, 404],
|
|
25291
|
+
empty: false
|
|
25292
|
+
}, requestOptions),
|
|
25293
|
+
wellknown: {
|
|
25294
|
+
add: (input, requestOptions) => request({
|
|
25295
|
+
method: "POST",
|
|
25296
|
+
path: `/api/experimental/integration/wellknown`,
|
|
25297
|
+
query: { location: input["location"] },
|
|
25298
|
+
body: { url: input["url"] },
|
|
25299
|
+
successStatus: 204,
|
|
25300
|
+
declaredStatuses: [400, 401],
|
|
25301
|
+
empty: true
|
|
25302
|
+
}, requestOptions)
|
|
25303
|
+
},
|
|
25304
|
+
connect: {
|
|
25305
|
+
key: (input, requestOptions) => request({
|
|
25306
|
+
method: "POST",
|
|
25307
|
+
path: `/api/integration/${encodeURIComponent(input.integrationID)}/connect/key`,
|
|
25308
|
+
query: { location: input["location"] },
|
|
25309
|
+
body: { key: input["key"], answer: input["answer"], label: input["label"] },
|
|
25310
|
+
successStatus: 204,
|
|
25311
|
+
declaredStatuses: [400, 401, 404],
|
|
25312
|
+
empty: true
|
|
25313
|
+
}, requestOptions)
|
|
25314
|
+
},
|
|
25315
|
+
oauth: {
|
|
25316
|
+
connect: (input, requestOptions) => request({
|
|
25317
|
+
method: "POST",
|
|
25318
|
+
path: `/api/integration/${encodeURIComponent(input.integrationID)}/connect/oauth`,
|
|
25319
|
+
query: { location: input["location"] },
|
|
25320
|
+
body: { methodID: input["methodID"], answer: input["answer"], label: input["label"] },
|
|
25321
|
+
successStatus: 200,
|
|
25322
|
+
declaredStatuses: [400, 401],
|
|
25323
|
+
empty: false
|
|
25324
|
+
}, requestOptions),
|
|
25325
|
+
status: (input, requestOptions) => request({
|
|
25326
|
+
method: "GET",
|
|
25327
|
+
path: `/api/integration/${encodeURIComponent(input.integrationID)}/connect/oauth/${encodeURIComponent(input.attemptID)}`,
|
|
25328
|
+
query: { location: input["location"] },
|
|
25329
|
+
successStatus: 200,
|
|
25330
|
+
declaredStatuses: [400, 401, 404],
|
|
25331
|
+
empty: false
|
|
25332
|
+
}, requestOptions),
|
|
25333
|
+
complete: (input, requestOptions) => request({
|
|
25334
|
+
method: "POST",
|
|
25335
|
+
path: `/api/integration/${encodeURIComponent(input.integrationID)}/connect/oauth/${encodeURIComponent(input.attemptID)}/complete`,
|
|
25336
|
+
query: { location: input["location"] },
|
|
25337
|
+
body: { code: input["code"] },
|
|
25338
|
+
successStatus: 204,
|
|
25339
|
+
declaredStatuses: [400, 401, 404],
|
|
25340
|
+
empty: true
|
|
25341
|
+
}, requestOptions),
|
|
25342
|
+
cancel: (input, requestOptions) => request({
|
|
25343
|
+
method: "DELETE",
|
|
25344
|
+
path: `/api/integration/${encodeURIComponent(input.integrationID)}/connect/oauth/${encodeURIComponent(input.attemptID)}`,
|
|
25345
|
+
query: { location: input["location"] },
|
|
25346
|
+
successStatus: 204,
|
|
25347
|
+
declaredStatuses: [400, 401],
|
|
25348
|
+
empty: true
|
|
25349
|
+
}, requestOptions)
|
|
25350
|
+
},
|
|
25351
|
+
command: {
|
|
25352
|
+
connect: (input, requestOptions) => request({
|
|
25353
|
+
method: "POST",
|
|
25354
|
+
path: `/api/integration/${encodeURIComponent(input.integrationID)}/connect/command`,
|
|
25355
|
+
query: { location: input["location"] },
|
|
25356
|
+
body: { methodID: input["methodID"], label: input["label"] },
|
|
25357
|
+
successStatus: 200,
|
|
25358
|
+
declaredStatuses: [400, 401, 404],
|
|
25359
|
+
empty: false
|
|
25360
|
+
}, requestOptions),
|
|
25361
|
+
status: (input, requestOptions) => request({
|
|
25362
|
+
method: "GET",
|
|
25363
|
+
path: `/api/integration/${encodeURIComponent(input.integrationID)}/connect/command/${encodeURIComponent(input.attemptID)}`,
|
|
25364
|
+
query: { location: input["location"] },
|
|
25365
|
+
successStatus: 200,
|
|
25366
|
+
declaredStatuses: [400, 401, 404],
|
|
25367
|
+
empty: false
|
|
25368
|
+
}, requestOptions),
|
|
25369
|
+
cancel: (input, requestOptions) => request({
|
|
25370
|
+
method: "DELETE",
|
|
25371
|
+
path: `/api/integration/${encodeURIComponent(input.integrationID)}/connect/command/${encodeURIComponent(input.attemptID)}`,
|
|
25372
|
+
query: { location: input["location"] },
|
|
25373
|
+
successStatus: 204,
|
|
25374
|
+
declaredStatuses: [400, 401],
|
|
25375
|
+
empty: true
|
|
25376
|
+
}, requestOptions)
|
|
25377
|
+
}
|
|
25378
|
+
},
|
|
25379
|
+
mcp: {
|
|
25380
|
+
list: (input, requestOptions) => request({
|
|
25381
|
+
method: "GET",
|
|
25382
|
+
path: `/api/mcp`,
|
|
25383
|
+
query: { location: input?.["location"] },
|
|
25384
|
+
successStatus: 200,
|
|
25385
|
+
declaredStatuses: [400, 401],
|
|
25386
|
+
empty: false
|
|
25387
|
+
}, requestOptions),
|
|
25388
|
+
add: (input, requestOptions) => request({
|
|
25389
|
+
method: "PUT",
|
|
25390
|
+
path: `/api/experimental/mcp/${encodeURIComponent(input.server)}`,
|
|
25391
|
+
query: { location: input["location"] },
|
|
25392
|
+
body: { config: input["config"] },
|
|
25393
|
+
successStatus: 204,
|
|
25394
|
+
declaredStatuses: [400, 401],
|
|
25395
|
+
empty: true
|
|
25396
|
+
}, requestOptions),
|
|
25397
|
+
remove: (input, requestOptions) => request({
|
|
25398
|
+
method: "DELETE",
|
|
25399
|
+
path: `/api/experimental/mcp/${encodeURIComponent(input.server)}`,
|
|
25400
|
+
query: { location: input["location"] },
|
|
25401
|
+
successStatus: 204,
|
|
25402
|
+
declaredStatuses: [400, 401, 404],
|
|
25403
|
+
empty: true
|
|
25404
|
+
}, requestOptions),
|
|
25405
|
+
connect: (input, requestOptions) => request({
|
|
25406
|
+
method: "POST",
|
|
25407
|
+
path: `/api/experimental/mcp/${encodeURIComponent(input.server)}/connect`,
|
|
25408
|
+
query: { location: input["location"] },
|
|
25409
|
+
successStatus: 204,
|
|
25410
|
+
declaredStatuses: [400, 401, 404],
|
|
25411
|
+
empty: true
|
|
25412
|
+
}, requestOptions),
|
|
25413
|
+
disconnect: (input, requestOptions) => request({
|
|
25414
|
+
method: "POST",
|
|
25415
|
+
path: `/api/experimental/mcp/${encodeURIComponent(input.server)}/disconnect`,
|
|
25416
|
+
query: { location: input["location"] },
|
|
25417
|
+
successStatus: 204,
|
|
25418
|
+
declaredStatuses: [400, 401, 404],
|
|
25419
|
+
empty: true
|
|
25420
|
+
}, requestOptions),
|
|
25421
|
+
resource: {
|
|
25422
|
+
catalog: (input, requestOptions) => request({
|
|
25423
|
+
method: "GET",
|
|
25424
|
+
path: `/api/mcp/resource`,
|
|
25425
|
+
query: { location: input?.["location"] },
|
|
25426
|
+
successStatus: 200,
|
|
25427
|
+
declaredStatuses: [400, 401],
|
|
25428
|
+
empty: false
|
|
25429
|
+
}, requestOptions)
|
|
25430
|
+
}
|
|
25431
|
+
},
|
|
25432
|
+
credential: {
|
|
25433
|
+
update: (input, requestOptions) => request({
|
|
25434
|
+
method: "PATCH",
|
|
25435
|
+
path: `/api/credential/${encodeURIComponent(input.credentialID)}`,
|
|
25436
|
+
body: { label: input["label"] },
|
|
25437
|
+
successStatus: 204,
|
|
25438
|
+
declaredStatuses: [400, 401],
|
|
25439
|
+
empty: true
|
|
25440
|
+
}, requestOptions),
|
|
25441
|
+
activate: (input, requestOptions) => request({
|
|
25442
|
+
method: "POST",
|
|
25443
|
+
path: `/api/credential/${encodeURIComponent(input.credentialID)}/activate`,
|
|
25444
|
+
successStatus: 204,
|
|
25445
|
+
declaredStatuses: [400, 401],
|
|
25446
|
+
empty: true
|
|
25447
|
+
}, requestOptions),
|
|
25448
|
+
remove: (input, requestOptions) => request({
|
|
25449
|
+
method: "DELETE",
|
|
25450
|
+
path: `/api/credential/${encodeURIComponent(input.credentialID)}`,
|
|
25451
|
+
successStatus: 204,
|
|
25452
|
+
declaredStatuses: [400, 401],
|
|
25453
|
+
empty: true
|
|
25454
|
+
}, requestOptions)
|
|
25455
|
+
},
|
|
25456
|
+
project: {
|
|
25457
|
+
list: (requestOptions) => request({ method: "GET", path: `/api/project`, successStatus: 200, declaredStatuses: [400, 401], empty: false }, requestOptions),
|
|
25458
|
+
update: (input, requestOptions) => request({
|
|
25459
|
+
method: "PATCH",
|
|
25460
|
+
path: `/api/project/${encodeURIComponent(input.projectID)}`,
|
|
25461
|
+
body: {
|
|
25462
|
+
canonical: input["canonical"],
|
|
25463
|
+
name: input["name"],
|
|
25464
|
+
icon: input["icon"],
|
|
25465
|
+
commands: input["commands"]
|
|
25466
|
+
},
|
|
25467
|
+
successStatus: 200,
|
|
25468
|
+
declaredStatuses: [400, 401, 404],
|
|
25469
|
+
empty: false
|
|
25470
|
+
}, requestOptions)
|
|
25471
|
+
},
|
|
25472
|
+
form: {
|
|
25473
|
+
list: (input, requestOptions) => request({
|
|
25474
|
+
method: "GET",
|
|
25475
|
+
path: `/api/form`,
|
|
25476
|
+
query: { location: input?.["location"] },
|
|
25477
|
+
successStatus: 200,
|
|
25478
|
+
declaredStatuses: [400, 401],
|
|
25479
|
+
empty: false
|
|
25480
|
+
}, requestOptions)
|
|
25481
|
+
},
|
|
25482
|
+
permission: {
|
|
25483
|
+
request: {
|
|
25484
|
+
list: (input, requestOptions) => request({
|
|
25485
|
+
method: "GET",
|
|
25486
|
+
path: `/api/permission/request`,
|
|
25487
|
+
query: { location: input?.["location"] },
|
|
25488
|
+
successStatus: 200,
|
|
25489
|
+
declaredStatuses: [400, 401],
|
|
25490
|
+
empty: false
|
|
25491
|
+
}, requestOptions)
|
|
25492
|
+
},
|
|
25493
|
+
saved: {
|
|
25494
|
+
list: (input, requestOptions) => request({
|
|
25495
|
+
method: "GET",
|
|
25496
|
+
path: `/api/permission/saved`,
|
|
25497
|
+
query: { projectID: input?.["projectID"] },
|
|
25498
|
+
successStatus: 200,
|
|
25499
|
+
declaredStatuses: [400, 401],
|
|
25500
|
+
empty: false
|
|
25501
|
+
}, requestOptions).then((value) => value.data),
|
|
25502
|
+
remove: (input, requestOptions) => request({
|
|
25503
|
+
method: "DELETE",
|
|
25504
|
+
path: `/api/permission/saved/${encodeURIComponent(input.id)}`,
|
|
25505
|
+
successStatus: 204,
|
|
25506
|
+
declaredStatuses: [400, 401],
|
|
25507
|
+
empty: true
|
|
25508
|
+
}, requestOptions)
|
|
25509
|
+
},
|
|
25510
|
+
create: (input, requestOptions) => request({
|
|
25511
|
+
method: "POST",
|
|
25512
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/permission`,
|
|
25513
|
+
body: {
|
|
25514
|
+
id: input["id"],
|
|
25515
|
+
action: input["action"],
|
|
25516
|
+
resources: input["resources"],
|
|
25517
|
+
save: input["save"],
|
|
25518
|
+
metadata: input["metadata"],
|
|
25519
|
+
source: input["source"],
|
|
25520
|
+
agent: input["agent"]
|
|
25521
|
+
},
|
|
25522
|
+
successStatus: 200,
|
|
25523
|
+
declaredStatuses: [400, 401, 404],
|
|
25524
|
+
empty: false
|
|
25525
|
+
}, requestOptions).then((value) => value.data),
|
|
25526
|
+
list: (input, requestOptions) => request({
|
|
25527
|
+
method: "GET",
|
|
25528
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/permission`,
|
|
25529
|
+
successStatus: 200,
|
|
25530
|
+
declaredStatuses: [400, 401, 404],
|
|
25531
|
+
empty: false
|
|
25532
|
+
}, requestOptions).then((value) => value.data),
|
|
25533
|
+
get: (input, requestOptions) => request({
|
|
25534
|
+
method: "GET",
|
|
25535
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/permission/${encodeURIComponent(input.requestID)}`,
|
|
25536
|
+
successStatus: 200,
|
|
25537
|
+
declaredStatuses: [400, 401, 404],
|
|
25538
|
+
empty: false
|
|
25539
|
+
}, requestOptions).then((value) => value.data),
|
|
25540
|
+
reply: (input, requestOptions) => request({
|
|
25541
|
+
method: "POST",
|
|
25542
|
+
path: `/api/session/${encodeURIComponent(input.sessionID)}/permission/${encodeURIComponent(input.requestID)}/reply`,
|
|
25543
|
+
body: { decision: input["decision"], message: input["message"] },
|
|
25544
|
+
successStatus: 204,
|
|
25545
|
+
declaredStatuses: [400, 401, 404],
|
|
25546
|
+
empty: true
|
|
25547
|
+
}, requestOptions)
|
|
25548
|
+
},
|
|
25549
|
+
file: {
|
|
25550
|
+
read: (input, requestOptions) => request({
|
|
25551
|
+
method: "GET",
|
|
25552
|
+
path: `/api/fs/read/${encodePath(input.path)}`,
|
|
25553
|
+
query: { location: input["location"] },
|
|
25554
|
+
successStatus: 200,
|
|
25555
|
+
declaredStatuses: [400, 401, 404],
|
|
25556
|
+
empty: false,
|
|
25557
|
+
binary: true
|
|
25558
|
+
}, requestOptions),
|
|
25559
|
+
list: (input, requestOptions) => request({
|
|
25560
|
+
method: "GET",
|
|
25561
|
+
path: `/api/fs/list`,
|
|
25562
|
+
query: { location: input?.["location"], path: input?.["path"] },
|
|
25563
|
+
successStatus: 200,
|
|
25564
|
+
declaredStatuses: [400, 401],
|
|
25565
|
+
empty: false
|
|
25566
|
+
}, requestOptions),
|
|
25567
|
+
find: (input, requestOptions) => request({
|
|
25568
|
+
method: "GET",
|
|
25569
|
+
path: `/api/fs/find`,
|
|
25570
|
+
query: { location: input["location"], query: input["query"], type: input["type"], limit: input["limit"] },
|
|
25571
|
+
successStatus: 200,
|
|
25572
|
+
declaredStatuses: [400, 401],
|
|
25573
|
+
empty: false
|
|
25574
|
+
}, requestOptions),
|
|
25575
|
+
write: (input, requestOptions) => request({
|
|
25576
|
+
method: "POST",
|
|
25577
|
+
path: `/api/experimental/fs/write`,
|
|
25578
|
+
query: { location: input["location"], path: input["path"] },
|
|
25579
|
+
body: input["payload"],
|
|
25580
|
+
successStatus: 200,
|
|
25581
|
+
declaredStatuses: [400, 401],
|
|
25582
|
+
empty: false,
|
|
25583
|
+
binaryBody: true
|
|
25584
|
+
}, requestOptions)
|
|
25585
|
+
},
|
|
25586
|
+
command: {
|
|
25587
|
+
list: (input, requestOptions) => request({
|
|
25588
|
+
method: "GET",
|
|
25589
|
+
path: `/api/command`,
|
|
25590
|
+
query: { location: input?.["location"] },
|
|
25591
|
+
successStatus: 200,
|
|
25592
|
+
declaredStatuses: [400, 401],
|
|
25593
|
+
empty: false
|
|
25594
|
+
}, requestOptions)
|
|
25595
|
+
},
|
|
25596
|
+
skill: {
|
|
25597
|
+
list: (input, requestOptions) => request({
|
|
25598
|
+
method: "GET",
|
|
25599
|
+
path: `/api/skill`,
|
|
25600
|
+
query: { location: input?.["location"] },
|
|
25601
|
+
successStatus: 200,
|
|
25602
|
+
declaredStatuses: [400, 401],
|
|
25603
|
+
empty: false
|
|
25604
|
+
}, requestOptions)
|
|
25605
|
+
},
|
|
25606
|
+
rpc: {
|
|
25607
|
+
call: (input, requestOptions) => request({
|
|
25608
|
+
method: "POST",
|
|
25609
|
+
path: `/api/rpc/${encodeURIComponent(input.rpcID)}/${encodeURIComponent(input.method)}`,
|
|
25610
|
+
query: { location: input["location"] },
|
|
25611
|
+
body: { input: input["input"] },
|
|
25612
|
+
successStatus: 200,
|
|
25613
|
+
declaredStatuses: [400, 401, 500],
|
|
25614
|
+
empty: false
|
|
25615
|
+
}, requestOptions)
|
|
25616
|
+
},
|
|
25617
|
+
event: {
|
|
25618
|
+
subscribe: (requestOptions) => sse({ method: "GET", path: `/api/event`, successStatus: 200, declaredStatuses: [400, 401], empty: false }, requestOptions)
|
|
25619
|
+
},
|
|
25620
|
+
pty: {
|
|
25621
|
+
list: (input, requestOptions) => request({
|
|
25622
|
+
method: "GET",
|
|
25623
|
+
path: `/api/pty`,
|
|
25624
|
+
query: { location: input?.["location"] },
|
|
25625
|
+
successStatus: 200,
|
|
25626
|
+
declaredStatuses: [400, 401],
|
|
25627
|
+
empty: false
|
|
25628
|
+
}, requestOptions),
|
|
25629
|
+
create: (input, requestOptions) => request({
|
|
25630
|
+
method: "POST",
|
|
25631
|
+
path: `/api/pty`,
|
|
25632
|
+
query: { location: input?.["location"] },
|
|
25633
|
+
body: {
|
|
25634
|
+
command: input?.["command"],
|
|
25635
|
+
args: input?.["args"],
|
|
25636
|
+
cwd: input?.["cwd"],
|
|
25637
|
+
title: input?.["title"],
|
|
25638
|
+
env: input?.["env"]
|
|
25639
|
+
},
|
|
25640
|
+
successStatus: 200,
|
|
25641
|
+
declaredStatuses: [400, 401],
|
|
25642
|
+
empty: false
|
|
25643
|
+
}, requestOptions),
|
|
25644
|
+
get: (input, requestOptions) => request({
|
|
25645
|
+
method: "GET",
|
|
25646
|
+
path: `/api/pty/${encodeURIComponent(input.ptyID)}`,
|
|
25647
|
+
query: { location: input["location"] },
|
|
25648
|
+
successStatus: 200,
|
|
25649
|
+
declaredStatuses: [400, 401, 404],
|
|
25650
|
+
empty: false
|
|
25651
|
+
}, requestOptions),
|
|
25652
|
+
update: (input, requestOptions) => request({
|
|
25653
|
+
method: "PUT",
|
|
25654
|
+
path: `/api/pty/${encodeURIComponent(input.ptyID)}`,
|
|
25655
|
+
query: { location: input["location"] },
|
|
25656
|
+
body: { title: input["title"], size: input["size"] },
|
|
25657
|
+
successStatus: 200,
|
|
25658
|
+
declaredStatuses: [400, 401, 404],
|
|
25659
|
+
empty: false
|
|
25660
|
+
}, requestOptions),
|
|
25661
|
+
remove: (input, requestOptions) => request({
|
|
25662
|
+
method: "DELETE",
|
|
25663
|
+
path: `/api/pty/${encodeURIComponent(input.ptyID)}`,
|
|
25664
|
+
query: { location: input["location"] },
|
|
25665
|
+
successStatus: 204,
|
|
25666
|
+
declaredStatuses: [400, 401, 404],
|
|
25667
|
+
empty: true
|
|
25668
|
+
}, requestOptions),
|
|
25669
|
+
connect: {
|
|
25670
|
+
token: (input, requestOptions) => request({
|
|
25671
|
+
method: "POST",
|
|
25672
|
+
path: `/api/pty/${encodeURIComponent(input.ptyID)}/connect-token`,
|
|
25673
|
+
query: { location: input["location"] },
|
|
25674
|
+
headers: { "x-opencode-ticket": input["x-opencode-ticket"] },
|
|
25675
|
+
successStatus: 200,
|
|
25676
|
+
declaredStatuses: [400, 401, 403, 404],
|
|
25677
|
+
empty: false
|
|
25678
|
+
}, requestOptions)
|
|
25679
|
+
}
|
|
25680
|
+
},
|
|
25681
|
+
experimental: {
|
|
25682
|
+
persistentPty: {
|
|
25683
|
+
read: (input, requestOptions) => request({
|
|
25684
|
+
method: "GET",
|
|
25685
|
+
path: `/api/experimental/session/${encodeURIComponent(input.sessionID)}/terminal/read`,
|
|
25686
|
+
query: { lines: input["lines"] },
|
|
25687
|
+
successStatus: 200,
|
|
25688
|
+
declaredStatuses: [400, 401, 503],
|
|
25689
|
+
empty: false
|
|
25690
|
+
}, requestOptions).then((value) => value.data),
|
|
25691
|
+
list: (input, requestOptions) => request({
|
|
25692
|
+
method: "GET",
|
|
25693
|
+
path: `/api/experimental/session/${encodeURIComponent(input.sessionID)}/terminal`,
|
|
25694
|
+
successStatus: 200,
|
|
25695
|
+
declaredStatuses: [400, 401, 503],
|
|
25696
|
+
empty: false
|
|
25697
|
+
}, requestOptions).then((value) => value.data),
|
|
25698
|
+
create: (input, requestOptions) => request({
|
|
25699
|
+
method: "POST",
|
|
25700
|
+
path: `/api/experimental/session/${encodeURIComponent(input.sessionID)}/terminal`,
|
|
25701
|
+
body: {
|
|
25702
|
+
command: input["command"],
|
|
25703
|
+
args: input["args"],
|
|
25704
|
+
cwd: input["cwd"],
|
|
25705
|
+
title: input["title"],
|
|
25706
|
+
env: input["env"],
|
|
25707
|
+
size: input["size"]
|
|
25708
|
+
},
|
|
25709
|
+
successStatus: 200,
|
|
25710
|
+
declaredStatuses: [400, 401, 503],
|
|
25711
|
+
empty: false
|
|
25712
|
+
}, requestOptions).then((value) => value.data),
|
|
25713
|
+
shutdown: (requestOptions) => request({
|
|
25714
|
+
method: "POST",
|
|
25715
|
+
path: `/api/experimental/persistent-pty/shutdown`,
|
|
25716
|
+
successStatus: 204,
|
|
25717
|
+
declaredStatuses: [400, 401, 503],
|
|
25718
|
+
empty: true
|
|
25719
|
+
}, requestOptions),
|
|
25720
|
+
handoff: (requestOptions) => request({
|
|
25721
|
+
method: "POST",
|
|
25722
|
+
path: `/api/experimental/persistent-pty/handoff`,
|
|
25723
|
+
successStatus: 200,
|
|
25724
|
+
declaredStatuses: [400, 401, 503],
|
|
25725
|
+
empty: false
|
|
25726
|
+
}, requestOptions),
|
|
25727
|
+
get: (input, requestOptions) => request({
|
|
25728
|
+
method: "GET",
|
|
25729
|
+
path: `/api/experimental/persistent-pty/${encodeURIComponent(input.ptyID)}`,
|
|
25730
|
+
successStatus: 200,
|
|
25731
|
+
declaredStatuses: [400, 401, 404, 503],
|
|
25732
|
+
empty: false
|
|
25733
|
+
}, requestOptions).then((value) => value.data),
|
|
25734
|
+
update: (input, requestOptions) => request({
|
|
25735
|
+
method: "PUT",
|
|
25736
|
+
path: `/api/experimental/persistent-pty/${encodeURIComponent(input.ptyID)}`,
|
|
25737
|
+
body: { attachmentID: input["attachmentID"], size: input["size"] },
|
|
25738
|
+
successStatus: 200,
|
|
25739
|
+
declaredStatuses: [400, 401, 404, 503],
|
|
25740
|
+
empty: false
|
|
25741
|
+
}, requestOptions).then((value) => value.data),
|
|
25742
|
+
snapshot: (input, requestOptions) => request({
|
|
25743
|
+
method: "GET",
|
|
25744
|
+
path: `/api/experimental/persistent-pty/${encodeURIComponent(input.ptyID)}/snapshot`,
|
|
25745
|
+
successStatus: 200,
|
|
25746
|
+
declaredStatuses: [400, 401, 404, 503],
|
|
25747
|
+
empty: false
|
|
25748
|
+
}, requestOptions).then((value) => value.data),
|
|
25749
|
+
remove: (input, requestOptions) => request({
|
|
25750
|
+
method: "DELETE",
|
|
25751
|
+
path: `/api/experimental/persistent-pty/${encodeURIComponent(input.ptyID)}`,
|
|
25752
|
+
successStatus: 204,
|
|
25753
|
+
declaredStatuses: [400, 401, 404, 503],
|
|
25754
|
+
empty: true
|
|
25755
|
+
}, requestOptions),
|
|
25756
|
+
connectToken: (input, requestOptions) => request({
|
|
25757
|
+
method: "POST",
|
|
25758
|
+
path: `/api/experimental/persistent-pty/${encodeURIComponent(input.ptyID)}/connect-token`,
|
|
25759
|
+
headers: { "x-opencode-ticket": input["x-opencode-ticket"] },
|
|
25760
|
+
successStatus: 200,
|
|
25761
|
+
declaredStatuses: [400, 401, 403, 404, 503],
|
|
25762
|
+
empty: false
|
|
25763
|
+
}, requestOptions).then((value) => value.data)
|
|
25764
|
+
}
|
|
25765
|
+
},
|
|
25766
|
+
shell: {
|
|
25767
|
+
list: (input, requestOptions) => request({
|
|
25768
|
+
method: "GET",
|
|
25769
|
+
path: `/api/shell`,
|
|
25770
|
+
query: { location: input?.["location"] },
|
|
25771
|
+
successStatus: 200,
|
|
25772
|
+
declaredStatuses: [400, 401],
|
|
25773
|
+
empty: false
|
|
25774
|
+
}, requestOptions),
|
|
25775
|
+
create: (input, requestOptions) => request({
|
|
25776
|
+
method: "POST",
|
|
25777
|
+
path: `/api/shell`,
|
|
25778
|
+
query: { location: input["location"] },
|
|
25779
|
+
body: {
|
|
25780
|
+
command: input["command"],
|
|
25781
|
+
cwd: input["cwd"],
|
|
25782
|
+
timeout: input["timeout"],
|
|
25783
|
+
metadata: input["metadata"]
|
|
25784
|
+
},
|
|
25785
|
+
successStatus: 200,
|
|
25786
|
+
declaredStatuses: [400, 401],
|
|
25787
|
+
empty: false
|
|
25788
|
+
}, requestOptions),
|
|
25789
|
+
get: (input, requestOptions) => request({
|
|
25790
|
+
method: "GET",
|
|
25791
|
+
path: `/api/shell/${encodeURIComponent(input.id)}`,
|
|
25792
|
+
query: { location: input["location"] },
|
|
25793
|
+
successStatus: 200,
|
|
25794
|
+
declaredStatuses: [400, 401, 404],
|
|
25795
|
+
empty: false
|
|
25796
|
+
}, requestOptions),
|
|
25797
|
+
output: (input, requestOptions) => request({
|
|
25798
|
+
method: "GET",
|
|
25799
|
+
path: `/api/shell/${encodeURIComponent(input.id)}/output`,
|
|
25800
|
+
query: { location: input["location"], cursor: input["cursor"], limit: input["limit"] },
|
|
25801
|
+
successStatus: 200,
|
|
25802
|
+
declaredStatuses: [400, 401, 404],
|
|
25803
|
+
empty: false
|
|
25804
|
+
}, requestOptions),
|
|
25805
|
+
remove: (input, requestOptions) => request({
|
|
25806
|
+
method: "DELETE",
|
|
25807
|
+
path: `/api/shell/${encodeURIComponent(input.id)}`,
|
|
25808
|
+
query: { location: input["location"] },
|
|
25809
|
+
successStatus: 204,
|
|
25810
|
+
declaredStatuses: [400, 401],
|
|
25811
|
+
empty: true
|
|
25812
|
+
}, requestOptions)
|
|
25813
|
+
},
|
|
25814
|
+
reference: {
|
|
25815
|
+
list: (input, requestOptions) => request({
|
|
25816
|
+
method: "GET",
|
|
25817
|
+
path: `/api/reference`,
|
|
25818
|
+
query: { location: input?.["location"] },
|
|
25819
|
+
successStatus: 200,
|
|
25820
|
+
declaredStatuses: [400, 401],
|
|
25821
|
+
empty: false
|
|
25822
|
+
}, requestOptions)
|
|
25823
|
+
},
|
|
25824
|
+
worktree: {
|
|
25825
|
+
list: (input, requestOptions) => request({
|
|
25826
|
+
method: "GET",
|
|
25827
|
+
path: `/api/worktree`,
|
|
25828
|
+
query: { projectID: input["projectID"] },
|
|
25829
|
+
successStatus: 200,
|
|
25830
|
+
declaredStatuses: [400, 401, 404],
|
|
25831
|
+
empty: false
|
|
25832
|
+
}, requestOptions),
|
|
25833
|
+
create: (input, requestOptions) => request({
|
|
25834
|
+
method: "POST",
|
|
25835
|
+
path: `/api/worktree`,
|
|
25836
|
+
body: {
|
|
25837
|
+
projectID: input["projectID"],
|
|
25838
|
+
from: input["from"],
|
|
25839
|
+
branch: input["branch"],
|
|
25840
|
+
directory: input["directory"],
|
|
25841
|
+
name: input["name"]
|
|
25842
|
+
},
|
|
25843
|
+
successStatus: 200,
|
|
25844
|
+
declaredStatuses: [400, 401, 404],
|
|
25845
|
+
empty: false
|
|
25846
|
+
}, requestOptions),
|
|
25847
|
+
remove: (input, requestOptions) => request({
|
|
25848
|
+
method: "DELETE",
|
|
25849
|
+
path: `/api/worktree`,
|
|
25850
|
+
body: { projectID: input["projectID"], directory: input["directory"], force: input["force"] },
|
|
25851
|
+
successStatus: 204,
|
|
25852
|
+
declaredStatuses: [400, 401, 404],
|
|
25853
|
+
empty: true
|
|
25854
|
+
}, requestOptions),
|
|
25855
|
+
refresh: (input, requestOptions) => request({
|
|
25856
|
+
method: "POST",
|
|
25857
|
+
path: `/api/worktree/refresh`,
|
|
25858
|
+
body: { projectID: input["projectID"] },
|
|
25859
|
+
successStatus: 204,
|
|
25860
|
+
declaredStatuses: [400, 401, 404],
|
|
25861
|
+
empty: true
|
|
25862
|
+
}, requestOptions)
|
|
25863
|
+
},
|
|
25864
|
+
vcs: {
|
|
25865
|
+
get: (input, requestOptions) => request({
|
|
25866
|
+
method: "GET",
|
|
25867
|
+
path: `/api/vcs`,
|
|
25868
|
+
query: { location: input?.["location"] },
|
|
25869
|
+
successStatus: 200,
|
|
25870
|
+
declaredStatuses: [400, 401],
|
|
25871
|
+
empty: false
|
|
25872
|
+
}, requestOptions),
|
|
25873
|
+
base: (input, requestOptions) => request({
|
|
25874
|
+
method: "GET",
|
|
25875
|
+
path: `/api/vcs/base`,
|
|
25876
|
+
query: { location: input?.["location"] },
|
|
25877
|
+
successStatus: 200,
|
|
25878
|
+
declaredStatuses: [400, 401, 503],
|
|
25879
|
+
empty: false
|
|
25880
|
+
}, requestOptions),
|
|
25881
|
+
status: (input, requestOptions) => request({
|
|
25882
|
+
method: "GET",
|
|
25883
|
+
path: `/api/vcs/status`,
|
|
25884
|
+
query: { location: input?.["location"] },
|
|
25885
|
+
successStatus: 200,
|
|
25886
|
+
declaredStatuses: [400, 401],
|
|
25887
|
+
empty: false
|
|
25888
|
+
}, requestOptions),
|
|
25889
|
+
branch: {
|
|
25890
|
+
list: (input, requestOptions) => request({
|
|
25891
|
+
method: "GET",
|
|
25892
|
+
path: `/api/vcs/branch`,
|
|
25893
|
+
query: { location: input?.["location"], search: input?.["search"], limit: input?.["limit"] },
|
|
25894
|
+
successStatus: 200,
|
|
25895
|
+
declaredStatuses: [400, 401],
|
|
25896
|
+
empty: false
|
|
25897
|
+
}, requestOptions)
|
|
25898
|
+
},
|
|
25899
|
+
diff: (input, requestOptions) => request({
|
|
25900
|
+
method: "GET",
|
|
25901
|
+
path: `/api/vcs/diff`,
|
|
25902
|
+
query: { location: input["location"], mode: input["mode"], base: input["base"], context: input["context"] },
|
|
25903
|
+
successStatus: 200,
|
|
25904
|
+
declaredStatuses: [400, 401, 503],
|
|
25905
|
+
empty: false
|
|
25906
|
+
}, requestOptions)
|
|
25907
|
+
},
|
|
25908
|
+
debug: {
|
|
25909
|
+
location: {
|
|
25910
|
+
list: (requestOptions) => request({
|
|
25911
|
+
method: "GET",
|
|
25912
|
+
path: `/api/debug/location`,
|
|
25913
|
+
successStatus: 200,
|
|
25914
|
+
declaredStatuses: [400, 401],
|
|
25915
|
+
empty: false
|
|
25916
|
+
}, requestOptions),
|
|
25917
|
+
evict: (input, requestOptions) => request({
|
|
25918
|
+
method: "DELETE",
|
|
25919
|
+
path: `/api/debug/location`,
|
|
25920
|
+
query: { location: input?.["location"] },
|
|
25921
|
+
successStatus: 204,
|
|
25922
|
+
declaredStatuses: [400, 401],
|
|
25923
|
+
empty: true
|
|
25924
|
+
}, requestOptions)
|
|
25925
|
+
}
|
|
25926
|
+
},
|
|
25927
|
+
migration: {
|
|
25928
|
+
v1: {
|
|
25929
|
+
status: (requestOptions) => request({
|
|
25930
|
+
method: "GET",
|
|
25931
|
+
path: `/api/experimental/migration/v1`,
|
|
25932
|
+
successStatus: 200,
|
|
25933
|
+
declaredStatuses: [400, 401],
|
|
25934
|
+
empty: false
|
|
25935
|
+
}, requestOptions)
|
|
25936
|
+
}
|
|
25937
|
+
},
|
|
25938
|
+
websearch: {
|
|
25939
|
+
providers: (input, requestOptions) => request({
|
|
25940
|
+
method: "GET",
|
|
25941
|
+
path: `/api/websearch/provider`,
|
|
25942
|
+
query: { location: input?.["location"] },
|
|
25943
|
+
successStatus: 200,
|
|
25944
|
+
declaredStatuses: [400, 401, 503],
|
|
25945
|
+
empty: false
|
|
25946
|
+
}, requestOptions),
|
|
25947
|
+
query: (input, requestOptions) => request({
|
|
25948
|
+
method: "POST",
|
|
25949
|
+
path: `/api/websearch`,
|
|
25950
|
+
query: { location: input["location"] },
|
|
25951
|
+
body: { query: input["query"], providerID: input["providerID"] },
|
|
25952
|
+
successStatus: 200,
|
|
25953
|
+
declaredStatuses: [400, 401, 503],
|
|
25954
|
+
empty: false
|
|
25955
|
+
}, requestOptions)
|
|
25956
|
+
},
|
|
25957
|
+
config: {
|
|
25958
|
+
get: (input, requestOptions) => request({
|
|
25959
|
+
method: "GET",
|
|
25960
|
+
path: `/api/config`,
|
|
25961
|
+
query: { location: input?.["location"] },
|
|
25962
|
+
successStatus: 200,
|
|
25963
|
+
declaredStatuses: [400, 401],
|
|
25964
|
+
empty: false
|
|
25965
|
+
}, requestOptions),
|
|
25966
|
+
shells: (requestOptions) => request({ method: "GET", path: `/api/config/shell`, successStatus: 200, declaredStatuses: [400, 401], empty: false }, requestOptions),
|
|
25967
|
+
update: (input, requestOptions) => request({
|
|
25968
|
+
method: "PATCH",
|
|
25969
|
+
path: `/api/experimental/config`,
|
|
25970
|
+
body: { shell: input["shell"] },
|
|
25971
|
+
successStatus: 204,
|
|
25972
|
+
declaredStatuses: [400, 401],
|
|
25973
|
+
empty: true
|
|
25974
|
+
}, requestOptions)
|
|
25975
|
+
}
|
|
25976
|
+
};
|
|
25977
|
+
}
|
|
25978
|
+
function encodePath(value) {
|
|
25979
|
+
return value.split("/").map(encodeURIComponent).join("/");
|
|
25980
|
+
}
|
|
25981
|
+
function appendQuery(params, key, value) {
|
|
25982
|
+
if (value === void 0)
|
|
25983
|
+
return;
|
|
25984
|
+
if (value === null) {
|
|
25985
|
+
params.append(key, "null");
|
|
25986
|
+
return;
|
|
25987
|
+
}
|
|
25988
|
+
if (Array.isArray(value)) {
|
|
25989
|
+
for (const item of value)
|
|
25990
|
+
appendQuery(params, key, item);
|
|
25991
|
+
return;
|
|
25992
|
+
}
|
|
25993
|
+
if (typeof value === "object") {
|
|
25994
|
+
for (const [child, item] of Object.entries(value))
|
|
25995
|
+
appendQuery(params, `${key}[${child}]`, item);
|
|
25996
|
+
return;
|
|
25997
|
+
}
|
|
25998
|
+
params.append(key, String(value));
|
|
25999
|
+
}
|
|
26000
|
+
async function json2(response) {
|
|
26001
|
+
if (!isContentType(response, "application/json") && !response.headers.get("content-type")?.includes("+json")) {
|
|
26002
|
+
try {
|
|
26003
|
+
await response.body?.cancel();
|
|
26004
|
+
} catch {
|
|
26005
|
+
}
|
|
26006
|
+
throw new ClientError3("UnsupportedContentType", { detail: response.headers.get("content-type") });
|
|
26007
|
+
}
|
|
26008
|
+
let text;
|
|
26009
|
+
try {
|
|
26010
|
+
text = await response.text();
|
|
26011
|
+
} catch (cause) {
|
|
26012
|
+
throw new ClientError3("Transport", { cause });
|
|
26013
|
+
}
|
|
26014
|
+
if (text === "")
|
|
26015
|
+
throw new ClientError3("MalformedResponse");
|
|
26016
|
+
try {
|
|
26017
|
+
return JSON.parse(text);
|
|
26018
|
+
} catch (cause) {
|
|
26019
|
+
throw new ClientError3("MalformedResponse", { cause });
|
|
26020
|
+
}
|
|
26021
|
+
}
|
|
26022
|
+
function declared(body) {
|
|
26023
|
+
const error51 = Object.assign(new Error(body.message ?? body.data?.message), body);
|
|
26024
|
+
if (body._tag)
|
|
26025
|
+
error51.name = body._tag;
|
|
26026
|
+
return error51;
|
|
26027
|
+
}
|
|
26028
|
+
function isContentType(response, expected) {
|
|
26029
|
+
return response.headers.get("content-type")?.split(";", 1)[0]?.trim().toLowerCase() === expected;
|
|
26030
|
+
}
|
|
26031
|
+
|
|
26032
|
+
// ../../../node_modules/@opencode/client/dist/chunks/service-timing-4tveyqeh.js
|
|
26033
|
+
var isRpcError2 = (value) => typeof value === "object" && value !== null && "_tag" in value && value["_tag"] === "RpcError";
|
|
26034
|
+
var isRpcInternalError2 = (value) => typeof value === "object" && value !== null && "_tag" in value && value["_tag"] === "RpcInternalError";
|
|
26035
|
+
|
|
26036
|
+
// ../../../node_modules/@opencode/client/dist/chunks/service-timing-1tbj6z39.js
|
|
26037
|
+
function makeRpc2(raw, events) {
|
|
26038
|
+
return (definition) => {
|
|
26039
|
+
const subscribe = (name, options) => {
|
|
26040
|
+
if (!Object.hasOwn(definition.events, name))
|
|
26041
|
+
throw new Error(`Unknown RPC event: ${definition.id}.${name}`);
|
|
26042
|
+
const type = eventType(definition, name);
|
|
26043
|
+
return {
|
|
26044
|
+
[Symbol.asyncIterator]() {
|
|
26045
|
+
const controller = new AbortController();
|
|
26046
|
+
const signal = options?.signal ? AbortSignal.any([controller.signal, options.signal]) : controller.signal;
|
|
26047
|
+
const iterator = (async function* () {
|
|
26048
|
+
try {
|
|
26049
|
+
for await (const published of events.subscribe({ signal })) {
|
|
26050
|
+
if (signal.aborted)
|
|
26051
|
+
return;
|
|
26052
|
+
if (published.type !== type)
|
|
26053
|
+
continue;
|
|
26054
|
+
yield published;
|
|
26055
|
+
}
|
|
26056
|
+
} catch (error51) {
|
|
26057
|
+
if (!signal.aborted)
|
|
26058
|
+
throw error51;
|
|
26059
|
+
} finally {
|
|
26060
|
+
controller.abort();
|
|
26061
|
+
}
|
|
26062
|
+
})();
|
|
26063
|
+
return {
|
|
26064
|
+
next: () => iterator.next(),
|
|
26065
|
+
return: () => {
|
|
26066
|
+
controller.abort();
|
|
26067
|
+
return iterator.return();
|
|
26068
|
+
}
|
|
26069
|
+
};
|
|
26070
|
+
}
|
|
26071
|
+
};
|
|
26072
|
+
};
|
|
26073
|
+
return Object.assign(Object.fromEntries(Object.keys(definition.methods).map((name) => [
|
|
26074
|
+
name,
|
|
26075
|
+
async (input, options) => {
|
|
26076
|
+
try {
|
|
26077
|
+
const result = await raw.rpc.call({
|
|
26078
|
+
rpcID: definition.id,
|
|
26079
|
+
method: name,
|
|
26080
|
+
input,
|
|
26081
|
+
location: options?.location
|
|
26082
|
+
}, { signal: options?.signal, headers: options?.headers });
|
|
26083
|
+
return result.output;
|
|
26084
|
+
} catch (error51) {
|
|
26085
|
+
if (!isRpcError2(error51) && !isRpcInternalError2(error51))
|
|
26086
|
+
throw error51;
|
|
26087
|
+
throw error51.data === void 0 ? { type: error51.type, message: error51.message } : { type: error51.type, message: error51.message, data: error51.data };
|
|
26088
|
+
}
|
|
26089
|
+
}
|
|
26090
|
+
])), {
|
|
26091
|
+
events: {
|
|
26092
|
+
subscribe,
|
|
26093
|
+
on: (name, handler, options) => {
|
|
26094
|
+
const controller = new AbortController();
|
|
26095
|
+
const signal = options?.signal ? AbortSignal.any([controller.signal, options.signal]) : controller.signal;
|
|
26096
|
+
const source = subscribe(name, { signal });
|
|
26097
|
+
(async () => {
|
|
26098
|
+
for await (const event of source)
|
|
26099
|
+
await handler(event);
|
|
26100
|
+
})().catch((error51) => console.error(error51));
|
|
26101
|
+
return () => controller.abort();
|
|
26102
|
+
}
|
|
26103
|
+
}
|
|
26104
|
+
});
|
|
26105
|
+
};
|
|
26106
|
+
}
|
|
26107
|
+
function eventType(definition, name) {
|
|
26108
|
+
return `rpc.${definition.id}.${name}`;
|
|
26109
|
+
}
|
|
26110
|
+
|
|
26111
|
+
// ../../../node_modules/@opencode/client/dist/chunks/service-timing-2twkm0vy.js
|
|
26112
|
+
var exports_client3 = {};
|
|
26113
|
+
__export2(exports_client3, {
|
|
26114
|
+
OpenCode: () => exports_client3,
|
|
26115
|
+
make: () => make5
|
|
26116
|
+
});
|
|
26117
|
+
function make5(options) {
|
|
26118
|
+
const raw = make6(options);
|
|
26119
|
+
const events = make7((signal, onActivity) => raw.event.subscribe({ signal, onActivity }));
|
|
26120
|
+
return {
|
|
26121
|
+
...raw,
|
|
26122
|
+
rpc: Object.assign(makeRpc2(raw, events), raw.rpc),
|
|
26123
|
+
event: events
|
|
26124
|
+
};
|
|
26125
|
+
}
|
|
26126
|
+
|
|
26127
|
+
// dist/v2/connection.js
|
|
26128
|
+
var V2Connection = class {
|
|
26129
|
+
options;
|
|
26130
|
+
cwd;
|
|
26131
|
+
#child;
|
|
26132
|
+
#starting;
|
|
26133
|
+
#closing;
|
|
26134
|
+
#abort = new AbortController();
|
|
26135
|
+
#stderr = "";
|
|
26136
|
+
constructor(options, cwd) {
|
|
26137
|
+
this.options = options;
|
|
26138
|
+
this.cwd = cwd;
|
|
26139
|
+
}
|
|
26140
|
+
get stderrTail() {
|
|
26141
|
+
return this.#stderr;
|
|
26142
|
+
}
|
|
26143
|
+
client() {
|
|
26144
|
+
if (this.#closing)
|
|
26145
|
+
return Promise.reject(new Error("OpenCode v2 connection is closed"));
|
|
26146
|
+
return this.#starting ??= this.#start();
|
|
26147
|
+
}
|
|
26148
|
+
async #start() {
|
|
26149
|
+
const password = randomBytes2(32).toString("base64url");
|
|
26150
|
+
const env = {
|
|
26151
|
+
...this.options.environment ?? process.env,
|
|
26152
|
+
OPENCODE_PASSWORD: password,
|
|
26153
|
+
OPENCODE_SERVER_PASSWORD: password
|
|
26154
|
+
};
|
|
26155
|
+
const executable = resolveOpenCodeExecutable({
|
|
26156
|
+
...this.options.command ? { command: this.options.command } : {},
|
|
26157
|
+
environment: env
|
|
26158
|
+
});
|
|
26159
|
+
const invocation = openCodeServerInvocation(executable, env);
|
|
26160
|
+
const child = spawn2(invocation.command, invocation.arguments, {
|
|
26161
|
+
env,
|
|
26162
|
+
cwd: this.cwd,
|
|
26163
|
+
stdio: "pipe",
|
|
26164
|
+
detached: process.platform !== "win32",
|
|
26165
|
+
windowsHide: true,
|
|
26166
|
+
windowsVerbatimArguments: invocation.windowsVerbatimArguments
|
|
26167
|
+
});
|
|
26168
|
+
this.#child = child;
|
|
26169
|
+
child.stderr.on("data", (chunk) => {
|
|
26170
|
+
this.#stderr = sanitizeDiagnosticTail(this.#stderr + chunk.toString());
|
|
26171
|
+
});
|
|
26172
|
+
try {
|
|
26173
|
+
const baseUrl = await new Promise((resolve, reject) => {
|
|
26174
|
+
let output = "";
|
|
26175
|
+
const timer = setTimeout(() => finish(new Error("OpenCode v2 server startup timed out")), this.options.startupTimeoutMs ?? 2e4);
|
|
26176
|
+
const abort = () => finish(new Error("OpenCode v2 connection closed during startup"));
|
|
26177
|
+
const finish = (error51, url2) => {
|
|
26178
|
+
clearTimeout(timer);
|
|
26179
|
+
this.#abort.signal.removeEventListener("abort", abort);
|
|
26180
|
+
if (error51)
|
|
26181
|
+
reject(error51);
|
|
26182
|
+
else if (url2)
|
|
26183
|
+
resolve(url2);
|
|
26184
|
+
};
|
|
26185
|
+
this.#abort.signal.addEventListener("abort", abort, { once: true });
|
|
26186
|
+
child.once("error", (error51) => finish(error51));
|
|
26187
|
+
child.once("exit", (code, signal) => finish(new Error(`OpenCode v2 server exited (${signal ?? code})`)));
|
|
26188
|
+
child.stdout.on("data", (chunk) => {
|
|
26189
|
+
output += chunk.toString();
|
|
26190
|
+
const lines = output.split(/\r?\n/u);
|
|
26191
|
+
output = (lines.pop() ?? "").slice(-8192);
|
|
26192
|
+
for (const line of lines) {
|
|
26193
|
+
const url2 = /^server listening on (http:\/\/127\.0\.0\.1:\d+)\s*$/u.exec(line)?.[1];
|
|
26194
|
+
if (url2)
|
|
26195
|
+
finish(void 0, url2);
|
|
26196
|
+
}
|
|
26197
|
+
});
|
|
26198
|
+
});
|
|
26199
|
+
const client2 = exports_client3.make({
|
|
26200
|
+
baseUrl,
|
|
26201
|
+
headers: {
|
|
26202
|
+
Authorization: `Basic ${Buffer.from(`opencode:${password}`).toString("base64")}`
|
|
26203
|
+
},
|
|
26204
|
+
fetch: (request, init) => {
|
|
26205
|
+
const signal = AbortSignal.any([
|
|
26206
|
+
this.#abort.signal,
|
|
26207
|
+
...init?.signal ? [init.signal] : [],
|
|
26208
|
+
// Event streams keep their caller-owned lifetime; ordinary requests are bounded.
|
|
26209
|
+
...(request instanceof Request ? request.url : String(request)).includes("/event") ? [] : [AbortSignal.timeout(this.options.commandTimeoutMs ?? 2e4)]
|
|
26210
|
+
]);
|
|
26211
|
+
return fetch(request, { ...init, signal });
|
|
26212
|
+
}
|
|
26213
|
+
});
|
|
26214
|
+
const info = await client2.server.info();
|
|
26215
|
+
if (!/^2\./u.test(info.version))
|
|
26216
|
+
throw new Error(`Expected OpenCode v2 server, received ${info.version}`);
|
|
26217
|
+
return client2;
|
|
26218
|
+
} catch (error51) {
|
|
26219
|
+
await this.#stop();
|
|
26220
|
+
throw error51;
|
|
26221
|
+
}
|
|
26222
|
+
}
|
|
26223
|
+
close() {
|
|
26224
|
+
return this.#closing ??= (async () => {
|
|
26225
|
+
this.#abort.abort();
|
|
26226
|
+
await this.#stop();
|
|
26227
|
+
await this.#starting?.catch(() => void 0);
|
|
26228
|
+
})();
|
|
26229
|
+
}
|
|
26230
|
+
async #stop() {
|
|
26231
|
+
const child = this.#child;
|
|
26232
|
+
if (!child?.pid)
|
|
26233
|
+
return;
|
|
26234
|
+
const pid = child.pid;
|
|
26235
|
+
const kill = (signal) => {
|
|
26236
|
+
try {
|
|
26237
|
+
if (process.platform === "win32")
|
|
26238
|
+
spawnSync2("taskkill.exe", ["/pid", String(child.pid), "/t", "/f"], {
|
|
26239
|
+
windowsHide: true,
|
|
26240
|
+
stdio: "ignore"
|
|
26241
|
+
});
|
|
26242
|
+
else
|
|
26243
|
+
process.kill(-pid, signal);
|
|
26244
|
+
} catch {
|
|
26245
|
+
}
|
|
26246
|
+
};
|
|
26247
|
+
if (child.exitCode === null && child.signalCode === null) {
|
|
26248
|
+
await new Promise((resolve) => {
|
|
26249
|
+
const timer = setTimeout(() => {
|
|
26250
|
+
kill("SIGKILL");
|
|
26251
|
+
resolve();
|
|
26252
|
+
}, this.options.closeTimeoutMs ?? 3e3);
|
|
26253
|
+
child.once("exit", () => {
|
|
26254
|
+
clearTimeout(timer);
|
|
26255
|
+
resolve();
|
|
26256
|
+
});
|
|
26257
|
+
kill("SIGTERM");
|
|
26258
|
+
});
|
|
26259
|
+
}
|
|
26260
|
+
if (this.#child === child)
|
|
26261
|
+
this.#child = void 0;
|
|
26262
|
+
}
|
|
26263
|
+
};
|
|
26264
|
+
|
|
26265
|
+
// dist/v2/history.js
|
|
26266
|
+
import path10 from "node:path";
|
|
26267
|
+
async function readMessages(client2, sessionID) {
|
|
26268
|
+
const messages = [];
|
|
26269
|
+
let cursor;
|
|
26270
|
+
const seen = /* @__PURE__ */ new Set();
|
|
26271
|
+
do {
|
|
26272
|
+
const page = await client2.message.list({
|
|
26273
|
+
sessionID,
|
|
26274
|
+
...cursor ? { cursor } : { order: "asc", limit: 100 }
|
|
26275
|
+
});
|
|
26276
|
+
messages.push(...page.data);
|
|
26277
|
+
cursor = page.cursor.next ?? void 0;
|
|
26278
|
+
if (cursor && seen.has(cursor))
|
|
26279
|
+
throw new Error("OpenCode v2 transcript pagination did not advance");
|
|
26280
|
+
if (cursor)
|
|
26281
|
+
seen.add(cursor);
|
|
26282
|
+
} while (cursor);
|
|
26283
|
+
return messages;
|
|
26284
|
+
}
|
|
26285
|
+
var contentId = (messageID, index) => hostItemIdSchema.parse(`${messageID}:${index}`);
|
|
26286
|
+
function assistantItems2(message, limit) {
|
|
26287
|
+
return message.content.map((part, index) => {
|
|
26288
|
+
const itemId2 = contentId(message.id, index);
|
|
26289
|
+
if (part.type === "text" || part.type === "reasoning") {
|
|
26290
|
+
return {
|
|
26291
|
+
item: {
|
|
26292
|
+
type: part.type === "text" ? "agentMessage" : "reasoning",
|
|
26293
|
+
itemId: itemId2,
|
|
26294
|
+
text: part.text
|
|
26295
|
+
},
|
|
26296
|
+
outcome: message.error ? { status: "failed", error: failure(message.error.message) } : { status: "succeeded" }
|
|
26297
|
+
};
|
|
26298
|
+
}
|
|
26299
|
+
const state = part.state;
|
|
26300
|
+
const text = "content" in state ? state.content?.map((p) => p.type === "text" ? p.text : `[File: ${p.uri}]`).join("\n") : void 0;
|
|
26301
|
+
return {
|
|
26302
|
+
item: {
|
|
26303
|
+
type: "toolExecution",
|
|
26304
|
+
itemId: itemId2,
|
|
26305
|
+
toolName: part.name,
|
|
26306
|
+
namespace: "opencode",
|
|
26307
|
+
arguments: typeof state.input === "string" ? state.input : state.input,
|
|
26308
|
+
...text ? {
|
|
26309
|
+
output: {
|
|
26310
|
+
content: [{ type: "text", text: text.slice(0, limit) }],
|
|
26311
|
+
...text.length > limit ? { truncated: true } : {}
|
|
26312
|
+
}
|
|
26313
|
+
} : {}
|
|
26314
|
+
},
|
|
26315
|
+
outcome: state.status === "error" ? { status: "failed", error: failure(state.error.message) } : state.status === "completed" ? { status: "succeeded" } : { status: "cancelled", reason: "Native Tool did not complete" }
|
|
26316
|
+
};
|
|
26317
|
+
});
|
|
26318
|
+
}
|
|
26319
|
+
function projectHistory(session, messages, limit) {
|
|
26320
|
+
if (session.revert)
|
|
26321
|
+
throw new Error("Clear the staged OpenCode v2 revert before using this Session in codexhost");
|
|
26322
|
+
const turns = [];
|
|
26323
|
+
let turn;
|
|
26324
|
+
for (const message of messages) {
|
|
26325
|
+
if (message.type === "user" && turn) {
|
|
26326
|
+
turn.input.push({ type: "text", text: message.text });
|
|
26327
|
+
} else if (message.type === "user" || message.type === "compaction" && message.reason === "manual" && !turn) {
|
|
26328
|
+
turn = {
|
|
26329
|
+
nativeTurnRef: nativeTurnRefSchema.parse({
|
|
26330
|
+
harnessId,
|
|
26331
|
+
nativeSessionId: session.id,
|
|
26332
|
+
nativeTurnKey: message.id,
|
|
26333
|
+
formatVersion: 1
|
|
26334
|
+
}),
|
|
26335
|
+
input: message.type === "user" ? [{ type: "text", text: message.text }] : [],
|
|
26336
|
+
items: [],
|
|
26337
|
+
outcome: { status: "unknown", reason: "OpenCode execution has no durable terminal" },
|
|
26338
|
+
startedAtMs: message.time.created
|
|
26339
|
+
};
|
|
26340
|
+
turns.push(turn);
|
|
26341
|
+
}
|
|
26342
|
+
if (!turn)
|
|
26343
|
+
continue;
|
|
26344
|
+
if (message.type === "assistant") {
|
|
26345
|
+
turn.items.push(...assistantItems2(message, limit));
|
|
26346
|
+
turn.model = encodeOpenCodeModelRef({
|
|
26347
|
+
providerID: message.model.providerID,
|
|
26348
|
+
modelID: message.model.id
|
|
26349
|
+
});
|
|
26350
|
+
} else if (message.type === "compaction") {
|
|
26351
|
+
turn.items.push({
|
|
26352
|
+
item: { type: "contextCompaction", itemId: hostItemIdSchema.parse(message.id) },
|
|
26353
|
+
outcome: message.status === "failed" ? { status: "failed", error: failure(message.error.message) } : message.status === "completed" ? { status: "succeeded" } : { status: "cancelled", reason: "Compaction is incomplete" }
|
|
26354
|
+
});
|
|
26355
|
+
} else if (message.type === "shell") {
|
|
26356
|
+
turn.items.push({
|
|
26357
|
+
item: {
|
|
26358
|
+
type: "commandExecution",
|
|
26359
|
+
itemId: hostItemIdSchema.parse(message.id),
|
|
26360
|
+
command: message.command,
|
|
26361
|
+
...message.output ? {
|
|
26362
|
+
output: message.output.output.slice(0, limit),
|
|
26363
|
+
outputTruncated: message.output.truncated || message.output.output.length > limit
|
|
26364
|
+
} : {},
|
|
26365
|
+
...typeof message.exit === "number" ? { exitCode: message.exit } : {}
|
|
26366
|
+
},
|
|
26367
|
+
outcome: message.status === "killed" ? { status: "cancelled" } : message.exit === 0 ? { status: "succeeded" } : {
|
|
26368
|
+
status: "failed",
|
|
26369
|
+
error: failure(`Shell ${message.status}, exit ${message.exit ?? "unknown"}`)
|
|
26370
|
+
}
|
|
26371
|
+
});
|
|
26372
|
+
} else if (message.type === "idle") {
|
|
26373
|
+
turn.outcome = message.outcome === "interrupted" ? { status: "cancelled" } : message.outcome === "failed" ? { status: "failed", error: failure("OpenCode v2 execution failed") } : { status: "succeeded" };
|
|
26374
|
+
turn.completedAtMs = message.time.created;
|
|
26375
|
+
turn.checkpoint = nativeCheckpointRefSchema.parse({
|
|
26376
|
+
harnessId,
|
|
26377
|
+
nativeSessionId: session.id,
|
|
26378
|
+
checkpointId: message.id,
|
|
26379
|
+
locator: { protocol: 2, userMessageID: turn.nativeTurnRef.nativeTurnKey },
|
|
26380
|
+
formatVersion: 1
|
|
26381
|
+
});
|
|
26382
|
+
turn = void 0;
|
|
26383
|
+
}
|
|
26384
|
+
}
|
|
26385
|
+
return { turns };
|
|
26386
|
+
}
|
|
26387
|
+
function fileChanges(session, turn, diffs) {
|
|
26388
|
+
if (!diffs.length)
|
|
26389
|
+
return void 0;
|
|
26390
|
+
const changes = diffs.map((diff) => {
|
|
26391
|
+
const absolute = path10.resolve(session.location.directory, diff.file);
|
|
26392
|
+
const relative = path10.relative(session.location.directory, absolute);
|
|
26393
|
+
if (relative.startsWith(`..${path10.sep}`) || relative === ".." || path10.isAbsolute(relative))
|
|
26394
|
+
throw new Error("OpenCode v2 diff escaped the Session directory");
|
|
26395
|
+
return {
|
|
26396
|
+
path: absolute,
|
|
26397
|
+
kind: diff.status === "added" ? "add" : diff.status === "deleted" ? "delete" : "update",
|
|
26398
|
+
unifiedDiff: diff.patch
|
|
26399
|
+
};
|
|
26400
|
+
});
|
|
26401
|
+
return {
|
|
26402
|
+
item: {
|
|
26403
|
+
type: "fileChange",
|
|
26404
|
+
itemId: hostItemIdSchema.parse(`${turn.nativeTurnRef.nativeTurnKey}:diff`),
|
|
26405
|
+
changes
|
|
26406
|
+
},
|
|
26407
|
+
outcome: { status: "succeeded" }
|
|
26408
|
+
};
|
|
26409
|
+
}
|
|
26410
|
+
async function readHistory(client2, session, limit) {
|
|
26411
|
+
const messages = await readMessages(client2, session.id);
|
|
26412
|
+
const snapshot = projectHistory(session, messages, limit);
|
|
26413
|
+
for (const turn of snapshot.turns) {
|
|
26414
|
+
if (!turn.checkpoint)
|
|
26415
|
+
continue;
|
|
26416
|
+
const first = messages.findIndex((m) => m.id === turn.nativeTurnRef.nativeTurnKey);
|
|
26417
|
+
const last = messages.findIndex((m) => m.id === turn.checkpoint?.checkpointId);
|
|
26418
|
+
if (!messages.slice(first, last).some((m) => m.type === "assistant" && m.snapshot?.files?.length))
|
|
26419
|
+
continue;
|
|
26420
|
+
const diffs = await client2.session.diff({
|
|
26421
|
+
sessionID: session.id,
|
|
26422
|
+
from: turn.nativeTurnRef.nativeTurnKey
|
|
26423
|
+
});
|
|
26424
|
+
const item = fileChanges(session, turn, diffs);
|
|
26425
|
+
if (item)
|
|
26426
|
+
turn.items.push(item);
|
|
26427
|
+
}
|
|
26428
|
+
return { messages, snapshot };
|
|
26429
|
+
}
|
|
26430
|
+
function terminalItemOutcome(outcome) {
|
|
26431
|
+
return outcome.status === "unknown" ? { status: "failed", error: failure(outcome.reason, "protocolError") } : outcome;
|
|
26432
|
+
}
|
|
26433
|
+
|
|
26434
|
+
// dist/v2/interactions.js
|
|
26435
|
+
function permissionInteraction(request, turnId) {
|
|
26436
|
+
return {
|
|
26437
|
+
request,
|
|
26438
|
+
interaction: {
|
|
26439
|
+
type: "approval",
|
|
26440
|
+
interactionId: hostInteractionIdSchema.parse(`oc2-permission:${request.id}`),
|
|
26441
|
+
turnId,
|
|
26442
|
+
title: request.action,
|
|
26443
|
+
description: request.message ?? request.resources.join("\n"),
|
|
26444
|
+
subject: { type: "nativeAction" },
|
|
26445
|
+
actions: [
|
|
26446
|
+
{ id: "once", label: "Allow once", effect: "allowOnce" },
|
|
26447
|
+
{ id: "reject", label: "Deny", effect: "deny" }
|
|
26448
|
+
]
|
|
26449
|
+
}
|
|
26450
|
+
};
|
|
26451
|
+
}
|
|
26452
|
+
function formInteraction(form, turnId) {
|
|
26453
|
+
const questions = form.fields.map((field) => {
|
|
26454
|
+
if (field.type === "external" || field.hidden || field.when?.length) {
|
|
26455
|
+
throw new Error("OpenCode v2 external, hidden or conditional form fields require its native UI");
|
|
26456
|
+
}
|
|
26457
|
+
const base = {
|
|
26458
|
+
id: field.key,
|
|
26459
|
+
prompt: [field.title, field.description].filter(Boolean).join("\n") || field.key,
|
|
26460
|
+
optional: !field.required
|
|
26461
|
+
};
|
|
26462
|
+
if (field.type === "boolean")
|
|
26463
|
+
return {
|
|
26464
|
+
...base,
|
|
26465
|
+
type: "choice",
|
|
26466
|
+
multiple: false,
|
|
26467
|
+
allowOther: false,
|
|
26468
|
+
options: [
|
|
26469
|
+
{ value: "true", label: "Yes" },
|
|
26470
|
+
{ value: "false", label: "No" }
|
|
26471
|
+
]
|
|
26472
|
+
};
|
|
26473
|
+
if (field.type === "multiselect" || field.type === "string" && field.options?.length) {
|
|
26474
|
+
return {
|
|
26475
|
+
...base,
|
|
26476
|
+
type: "choice",
|
|
26477
|
+
multiple: field.type === "multiselect",
|
|
26478
|
+
allowOther: field.custom ?? false,
|
|
26479
|
+
options: field.options ?? []
|
|
26480
|
+
};
|
|
26481
|
+
}
|
|
26482
|
+
return {
|
|
26483
|
+
...base,
|
|
26484
|
+
type: "text",
|
|
26485
|
+
multiline: field.type === "string",
|
|
26486
|
+
secret: false,
|
|
26487
|
+
...field.type === "string" && field.placeholder ? { placeholder: field.placeholder } : {},
|
|
26488
|
+
...field.default !== void 0 ? { prefill: String(field.default) } : {}
|
|
26489
|
+
};
|
|
26490
|
+
});
|
|
26491
|
+
return {
|
|
26492
|
+
form,
|
|
26493
|
+
interaction: {
|
|
26494
|
+
type: "question",
|
|
26495
|
+
interactionId: hostInteractionIdSchema.parse(`oc2-form:${form.id}`),
|
|
26496
|
+
turnId,
|
|
26497
|
+
title: form.title,
|
|
26498
|
+
questions
|
|
26499
|
+
}
|
|
26500
|
+
};
|
|
26501
|
+
}
|
|
26502
|
+
async function replyInteraction(client2, pending, command) {
|
|
26503
|
+
if (pending.interaction.type === "approval" && pending.request) {
|
|
26504
|
+
if (command.response.type !== "approval")
|
|
26505
|
+
throw new Error("Expected OpenCode approval decision");
|
|
26506
|
+
const validation2 = validateHostApprovalResponse(pending.interaction, command.response);
|
|
26507
|
+
if (validation2)
|
|
26508
|
+
throw new Error(validation2.message);
|
|
26509
|
+
if (command.response.type !== "approval" || !["once", "reject"].includes(command.response.actionId))
|
|
26510
|
+
throw new Error("Invalid OpenCode approval decision");
|
|
26511
|
+
await client2.permission.reply({
|
|
26512
|
+
sessionID: pending.request.sessionID,
|
|
26513
|
+
requestID: pending.request.id,
|
|
26514
|
+
decision: command.response.actionId === "once" ? "once" : "reject"
|
|
26515
|
+
});
|
|
26516
|
+
return;
|
|
26517
|
+
}
|
|
26518
|
+
if (pending.interaction.type !== "question" || !pending.form)
|
|
26519
|
+
throw new Error("Invalid OpenCode interaction");
|
|
26520
|
+
if (command.response.type !== "question")
|
|
26521
|
+
throw new Error("Expected OpenCode form answer");
|
|
26522
|
+
const validation = validateHostQuestionResponse(pending.interaction, command.response);
|
|
26523
|
+
if (validation)
|
|
26524
|
+
throw new Error(validation.message);
|
|
26525
|
+
const form = pending.form;
|
|
26526
|
+
if (command.response.cancelled) {
|
|
26527
|
+
await client2.session.form.cancel({ sessionID: form.sessionID, formID: form.id });
|
|
26528
|
+
return;
|
|
26529
|
+
}
|
|
26530
|
+
const answer = {};
|
|
26531
|
+
for (const field of form.fields) {
|
|
26532
|
+
const values = command.response.answers[field.key] ?? [];
|
|
26533
|
+
if (!values.length)
|
|
26534
|
+
continue;
|
|
26535
|
+
const value = values[0];
|
|
26536
|
+
if (value === void 0)
|
|
26537
|
+
continue;
|
|
26538
|
+
if (field.type === "multiselect")
|
|
26539
|
+
answer[field.key] = values;
|
|
26540
|
+
else if (field.type === "boolean")
|
|
26541
|
+
answer[field.key] = value === "true";
|
|
26542
|
+
else if (field.type === "number" || field.type === "integer") {
|
|
26543
|
+
const number4 = Number(value);
|
|
26544
|
+
if (!value.trim() || !Number.isFinite(number4) || field.type === "integer" && !Number.isInteger(number4))
|
|
26545
|
+
throw new Error(`Invalid number for ${field.key}`);
|
|
26546
|
+
answer[field.key] = number4;
|
|
26547
|
+
} else
|
|
26548
|
+
answer[field.key] = value;
|
|
26549
|
+
}
|
|
26550
|
+
await client2.session.form.reply({ sessionID: form.sessionID, formID: form.id, answer });
|
|
26551
|
+
}
|
|
26552
|
+
|
|
26553
|
+
// dist/v2/session.js
|
|
26554
|
+
function v2Capabilities(catalog) {
|
|
26555
|
+
return {
|
|
26556
|
+
configuration: {
|
|
26557
|
+
selectModel: catalog.models.length > 0,
|
|
26558
|
+
selectThinkingOption: catalog.thinkingOptions.length > 1,
|
|
26559
|
+
selectPermissionMode: true,
|
|
26560
|
+
permissionModeScope: "live"
|
|
26561
|
+
},
|
|
26562
|
+
history: { fork: true, forkAcrossCwd: false, rollbackLastTurn: true }
|
|
26563
|
+
};
|
|
26564
|
+
}
|
|
26565
|
+
var V2Session = class {
|
|
26566
|
+
client;
|
|
26567
|
+
connection;
|
|
26568
|
+
info;
|
|
26569
|
+
catalog;
|
|
26570
|
+
policy;
|
|
26571
|
+
limit;
|
|
26572
|
+
onClosed;
|
|
26573
|
+
harnessId = harnessId;
|
|
26574
|
+
capabilities;
|
|
26575
|
+
initialState;
|
|
26576
|
+
initialUsage;
|
|
26577
|
+
commands;
|
|
26578
|
+
#channel = new HarnessOutputChannel();
|
|
26579
|
+
outputs = this.#channel.outputs;
|
|
26580
|
+
#abort = new AbortController();
|
|
26581
|
+
#active;
|
|
26582
|
+
#closed = false;
|
|
26583
|
+
#closePromise;
|
|
26584
|
+
#pump;
|
|
26585
|
+
#reconciling;
|
|
26586
|
+
#timer;
|
|
26587
|
+
#configuring = false;
|
|
26588
|
+
constructor(client2, connection, info, catalog, policy, limit, onClosed) {
|
|
26589
|
+
this.client = client2;
|
|
26590
|
+
this.connection = connection;
|
|
26591
|
+
this.info = info;
|
|
26592
|
+
this.catalog = catalog;
|
|
26593
|
+
this.policy = policy;
|
|
26594
|
+
this.limit = limit;
|
|
26595
|
+
this.onClosed = onClosed;
|
|
26596
|
+
this.initialState = v2State(info, catalog, policy);
|
|
26597
|
+
this.initialUsage = v2Usage(info);
|
|
26598
|
+
this.capabilities = v2Capabilities(catalog);
|
|
26599
|
+
this.commands = {
|
|
26600
|
+
list: async () => ({ ok: true, value: openCodeCommandCatalog }),
|
|
26601
|
+
execute: async (command) => {
|
|
26602
|
+
if (command.commandId !== "opencode.compact" || Object.keys(command.arguments ?? {}).length)
|
|
26603
|
+
return { ok: false, error: failure("Unsupported OpenCode command", "unsupported") };
|
|
26604
|
+
return this.#start({ type: "turn.start", turnId: command.turnId, input: [] }, true);
|
|
26605
|
+
}
|
|
26606
|
+
};
|
|
26607
|
+
}
|
|
26608
|
+
async start() {
|
|
26609
|
+
await new Promise((resolve, reject) => {
|
|
26610
|
+
const timer = setTimeout(() => reject(new Error("OpenCode v2 event subscription timed out")), this.connection.options.startupTimeoutMs ?? 2e4);
|
|
26611
|
+
this.#pump = (async () => {
|
|
26612
|
+
try {
|
|
26613
|
+
for await (const event of this.client.event.subscribe({ signal: this.#abort.signal })) {
|
|
26614
|
+
if (this.#abort.signal.aborted)
|
|
26615
|
+
break;
|
|
26616
|
+
if (event.type === "server.connected") {
|
|
26617
|
+
clearTimeout(timer);
|
|
26618
|
+
resolve();
|
|
26619
|
+
}
|
|
26620
|
+
this.#onEvent(event);
|
|
26621
|
+
}
|
|
26622
|
+
if (!this.#abort.signal.aborted)
|
|
26623
|
+
throw new Error("OpenCode v2 event stream disconnected");
|
|
26624
|
+
} catch (error51) {
|
|
26625
|
+
clearTimeout(timer);
|
|
26626
|
+
reject(error51);
|
|
26627
|
+
if (!this.#closed)
|
|
26628
|
+
await this.#fault(failure(error51 instanceof Error ? error51.message : String(error51), "processExited"));
|
|
26629
|
+
}
|
|
26630
|
+
})();
|
|
26631
|
+
});
|
|
26632
|
+
this.#timer = setInterval(() => {
|
|
26633
|
+
void this.#refresh();
|
|
26634
|
+
}, 400);
|
|
26635
|
+
}
|
|
26636
|
+
async readSnapshot() {
|
|
26637
|
+
if (this.#closed)
|
|
26638
|
+
return { ok: false, error: failure("OpenCode Session is closed", "invalidState") };
|
|
26639
|
+
if (this.#active || this.#configuring)
|
|
26640
|
+
return { ok: false, error: failure("OpenCode Session is busy", "sessionBusy") };
|
|
26641
|
+
try {
|
|
26642
|
+
this.info = await this.client.session.get({ sessionID: this.info.id });
|
|
26643
|
+
const { snapshot } = await readHistory(this.client, this.info, this.limit);
|
|
26644
|
+
return {
|
|
26645
|
+
ok: true,
|
|
26646
|
+
value: { ...snapshot, state: v2State(this.info, this.catalog, this.policy) }
|
|
26647
|
+
};
|
|
26648
|
+
} catch (error51) {
|
|
26649
|
+
return errorResult(error51);
|
|
26650
|
+
}
|
|
26651
|
+
}
|
|
26652
|
+
async execute(command) {
|
|
26653
|
+
if (this.#closed)
|
|
26654
|
+
return { ok: false, error: failure("OpenCode Session is closed", "invalidState") };
|
|
26655
|
+
if (command.type === "turn.start")
|
|
26656
|
+
return this.#start(command, false);
|
|
26657
|
+
if (command.type === "turn.cancel") {
|
|
26658
|
+
const active = this.#active;
|
|
26659
|
+
if (!active?.admitted || active.turnId !== command.turnId)
|
|
26660
|
+
return { ok: false, error: failure("No matching OpenCode Turn", "invalidState") };
|
|
26661
|
+
try {
|
|
26662
|
+
await this.client.session.interrupt({ sessionID: this.info.id, resume: false });
|
|
26663
|
+
await this.#refresh();
|
|
26664
|
+
return { ok: true, value: { cancellationRequested: true } };
|
|
26665
|
+
} catch (error51) {
|
|
26666
|
+
return errorResult(error51);
|
|
26667
|
+
}
|
|
26668
|
+
}
|
|
26669
|
+
if (command.type === "interaction.respond") {
|
|
26670
|
+
const active = this.#active;
|
|
26671
|
+
const pending = active?.interactions.get(command.interactionId);
|
|
26672
|
+
if (!active || !pending || active.replying.has(command.interactionId))
|
|
26673
|
+
return {
|
|
26674
|
+
ok: false,
|
|
26675
|
+
error: failure("OpenCode interaction is no longer pending", "invalidState")
|
|
26676
|
+
};
|
|
26677
|
+
active.replying.add(command.interactionId);
|
|
26678
|
+
try {
|
|
26679
|
+
await replyInteraction(this.client, pending, command);
|
|
26680
|
+
this.#closeInteraction(active, command.interactionId, command.response.type === "question" && command.response.cancelled ? "cancelled" : "responded");
|
|
26681
|
+
return { ok: true, value: { accepted: true } };
|
|
26682
|
+
} catch (error51) {
|
|
26683
|
+
return errorResult(error51);
|
|
26684
|
+
} finally {
|
|
26685
|
+
active.replying.delete(command.interactionId);
|
|
26686
|
+
}
|
|
26687
|
+
}
|
|
26688
|
+
if (this.#active || this.#configuring)
|
|
26689
|
+
return { ok: false, error: failure("OpenCode Session is busy", "sessionBusy") };
|
|
26690
|
+
this.#configuring = true;
|
|
26691
|
+
try {
|
|
26692
|
+
if ((await this.client.session.active())[this.info.id])
|
|
26693
|
+
throw new Error("OpenCode Session is running");
|
|
26694
|
+
if (command.type === "permissionMode.select") {
|
|
26695
|
+
await this.client.session.update({
|
|
26696
|
+
sessionID: this.info.id,
|
|
26697
|
+
permissions: v2Permissions(this.info.permissions, command.permissionModeId)
|
|
26698
|
+
});
|
|
26699
|
+
} else {
|
|
26700
|
+
let model = this.info.model;
|
|
26701
|
+
if (command.type === "model.select") {
|
|
26702
|
+
if (!this.catalog.models.some((m) => m.ref.id === command.model.id))
|
|
26703
|
+
throw new Error("OpenCode Model is not available");
|
|
26704
|
+
const decoded = decodeOpenCodeModelRef(command.model);
|
|
26705
|
+
model = { providerID: decoded.providerID, id: decoded.modelID };
|
|
26706
|
+
} else {
|
|
26707
|
+
if (!model)
|
|
26708
|
+
throw new Error("Select a Model before a Thinking option");
|
|
26709
|
+
const state = v2State(this.info, this.catalog, this.policy);
|
|
26710
|
+
if (!state.availableThinkingOptions?.some((v) => v.id === command.thinkingOptionId))
|
|
26711
|
+
throw new Error("Thinking option is unavailable for this Model");
|
|
26712
|
+
const variant = decodeOpenCodeVariant(command.thinkingOptionId);
|
|
26713
|
+
model = { providerID: model.providerID, id: model.id, ...variant ? { variant } : {} };
|
|
26714
|
+
}
|
|
26715
|
+
await this.client.session.switchModel({ sessionID: this.info.id, model });
|
|
26716
|
+
}
|
|
26717
|
+
this.info = await this.client.session.get({ sessionID: this.info.id });
|
|
26718
|
+
this.#emit({
|
|
26719
|
+
type: "session.state.changed",
|
|
26720
|
+
state: v2State(this.info, this.catalog, this.policy)
|
|
26721
|
+
});
|
|
26722
|
+
return { ok: true, value: { completed: true } };
|
|
26723
|
+
} catch (error51) {
|
|
26724
|
+
return errorResult(error51);
|
|
26725
|
+
} finally {
|
|
26726
|
+
this.#configuring = false;
|
|
26727
|
+
}
|
|
26728
|
+
}
|
|
26729
|
+
async #start(command, compact) {
|
|
26730
|
+
if (this.#closed || this.#active || this.#configuring)
|
|
26731
|
+
return {
|
|
26732
|
+
ok: false,
|
|
26733
|
+
error: failure("OpenCode Session is closed or busy", this.#closed ? "invalidState" : "sessionBusy")
|
|
26734
|
+
};
|
|
26735
|
+
if (!compact && !command.input.some((p) => p.text.trim()))
|
|
26736
|
+
return { ok: false, error: failure("OpenCode requires text input", "invalidRequest") };
|
|
26737
|
+
let resolve;
|
|
26738
|
+
const done = new Promise((r) => {
|
|
26739
|
+
resolve = r;
|
|
26740
|
+
});
|
|
26741
|
+
const active = {
|
|
26742
|
+
turnId: command.turnId,
|
|
26743
|
+
compact,
|
|
26744
|
+
admitted: false,
|
|
26745
|
+
baseline: /* @__PURE__ */ new Set(),
|
|
26746
|
+
live: /* @__PURE__ */ new Map(),
|
|
26747
|
+
assistants: /* @__PURE__ */ new Set(),
|
|
26748
|
+
transient: /* @__PURE__ */ new Map(),
|
|
26749
|
+
interactions: /* @__PURE__ */ new Map(),
|
|
26750
|
+
replying: /* @__PURE__ */ new Set(),
|
|
26751
|
+
settledInteractions: /* @__PURE__ */ new Set(),
|
|
26752
|
+
done,
|
|
26753
|
+
resolve
|
|
26754
|
+
};
|
|
26755
|
+
this.#active = active;
|
|
26756
|
+
let attempted = false;
|
|
26757
|
+
try {
|
|
26758
|
+
if ((await this.client.session.active())[this.info.id])
|
|
26759
|
+
throw new Error("OpenCode Session is already running");
|
|
26760
|
+
this.info = await this.client.session.get({ sessionID: this.info.id });
|
|
26761
|
+
const before = await readHistory(this.client, this.info, this.limit);
|
|
26762
|
+
if (before.snapshot.turns.some((turn) => turn.outcome.status === "unknown"))
|
|
26763
|
+
throw new Error("OpenCode history contains an incomplete execution");
|
|
26764
|
+
active.baseline = new Set(before.snapshot.turns.map((t) => t.nativeTurnRef.nativeTurnKey));
|
|
26765
|
+
attempted = true;
|
|
26766
|
+
if (compact)
|
|
26767
|
+
await this.client.session.compact({ sessionID: this.info.id });
|
|
26768
|
+
else
|
|
26769
|
+
await this.client.session.prompt({
|
|
26770
|
+
sessionID: this.info.id,
|
|
26771
|
+
text: command.input.map((p) => p.text).join("\n"),
|
|
26772
|
+
delivery: "queue",
|
|
26773
|
+
metadata: { "codexhost.turnId": active.turnId }
|
|
26774
|
+
});
|
|
26775
|
+
if (this.#closed) {
|
|
26776
|
+
await this.client.session.interrupt({ sessionID: this.info.id, resume: false });
|
|
26777
|
+
throw new Error("OpenCode Session closed during admission");
|
|
26778
|
+
}
|
|
26779
|
+
active.admitted = true;
|
|
26780
|
+
this.#emit({ type: "turn.started", turnId: active.turnId });
|
|
26781
|
+
for (const item of active.transient.values())
|
|
26782
|
+
this.#projectItem(active, { item, outcome: { status: "succeeded" } }, false);
|
|
26783
|
+
void this.#refresh();
|
|
26784
|
+
return { ok: true, value: { turnId: active.turnId } };
|
|
26785
|
+
} catch (error51) {
|
|
26786
|
+
if (attempted)
|
|
26787
|
+
await this.client.session.interrupt({ sessionID: this.info.id, resume: false }).catch((interruptError) => this.#fault(errorResult(interruptError).error));
|
|
26788
|
+
if (this.#active === active)
|
|
26789
|
+
this.#active = void 0;
|
|
26790
|
+
active.resolve();
|
|
26791
|
+
return errorResult(error51);
|
|
26792
|
+
}
|
|
26793
|
+
}
|
|
26794
|
+
#onEvent(event) {
|
|
26795
|
+
const active = this.#active;
|
|
26796
|
+
if (!active || !("data" in event) || !("sessionID" in event.data) || event.data.sessionID !== this.info.id)
|
|
26797
|
+
return;
|
|
26798
|
+
if (event.type === "session.step.started")
|
|
26799
|
+
active.assistants.add(event.data.assistantMessageID);
|
|
26800
|
+
if ((event.type === "session.text.delta" || event.type === "session.reasoning.delta") && active.assistants.has(event.data.assistantMessageID)) {
|
|
26801
|
+
const itemId2 = contentId(event.data.assistantMessageID, event.data.ordinal);
|
|
26802
|
+
const type = event.type === "session.text.delta" ? "agentMessage" : "reasoning";
|
|
26803
|
+
const previous = active.transient.get(itemId2);
|
|
26804
|
+
const item = {
|
|
26805
|
+
type,
|
|
26806
|
+
itemId: itemId2,
|
|
26807
|
+
text: (previous?.text ?? "") + event.data.delta
|
|
26808
|
+
};
|
|
26809
|
+
active.transient.set(itemId2, item);
|
|
26810
|
+
if (active.admitted)
|
|
26811
|
+
this.#projectItem(active, { item, outcome: { status: "succeeded" } }, false);
|
|
26812
|
+
}
|
|
26813
|
+
if (!event.type.endsWith(".delta"))
|
|
26814
|
+
void this.#refresh();
|
|
26815
|
+
}
|
|
26816
|
+
#refresh() {
|
|
26817
|
+
if (this.#closed || !this.#active?.admitted)
|
|
26818
|
+
return Promise.resolve();
|
|
26819
|
+
return this.#reconciling ??= this.#reconcile().catch(async (error51) => {
|
|
26820
|
+
await this.#fault(failure(error51 instanceof Error ? error51.message : String(error51), "protocolError"));
|
|
26821
|
+
}).finally(() => {
|
|
26822
|
+
this.#reconciling = void 0;
|
|
26823
|
+
});
|
|
26824
|
+
}
|
|
26825
|
+
async #reconcile() {
|
|
26826
|
+
const active = this.#active;
|
|
26827
|
+
if (!active?.admitted)
|
|
26828
|
+
return;
|
|
26829
|
+
const info = await this.client.session.get({ sessionID: this.info.id });
|
|
26830
|
+
const { snapshot, messages } = await readHistory(this.client, info, this.limit);
|
|
26831
|
+
if (this.#active !== active || this.#closed)
|
|
26832
|
+
return;
|
|
26833
|
+
this.info = info;
|
|
26834
|
+
const turns = snapshot.turns.filter((t) => !active.baseline.has(t.nativeTurnRef.nativeTurnKey));
|
|
26835
|
+
if (turns.length > 1)
|
|
26836
|
+
throw new Error("Concurrent native prompts cannot be assigned to one Host Turn");
|
|
26837
|
+
const turn = turns[0];
|
|
26838
|
+
if (turn) {
|
|
26839
|
+
const prompt = messages.find((message) => message.id === turn.nativeTurnRef.nativeTurnKey);
|
|
26840
|
+
if (active.compact ? turn.input.length !== 0 : prompt?.type !== "user" || prompt.metadata?.["codexhost.turnId"] !== active.turnId || turn.input.length !== 1)
|
|
26841
|
+
throw new Error("Concurrent native input cannot be assigned to this Host Turn");
|
|
26842
|
+
const terminal = turn.outcome.status !== "unknown";
|
|
26843
|
+
for (const item of turn.items)
|
|
26844
|
+
this.#projectItem(active, item, terminal, turn.outcome.status === "cancelled" || turn.outcome.status === "failed");
|
|
26845
|
+
if (terminal) {
|
|
26846
|
+
if ((await this.client.session.active())[info.id])
|
|
26847
|
+
return;
|
|
26848
|
+
if (this.#active === active)
|
|
26849
|
+
this.#finish(active, turn);
|
|
26850
|
+
return;
|
|
26851
|
+
}
|
|
26852
|
+
}
|
|
26853
|
+
const [permissions, forms] = await Promise.all([
|
|
26854
|
+
this.client.permission.list({ sessionID: info.id }),
|
|
26855
|
+
this.client.session.form.list({ sessionID: info.id })
|
|
26856
|
+
]);
|
|
26857
|
+
if (this.#active !== active || this.#closed)
|
|
26858
|
+
return;
|
|
26859
|
+
const current = /* @__PURE__ */ new Map();
|
|
26860
|
+
for (const request of permissions) {
|
|
26861
|
+
const pending = permissionInteraction(request, active.turnId);
|
|
26862
|
+
current.set(pending.interaction.interactionId, pending);
|
|
26863
|
+
}
|
|
26864
|
+
for (const form of forms) {
|
|
26865
|
+
const pending = formInteraction(form, active.turnId);
|
|
26866
|
+
current.set(pending.interaction.interactionId, pending);
|
|
26867
|
+
}
|
|
26868
|
+
for (const [id, pending] of current)
|
|
26869
|
+
if (!active.interactions.has(id) && !active.settledInteractions.has(id)) {
|
|
26870
|
+
active.interactions.set(id, pending);
|
|
26871
|
+
this.#channel.emit({ kind: "interaction", interaction: pending.interaction });
|
|
26872
|
+
}
|
|
26873
|
+
for (const id of active.interactions.keys())
|
|
26874
|
+
if (!current.has(id) && !active.replying.has(id))
|
|
26875
|
+
this.#closeInteraction(active, id, "expired");
|
|
26876
|
+
}
|
|
26877
|
+
#projectItem(active, snapshot, terminal, interrupted = false) {
|
|
26878
|
+
const item = snapshot.item;
|
|
26879
|
+
const old = active.live.get(item.itemId);
|
|
26880
|
+
if (!old) {
|
|
26881
|
+
active.live.set(item.itemId, item);
|
|
26882
|
+
this.#emit({ type: "item.started", turnId: active.turnId, item });
|
|
26883
|
+
return;
|
|
26884
|
+
}
|
|
26885
|
+
if ((item.type === "agentMessage" || item.type === "reasoning") && "text" in old) {
|
|
26886
|
+
if (old.text.startsWith(item.text) && !terminal)
|
|
26887
|
+
return;
|
|
26888
|
+
if (terminal && interrupted && old.text.startsWith(item.text)) {
|
|
26889
|
+
active.live.set(item.itemId, item);
|
|
26890
|
+
return;
|
|
26891
|
+
}
|
|
26892
|
+
if (!item.text.startsWith(old.text))
|
|
26893
|
+
throw new Error("OpenCode v2 streamed text differs from durable history");
|
|
26894
|
+
const delta = item.text.slice(old.text.length);
|
|
26895
|
+
if (delta)
|
|
26896
|
+
this.#emit({
|
|
26897
|
+
type: "item.updated",
|
|
26898
|
+
turnId: active.turnId,
|
|
26899
|
+
itemId: item.itemId,
|
|
26900
|
+
update: { type: "text.append", text: delta }
|
|
26901
|
+
});
|
|
26902
|
+
} else if (item.type === "toolExecution" && item.output && JSON.stringify(item) !== JSON.stringify(old)) {
|
|
26903
|
+
this.#emit({
|
|
26904
|
+
type: "item.updated",
|
|
26905
|
+
turnId: active.turnId,
|
|
26906
|
+
itemId: item.itemId,
|
|
26907
|
+
update: { type: "output.replace", output: item.output }
|
|
26908
|
+
});
|
|
26909
|
+
}
|
|
26910
|
+
active.live.set(item.itemId, item);
|
|
26911
|
+
}
|
|
26912
|
+
#finish(active, turn) {
|
|
26913
|
+
if (this.#active !== active || turn.outcome.status === "unknown")
|
|
26914
|
+
return;
|
|
26915
|
+
for (const id of active.interactions.keys())
|
|
26916
|
+
this.#closeInteraction(active, id, "cancelled");
|
|
26917
|
+
for (const [id, item] of active.live) {
|
|
26918
|
+
const snapshot = turn.items.find((entry) => entry.item.itemId === id) ?? {
|
|
26919
|
+
item,
|
|
26920
|
+
outcome: terminalItemOutcome(turn.outcome)
|
|
26921
|
+
};
|
|
26922
|
+
this.#emit({ type: "item.completed", turnId: active.turnId, snapshot });
|
|
26923
|
+
}
|
|
26924
|
+
this.#emit({
|
|
26925
|
+
type: "session.state.changed",
|
|
26926
|
+
state: v2State(this.info, this.catalog, this.policy)
|
|
26927
|
+
});
|
|
26928
|
+
this.#emit({
|
|
26929
|
+
type: "session.usage.changed",
|
|
26930
|
+
usage: v2Usage(this.info),
|
|
26931
|
+
observedForTurnId: active.turnId
|
|
26932
|
+
});
|
|
26933
|
+
this.#active = void 0;
|
|
26934
|
+
this.#emit({
|
|
26935
|
+
type: "turn.completed",
|
|
26936
|
+
turnId: active.turnId,
|
|
26937
|
+
nativeTurnRef: turn.nativeTurnRef,
|
|
26938
|
+
outcome: { ...turn.outcome, ...turn.checkpoint ? { checkpoint: turn.checkpoint } : {} }
|
|
26939
|
+
});
|
|
26940
|
+
active.resolve();
|
|
26941
|
+
}
|
|
26942
|
+
#closeInteraction(active, id, reason) {
|
|
26943
|
+
const pending = active.interactions.get(id);
|
|
26944
|
+
if (!pending)
|
|
26945
|
+
return;
|
|
26946
|
+
active.interactions.delete(id);
|
|
26947
|
+
active.settledInteractions.add(id);
|
|
26948
|
+
this.#emit({
|
|
26949
|
+
type: "interaction.closed",
|
|
26950
|
+
interactionId: pending.interaction.interactionId,
|
|
26951
|
+
turnId: active.turnId,
|
|
26952
|
+
reason
|
|
26953
|
+
});
|
|
26954
|
+
}
|
|
26955
|
+
#emit(event) {
|
|
26956
|
+
this.#channel.emit({ kind: "event", event });
|
|
26957
|
+
}
|
|
26958
|
+
async #fault(error51) {
|
|
26959
|
+
if (this.#closed)
|
|
26960
|
+
return;
|
|
26961
|
+
this.#closed = true;
|
|
26962
|
+
if (this.#timer)
|
|
26963
|
+
clearInterval(this.#timer);
|
|
26964
|
+
this.#abort.abort();
|
|
26965
|
+
const active = this.#active;
|
|
26966
|
+
if (active?.admitted) {
|
|
26967
|
+
for (const id of active.interactions.keys())
|
|
26968
|
+
this.#closeInteraction(active, id, "cancelled");
|
|
26969
|
+
for (const item of active.live.values())
|
|
26970
|
+
this.#emit({
|
|
26971
|
+
type: "item.completed",
|
|
26972
|
+
turnId: active.turnId,
|
|
26973
|
+
snapshot: { item, outcome: { status: "failed", error: error51 } }
|
|
26974
|
+
});
|
|
26975
|
+
this.#emit({
|
|
26976
|
+
type: "turn.completed",
|
|
26977
|
+
turnId: active.turnId,
|
|
26978
|
+
outcome: { status: "failed", error: error51 }
|
|
26979
|
+
});
|
|
26980
|
+
}
|
|
26981
|
+
this.#active = void 0;
|
|
26982
|
+
active?.resolve();
|
|
26983
|
+
this.#emit({ type: "session.faulted", error: error51 });
|
|
26984
|
+
this.#channel.end();
|
|
26985
|
+
await this.client.session.interrupt({ sessionID: this.info.id, resume: false }).catch(() => void 0);
|
|
26986
|
+
await this.connection.close();
|
|
26987
|
+
this.onClosed();
|
|
26988
|
+
}
|
|
26989
|
+
close() {
|
|
26990
|
+
return this.#closePromise ??= (async () => {
|
|
26991
|
+
const active = this.#active;
|
|
26992
|
+
if (active?.admitted && !this.#closed) {
|
|
26993
|
+
await this.client.session.interrupt({ sessionID: this.info.id, resume: false }).catch(() => void 0);
|
|
26994
|
+
await this.#refresh();
|
|
26995
|
+
if (this.#active) {
|
|
26996
|
+
let timer;
|
|
26997
|
+
await Promise.race([
|
|
26998
|
+
active.done,
|
|
26999
|
+
new Promise((resolve) => {
|
|
27000
|
+
timer = setTimeout(resolve, this.connection.options.closeTimeoutMs ?? 3e3);
|
|
27001
|
+
})
|
|
27002
|
+
]).finally(() => {
|
|
27003
|
+
if (timer)
|
|
27004
|
+
clearTimeout(timer);
|
|
27005
|
+
});
|
|
27006
|
+
}
|
|
27007
|
+
if (this.#active)
|
|
27008
|
+
await this.#fault(failure("OpenCode Session closed before native completion was confirmed", "processExited"));
|
|
27009
|
+
}
|
|
27010
|
+
this.#closed = true;
|
|
27011
|
+
if (this.#timer)
|
|
27012
|
+
clearInterval(this.#timer);
|
|
27013
|
+
this.#abort.abort();
|
|
27014
|
+
await this.connection.close();
|
|
27015
|
+
await this.#pump;
|
|
27016
|
+
this.#channel.end();
|
|
27017
|
+
this.onClosed();
|
|
27018
|
+
})();
|
|
27019
|
+
}
|
|
27020
|
+
};
|
|
27021
|
+
|
|
27022
|
+
// dist/v2/adapter.js
|
|
27023
|
+
var V2Adapter = class {
|
|
27024
|
+
options;
|
|
27025
|
+
harnessId = harnessId;
|
|
27026
|
+
commandCatalog = openCodeCommandCatalog;
|
|
27027
|
+
#connections = /* @__PURE__ */ new Set();
|
|
27028
|
+
#sessions = /* @__PURE__ */ new Set();
|
|
27029
|
+
#closed = false;
|
|
27030
|
+
constructor(options) {
|
|
27031
|
+
this.options = options;
|
|
27032
|
+
}
|
|
27033
|
+
async #catalog(client2, cwd) {
|
|
27034
|
+
return readCatalog(client2, cwd, this.options.startupTimeoutMs ?? 2e4);
|
|
27035
|
+
}
|
|
27036
|
+
async inspect(input = {}) {
|
|
27037
|
+
const cwd = input.cwd ?? process.cwd();
|
|
27038
|
+
const connection = new V2Connection(this.options, cwd);
|
|
27039
|
+
this.#connections.add(connection);
|
|
27040
|
+
try {
|
|
27041
|
+
if (this.#closed)
|
|
27042
|
+
throw new Error("OpenCode Adapter is closed");
|
|
27043
|
+
const client2 = await connection.client();
|
|
27044
|
+
const catalog = await this.#catalog(client2, cwd);
|
|
27045
|
+
return {
|
|
27046
|
+
status: "ready",
|
|
27047
|
+
catalog,
|
|
27048
|
+
capabilities: v2Capabilities(catalog),
|
|
27049
|
+
permissionModes: OPENCODE_PERMISSION_MODE_CATALOG
|
|
27050
|
+
};
|
|
27051
|
+
} catch (error51) {
|
|
27052
|
+
return {
|
|
27053
|
+
status: "error",
|
|
27054
|
+
error: {
|
|
27055
|
+
...errorResult(error51).error,
|
|
27056
|
+
...connection.stderrTail ? { stderrTail: connection.stderrTail } : {}
|
|
27057
|
+
}
|
|
27058
|
+
};
|
|
27059
|
+
} finally {
|
|
27060
|
+
await connection.close();
|
|
27061
|
+
this.#connections.delete(connection);
|
|
27062
|
+
}
|
|
27063
|
+
}
|
|
27064
|
+
async open(input) {
|
|
27065
|
+
try {
|
|
27066
|
+
input = { ...input, cwd: fs6.realpathSync(input.cwd) };
|
|
27067
|
+
} catch (error51) {
|
|
27068
|
+
return errorResult(error51);
|
|
27069
|
+
}
|
|
27070
|
+
const connection = new V2Connection({
|
|
27071
|
+
...this.options,
|
|
27072
|
+
environment: { ...this.options.environment ?? process.env, ...input.environment }
|
|
27073
|
+
}, input.cwd);
|
|
27074
|
+
this.#connections.add(connection);
|
|
27075
|
+
let created;
|
|
27076
|
+
let client2;
|
|
27077
|
+
try {
|
|
27078
|
+
if (this.#closed)
|
|
27079
|
+
throw new Error("OpenCode Adapter is closed");
|
|
27080
|
+
if (!input.cwd)
|
|
27081
|
+
throw new Error("OpenCode requires a working directory");
|
|
27082
|
+
let policy = input.kind === "create" ? input.executionPolicy ?? "default" : "default";
|
|
27083
|
+
if (input.kind !== "create") {
|
|
27084
|
+
const locator = v2Locator(input.kind === "resume" ? input.nativeRef : input.sourceRef);
|
|
27085
|
+
if (!sameDirectory(locator.directory, input.cwd))
|
|
27086
|
+
throw new Error("OpenCode cannot resume or derive a Session across directories");
|
|
27087
|
+
policy = locator.executionPolicy;
|
|
27088
|
+
}
|
|
27089
|
+
client2 = await connection.client();
|
|
27090
|
+
const catalog = await this.#catalog(client2, input.cwd);
|
|
27091
|
+
let info;
|
|
27092
|
+
if (input.kind === "create") {
|
|
27093
|
+
const model = selectedModel(input, catalog);
|
|
27094
|
+
info = await client2.session.create({
|
|
27095
|
+
location: { directory: input.cwd },
|
|
27096
|
+
...model ? { model } : {},
|
|
27097
|
+
permissions: v2Permissions([], input.permissionModeId ?? harnessPermissionModeIdSchema.parse(policy === "unattended-full-access" ? "allow" : "default"))
|
|
27098
|
+
});
|
|
27099
|
+
created = info.id;
|
|
27100
|
+
} else {
|
|
27101
|
+
const ref = input.kind === "resume" ? input.nativeRef : input.sourceRef;
|
|
27102
|
+
info = await client2.session.get({ sessionID: ref.nativeSessionId });
|
|
27103
|
+
if (info.id !== ref.nativeSessionId || !sameDirectory(info.location.directory, input.cwd))
|
|
27104
|
+
throw new Error("OpenCode returned a different Native Session or directory");
|
|
27105
|
+
if ((await client2.session.active())[info.id])
|
|
27106
|
+
throw new Error("OpenCode Session is already running");
|
|
27107
|
+
const source = await readHistory(client2, info, this.options.toolOutputLimit ?? 64e3);
|
|
27108
|
+
if (source.snapshot.turns.some((turn) => turn.outcome.status === "unknown"))
|
|
27109
|
+
throw new Error("OpenCode history contains an incomplete execution");
|
|
27110
|
+
if (input.kind !== "resume") {
|
|
27111
|
+
const parent = info;
|
|
27112
|
+
const turns = source.snapshot.turns;
|
|
27113
|
+
let count;
|
|
27114
|
+
if (input.kind === "rollbackLastTurn") {
|
|
27115
|
+
if (!turns.length)
|
|
27116
|
+
throw new Error("OpenCode history is empty");
|
|
27117
|
+
count = turns.length - 1;
|
|
27118
|
+
} else {
|
|
27119
|
+
if (input.checkpoint.harnessId !== harnessId || input.checkpoint.nativeSessionId !== info.id)
|
|
27120
|
+
throw new Error("Checkpoint belongs to another Session");
|
|
27121
|
+
count = turns.findIndex((turn) => turn.checkpoint?.checkpointId === input.checkpoint.checkpointId) + 1;
|
|
27122
|
+
if (!count || JSON.stringify(turns[count - 1]?.checkpoint) !== JSON.stringify(input.checkpoint))
|
|
27123
|
+
throw new Error("OpenCode checkpoint does not match native history");
|
|
27124
|
+
}
|
|
27125
|
+
const before = turns[count]?.nativeTurnRef.nativeTurnKey;
|
|
27126
|
+
info = await client2.session.fork({ sessionID: parent.id, ...before ? { before } : {} });
|
|
27127
|
+
if (info.id === parent.id)
|
|
27128
|
+
throw new Error("OpenCode fork returned its source Session");
|
|
27129
|
+
created = info.id;
|
|
27130
|
+
if (!sameDirectory(info.location.directory, parent.location.directory))
|
|
27131
|
+
throw new Error("OpenCode fork changed directory");
|
|
27132
|
+
await client2.session.update({
|
|
27133
|
+
sessionID: info.id,
|
|
27134
|
+
permissions: parent.permissions ?? []
|
|
27135
|
+
});
|
|
27136
|
+
if (parent.model)
|
|
27137
|
+
await client2.session.switchModel({ sessionID: info.id, model: parent.model });
|
|
27138
|
+
info = await client2.session.get({ sessionID: info.id });
|
|
27139
|
+
const derived = await readHistory(client2, info, this.options.toolOutputLimit ?? 64e3);
|
|
27140
|
+
if (historyContent(derived.snapshot, false) !== historyContent({ turns: turns.slice(0, count) }, false))
|
|
27141
|
+
throw new Error("OpenCode fork did not preserve the exact history prefix");
|
|
27142
|
+
if (!isDeepStrictEqual2(info.permissions ?? [], parent.permissions ?? []) || !isDeepStrictEqual2(info.model, parent.model))
|
|
27143
|
+
throw new Error("OpenCode fork did not preserve the current configuration");
|
|
27144
|
+
const currentParent = await client2.session.get({ sessionID: parent.id });
|
|
27145
|
+
if (!isDeepStrictEqual2(currentParent.model, parent.model) || !isDeepStrictEqual2(currentParent.permissions, parent.permissions) || !sameDirectory(currentParent.location.directory, parent.location.directory))
|
|
27146
|
+
throw new Error("OpenCode source configuration changed during derivation");
|
|
27147
|
+
const unchanged = await readHistory(client2, currentParent, this.options.toolOutputLimit ?? 64e3);
|
|
27148
|
+
if (historyContent(unchanged.snapshot) !== historyContent(source.snapshot))
|
|
27149
|
+
throw new Error("OpenCode source history changed during derivation");
|
|
27150
|
+
}
|
|
27151
|
+
}
|
|
27152
|
+
if (this.#closed)
|
|
27153
|
+
throw new Error("OpenCode Adapter closed during Session open");
|
|
27154
|
+
const session = new V2Session(client2, connection, info, catalog, policy, this.options.toolOutputLimit ?? 64e3, () => {
|
|
27155
|
+
this.#sessions.delete(session);
|
|
27156
|
+
this.#connections.delete(connection);
|
|
27157
|
+
});
|
|
27158
|
+
this.#sessions.add(session);
|
|
27159
|
+
try {
|
|
27160
|
+
await session.start();
|
|
27161
|
+
} catch (error51) {
|
|
27162
|
+
await session.close();
|
|
27163
|
+
throw error51;
|
|
27164
|
+
}
|
|
27165
|
+
return { ok: true, value: session };
|
|
27166
|
+
} catch (error51) {
|
|
27167
|
+
if (created && client2)
|
|
27168
|
+
await client2.session.remove({ sessionID: created }).catch(() => void 0);
|
|
27169
|
+
await connection.close();
|
|
27170
|
+
this.#connections.delete(connection);
|
|
27171
|
+
return errorResult(error51);
|
|
27172
|
+
}
|
|
27173
|
+
}
|
|
27174
|
+
async close() {
|
|
27175
|
+
this.#closed = true;
|
|
27176
|
+
await Promise.all([...this.#sessions].map((session) => session.close()));
|
|
27177
|
+
await Promise.all([...this.#connections].map((connection) => connection.close()));
|
|
27178
|
+
this.#sessions.clear();
|
|
27179
|
+
this.#connections.clear();
|
|
27180
|
+
}
|
|
27181
|
+
};
|
|
27182
|
+
function selectedModel(input, catalog) {
|
|
27183
|
+
const selected = input.model ?? catalog.defaultModel;
|
|
27184
|
+
if (!selected) {
|
|
27185
|
+
if (input.thinkingOptionId)
|
|
27186
|
+
throw new Error("Thinking selection requires a Model");
|
|
27187
|
+
return void 0;
|
|
27188
|
+
}
|
|
27189
|
+
const entry = catalog.models.find((model2) => model2.ref.id === selected.id);
|
|
27190
|
+
if (!entry)
|
|
27191
|
+
throw new Error("OpenCode Model is not available");
|
|
27192
|
+
if (input.thinkingOptionId && !entry.supportedThinkingOptionIds?.includes(input.thinkingOptionId))
|
|
27193
|
+
throw new Error("OpenCode Thinking option is not available for this Model");
|
|
27194
|
+
const model = decodeOpenCodeModelRef(selected);
|
|
27195
|
+
const variant = input.thinkingOptionId ? decodeOpenCodeVariant(input.thinkingOptionId) : void 0;
|
|
27196
|
+
return { providerID: model.providerID, id: model.modelID, ...variant ? { variant } : {} };
|
|
27197
|
+
}
|
|
27198
|
+
function historyContent(snapshot, identities = true) {
|
|
27199
|
+
return JSON.stringify(snapshot.turns.map((turn) => ({
|
|
27200
|
+
...identities ? { key: turn.nativeTurnRef.nativeTurnKey } : {},
|
|
27201
|
+
input: turn.input,
|
|
27202
|
+
model: turn.model,
|
|
27203
|
+
checkpoint: Boolean(turn.checkpoint),
|
|
27204
|
+
items: identities ? turn.items : turn.items.map(({ item, ...rest }) => ({
|
|
27205
|
+
...rest,
|
|
27206
|
+
item: { ...item, itemId: void 0 }
|
|
27207
|
+
})),
|
|
27208
|
+
outcome: turn.outcome
|
|
27209
|
+
})));
|
|
27210
|
+
}
|
|
27211
|
+
|
|
27212
|
+
// dist/versioned-adapter.js
|
|
27213
|
+
var OpenCodeAdapter2 = class {
|
|
27214
|
+
options;
|
|
27215
|
+
dependencies;
|
|
27216
|
+
harnessId = harnessId;
|
|
27217
|
+
commandCatalog = openCodeCommandCatalog;
|
|
27218
|
+
#adapters = /* @__PURE__ */ new Set();
|
|
27219
|
+
#closed = false;
|
|
27220
|
+
constructor(options = {}, dependencies) {
|
|
27221
|
+
this.options = options;
|
|
27222
|
+
this.dependencies = dependencies;
|
|
27223
|
+
}
|
|
27224
|
+
async #select(environment, input) {
|
|
27225
|
+
if (this.#closed)
|
|
27226
|
+
throw new Error("OpenCode Adapter is closed");
|
|
27227
|
+
const options = {
|
|
27228
|
+
...this.options,
|
|
27229
|
+
environment: { ...this.options.environment ?? process.env, ...environment }
|
|
27230
|
+
};
|
|
27231
|
+
const detected = this.dependencies ? { executable: options.command, major: 1 } : await detectOpenCode(options);
|
|
27232
|
+
if (this.#closed)
|
|
27233
|
+
throw new Error("OpenCode Adapter closed during version detection");
|
|
27234
|
+
if (input && input.kind !== "create") {
|
|
27235
|
+
const ref = input.kind === "resume" ? input.nativeRef : input.sourceRef;
|
|
27236
|
+
const locator = ref.locator;
|
|
27237
|
+
const nativeMajor = locator && typeof locator === "object" && !Array.isArray(locator) && locator.protocol === 2 ? 2 : 1;
|
|
27238
|
+
if (nativeMajor !== detected.major)
|
|
27239
|
+
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.`);
|
|
27240
|
+
}
|
|
27241
|
+
const pinned = { ...options, ...detected.executable ? { command: detected.executable } : {} };
|
|
27242
|
+
const adapter = detected.major === 2 ? new V2Adapter(pinned) : new OpenCodeAdapter(pinned, this.dependencies);
|
|
27243
|
+
this.#adapters.add(adapter);
|
|
27244
|
+
return adapter;
|
|
27245
|
+
}
|
|
27246
|
+
async inspect(input = {}) {
|
|
27247
|
+
let adapter;
|
|
27248
|
+
try {
|
|
27249
|
+
adapter = await this.#select();
|
|
27250
|
+
return await adapter.inspect(input);
|
|
27251
|
+
} catch (error51) {
|
|
27252
|
+
return {
|
|
27253
|
+
status: error51 instanceof OpenCodeExecutableError ? "notInstalled" : "error",
|
|
27254
|
+
error: normalize(error51)
|
|
27255
|
+
};
|
|
27256
|
+
} finally {
|
|
27257
|
+
if (adapter) {
|
|
27258
|
+
await adapter.close();
|
|
27259
|
+
this.#adapters.delete(adapter);
|
|
27260
|
+
}
|
|
27261
|
+
}
|
|
27262
|
+
}
|
|
27263
|
+
async open(input) {
|
|
27264
|
+
let adapter;
|
|
27265
|
+
try {
|
|
27266
|
+
adapter = await this.#select(input.environment, input);
|
|
27267
|
+
const result = await adapter.open(input);
|
|
27268
|
+
if (!result.ok) {
|
|
27269
|
+
await adapter.close();
|
|
27270
|
+
this.#adapters.delete(adapter);
|
|
27271
|
+
}
|
|
27272
|
+
if (result.ok) {
|
|
27273
|
+
const owner = adapter;
|
|
27274
|
+
const close = result.value.close.bind(result.value);
|
|
27275
|
+
result.value.close = async () => {
|
|
27276
|
+
await close();
|
|
27277
|
+
this.#adapters.delete(owner);
|
|
27278
|
+
};
|
|
27279
|
+
}
|
|
27280
|
+
return result;
|
|
27281
|
+
} catch (error51) {
|
|
27282
|
+
if (adapter) {
|
|
27283
|
+
await adapter.close();
|
|
27284
|
+
this.#adapters.delete(adapter);
|
|
27285
|
+
}
|
|
27286
|
+
return { ok: false, error: normalize(error51) };
|
|
27287
|
+
}
|
|
27288
|
+
}
|
|
27289
|
+
async close() {
|
|
27290
|
+
this.#closed = true;
|
|
27291
|
+
await Promise.all([...this.#adapters].map((adapter) => adapter.close()));
|
|
27292
|
+
this.#adapters.clear();
|
|
27293
|
+
}
|
|
27294
|
+
};
|
|
27295
|
+
function normalize(error51) {
|
|
27296
|
+
return failure(error51 instanceof Error ? error51.message : String(error51), error51 instanceof OpenCodeExecutableError ? "notInstalled" : "unavailable");
|
|
27297
|
+
}
|
|
27298
|
+
|
|
27299
|
+
// dist/installation.js
|
|
27300
|
+
import { realpath as realpath2 } from "node:fs/promises";
|
|
27301
|
+
import { homedir as homedir3 } from "node:os";
|
|
27302
|
+
import path11 from "node:path";
|
|
27303
|
+
function createOpenCodeInstallation(environment, command) {
|
|
27304
|
+
let update;
|
|
27305
|
+
return createInstallationManager({
|
|
27306
|
+
async check() {
|
|
27307
|
+
const executable = resolveOpenCodeExecutable({
|
|
27308
|
+
environment,
|
|
27309
|
+
...command ? { command } : {}
|
|
27310
|
+
});
|
|
27311
|
+
const currentVersion = versionFromOutput(await runInstallationCommand(executable, ["--version"], environment));
|
|
27312
|
+
const npm = await npmInstallation(executable, ["opencode-ai"], environment);
|
|
27313
|
+
let latestVersion;
|
|
27314
|
+
let canUpdate;
|
|
27315
|
+
if (npm) {
|
|
27316
|
+
latestVersion = await npm.latest();
|
|
27317
|
+
canUpdate = npm.canUpdate;
|
|
27318
|
+
update = npm.update;
|
|
27319
|
+
} else {
|
|
27320
|
+
const release = JSON.parse(await fetchInstallationText("https://api.github.com/repos/anomalyco/opencode/releases/latest"));
|
|
27321
|
+
latestVersion = installationVersion(release.tag_name);
|
|
27322
|
+
const home = environment.HOME ?? environment.USERPROFILE ?? homedir3();
|
|
27323
|
+
const standard = path11.join(home, ".opencode", "bin", process.platform === "win32" ? "opencode.exe" : "opencode");
|
|
27324
|
+
canUpdate = process.platform !== "win32" && path11.resolve(executable) === standard && await realpath2(executable) === standard;
|
|
27325
|
+
update = async (version2) => {
|
|
27326
|
+
await runInstallationCommand(executable, ["upgrade", version2, "--method", "curl"], environment, 3e5);
|
|
27327
|
+
};
|
|
27328
|
+
}
|
|
27329
|
+
return {
|
|
27330
|
+
currentVersion,
|
|
27331
|
+
latestVersion,
|
|
27332
|
+
updateAvailable: newerInstallationVersion(currentVersion, latestVersion),
|
|
27333
|
+
canUpdate,
|
|
27334
|
+
...!canUpdate ? { message: "Use the original package manager to update this OpenCode installation." } : {}
|
|
27335
|
+
};
|
|
27336
|
+
},
|
|
27337
|
+
async update(state) {
|
|
27338
|
+
await update(state.latestVersion);
|
|
27339
|
+
}
|
|
27340
|
+
});
|
|
27341
|
+
}
|
|
27342
|
+
|
|
27343
|
+
// dist/plugin.js
|
|
27344
|
+
var OPENCODE_COMMAND_ENV = "CODEXHOST_OPENCODE_COMMAND";
|
|
27345
|
+
function createHarnessAdapter(context) {
|
|
27346
|
+
const environment = { ...context.environment };
|
|
27347
|
+
return Object.assign(new OpenCodeAdapter2({
|
|
27348
|
+
...environment[OPENCODE_COMMAND_ENV] ? { command: environment[OPENCODE_COMMAND_ENV] } : {},
|
|
27349
|
+
environment
|
|
27350
|
+
}), { installation: createOpenCodeInstallation(environment, environment[OPENCODE_COMMAND_ENV]) });
|
|
23957
27351
|
}
|
|
23958
27352
|
export {
|
|
23959
27353
|
OPENCODE_COMMAND_ENV,
|