@codexhost/cli-darwin-arm64 0.17.1 → 0.17.3
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/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +15 -0
- package/app/console-web.js +15 -0
- package/app/desktop-controller.mjs +154 -21
- package/app/host-runtime.mjs +218 -29
- package/app/plugins/antigravity/plugin.mjs +15 -0
- package/app/plugins/claude-code/plugin.mjs +15 -0
- package/app/plugins/codebuddy/plugin.mjs +15 -0
- package/app/plugins/codex-usage/plugin.mjs +15 -0
- package/app/plugins/copilot/plugin.mjs +15 -0
- package/app/plugins/cursor-cli/plugin.mjs +15 -0
- package/app/plugins/deepseek-harness/plugin.mjs +15 -0
- package/app/plugins/devin/plugin.mjs +15 -0
- package/app/plugins/grok/plugin.mjs +15 -0
- package/app/plugins/hermes/plugin.mjs +15 -0
- package/app/plugins/kimi-code/plugin.mjs +15 -0
- package/app/plugins/kiro-cli/plugin.mjs +15 -0
- package/app/plugins/omp/plugin.mjs +15 -0
- package/app/plugins/opencode/plugin.mjs +15 -0
- package/app/plugins/pi/plugin.mjs +15 -0
- package/app/plugins/qoder/plugin.mjs +15 -0
- package/app/plugins/qoder-cn/plugin.mjs +15 -0
- package/app/plugins/qwen-code/plugin.mjs +15 -0
- package/app/plugins/workbuddy/plugin.mjs +15 -0
- package/app/plugins/zcode/plugin.mjs +15 -0
- package/app/renderer-extension.js +558 -215
- package/bin/codexhost +0 -0
- package/libexec/codexhost-shim +0 -0
- package/libexec/codexhost-updater +0 -0
- package/package.json +1 -1
package/app/host-runtime.mjs
CHANGED
|
@@ -21005,6 +21005,22 @@ var threadSteeringInspectParamsSchema = external_exports.object({
|
|
|
21005
21005
|
text: external_exports.string().optional()
|
|
21006
21006
|
}).strict();
|
|
21007
21007
|
var THREAD_STEER_DELIVERY_PARAM = "codexhostSteerDelivery";
|
|
21008
|
+
var THREAD_STEERING_CONTEXT_PARAM = "codexhost_external_steering";
|
|
21009
|
+
var threadSteeringContextSchema = external_exports.object({
|
|
21010
|
+
kind: external_exports.literal("application"),
|
|
21011
|
+
value: external_exports.string().transform((text, context) => {
|
|
21012
|
+
try {
|
|
21013
|
+
return JSON.parse(text);
|
|
21014
|
+
} catch {
|
|
21015
|
+
context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
|
|
21016
|
+
return external_exports.NEVER;
|
|
21017
|
+
}
|
|
21018
|
+
}).pipe(external_exports.object({
|
|
21019
|
+
expectedTurnId: hostTurnIdSchema,
|
|
21020
|
+
clientUserMessageId: external_exports.string().min(1),
|
|
21021
|
+
delivery: external_exports.enum(["newTurn", "activeTurn"])
|
|
21022
|
+
}).strict())
|
|
21023
|
+
}).strict().transform((context) => context.value);
|
|
21008
21024
|
var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
|
|
21009
21025
|
var threadSteeringInspectResultSchema = external_exports.object({
|
|
21010
21026
|
delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
|
|
@@ -23541,7 +23557,9 @@ function findRendererHostRpcFamily(store) {
|
|
|
23541
23557
|
if (!record6(members) || typeof members.get !== "function")
|
|
23542
23558
|
continue;
|
|
23543
23559
|
for (const [hostId2, member] of members) {
|
|
23544
|
-
if (typeof hostId2 !== "string" ||
|
|
23560
|
+
if (typeof hostId2 !== "string" || !/^(?:local$|durable$|remote[-:])/u.test(hostId2))
|
|
23561
|
+
continue;
|
|
23562
|
+
if (!record6(member))
|
|
23545
23563
|
continue;
|
|
23546
23564
|
const signal = member.value;
|
|
23547
23565
|
if (!record6(signal) || typeof signal.get !== "function")
|
|
@@ -23596,7 +23614,9 @@ function installRendererHostRpcRouting(root, target, dependencies2) {
|
|
|
23596
23614
|
return null;
|
|
23597
23615
|
try {
|
|
23598
23616
|
const store = dependencies2.findStore(root);
|
|
23599
|
-
|
|
23617
|
+
const bound = store && discovery?.store === store ? [...store.familyBindings.values()].includes(discovery.family) : false;
|
|
23618
|
+
if (!bound)
|
|
23619
|
+
discovery = store ? dependencies2.findFamily(store) : null;
|
|
23600
23620
|
} catch {
|
|
23601
23621
|
discovery = null;
|
|
23602
23622
|
}
|
|
@@ -23604,14 +23624,15 @@ function installRendererHostRpcRouting(root, target, dependencies2) {
|
|
|
23604
23624
|
};
|
|
23605
23625
|
if (!read())
|
|
23606
23626
|
return null;
|
|
23607
|
-
const
|
|
23608
|
-
|
|
23609
|
-
|
|
23610
|
-
|
|
23611
|
-
|
|
23612
|
-
|
|
23627
|
+
const discoverComposer = (composer) => {
|
|
23628
|
+
const owners = dependencies2.discoverComposer(composer);
|
|
23629
|
+
if (!nativeRouting && (owners.managers.length || owners.registries.length)) {
|
|
23630
|
+
try {
|
|
23631
|
+
nativeRouting = dependencies2.installNativeRouting();
|
|
23632
|
+
} catch {
|
|
23633
|
+
}
|
|
23613
23634
|
}
|
|
23614
|
-
return
|
|
23635
|
+
return owners;
|
|
23615
23636
|
};
|
|
23616
23637
|
const connectionFor = (hostId2) => {
|
|
23617
23638
|
if (!hostId2.startsWith("remote-control:"))
|
|
@@ -23813,7 +23834,7 @@ function installRendererHostRpcRouting(root, target, dependencies2) {
|
|
|
23813
23834
|
if (disposed)
|
|
23814
23835
|
return null;
|
|
23815
23836
|
const connection = connectionFor(hostId2);
|
|
23816
|
-
const preferred = nativeRoute === void 0 ?
|
|
23837
|
+
const preferred = nativeRoute === void 0 ? nativeRouting?.forHost(hostId2) : nativeRoute;
|
|
23817
23838
|
if (connection === null || preferred) {
|
|
23818
23839
|
retire(hostId2);
|
|
23819
23840
|
return connection === null ? null : preferred ?? null;
|
|
@@ -23842,11 +23863,11 @@ function installRendererHostRpcRouting(root, target, dependencies2) {
|
|
|
23842
23863
|
target.dispatchEvent(new CustomEvent("codexhost:draft-prewarm-policy-changed"));
|
|
23843
23864
|
}
|
|
23844
23865
|
};
|
|
23845
|
-
const composerHostId = (composer) => {
|
|
23846
|
-
const nativeHostId =
|
|
23866
|
+
const composerHostId = (owners, composer) => {
|
|
23867
|
+
const nativeHostId = nativeRouting?.hostIdForComposer(composer);
|
|
23847
23868
|
if (nativeHostId)
|
|
23848
23869
|
return nativeHostId;
|
|
23849
|
-
const hostIds = new Set(
|
|
23870
|
+
const hostIds = new Set((owners ?? discoverComposer(composer)).hostIds);
|
|
23850
23871
|
const hostId2 = hostIds.size === 1 ? hostIds.values().next().value : null;
|
|
23851
23872
|
return typeof hostId2 === "string" && hostId2 ? hostId2 : null;
|
|
23852
23873
|
};
|
|
@@ -23854,11 +23875,16 @@ function installRendererHostRpcRouting(root, target, dependencies2) {
|
|
|
23854
23875
|
knownHostIds() {
|
|
23855
23876
|
if (disposed)
|
|
23856
23877
|
return [];
|
|
23878
|
+
try {
|
|
23879
|
+
if (!nativeRouting)
|
|
23880
|
+
discoverComposer();
|
|
23881
|
+
} catch {
|
|
23882
|
+
}
|
|
23857
23883
|
const current = read();
|
|
23858
23884
|
return [
|
|
23859
23885
|
.../* @__PURE__ */ new Set([
|
|
23860
23886
|
...current ? dependencies2.hostIds(current) : [],
|
|
23861
|
-
...
|
|
23887
|
+
...nativeRouting?.knownHostIds?.() ?? []
|
|
23862
23888
|
])
|
|
23863
23889
|
];
|
|
23864
23890
|
},
|
|
@@ -23869,7 +23895,7 @@ function installRendererHostRpcRouting(root, target, dependencies2) {
|
|
|
23869
23895
|
if (disposed)
|
|
23870
23896
|
return null;
|
|
23871
23897
|
try {
|
|
23872
|
-
return composerHostId(composer);
|
|
23898
|
+
return composerHostId(nativeRouting ? null : discoverComposer(composer), composer);
|
|
23873
23899
|
} catch {
|
|
23874
23900
|
return null;
|
|
23875
23901
|
}
|
|
@@ -23880,8 +23906,9 @@ function installRendererHostRpcRouting(root, target, dependencies2) {
|
|
|
23880
23906
|
let hostId2;
|
|
23881
23907
|
let preferred = null;
|
|
23882
23908
|
try {
|
|
23883
|
-
|
|
23884
|
-
|
|
23909
|
+
const owners = nativeRouting ? null : discoverComposer(composer);
|
|
23910
|
+
preferred = nativeRouting?.forComposer(composer) ?? null;
|
|
23911
|
+
hostId2 = preferred?.hostId ?? composerHostId(owners, composer);
|
|
23885
23912
|
} catch {
|
|
23886
23913
|
hostId2 = null;
|
|
23887
23914
|
}
|
|
@@ -23972,17 +23999,14 @@ function directRendererInstaller() {
|
|
|
23972
23999
|
findFamily: ${findRendererHostRpcFamily.toString()},
|
|
23973
24000
|
resolve: ${resolveRendererHostRpc.toString()},
|
|
23974
24001
|
hostIds: ${rendererHostRpcHostIds.toString()},
|
|
23975
|
-
|
|
24002
|
+
discoverComposer: (composer) => {
|
|
23976
24003
|
const source = composer?.matches?.('[data-codex-composer], [contenteditable="true"][role="textbox"]')
|
|
23977
24004
|
? { querySelectorAll: () => [composer] }
|
|
23978
24005
|
: (composer ?? document);
|
|
23979
24006
|
return discover(source);
|
|
23980
24007
|
},
|
|
23981
24008
|
portPrototype: MessagePort.prototype,
|
|
23982
|
-
|
|
23983
|
-
const native = discover(document);
|
|
23984
|
-
return native.managers.length || native.registries.length ? installNative(false) : null;
|
|
23985
|
-
},
|
|
24009
|
+
installNativeRouting: () => installNative(false),
|
|
23986
24010
|
readConnection: (hostId) => readRendererConnectionGeneration(findRendererAppScopeStore(document), hostId),
|
|
23987
24011
|
});
|
|
23988
24012
|
const connected = (routing) => routing.forComposer() !== null ||
|
|
@@ -24930,6 +24954,114 @@ async function installNativeRpcRemoteControlDirect(renderer) {
|
|
|
24930
24954
|
}
|
|
24931
24955
|
}
|
|
24932
24956
|
|
|
24957
|
+
// packages/desktop-control/dist/renderer-rpc-steering.js
|
|
24958
|
+
var RETRY_BASE_MS = 5e3;
|
|
24959
|
+
var RETRY_MAX_MS = 3e5;
|
|
24960
|
+
var retries = /* @__PURE__ */ new WeakMap();
|
|
24961
|
+
async function installRendererRpcSteeringDirect(client, now = Date.now) {
|
|
24962
|
+
try {
|
|
24963
|
+
const needed = await client.evaluate(`(() => {
|
|
24964
|
+
const steering = window.__codexhostRpcSteeringV1;
|
|
24965
|
+
if (steering && steering.controller.forHost === steering.forHost) return false;
|
|
24966
|
+
steering?.release();
|
|
24967
|
+
const routing=window.__codexhostHostRoutingV1;
|
|
24968
|
+
return ['local', ...(routing?.knownHostIds?.() ?? [])].some(id => routing?.forHost(id)?.manager.kind === 'main-process-rpc');
|
|
24969
|
+
})()`);
|
|
24970
|
+
if (!needed)
|
|
24971
|
+
return false;
|
|
24972
|
+
const retry = retries.get(client);
|
|
24973
|
+
if (retry && now() < retry.nextAt)
|
|
24974
|
+
return false;
|
|
24975
|
+
try {
|
|
24976
|
+
await discoverAndInstall(client);
|
|
24977
|
+
retries.delete(client);
|
|
24978
|
+
return true;
|
|
24979
|
+
} catch (error51) {
|
|
24980
|
+
const attempts = (retry?.attempts ?? 0) + 1;
|
|
24981
|
+
const delay7 = Math.min(RETRY_BASE_MS * 2 ** (attempts - 1), RETRY_MAX_MS);
|
|
24982
|
+
retries.set(client, { attempts, nextAt: now() + delay7 });
|
|
24983
|
+
console.error(`codexhost native steering discovery failed (attempt ${attempts}):`, error51 instanceof Error ? error51.message : String(error51));
|
|
24984
|
+
return false;
|
|
24985
|
+
}
|
|
24986
|
+
} catch {
|
|
24987
|
+
return false;
|
|
24988
|
+
}
|
|
24989
|
+
}
|
|
24990
|
+
async function discoverAndInstall(client) {
|
|
24991
|
+
const group = `codexhost-rpc-steering-${crypto.randomUUID()}`;
|
|
24992
|
+
const command = (method, params) => client.command(method, params);
|
|
24993
|
+
const properties = (objectId) => command("Runtime.getProperties", { objectId, ownProperties: true });
|
|
24994
|
+
const call = (objectId, functionDeclaration, args = []) => command("Runtime.callFunctionOn", {
|
|
24995
|
+
objectId,
|
|
24996
|
+
functionDeclaration,
|
|
24997
|
+
arguments: args,
|
|
24998
|
+
objectGroup: group,
|
|
24999
|
+
returnByValue: true
|
|
25000
|
+
});
|
|
25001
|
+
try {
|
|
25002
|
+
const proto = await command("Runtime.evaluate", {
|
|
25003
|
+
expression: "Object.getPrototypeOf(async function(){})",
|
|
25004
|
+
objectGroup: group
|
|
25005
|
+
});
|
|
25006
|
+
if (!proto.result.objectId)
|
|
25007
|
+
throw new Error("Native RPC steering discovery is unavailable");
|
|
25008
|
+
const objects = await command("Runtime.queryObjects", {
|
|
25009
|
+
prototypeObjectId: proto.result.objectId,
|
|
25010
|
+
objectGroup: group
|
|
25011
|
+
});
|
|
25012
|
+
if (!objects.objects.objectId)
|
|
25013
|
+
throw new Error("Native RPC steering discovery is unavailable");
|
|
25014
|
+
const filtered = await command("Runtime.callFunctionOn", {
|
|
25015
|
+
objectId: objects.objects.objectId,
|
|
25016
|
+
functionDeclaration: 'function(){return this.filter(fn=>fn.name==="collectAppStateSnapshot"&&String(fn).includes("collectSnapshot")).slice(0,9)}',
|
|
25017
|
+
objectGroup: group
|
|
25018
|
+
});
|
|
25019
|
+
if (!filtered.result.objectId)
|
|
25020
|
+
throw new Error("Native RPC Controller is unavailable");
|
|
25021
|
+
const snapshots = (await properties(filtered.result.objectId)).result.flatMap((entry) => entry.value?.type === "function" && entry.value.objectId ? [entry.value.objectId] : []);
|
|
25022
|
+
if (snapshots.length > 8)
|
|
25023
|
+
throw new Error("Native RPC Controller is ambiguous");
|
|
25024
|
+
const controllers = [];
|
|
25025
|
+
for (const snapshot2 of snapshots) {
|
|
25026
|
+
const scopes = (await properties(snapshot2)).internalProperties?.find((entry) => entry.name === "[[Scopes]]")?.value?.objectId;
|
|
25027
|
+
if (!scopes)
|
|
25028
|
+
continue;
|
|
25029
|
+
for (const scope of (await properties(scopes)).result) {
|
|
25030
|
+
if (!scope.value?.objectId || !scope.value.description?.startsWith("Closure"))
|
|
25031
|
+
continue;
|
|
25032
|
+
const bindings = (await properties(scope.value.objectId)).result;
|
|
25033
|
+
const owners = [];
|
|
25034
|
+
let rootScope;
|
|
25035
|
+
for (const binding of bindings) {
|
|
25036
|
+
if (binding.value?.type !== "object" || !binding.value.objectId)
|
|
25037
|
+
continue;
|
|
25038
|
+
const id2 = binding.value.objectId;
|
|
25039
|
+
const result2 = await call(id2, `function(){return (${nativeRpcObjectShape.toString()})(this)}`);
|
|
25040
|
+
const shape = result2.result.value;
|
|
25041
|
+
if (shape?.scope)
|
|
25042
|
+
rootScope = id2;
|
|
25043
|
+
if (shape?.controller && (await call(id2, "function(fn){return this.collectAppStateSnapshot===fn}", [
|
|
25044
|
+
{ objectId: snapshot2 }
|
|
25045
|
+
])).result.value === true)
|
|
25046
|
+
owners.push(id2);
|
|
25047
|
+
}
|
|
25048
|
+
if (owners.length !== 1 || !rootScope)
|
|
25049
|
+
continue;
|
|
25050
|
+
const root = await call(rootScope, `function(){let node=this.node;const seen=new Set();while(node?.parent&&!seen.has(node.parent)&&seen.size<100){seen.add(node);node=node.parent}return (${findRendererAppScopeStore.toString()})(document)===node}`);
|
|
25051
|
+
if (root.result.value === true)
|
|
25052
|
+
controllers.push(owners[0]);
|
|
25053
|
+
}
|
|
25054
|
+
}
|
|
25055
|
+
if (controllers.length !== 1)
|
|
25056
|
+
throw new Error("Native RPC Controller is missing or ambiguous");
|
|
25057
|
+
const result = await call(controllers[0], "function(){return window.__codexhostInstallRpcSteeringV1?.(this) === true}");
|
|
25058
|
+
if (result.exceptionDetails || result.result.value !== true)
|
|
25059
|
+
throw new Error("Native RPC steering installation failed");
|
|
25060
|
+
} finally {
|
|
25061
|
+
await client.command("Runtime.releaseObjectGroup", { objectGroup: group }).catch(() => void 0);
|
|
25062
|
+
}
|
|
25063
|
+
}
|
|
25064
|
+
|
|
24933
25065
|
// packages/desktop-control/dist/renderer-cdp-control-session.js
|
|
24934
25066
|
function isRecord2(value2) {
|
|
24935
25067
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
@@ -25160,6 +25292,7 @@ var defaultOperations = {
|
|
|
25160
25292
|
async installDraftPrewarmPolicy(renderer) {
|
|
25161
25293
|
const status2 = await installRendererDraftPrewarmPolicyDirect(renderer);
|
|
25162
25294
|
await installNativeRpcRemoteControlDirect(renderer);
|
|
25295
|
+
await installRendererRpcSteeringDirect(renderer);
|
|
25163
25296
|
return status2;
|
|
25164
25297
|
}
|
|
25165
25298
|
};
|
|
@@ -35432,6 +35565,7 @@ var publicSubmission = ({
|
|
|
35432
35565
|
var DEFAULT_PAGE_SIZE3 = 50;
|
|
35433
35566
|
var ExternalThreadQueue = class {
|
|
35434
35567
|
#queues = /* @__PURE__ */ new Map();
|
|
35568
|
+
#acceptedSteers = /* @__PURE__ */ new Map();
|
|
35435
35569
|
#notifyChanged;
|
|
35436
35570
|
#createId;
|
|
35437
35571
|
constructor(options) {
|
|
@@ -35473,7 +35607,7 @@ var ExternalThreadQueue = class {
|
|
|
35473
35607
|
async delete(threadId2, id2) {
|
|
35474
35608
|
const items = this.#queues.get(threadId2);
|
|
35475
35609
|
const index = items?.findIndex((item) => item.id === id2) ?? -1;
|
|
35476
|
-
if (!items || index === -1) return
|
|
35610
|
+
if (!items || index === -1) return this.#acceptedSteers.get(id2) === threadId2;
|
|
35477
35611
|
items.splice(index, 1);
|
|
35478
35612
|
this.#prune(threadId2);
|
|
35479
35613
|
await this.#notifyChanged(threadId2);
|
|
@@ -35506,6 +35640,26 @@ var ExternalThreadQueue = class {
|
|
|
35506
35640
|
index
|
|
35507
35641
|
};
|
|
35508
35642
|
}
|
|
35643
|
+
/** Reserve the exact queued input before steering can finish a replacement Turn.
|
|
35644
|
+
* Otherwise automatic queue advancement can deliver that input a second time. */
|
|
35645
|
+
takeSteered(threadId2, clientUserMessageId, input) {
|
|
35646
|
+
if (typeof clientUserMessageId !== "string") return;
|
|
35647
|
+
const matches = (this.#queues.get(threadId2) ?? []).filter(
|
|
35648
|
+
(item2) => item2.clientUserMessageId === clientUserMessageId
|
|
35649
|
+
);
|
|
35650
|
+
if (matches.length === 0) return;
|
|
35651
|
+
const item = matches[0];
|
|
35652
|
+
if (matches.length !== 1 || externalTurnInputText(item.input) !== externalTurnInputText(input))
|
|
35653
|
+
throw new ExternalQueueError(-32602, "Queued steering input changed before delivery");
|
|
35654
|
+
return this.take(threadId2, item.id);
|
|
35655
|
+
}
|
|
35656
|
+
async acceptSteered(threadId2, taken) {
|
|
35657
|
+
this.#acceptedSteers.set(taken.submission.id, threadId2);
|
|
35658
|
+
while (this.#acceptedSteers.size > 128) {
|
|
35659
|
+
this.#acceptedSteers.delete(this.#acceptedSteers.keys().next().value);
|
|
35660
|
+
}
|
|
35661
|
+
await this.#notifyChanged(threadId2);
|
|
35662
|
+
}
|
|
35509
35663
|
restore(threadId2, taken) {
|
|
35510
35664
|
const items = this.#items(threadId2);
|
|
35511
35665
|
if (items.some((item) => item.id === taken.submission.id)) return;
|
|
@@ -35519,6 +35673,9 @@ var ExternalThreadQueue = class {
|
|
|
35519
35673
|
}
|
|
35520
35674
|
forget(threadId2) {
|
|
35521
35675
|
this.#queues.delete(threadId2);
|
|
35676
|
+
for (const [id2, owner] of this.#acceptedSteers) {
|
|
35677
|
+
if (owner === threadId2) this.#acceptedSteers.delete(id2);
|
|
35678
|
+
}
|
|
35522
35679
|
}
|
|
35523
35680
|
#items(threadId2) {
|
|
35524
35681
|
let items = this.#queues.get(threadId2);
|
|
@@ -43524,7 +43681,7 @@ var AppServerHost = class {
|
|
|
43524
43681
|
...arguments_2 ? { arguments: arguments_2 } : {}
|
|
43525
43682
|
});
|
|
43526
43683
|
if (!result.ok) throw new ExternalCommandError(-32073, result.error.message);
|
|
43527
|
-
return { turnId
|
|
43684
|
+
return { turnId, turn: projection.projector.pendingTurn(), gate };
|
|
43528
43685
|
} catch (error51) {
|
|
43529
43686
|
restoreExecutionHost();
|
|
43530
43687
|
thread.running = false;
|
|
@@ -44306,6 +44463,11 @@ var AppServerHost = class {
|
|
|
44306
44463
|
}
|
|
44307
44464
|
}
|
|
44308
44465
|
async #startExternalTurn(request, thread) {
|
|
44466
|
+
const context = routingParams(request).additionalContext;
|
|
44467
|
+
if (isRecord18(context) && Object.hasOwn(context, THREAD_STEERING_CONTEXT_PARAM)) {
|
|
44468
|
+
await this.#steerExternalTurn(request, thread, true);
|
|
44469
|
+
return;
|
|
44470
|
+
}
|
|
44309
44471
|
if (this.#externalThreadBusy(thread) || this.#pendingExternalCommandRequests.has(thread.id)) {
|
|
44310
44472
|
await this.#writer.json(
|
|
44311
44473
|
rpcError(request, -32072, "External Thread already has an active Turn")
|
|
@@ -44477,34 +44639,61 @@ var AppServerHost = class {
|
|
|
44477
44639
|
this.#diagnose(error51);
|
|
44478
44640
|
}
|
|
44479
44641
|
}
|
|
44480
|
-
async #steerExternalTurn(request, thread) {
|
|
44642
|
+
async #steerExternalTurn(request, thread, asStart = false) {
|
|
44643
|
+
let queued;
|
|
44644
|
+
let accepted = false;
|
|
44481
44645
|
try {
|
|
44646
|
+
let params = requestObject(request);
|
|
44647
|
+
const context = params.additionalContext;
|
|
44648
|
+
if (isRecord18(context) && Object.hasOwn(context, THREAD_STEERING_CONTEXT_PARAM)) {
|
|
44649
|
+
const marker = threadSteeringContextSchema.safeParse(
|
|
44650
|
+
context[THREAD_STEERING_CONTEXT_PARAM]
|
|
44651
|
+
);
|
|
44652
|
+
if (!marker.success || marker.data.clientUserMessageId !== params.clientUserMessageId || asStart && marker.data.delivery !== "newTurn")
|
|
44653
|
+
throw new ExternalSteerError(-32602, "Invalid native steering preparation context");
|
|
44654
|
+
if (!asStart && params.expectedTurnId !== marker.data.expectedTurnId)
|
|
44655
|
+
throw new ExternalSteerError(-32074, "Native steering target changed before submission");
|
|
44656
|
+
params = {
|
|
44657
|
+
...params,
|
|
44658
|
+
expectedTurnId: marker.data.expectedTurnId,
|
|
44659
|
+
[THREAD_STEER_DELIVERY_PARAM]: marker.data.delivery
|
|
44660
|
+
};
|
|
44661
|
+
}
|
|
44662
|
+
queued = this.#externalQueue.takeSteered(thread.id, params.clientUserMessageId, params.input);
|
|
44482
44663
|
const started = await this.#externalSteering.run(
|
|
44483
44664
|
thread,
|
|
44484
|
-
|
|
44665
|
+
params,
|
|
44485
44666
|
(text, assertActive) => this.#beginExternalInputTurn(
|
|
44486
44667
|
thread,
|
|
44487
44668
|
text,
|
|
44488
44669
|
assertActive,
|
|
44489
44670
|
typeof requestObject(request).clientUserMessageId === "string" ? requestObject(request).clientUserMessageId : void 0,
|
|
44490
|
-
requestObject(request)[THREAD_REFERENCE_SOURCE_HOST_PARAM]
|
|
44671
|
+
queued ? queued.sourceHostId : requestObject(request)[THREAD_REFERENCE_SOURCE_HOST_PARAM]
|
|
44491
44672
|
),
|
|
44492
44673
|
(input) => this.#insertExternalInput(thread, input)
|
|
44493
44674
|
);
|
|
44675
|
+
accepted = true;
|
|
44676
|
+
if (queued) {
|
|
44677
|
+
await this.#externalQueue.acceptSteered(thread.id, queued).catch((error51) => this.#diagnose(error51));
|
|
44678
|
+
}
|
|
44494
44679
|
try {
|
|
44495
44680
|
await this.#writer.json(
|
|
44496
44681
|
rpcEnvelope(request, {
|
|
44497
|
-
result: { turnId: started.turnId, delivery: started.delivery }
|
|
44682
|
+
result: asStart ? { turn: this.#projectedTurn(thread, started.turnId).projector.pendingTurn() } : { turnId: started.turnId, delivery: started.delivery }
|
|
44498
44683
|
})
|
|
44499
44684
|
);
|
|
44500
44685
|
} finally {
|
|
44501
44686
|
started.gate.resolve();
|
|
44502
44687
|
}
|
|
44503
44688
|
} catch (error51) {
|
|
44689
|
+
if (queued && !accepted) {
|
|
44690
|
+
this.#externalQueue.restore(thread.id, queued);
|
|
44691
|
+
await this.#externalQueue.notifyChanged(thread.id).catch((failure) => this.#diagnose(failure));
|
|
44692
|
+
}
|
|
44504
44693
|
await this.#writer.json(
|
|
44505
44694
|
rpcError(
|
|
44506
44695
|
request,
|
|
44507
|
-
error51 instanceof ExternalSteerError || error51 instanceof ExternalCommandError ? error51.code : -32074,
|
|
44696
|
+
error51 instanceof ExternalSteerError || error51 instanceof ExternalCommandError || error51 instanceof ExternalQueueError ? error51.code : -32074,
|
|
44508
44697
|
errorMessage4(error51)
|
|
44509
44698
|
)
|
|
44510
44699
|
);
|
|
@@ -15898,6 +15898,21 @@ var threadSteeringInspectParamsSchema = external_exports.object({
|
|
|
15898
15898
|
/** The text about to be steered; a Harness command always stops and restarts. */
|
|
15899
15899
|
text: external_exports.string().optional()
|
|
15900
15900
|
}).strict();
|
|
15901
|
+
var threadSteeringContextSchema = external_exports.object({
|
|
15902
|
+
kind: external_exports.literal("application"),
|
|
15903
|
+
value: external_exports.string().transform((text, context) => {
|
|
15904
|
+
try {
|
|
15905
|
+
return JSON.parse(text);
|
|
15906
|
+
} catch {
|
|
15907
|
+
context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
|
|
15908
|
+
return external_exports.NEVER;
|
|
15909
|
+
}
|
|
15910
|
+
}).pipe(external_exports.object({
|
|
15911
|
+
expectedTurnId: hostTurnIdSchema,
|
|
15912
|
+
clientUserMessageId: external_exports.string().min(1),
|
|
15913
|
+
delivery: external_exports.enum(["newTurn", "activeTurn"])
|
|
15914
|
+
}).strict())
|
|
15915
|
+
}).strict().transform((context) => context.value);
|
|
15901
15916
|
var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
|
|
15902
15917
|
var threadSteeringInspectResultSchema = external_exports.object({
|
|
15903
15918
|
delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
|
|
@@ -15492,6 +15492,21 @@ var threadSteeringInspectParamsSchema = external_exports.object({
|
|
|
15492
15492
|
/** The text about to be steered; a Harness command always stops and restarts. */
|
|
15493
15493
|
text: external_exports.string().optional()
|
|
15494
15494
|
}).strict();
|
|
15495
|
+
var threadSteeringContextSchema = external_exports.object({
|
|
15496
|
+
kind: external_exports.literal("application"),
|
|
15497
|
+
value: external_exports.string().transform((text2, context) => {
|
|
15498
|
+
try {
|
|
15499
|
+
return JSON.parse(text2);
|
|
15500
|
+
} catch {
|
|
15501
|
+
context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
|
|
15502
|
+
return external_exports.NEVER;
|
|
15503
|
+
}
|
|
15504
|
+
}).pipe(external_exports.object({
|
|
15505
|
+
expectedTurnId: hostTurnIdSchema,
|
|
15506
|
+
clientUserMessageId: external_exports.string().min(1),
|
|
15507
|
+
delivery: external_exports.enum(["newTurn", "activeTurn"])
|
|
15508
|
+
}).strict())
|
|
15509
|
+
}).strict().transform((context) => context.value);
|
|
15495
15510
|
var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
|
|
15496
15511
|
var threadSteeringInspectResultSchema = external_exports.object({
|
|
15497
15512
|
delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
|
|
@@ -15968,6 +15968,21 @@ var threadSteeringInspectParamsSchema = external_exports.object({
|
|
|
15968
15968
|
/** The text about to be steered; a Harness command always stops and restarts. */
|
|
15969
15969
|
text: external_exports.string().optional()
|
|
15970
15970
|
}).strict();
|
|
15971
|
+
var threadSteeringContextSchema = external_exports.object({
|
|
15972
|
+
kind: external_exports.literal("application"),
|
|
15973
|
+
value: external_exports.string().transform((text2, context) => {
|
|
15974
|
+
try {
|
|
15975
|
+
return JSON.parse(text2);
|
|
15976
|
+
} catch {
|
|
15977
|
+
context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
|
|
15978
|
+
return external_exports.NEVER;
|
|
15979
|
+
}
|
|
15980
|
+
}).pipe(external_exports.object({
|
|
15981
|
+
expectedTurnId: hostTurnIdSchema,
|
|
15982
|
+
clientUserMessageId: external_exports.string().min(1),
|
|
15983
|
+
delivery: external_exports.enum(["newTurn", "activeTurn"])
|
|
15984
|
+
}).strict())
|
|
15985
|
+
}).strict().transform((context) => context.value);
|
|
15971
15986
|
var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
|
|
15972
15987
|
var threadSteeringInspectResultSchema = external_exports.object({
|
|
15973
15988
|
delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
|
|
@@ -15486,6 +15486,21 @@ var threadSteeringInspectParamsSchema = external_exports.object({
|
|
|
15486
15486
|
/** The text about to be steered; a Harness command always stops and restarts. */
|
|
15487
15487
|
text: external_exports.string().optional()
|
|
15488
15488
|
}).strict();
|
|
15489
|
+
var threadSteeringContextSchema = external_exports.object({
|
|
15490
|
+
kind: external_exports.literal("application"),
|
|
15491
|
+
value: external_exports.string().transform((text2, context) => {
|
|
15492
|
+
try {
|
|
15493
|
+
return JSON.parse(text2);
|
|
15494
|
+
} catch {
|
|
15495
|
+
context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
|
|
15496
|
+
return external_exports.NEVER;
|
|
15497
|
+
}
|
|
15498
|
+
}).pipe(external_exports.object({
|
|
15499
|
+
expectedTurnId: hostTurnIdSchema,
|
|
15500
|
+
clientUserMessageId: external_exports.string().min(1),
|
|
15501
|
+
delivery: external_exports.enum(["newTurn", "activeTurn"])
|
|
15502
|
+
}).strict())
|
|
15503
|
+
}).strict().transform((context) => context.value);
|
|
15489
15504
|
var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
|
|
15490
15505
|
var threadSteeringInspectResultSchema = external_exports.object({
|
|
15491
15506
|
delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
|
|
@@ -19543,6 +19543,21 @@ var threadSteeringInspectParamsSchema = external_exports.object({
|
|
|
19543
19543
|
/** The text about to be steered; a Harness command always stops and restarts. */
|
|
19544
19544
|
text: external_exports.string().optional()
|
|
19545
19545
|
}).strict();
|
|
19546
|
+
var threadSteeringContextSchema = external_exports.object({
|
|
19547
|
+
kind: external_exports.literal("application"),
|
|
19548
|
+
value: external_exports.string().transform((text, context) => {
|
|
19549
|
+
try {
|
|
19550
|
+
return JSON.parse(text);
|
|
19551
|
+
} catch {
|
|
19552
|
+
context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
|
|
19553
|
+
return external_exports.NEVER;
|
|
19554
|
+
}
|
|
19555
|
+
}).pipe(external_exports.object({
|
|
19556
|
+
expectedTurnId: hostTurnIdSchema,
|
|
19557
|
+
clientUserMessageId: external_exports.string().min(1),
|
|
19558
|
+
delivery: external_exports.enum(["newTurn", "activeTurn"])
|
|
19559
|
+
}).strict())
|
|
19560
|
+
}).strict().transform((context) => context.value);
|
|
19546
19561
|
var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
|
|
19547
19562
|
var threadSteeringInspectResultSchema = external_exports.object({
|
|
19548
19563
|
delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
|
|
@@ -15853,6 +15853,21 @@ var threadSteeringInspectParamsSchema = external_exports.object({
|
|
|
15853
15853
|
/** The text about to be steered; a Harness command always stops and restarts. */
|
|
15854
15854
|
text: external_exports.string().optional()
|
|
15855
15855
|
}).strict();
|
|
15856
|
+
var threadSteeringContextSchema = external_exports.object({
|
|
15857
|
+
kind: external_exports.literal("application"),
|
|
15858
|
+
value: external_exports.string().transform((text, context) => {
|
|
15859
|
+
try {
|
|
15860
|
+
return JSON.parse(text);
|
|
15861
|
+
} catch {
|
|
15862
|
+
context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
|
|
15863
|
+
return external_exports.NEVER;
|
|
15864
|
+
}
|
|
15865
|
+
}).pipe(external_exports.object({
|
|
15866
|
+
expectedTurnId: hostTurnIdSchema,
|
|
15867
|
+
clientUserMessageId: external_exports.string().min(1),
|
|
15868
|
+
delivery: external_exports.enum(["newTurn", "activeTurn"])
|
|
15869
|
+
}).strict())
|
|
15870
|
+
}).strict().transform((context) => context.value);
|
|
15856
15871
|
var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
|
|
15857
15872
|
var threadSteeringInspectResultSchema = external_exports.object({
|
|
15858
15873
|
delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
|
|
@@ -19733,6 +19733,21 @@ var threadSteeringInspectParamsSchema = external_exports.object({
|
|
|
19733
19733
|
/** The text about to be steered; a Harness command always stops and restarts. */
|
|
19734
19734
|
text: external_exports.string().optional()
|
|
19735
19735
|
}).strict();
|
|
19736
|
+
var threadSteeringContextSchema = external_exports.object({
|
|
19737
|
+
kind: external_exports.literal("application"),
|
|
19738
|
+
value: external_exports.string().transform((text, context) => {
|
|
19739
|
+
try {
|
|
19740
|
+
return JSON.parse(text);
|
|
19741
|
+
} catch {
|
|
19742
|
+
context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
|
|
19743
|
+
return external_exports.NEVER;
|
|
19744
|
+
}
|
|
19745
|
+
}).pipe(external_exports.object({
|
|
19746
|
+
expectedTurnId: hostTurnIdSchema,
|
|
19747
|
+
clientUserMessageId: external_exports.string().min(1),
|
|
19748
|
+
delivery: external_exports.enum(["newTurn", "activeTurn"])
|
|
19749
|
+
}).strict())
|
|
19750
|
+
}).strict().transform((context) => context.value);
|
|
19736
19751
|
var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
|
|
19737
19752
|
var threadSteeringInspectResultSchema = external_exports.object({
|
|
19738
19753
|
delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
|
|
@@ -15490,6 +15490,21 @@ var threadSteeringInspectParamsSchema = external_exports.object({
|
|
|
15490
15490
|
/** The text about to be steered; a Harness command always stops and restarts. */
|
|
15491
15491
|
text: external_exports.string().optional()
|
|
15492
15492
|
}).strict();
|
|
15493
|
+
var threadSteeringContextSchema = external_exports.object({
|
|
15494
|
+
kind: external_exports.literal("application"),
|
|
15495
|
+
value: external_exports.string().transform((text, context) => {
|
|
15496
|
+
try {
|
|
15497
|
+
return JSON.parse(text);
|
|
15498
|
+
} catch {
|
|
15499
|
+
context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
|
|
15500
|
+
return external_exports.NEVER;
|
|
15501
|
+
}
|
|
15502
|
+
}).pipe(external_exports.object({
|
|
15503
|
+
expectedTurnId: hostTurnIdSchema,
|
|
15504
|
+
clientUserMessageId: external_exports.string().min(1),
|
|
15505
|
+
delivery: external_exports.enum(["newTurn", "activeTurn"])
|
|
15506
|
+
}).strict())
|
|
15507
|
+
}).strict().transform((context) => context.value);
|
|
15493
15508
|
var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
|
|
15494
15509
|
var threadSteeringInspectResultSchema = external_exports.object({
|
|
15495
15510
|
delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
|
|
@@ -16086,6 +16086,21 @@ var threadSteeringInspectParamsSchema = external_exports.object({
|
|
|
16086
16086
|
/** The text about to be steered; a Harness command always stops and restarts. */
|
|
16087
16087
|
text: external_exports.string().optional()
|
|
16088
16088
|
}).strict();
|
|
16089
|
+
var threadSteeringContextSchema = external_exports.object({
|
|
16090
|
+
kind: external_exports.literal("application"),
|
|
16091
|
+
value: external_exports.string().transform((text, context) => {
|
|
16092
|
+
try {
|
|
16093
|
+
return JSON.parse(text);
|
|
16094
|
+
} catch {
|
|
16095
|
+
context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
|
|
16096
|
+
return external_exports.NEVER;
|
|
16097
|
+
}
|
|
16098
|
+
}).pipe(external_exports.object({
|
|
16099
|
+
expectedTurnId: hostTurnIdSchema,
|
|
16100
|
+
clientUserMessageId: external_exports.string().min(1),
|
|
16101
|
+
delivery: external_exports.enum(["newTurn", "activeTurn"])
|
|
16102
|
+
}).strict())
|
|
16103
|
+
}).strict().transform((context) => context.value);
|
|
16089
16104
|
var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
|
|
16090
16105
|
var threadSteeringInspectResultSchema = external_exports.object({
|
|
16091
16106
|
delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
|
|
@@ -15853,6 +15853,21 @@ var threadSteeringInspectParamsSchema = external_exports.object({
|
|
|
15853
15853
|
/** The text about to be steered; a Harness command always stops and restarts. */
|
|
15854
15854
|
text: external_exports.string().optional()
|
|
15855
15855
|
}).strict();
|
|
15856
|
+
var threadSteeringContextSchema = external_exports.object({
|
|
15857
|
+
kind: external_exports.literal("application"),
|
|
15858
|
+
value: external_exports.string().transform((text2, context) => {
|
|
15859
|
+
try {
|
|
15860
|
+
return JSON.parse(text2);
|
|
15861
|
+
} catch {
|
|
15862
|
+
context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
|
|
15863
|
+
return external_exports.NEVER;
|
|
15864
|
+
}
|
|
15865
|
+
}).pipe(external_exports.object({
|
|
15866
|
+
expectedTurnId: hostTurnIdSchema,
|
|
15867
|
+
clientUserMessageId: external_exports.string().min(1),
|
|
15868
|
+
delivery: external_exports.enum(["newTurn", "activeTurn"])
|
|
15869
|
+
}).strict())
|
|
15870
|
+
}).strict().transform((context) => context.value);
|
|
15856
15871
|
var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
|
|
15857
15872
|
var threadSteeringInspectResultSchema = external_exports.object({
|
|
15858
15873
|
delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
|
|
@@ -15973,6 +15973,21 @@ var threadSteeringInspectParamsSchema = external_exports.object({
|
|
|
15973
15973
|
/** The text about to be steered; a Harness command always stops and restarts. */
|
|
15974
15974
|
text: external_exports.string().optional()
|
|
15975
15975
|
}).strict();
|
|
15976
|
+
var threadSteeringContextSchema = external_exports.object({
|
|
15977
|
+
kind: external_exports.literal("application"),
|
|
15978
|
+
value: external_exports.string().transform((text, context) => {
|
|
15979
|
+
try {
|
|
15980
|
+
return JSON.parse(text);
|
|
15981
|
+
} catch {
|
|
15982
|
+
context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
|
|
15983
|
+
return external_exports.NEVER;
|
|
15984
|
+
}
|
|
15985
|
+
}).pipe(external_exports.object({
|
|
15986
|
+
expectedTurnId: hostTurnIdSchema,
|
|
15987
|
+
clientUserMessageId: external_exports.string().min(1),
|
|
15988
|
+
delivery: external_exports.enum(["newTurn", "activeTurn"])
|
|
15989
|
+
}).strict())
|
|
15990
|
+
}).strict().transform((context) => context.value);
|
|
15976
15991
|
var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
|
|
15977
15992
|
var threadSteeringInspectResultSchema = external_exports.object({
|
|
15978
15993
|
delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
|