@aiwayds/dsh-opentui 0.26.0 → 0.26.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bridge/bundle-fingerprint.json +1 -1
- package/dist/bridge/index.js +88 -7
- package/dist/client/index.js +3026 -3183
- package/dist/client/index.js.map +23 -23
- package/dist/host-launch.mjs.map +1 -1
- package/dist/locales/en.json +1 -13
- package/dist/locales/zh-CN.json +1 -13
- package/dist/watchdog.mjs.map +1 -1
- package/package.json +1 -1
- package/scripts/lib/inproc-companions.mjs +213 -0
- package/scripts/provision-inproc-profile.mjs +297 -34
package/dist/bridge/index.js
CHANGED
|
@@ -169,6 +169,12 @@ function validateAskRequest(value) {
|
|
|
169
169
|
const escalation = optionalBoolean(value.escalation, "escalation", code);
|
|
170
170
|
if (typeof escalation === "object")
|
|
171
171
|
return escalation;
|
|
172
|
+
const childSessionId = optionalString(value.childSessionId, "childSessionId", code);
|
|
173
|
+
if (typeof childSessionId === "object")
|
|
174
|
+
return childSessionId;
|
|
175
|
+
const parentSessionId = optionalString(value.parentSessionId, "parentSessionId", code);
|
|
176
|
+
if (typeof parentSessionId === "object")
|
|
177
|
+
return parentSessionId;
|
|
172
178
|
let questions;
|
|
173
179
|
if (value.questions !== undefined) {
|
|
174
180
|
if (!Array.isArray(value.questions))
|
|
@@ -193,7 +199,9 @@ function validateAskRequest(value) {
|
|
|
193
199
|
...questions !== undefined ? { questions } : {},
|
|
194
200
|
...deadlineAt !== undefined ? { deadlineAt } : {},
|
|
195
201
|
...detachGraceMs !== undefined ? { detachGraceMs } : {},
|
|
196
|
-
...escalation !== undefined ? { escalation } : {}
|
|
202
|
+
...escalation !== undefined ? { escalation } : {},
|
|
203
|
+
...childSessionId !== undefined ? { childSessionId } : {},
|
|
204
|
+
...parentSessionId !== undefined ? { parentSessionId } : {}
|
|
197
205
|
}
|
|
198
206
|
};
|
|
199
207
|
}
|
|
@@ -392,6 +400,7 @@ class SessionPermissionSummary {
|
|
|
392
400
|
|
|
393
401
|
// ../bridge/src/ask-registry.ts
|
|
394
402
|
var DEFAULT_RECORD_LIMIT = 256;
|
|
403
|
+
var DEFAULT_MAX_ASK_WAIT_MS = 3600000;
|
|
395
404
|
function remember(ids, id, limit) {
|
|
396
405
|
ids.add(id);
|
|
397
406
|
while (ids.size > limit) {
|
|
@@ -425,7 +434,7 @@ class AskRegistry {
|
|
|
425
434
|
constructor(options = {}) {
|
|
426
435
|
this.#askDeadlineMs = options.askDeadlineMs === undefined ? null : options.askDeadlineMs;
|
|
427
436
|
this.#detachGraceMs = options.detachGraceMs ?? 30000;
|
|
428
|
-
this.#maxAskWaitMs = options.maxAskWaitMs ??
|
|
437
|
+
this.#maxAskWaitMs = options.maxAskWaitMs ?? DEFAULT_MAX_ASK_WAIT_MS;
|
|
429
438
|
this.#recordLimit = options.recordLimit ?? DEFAULT_RECORD_LIMIT;
|
|
430
439
|
this.#now = options.now ?? Date.now;
|
|
431
440
|
this.#sink = options.sink ?? (() => {});
|
|
@@ -7804,6 +7813,19 @@ function parseRequest(raw) {
|
|
|
7804
7813
|
const params = obj.params !== null && typeof obj.params === "object" && !Array.isArray(obj.params) ? obj.params : {};
|
|
7805
7814
|
return { id, method: obj.method, params };
|
|
7806
7815
|
}
|
|
7816
|
+
function resolveAskDeadlineMs(raw, maxAskWaitMs = DEFAULT_MAX_ASK_WAIT_MS, warn = () => {}) {
|
|
7817
|
+
if (raw === undefined || raw === null)
|
|
7818
|
+
return null;
|
|
7819
|
+
if (typeof raw !== "number" || Number.isNaN(raw) || raw < 0) {
|
|
7820
|
+
warn("[dsh-opentui-bridge] invalid askDeadlineMs %s ignored (no per-ask deadline)", String(raw));
|
|
7821
|
+
return null;
|
|
7822
|
+
}
|
|
7823
|
+
if (raw > maxAskWaitMs) {
|
|
7824
|
+
warn("[dsh-opentui-bridge] askDeadlineMs %d exceeds maxAskWaitMs %d; clamped to hard cap", raw, maxAskWaitMs);
|
|
7825
|
+
return maxAskWaitMs;
|
|
7826
|
+
}
|
|
7827
|
+
return raw;
|
|
7828
|
+
}
|
|
7807
7829
|
function apply(ctx, config) {
|
|
7808
7830
|
const logger = ctx.logger;
|
|
7809
7831
|
if (process.env[STDIO_SWITCH] !== "1") {
|
|
@@ -8258,7 +8280,10 @@ function apply(ctx, config) {
|
|
|
8258
8280
|
logger.warn("[dsh-opentui-bridge] ask journal append failed (decision unchanged): %s", err);
|
|
8259
8281
|
}
|
|
8260
8282
|
}
|
|
8283
|
+
const askDeadlineMsRaw = config !== null && typeof config === "object" ? config.askDeadlineMs : undefined;
|
|
8284
|
+
const askDeadlineMs = resolveAskDeadlineMs(askDeadlineMsRaw, DEFAULT_MAX_ASK_WAIT_MS, (fmt, ...params) => logger.warn(fmt, ...params));
|
|
8261
8285
|
const ask = new AskRegistry({
|
|
8286
|
+
askDeadlineMs,
|
|
8262
8287
|
logger,
|
|
8263
8288
|
journal: writeAskJournal,
|
|
8264
8289
|
sink: (frame) => {
|
|
@@ -8375,6 +8400,48 @@ function apply(ctx, config) {
|
|
|
8375
8400
|
logger.warn("[bridge:stat] turn=%s deltas=%d tokenFrames=%d textChars=%d reasonChars=%d", state.turnId, state.deltaCount, state.tokenFrameCount, state.textAcc.length, state.reasoningAcc.length);
|
|
8376
8401
|
}
|
|
8377
8402
|
}
|
|
8403
|
+
const repinnedChildren = new Set;
|
|
8404
|
+
function repinChildApprovalPolicy(childId, parentSessionId) {
|
|
8405
|
+
if (binding === undefined || parentSessionId !== binding.sessionId)
|
|
8406
|
+
return;
|
|
8407
|
+
if (repinnedChildren.has(childId))
|
|
8408
|
+
return;
|
|
8409
|
+
const get = ctx.get;
|
|
8410
|
+
if (typeof get !== "function")
|
|
8411
|
+
return;
|
|
8412
|
+
let sessions;
|
|
8413
|
+
let approval;
|
|
8414
|
+
try {
|
|
8415
|
+
sessions = get.call(ctx, "sessions");
|
|
8416
|
+
approval = get.call(ctx, "approval");
|
|
8417
|
+
} catch {
|
|
8418
|
+
return;
|
|
8419
|
+
}
|
|
8420
|
+
if (typeof sessions?.get !== "function")
|
|
8421
|
+
return;
|
|
8422
|
+
let childSession;
|
|
8423
|
+
try {
|
|
8424
|
+
childSession = sessions.get(childId);
|
|
8425
|
+
} catch {
|
|
8426
|
+
return;
|
|
8427
|
+
}
|
|
8428
|
+
if (childSession === undefined || typeof childSession.append !== "function")
|
|
8429
|
+
return;
|
|
8430
|
+
if (approval !== undefined && typeof approval.overrideOf === "function") {
|
|
8431
|
+
const current = approval.overrideOf(childSession);
|
|
8432
|
+
if (current !== undefined && current !== "never") {
|
|
8433
|
+
repinnedChildren.add(childId);
|
|
8434
|
+
return;
|
|
8435
|
+
}
|
|
8436
|
+
}
|
|
8437
|
+
try {
|
|
8438
|
+
childSession.append("approval/policy", { policy: "ask" });
|
|
8439
|
+
repinnedChildren.add(childId);
|
|
8440
|
+
logger.info("[dsh-opentui-bridge] child approval re-pinned to ask child=%s parent=%s (delegation never pin overridden)", childId, parentSessionId);
|
|
8441
|
+
} catch (err) {
|
|
8442
|
+
logger.warn("[dsh-opentui-bridge] child approval re-pin failed child=%s: %s", childId, String(err));
|
|
8443
|
+
}
|
|
8444
|
+
}
|
|
8378
8445
|
function onSessionEvent(session, event) {
|
|
8379
8446
|
const state = activeTurn;
|
|
8380
8447
|
const s = session;
|
|
@@ -8390,13 +8457,16 @@ function apply(ctx, config) {
|
|
|
8390
8457
|
if (!childId)
|
|
8391
8458
|
return;
|
|
8392
8459
|
getSubagentIndex(ctx).noteCatalog(childId, sessionId, typeof data.childCreatedAt === "number" ? data.childCreatedAt : undefined);
|
|
8460
|
+
repinChildApprovalPolicy(childId, sessionId);
|
|
8393
8461
|
const turnId = state !== undefined && !state.ended ? state.turnId : inFlightTurnId ?? "";
|
|
8394
8462
|
const label = typeof data.label === "string" && data.label !== "" ? data.label : typeof data.name === "string" ? data.name : "";
|
|
8463
|
+
const name = typeof data.name === "string" && data.name !== "" ? data.name : "";
|
|
8395
8464
|
emitEvent("agent.spawn", {
|
|
8396
8465
|
turnId,
|
|
8397
8466
|
sessionId: boundId,
|
|
8398
8467
|
childId,
|
|
8399
8468
|
label,
|
|
8469
|
+
...name !== "" ? { name } : {},
|
|
8400
8470
|
runId: `catalog:${childId}`,
|
|
8401
8471
|
seq: 0,
|
|
8402
8472
|
...typeof data.childCreatedAt === "number" ? { childCreatedAt: data.childCreatedAt } : {}
|
|
@@ -8529,10 +8599,18 @@ function apply(ctx, config) {
|
|
|
8529
8599
|
return;
|
|
8530
8600
|
if (state.sessionId !== binding.sessionId)
|
|
8531
8601
|
return;
|
|
8532
|
-
const
|
|
8533
|
-
if (
|
|
8602
|
+
const rawSessionId = agent?.session?.id;
|
|
8603
|
+
if (rawSessionId === undefined)
|
|
8604
|
+
return { turn: state, sessionId: binding.sessionId };
|
|
8605
|
+
const agentSessionId = idString(rawSessionId);
|
|
8606
|
+
if (agentSessionId === binding.sessionId)
|
|
8607
|
+
return { turn: state, sessionId: binding.sessionId };
|
|
8608
|
+
const child = getSubagentIndex(ctx).get(agentSessionId);
|
|
8609
|
+
if (child === undefined || child.parentSessionId !== binding.sessionId || child.status === "settled") {
|
|
8610
|
+
logger.warn("[dsh-opentui-bridge] ask target rejected child session=%s parent=%s (unknown/foreign/settled) — fail-closed", agentSessionId, binding.sessionId);
|
|
8534
8611
|
return;
|
|
8535
|
-
|
|
8612
|
+
}
|
|
8613
|
+
return { turn: state, sessionId: binding.sessionId, childSessionId: agentSessionId };
|
|
8536
8614
|
}
|
|
8537
8615
|
const FAIL_CLOSED_UNKNOWN_SESSION = "unknown";
|
|
8538
8616
|
function failClosedAsk(kind, turnId, sessionId, reason) {
|
|
@@ -8566,7 +8644,8 @@ function apply(ctx, config) {
|
|
|
8566
8644
|
...toolName !== undefined ? { toolName } : {},
|
|
8567
8645
|
...callId !== undefined ? { callId } : {},
|
|
8568
8646
|
...reason !== undefined ? { reason } : {},
|
|
8569
|
-
escalation: true
|
|
8647
|
+
escalation: true,
|
|
8648
|
+
...target.childSessionId !== undefined ? { childSessionId: target.childSessionId, parentSessionId: target.sessionId } : {}
|
|
8570
8649
|
});
|
|
8571
8650
|
} catch (err) {
|
|
8572
8651
|
logger.error("[dsh-opentui-bridge] ask.create(approval) failed: %s", err);
|
|
@@ -8615,7 +8694,8 @@ function apply(ctx, config) {
|
|
|
8615
8694
|
sessionId: target.sessionId,
|
|
8616
8695
|
kind: "questions",
|
|
8617
8696
|
questions,
|
|
8618
|
-
...callId !== undefined ? { callId } : {}
|
|
8697
|
+
...callId !== undefined ? { callId } : {},
|
|
8698
|
+
...target.childSessionId !== undefined ? { childSessionId: target.childSessionId, parentSessionId: target.sessionId } : {}
|
|
8619
8699
|
});
|
|
8620
8700
|
} catch (err) {
|
|
8621
8701
|
logger.error("[dsh-opentui-bridge] ask.create(questions) failed: %s", err);
|
|
@@ -9532,6 +9612,7 @@ export {
|
|
|
9532
9612
|
projectAccountScalarResult,
|
|
9533
9613
|
projectAccountViewForFrame,
|
|
9534
9614
|
redactIdentifier,
|
|
9615
|
+
resolveAskDeadlineMs,
|
|
9535
9616
|
sanitizeFrameForWire,
|
|
9536
9617
|
summarizeAnswers,
|
|
9537
9618
|
turnIdOf,
|