@p4code/cli 0.5.7 → 0.5.9
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/bin.mjs +173 -50
- package/dist/client/assets/{DiffPanel-BS0biQw-.js → DiffPanel-D51hS5c1.js} +2 -2
- package/dist/client/assets/{FilePreviewPanel-Dn9DSGk3.js → FilePreviewPanel-QmfioQ0N.js} +2 -2
- package/dist/client/assets/{PreviewPanel-DWNwzOqs.js → PreviewPanel-CWbxdztG.js} +2 -2
- package/dist/client/assets/{PullRequestCodeTab-fnd5EeZp.js → PullRequestCodeTab-DUOXf_aK.js} +2 -2
- package/dist/client/assets/{fileCommentAnnotations-BDibf4o7.js → fileCommentAnnotations-Cwe1m2tY.js} +2 -2
- package/dist/client/assets/{index-Cj8u-oxt.js → index-eY4vseie.js} +251 -238
- package/dist/client/assets/{previewAssetResource-FVg-QUYZ.js → previewAssetResource-CEg07K2Q.js} +2 -2
- package/dist/client/assets/{renderFileChildren-BnxsBYhc.js → renderFileChildren-B_YbbTSW.js} +2 -2
- package/dist/client/assets/{toggle-group-B7_HMe_x.js → toggle-group-CD_Cy-Mn.js} +2 -2
- package/dist/client/index.html +2 -2
- package/package.json +1 -1
package/dist/bin.mjs
CHANGED
|
@@ -265,7 +265,7 @@ const make$116 = () => {
|
|
|
265
265
|
const layer$119 = Layer.sync(NetService, make$116);
|
|
266
266
|
//#endregion
|
|
267
267
|
//#region package.json
|
|
268
|
-
var version$1 = "0.5.
|
|
268
|
+
var version$1 = "0.5.9";
|
|
269
269
|
//#endregion
|
|
270
270
|
//#region src/config.ts
|
|
271
271
|
/**
|
|
@@ -5838,7 +5838,8 @@ const PREVIEW_AUTOMATION_OPERATIONS = [
|
|
|
5838
5838
|
...PREVIEW_AUTOMATION_V1_OPERATIONS,
|
|
5839
5839
|
"resize",
|
|
5840
5840
|
"setColorScheme",
|
|
5841
|
-
"saveScreenshot"
|
|
5841
|
+
"saveScreenshot",
|
|
5842
|
+
"upload"
|
|
5842
5843
|
];
|
|
5843
5844
|
const PreviewAutomationOperation = Schema.Literals(PREVIEW_AUTOMATION_OPERATIONS);
|
|
5844
5845
|
const PreviewAutomationTabTargetFields = { tabId: Schema.optional(PreviewTabId.annotate({ description: "Exact collaborative browser tab to target. Omit to use this agent session's current tab." })).annotate({ description: "Exact collaborative browser tab to target. Omit to use this agent session's current tab." }) };
|
|
@@ -5954,6 +5955,13 @@ const PreviewAutomationTypeInput = Schema.Struct({
|
|
|
5954
5955
|
clear: Schema.optional(Schema.Boolean.annotate({ description: "Clear the existing input value before inserting text. Defaults to false." })),
|
|
5955
5956
|
timeoutMs: OptionalTimeoutMs
|
|
5956
5957
|
}).check(Schema.makeFilter((input) => !(input.selector !== void 0 && input.locator !== void 0) || "Provide at most one of selector or locator.")).annotate({ description: "Types into locator/selector, or into the currently focused element when neither target is provided." });
|
|
5958
|
+
Schema.Struct({
|
|
5959
|
+
...PreviewAutomationTabTargetFields,
|
|
5960
|
+
files: Schema.Array(TrimmedNonEmptyString).check(Schema.isMinLength(1)).annotate({ description: "Absolute file paths on the browser host to attach to the input, in the order they should appear." }),
|
|
5961
|
+
selector: Schema.optional(LegacySelector).annotate({ description: "Legacy CSS selector for the file input. Prefer locator." }),
|
|
5962
|
+
locator: Schema.optional(Locator).annotate({ description: "Playwright selector for the file input, for example input[type='file'] or role=button[name='Attach']." }),
|
|
5963
|
+
timeoutMs: OptionalTimeoutMs
|
|
5964
|
+
}).check(Schema.makeFilter((input) => !(input.selector !== void 0 && input.locator !== void 0) || "Provide at most one of selector or locator."), Schema.makeFilter((input) => input.selector !== void 0 || input.locator !== void 0 || "Upload needs a locator or selector: there is no focused-element fallback for a file input.")).annotate({ description: "Attaches browser-host files to a file input directly, because clicking one opens a system dialog automation cannot answer." });
|
|
5957
5965
|
const PreviewAutomationPressInput = Schema.Struct({
|
|
5958
5966
|
...PreviewAutomationTabTargetFields,
|
|
5959
5967
|
key: Schema.String.check(Schema.isTrimmed()).check(Schema.isNonEmpty({ description: "Keyboard key name such as Enter, Escape, Tab, ArrowDown, Backspace, or a single character." })).annotateKey({ description: "Keyboard key name such as Enter, Escape, Tab, ArrowDown, Backspace, or a single character." }),
|
|
@@ -7272,6 +7280,8 @@ Schema$1.Struct({
|
|
|
7272
7280
|
message: Schema$1.optional(TrimmedNonEmptyString),
|
|
7273
7281
|
turnId: Schema$1.optional(TurnId),
|
|
7274
7282
|
itemId: Schema$1.optional(ProviderItemId),
|
|
7283
|
+
/** Provider child conversation whose events belong to a subagent run. */
|
|
7284
|
+
taskId: Schema$1.optional(TrimmedNonEmptyString),
|
|
7275
7285
|
requestId: Schema$1.optional(ApprovalRequestId),
|
|
7276
7286
|
requestKind: Schema$1.optional(ProviderRequestKind),
|
|
7277
7287
|
textDelta: Schema$1.optional(Schema$1.String),
|
|
@@ -65116,9 +65126,9 @@ const FUSION_WATCHER_TOOL_INSTRUCTIONS = `Supervisor tools belong to the p4-code
|
|
|
65116
65126
|
## Recommendation
|
|
65117
65127
|
State the decision or correction in one sentence. For a phase review, say whether the phase is approved or needs changes.
|
|
65118
65128
|
## Reason
|
|
65119
|
-
Give concise evidence, relevant file/line references, and any unresolved risk. Distinguish observed facts from assumptions; do not claim checks you did not run.
|
|
65129
|
+
Give concise evidence, relevant file/line references, and any unresolved risk. Distinguish observed facts from assumptions; do not claim checks you did not run. Before prescribing a blocking product fix, identify the violated requirement and evidence of product ownership. If ownership is uncertain, state the hypothesis and request the smallest discriminating check, such as comparing the unchanged baseline or another app, rather than prescribing a speculative fix. Do not block a product fix on an artifact reproduced outside the product unless evidence still ties it to an unmet task requirement.
|
|
65120
65130
|
## Next step
|
|
65121
|
-
Give ordered, concrete actions for the builder, including the next phase and its completion condition. Preserve user requirements, constraints, and delivery authorization. Keep each section short; omit empty bullets and repeated status. Formatting does not authorize an otherwise unnecessary advice turn or replace an exact protocol response.`;
|
|
65131
|
+
Give ordered, concrete actions for the builder, including the next phase and its completion condition. Preserve user requirements, constraints, and delivery authorization. Before repeating an objection, compare the builder's response and intervening changes with the prior finding; cite new evidence and explain why the builder's response does not resolve it. Without new evidence and an actionable next step, do not resend the objection or repeat passed checks; report the unresolved state in your own thread and end. A supported unresolved blocker remains unapproved; avoiding repetition never justifies approval. For an open gate, follow its response and escalation protocol. Keep each section short; omit empty bullets and repeated status. Formatting does not authorize an otherwise unnecessary advice turn or replace an exact protocol response.`;
|
|
65122
65132
|
const FUSION_WATCHER_INSTRUCTIONS = `You are Fusion Supervisor (watcher) in an already-created native server pair. Follow the current turn's [fusion-review-policy] block when present; it overrides phase scheduling. Server owns pairing and coordination and wakes you with ${FUSION_REVIEW_PROMPT_PREFIX} or ${FUSION_GATE_PROMPT_PREFIX} prompts at builder turn boundaries. A plain message outside such a wake may arrive after your conversational memory of the pair is gone; its [fusion-pair] metadata block is authoritative: the builder thread exists and is the counterpart thread id. Never report that no builder thread exists. For a new pair, the initial user request is yours, and its first turn is research, not relay. Research it: when the request names a ticket, read that ticket AND its comments, including replies and inline comments, and treat a later comment as newer intent than the description; read the code, docs, project instructions, and current state the request touches. Analyse what you found: root cause or the concrete design constraint, scope, what the user actually wants delivered, and which delivery steps they authorized. Only then direct the first actionable phase to the idle builder through thread_advise, stating the findings that make the direction actionable alongside the original requirements, constraints, and authorized delivery scope. Never echo the request back as its own direction, never hand over a plan you did not ground in evidence, and never send ${FUSION_NO_OBJECTION_TEXT} before the builder has received its first phase and produced a turn to review. The builder has not received the initial prompt and must not start before your direction. Missing builder turn evidence is expected before that first direction; do not wait for it or implement the work yourself. Ask the user only when needed to resolve a blocking requirement. ${FUSION_WATCHER_TOOL_INSTRUCTIONS} To resume supervision, read builder evidence with thread_watch_review from lastReviewedImplementerSequence, capture its throughSequence on the first page and reuse that fixed bound while paging with nextAfterSequence until hasMore is false (including empty pages). Apply message append/replace operations by identity; recover truncated evidence through targeted raw thread_watch_events source ranges. Retain reviewed requirements and evidence for final review; recover missing context with targeted history reads rather than mandatory raw replay from zero, derive phase from artifacts (git log/status, PR, builder events, including its turn.plan.updated phase list), steer with thread_advise, and answer an open gate with thread_gate_respond. When a review or gate wake prompt specifies an explicit event range, that range wins over this metadata. Never poll or wait for the builder; deliver review or advice, then end the turn. Every thread_advise starts a builder turn whose completion wakes you again, so never advise a builder that is idle on an external wait or has nothing actionable; report the state in your own thread and end without advising. ${FUSION_PAIR_COMMUNICATION_INSTRUCTIONS}`;
|
|
65123
65133
|
/**
|
|
65124
65134
|
* The one-line stand-in for the full block on a message whose session already
|
|
@@ -87433,6 +87443,52 @@ const makeCodexTextGeneration = Effect.fn("makeCodexTextGeneration")(function* (
|
|
|
87433
87443
|
};
|
|
87434
87444
|
});
|
|
87435
87445
|
//#endregion
|
|
87446
|
+
//#region src/provider/Layers/codexSubagentModel.ts
|
|
87447
|
+
const CodexSubagentModel = Schema$1.Struct({
|
|
87448
|
+
model: Schema$1.NonEmptyString,
|
|
87449
|
+
reasoningEffort: Schema$1.optionalKey(Schema$1.NonEmptyString)
|
|
87450
|
+
});
|
|
87451
|
+
const decodeTurnContext = Schema$1.decodeUnknownOption(Schema$1.fromJsonString(Schema$1.Struct({
|
|
87452
|
+
type: Schema$1.Literal("turn_context"),
|
|
87453
|
+
payload: Schema$1.Struct({
|
|
87454
|
+
turn_id: Schema$1.String,
|
|
87455
|
+
model: Schema$1.NonEmptyString,
|
|
87456
|
+
effort: Schema$1.optionalKey(Schema$1.NullOr(Schema$1.String))
|
|
87457
|
+
})
|
|
87458
|
+
})));
|
|
87459
|
+
/** Match the child turn exactly: forked rollouts also contain parent model records. */
|
|
87460
|
+
const readCodexSubagentModel = Effect.fn("readCodexSubagentModel")(function* (path, turnId) {
|
|
87461
|
+
return yield* (yield* FileSystem.FileSystem).stream(path).pipe(Stream.decodeText(), Stream.splitLines, Stream.filterMap((line) => Option.match(decodeTurnContext(line).pipe(Option.filter((record) => record.payload.turn_id === turnId), Option.map(({ payload }) => ({
|
|
87462
|
+
model: payload.model,
|
|
87463
|
+
...payload.effort?.trim() ? { reasoningEffort: payload.effort.trim() } : {}
|
|
87464
|
+
}))), {
|
|
87465
|
+
onNone: () => Result$1.failVoid,
|
|
87466
|
+
onSome: Result$1.succeed
|
|
87467
|
+
})), Stream.runHead);
|
|
87468
|
+
});
|
|
87469
|
+
/**
|
|
87470
|
+
* Reports each Codex subagent's model once per subagent. A subagent keeps its
|
|
87471
|
+
* model across follow-up turns, so reporting per turn would re-read the rollout
|
|
87472
|
+
* on every child notification. A read that finds nothing is not remembered, so
|
|
87473
|
+
* the next turn of that subagent tries again.
|
|
87474
|
+
*/
|
|
87475
|
+
const makeCodexSubagentModelReporter = (options) => {
|
|
87476
|
+
const reported = /* @__PURE__ */ new Set();
|
|
87477
|
+
return Effect.fn("reportCodexSubagentModel")(function* (taskId, childTurnId, context) {
|
|
87478
|
+
if (reported.has(taskId)) return;
|
|
87479
|
+
const path = yield* options.resolveThreadPath(taskId);
|
|
87480
|
+
if (!path) return;
|
|
87481
|
+
const metadata = yield* readCodexSubagentModel(path, childTurnId);
|
|
87482
|
+
if (Option.isNone(metadata)) return;
|
|
87483
|
+
yield* options.emit({
|
|
87484
|
+
taskId,
|
|
87485
|
+
context,
|
|
87486
|
+
model: metadata.value
|
|
87487
|
+
});
|
|
87488
|
+
reported.add(taskId);
|
|
87489
|
+
});
|
|
87490
|
+
};
|
|
87491
|
+
//#endregion
|
|
87436
87492
|
//#region src/provider/Layers/codexMcpArgs.ts
|
|
87437
87493
|
/** Codex's own name for the token variable of p4code's built-in server. */
|
|
87438
87494
|
const CODEX_P4CODE_BEARER_TOKEN_ENV_VAR = "P4_MCP_BEARER_TOKEN";
|
|
@@ -87956,11 +88012,20 @@ function readRouteFields(notification) {
|
|
|
87956
88012
|
};
|
|
87957
88013
|
}
|
|
87958
88014
|
}
|
|
87959
|
-
function
|
|
87960
|
-
|
|
87961
|
-
|
|
87962
|
-
|
|
87963
|
-
|
|
88015
|
+
function routeCodexSubagentNotification(collabReceiverTurns, notification) {
|
|
88016
|
+
const providerThreadId = readNotificationThreadId(notification);
|
|
88017
|
+
const childParentTurnId = providerThreadId ? collabReceiverTurns.get(providerThreadId) : void 0;
|
|
88018
|
+
const childRoute = providerThreadId && childParentTurnId ? {
|
|
88019
|
+
taskId: providerThreadId,
|
|
88020
|
+
turnId: childParentTurnId
|
|
88021
|
+
} : void 0;
|
|
88022
|
+
const parentTurnId = childParentTurnId ?? readRouteFields(notification).turnId;
|
|
88023
|
+
if (!parentTurnId) return childRoute;
|
|
88024
|
+
if (notification.method !== "item/started" && notification.method !== "item/completed") return childRoute;
|
|
88025
|
+
const item = notification.params.item;
|
|
88026
|
+
if (item.type === "subAgentActivity") collabReceiverTurns.set(item.agentThreadId, parentTurnId);
|
|
88027
|
+
else if (item.type === "collabAgentToolCall") for (const receiverThreadId of item.receiverThreadIds) collabReceiverTurns.set(receiverThreadId, parentTurnId);
|
|
88028
|
+
return childRoute;
|
|
87964
88029
|
}
|
|
87965
88030
|
function shouldSuppressChildConversationNotification(method) {
|
|
87966
88031
|
return method === "thread/started" || method === "thread/status/changed" || method === "thread/archived" || method === "thread/unarchived" || method === "thread/closed" || method === "thread/compacted" || method === "thread/name/updated" || method === "thread/tokenUsage/updated" || method === "turn/started" || method === "turn/completed" || method === "turn/plan/updated" || method === "item/plan/delta";
|
|
@@ -88083,50 +88148,35 @@ const makeCodexSessionRuntime = (options) => Effect.gen(function* () {
|
|
|
88083
88148
|
const settlePendingApprovals = (decision) => Ref.get(pendingApprovalsRef).pipe(Effect.flatMap((pendingApprovals) => Effect.forEach(Array.from(pendingApprovals.values()), (pendingApproval) => Deferred.succeed(pendingApproval.decision, decision).pipe(Effect.ignore), { discard: true })));
|
|
88084
88149
|
const settlePendingUserInputs = (answers) => Ref.get(pendingUserInputsRef).pipe(Effect.flatMap((pendingUserInputs) => Effect.forEach(Array.from(pendingUserInputs.values()), (pendingUserInput) => Deferred.succeed(pendingUserInput.answers, answers).pipe(Effect.ignore), { discard: true })));
|
|
88085
88150
|
const usageBinding = makeCodexUsageBinding(options.onUsageLimits);
|
|
88151
|
+
const reportChildModel = Effect.fn("CodexSessionRuntime.reportChildModel")(makeCodexSubagentModelReporter({
|
|
88152
|
+
resolveThreadPath: (taskId) => client.request("thread/read", {
|
|
88153
|
+
threadId: taskId,
|
|
88154
|
+
includeTurns: false
|
|
88155
|
+
}).pipe(Effect.map((response) => response.thread.path)),
|
|
88156
|
+
emit: ({ taskId, context, model }) => emitEvent({
|
|
88157
|
+
kind: "notification",
|
|
88158
|
+
threadId: options.threadId,
|
|
88159
|
+
turnId: context,
|
|
88160
|
+
taskId,
|
|
88161
|
+
method: "subagent/model",
|
|
88162
|
+
payload: model
|
|
88163
|
+
})
|
|
88164
|
+
}), Effect.catch((error) => Effect.logDebug("Could not read Codex subagent model", { error })));
|
|
88086
88165
|
const handleRawNotification = (notification) => Effect.gen(function* () {
|
|
88087
88166
|
if (notification.method === "account/updated") yield* usageBinding.invalidate;
|
|
88088
88167
|
if (notification.method === "account/rateLimits/updated") yield* usageBinding.update(notification.params.rateLimits);
|
|
88089
88168
|
const payload = notification.params;
|
|
88090
88169
|
const route = readRouteFields(notification);
|
|
88091
88170
|
const collabReceiverTurns = yield* Ref.get(collabReceiverTurnsRef);
|
|
88092
|
-
const
|
|
88093
|
-
|
|
88094
|
-
|
|
88095
|
-
})();
|
|
88096
|
-
rememberCollabReceiverTurns(collabReceiverTurns, notification, route.turnId);
|
|
88097
|
-
if (childParentTurnId && notification.method === "turn/completed" && notification.params.turn.status !== "inProgress") {
|
|
88098
|
-
const childThreadId = notification.params.threadId;
|
|
88099
|
-
const childStatus = notification.params.turn.status === "failed" ? "errored" : notification.params.turn.status === "interrupted" ? "interrupted" : "completed";
|
|
88100
|
-
yield* emitEvent({
|
|
88101
|
-
kind: "notification",
|
|
88102
|
-
threadId: options.threadId,
|
|
88103
|
-
method: "item/completed",
|
|
88104
|
-
turnId: childParentTurnId,
|
|
88105
|
-
itemId: ProviderItemId.make(`subagent-${notification.params.turn.id}`),
|
|
88106
|
-
payload: {
|
|
88107
|
-
completedAtMs: DateTime.toEpochMillis(yield* DateTime.now),
|
|
88108
|
-
threadId: childThreadId,
|
|
88109
|
-
turnId: childParentTurnId,
|
|
88110
|
-
item: {
|
|
88111
|
-
type: "collabAgentToolCall",
|
|
88112
|
-
id: `subagent-${notification.params.turn.id}`,
|
|
88113
|
-
tool: "wait",
|
|
88114
|
-
status: childStatus === "errored" ? "failed" : "completed",
|
|
88115
|
-
senderThreadId: childThreadId,
|
|
88116
|
-
receiverThreadIds: [childThreadId],
|
|
88117
|
-
agentsStates: { [childThreadId]: { status: childStatus } }
|
|
88118
|
-
}
|
|
88119
|
-
}
|
|
88120
|
-
});
|
|
88121
|
-
collabReceiverTurns.delete(childThreadId);
|
|
88122
|
-
}
|
|
88123
|
-
if (childParentTurnId && shouldSuppressChildConversationNotification(notification.method)) {
|
|
88171
|
+
const childRoute = routeCodexSubagentNotification(collabReceiverTurns, notification);
|
|
88172
|
+
if (childRoute && (notification.method === "turn/started" || notification.method === "turn/completed")) yield* reportChildModel(childRoute.taskId, notification.params.turn.id, childRoute.turnId);
|
|
88173
|
+
if (childRoute && notification.method !== "turn/completed" && shouldSuppressChildConversationNotification(notification.method)) {
|
|
88124
88174
|
yield* Ref.set(collabReceiverTurnsRef, collabReceiverTurns);
|
|
88125
88175
|
return;
|
|
88126
88176
|
}
|
|
88127
88177
|
let requestId;
|
|
88128
88178
|
let requestKind;
|
|
88129
|
-
let turnId =
|
|
88179
|
+
let turnId = childRoute?.turnId ?? route.turnId;
|
|
88130
88180
|
let itemId = route.itemId;
|
|
88131
88181
|
if (notification.method === "serverRequest/resolved") {
|
|
88132
88182
|
const rawRequestId = typeof notification.params.requestId === "string" ? notification.params.requestId : String(notification.params.requestId);
|
|
@@ -88148,6 +88198,7 @@ const makeCodexSessionRuntime = (options) => Effect.gen(function* () {
|
|
|
88148
88198
|
kind: "notification",
|
|
88149
88199
|
threadId: options.threadId,
|
|
88150
88200
|
method: notification.method,
|
|
88201
|
+
...childRoute ? { taskId: childRoute.taskId } : {},
|
|
88151
88202
|
...turnId ? { turnId } : {},
|
|
88152
88203
|
...itemId ? { itemId } : {},
|
|
88153
88204
|
...requestId ? { requestId } : {},
|
|
@@ -88908,7 +88959,64 @@ function rememberAgentName(item, collabDefaults) {
|
|
|
88908
88959
|
const name = agentNameFromPath(item.agentPath);
|
|
88909
88960
|
if (name) collabDefaults.agentNames.set(item.agentThreadId, name);
|
|
88910
88961
|
}
|
|
88962
|
+
function childTaskEvents(event, canonicalThreadId, defaults) {
|
|
88963
|
+
if (!event.taskId) return [];
|
|
88964
|
+
const taskId = RuntimeTaskId.make(event.taskId);
|
|
88965
|
+
const base = runtimeEventBase(event, canonicalThreadId);
|
|
88966
|
+
if (event.method === "subagent/model") {
|
|
88967
|
+
const metadata = readPayload$1(CodexSubagentModel, event.payload);
|
|
88968
|
+
return metadata ? [{
|
|
88969
|
+
...collabTaskEventBase(base, taskId, "started"),
|
|
88970
|
+
type: "task.started",
|
|
88971
|
+
payload: {
|
|
88972
|
+
taskId,
|
|
88973
|
+
...metadata
|
|
88974
|
+
}
|
|
88975
|
+
}] : [];
|
|
88976
|
+
}
|
|
88977
|
+
if (event.method === "turn/completed") {
|
|
88978
|
+
const payload = readPayload$1(V2TurnCompletedNotification, event.payload);
|
|
88979
|
+
if (!payload || payload.turn.status === "inProgress") return [];
|
|
88980
|
+
const result = payload.turn.items.findLast((item) => item.type === "agentMessage");
|
|
88981
|
+
const summary = (result?.type === "agentMessage" ? trimText$1(result.text) : void 0) ?? defaults?.agentResults.get(payload.turn.id);
|
|
88982
|
+
defaults?.agentResults.delete(payload.turn.id);
|
|
88983
|
+
return [{
|
|
88984
|
+
...collabTaskEventBase(base, taskId, "completed"),
|
|
88985
|
+
type: "task.completed",
|
|
88986
|
+
payload: {
|
|
88987
|
+
taskId,
|
|
88988
|
+
status: payload.turn.status === "failed" ? "failed" : payload.turn.status === "interrupted" ? "stopped" : "completed",
|
|
88989
|
+
...summary ? { summary } : {}
|
|
88990
|
+
}
|
|
88991
|
+
}];
|
|
88992
|
+
}
|
|
88993
|
+
if (event.method !== "item/completed") return [];
|
|
88994
|
+
const payload = readPayload$1(V2ItemCompletedNotification, event.payload);
|
|
88995
|
+
if (!payload) return [];
|
|
88996
|
+
const item = payload.item;
|
|
88997
|
+
if (item.type === "subAgentActivity" || item.type === "collabAgentToolCall") {
|
|
88998
|
+
rememberAgentName(item, defaults);
|
|
88999
|
+
return collabTaskEvents(event, canonicalThreadId, item, defaults);
|
|
89000
|
+
}
|
|
89001
|
+
const itemType = toCanonicalItemType(item.type);
|
|
89002
|
+
if (itemType === "reasoning") return [];
|
|
89003
|
+
const detail = itemDetail(itemType, item);
|
|
89004
|
+
const title = itemTitle(itemType, item);
|
|
89005
|
+
const description = detail ?? title;
|
|
89006
|
+
if (!description) return [];
|
|
89007
|
+
if (item.type === "agentMessage" && detail) defaults?.agentResults.set(payload.turnId, detail);
|
|
89008
|
+
return [{
|
|
89009
|
+
...collabTaskEventBase(base, taskId, "progress"),
|
|
89010
|
+
type: "task.progress",
|
|
89011
|
+
payload: {
|
|
89012
|
+
taskId,
|
|
89013
|
+
description,
|
|
89014
|
+
...itemType !== "assistant_message" && itemType !== "user_message" && title ? { lastToolName: title } : {}
|
|
89015
|
+
}
|
|
89016
|
+
}];
|
|
89017
|
+
}
|
|
88911
89018
|
function mapToRuntimeEvents(event, canonicalThreadId, collabDefaults) {
|
|
89019
|
+
if (event.taskId && event.kind === "notification") return childTaskEvents(event, canonicalThreadId, collabDefaults);
|
|
88912
89020
|
if (event.kind === "error") {
|
|
88913
89021
|
if (!event.message) return [];
|
|
88914
89022
|
return [{
|
|
@@ -89499,7 +89607,7 @@ const makeCodexAdapter = Effect.fn("makeCodexAdapter")(function* (codexConfig, o
|
|
|
89499
89607
|
const sessionScope = yield* Scope.make("sequential");
|
|
89500
89608
|
let sessionScopeTransferred = false;
|
|
89501
89609
|
yield* Effect.addFinalizer(() => sessionScopeTransferred ? Effect.void : Scope.close(sessionScope, Exit.void));
|
|
89502
|
-
const runtime = yield* (options?.makeRuntime ?? makeCodexSessionRuntime)(runtimeInput).pipe(Effect.provideService(Scope.Scope, sessionScope), Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, childProcessSpawner), Effect.provideService(Crypto.Crypto, crypto), Effect.mapError((cause) => new ProviderAdapterProcessError({
|
|
89610
|
+
const runtime = yield* (options?.makeRuntime ?? makeCodexSessionRuntime)(runtimeInput).pipe(Effect.provideService(Scope.Scope, sessionScope), Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, childProcessSpawner), Effect.provideService(Crypto.Crypto, crypto), Effect.provideService(FileSystem.FileSystem, fileSystem), Effect.mapError((cause) => new ProviderAdapterProcessError({
|
|
89503
89611
|
provider: PROVIDER$4,
|
|
89504
89612
|
threadId: input.threadId,
|
|
89505
89613
|
detail: cause.message,
|
|
@@ -89507,6 +89615,7 @@ const makeCodexAdapter = Effect.fn("makeCodexAdapter")(function* (codexConfig, o
|
|
|
89507
89615
|
})));
|
|
89508
89616
|
const collabDefaults = {
|
|
89509
89617
|
agentNames: /* @__PURE__ */ new Map(),
|
|
89618
|
+
agentResults: /* @__PURE__ */ new Map(),
|
|
89510
89619
|
model: input.modelSelection?.instanceId === boundInstanceId ? input.modelSelection.model : void 0,
|
|
89511
89620
|
reasoningEffort: input.modelSelection?.instanceId === boundInstanceId ? getModelSelectionStringOptionValue(input.modelSelection, "reasoningEffort") : void 0
|
|
89512
89621
|
};
|
|
@@ -94356,8 +94465,10 @@ function makeMuseAdapter(museSettings, options) {
|
|
|
94356
94465
|
threadId: input.threadId,
|
|
94357
94466
|
museSessionId,
|
|
94358
94467
|
cwd,
|
|
94468
|
+
turnGate: yield* Semaphore.make(1),
|
|
94359
94469
|
session,
|
|
94360
94470
|
activeTurn: void 0,
|
|
94471
|
+
queueEpoch: 0,
|
|
94361
94472
|
turns: [],
|
|
94362
94473
|
stopped: false
|
|
94363
94474
|
};
|
|
@@ -94391,19 +94502,28 @@ function makeMuseAdapter(museSettings, options) {
|
|
|
94391
94502
|
});
|
|
94392
94503
|
return { ...session };
|
|
94393
94504
|
});
|
|
94505
|
+
/**
|
|
94506
|
+
* `muse exec` takes one prompt per process, so a follow-up sent mid-turn
|
|
94507
|
+
* waits for the running one instead of being refused. Turns still never
|
|
94508
|
+
* overlap; they queue in the order the user sent them.
|
|
94509
|
+
*/
|
|
94394
94510
|
const sendTurn = (input) => Effect.gen(function* () {
|
|
94395
94511
|
const ctx = yield* requireSession(input.threadId);
|
|
94396
|
-
if (ctx.activeTurn) return yield* new ProviderAdapterRequestError({
|
|
94397
|
-
provider: PROVIDER$1,
|
|
94398
|
-
method: "muse/exec",
|
|
94399
|
-
detail: "A Muse turn is already running on this thread. `muse exec` runs one prompt per process, so turns cannot overlap."
|
|
94400
|
-
});
|
|
94401
94512
|
const prompt = input.input?.trim();
|
|
94402
94513
|
if (!prompt) return yield* new ProviderAdapterValidationError({
|
|
94403
94514
|
provider: PROVIDER$1,
|
|
94404
94515
|
operation: "sendTurn",
|
|
94405
94516
|
issue: "Muse Code requires prompt text; attachments alone cannot start a turn."
|
|
94406
94517
|
});
|
|
94518
|
+
const queuedEpoch = ctx.queueEpoch;
|
|
94519
|
+
return yield* ctx.turnGate.withPermits(1)(runTurn(ctx, input, prompt, queuedEpoch));
|
|
94520
|
+
});
|
|
94521
|
+
const runTurn = (ctx, input, prompt, queuedEpoch) => Effect.gen(function* () {
|
|
94522
|
+
if (ctx.stopped || ctx.queueEpoch !== queuedEpoch) return yield* new ProviderAdapterRequestError({
|
|
94523
|
+
provider: PROVIDER$1,
|
|
94524
|
+
method: "muse/exec",
|
|
94525
|
+
detail: "This Muse message was dropped: the turn it was queued behind was stopped, so the prompt no longer applies."
|
|
94526
|
+
});
|
|
94407
94527
|
const imagePaths = [];
|
|
94408
94528
|
for (const attachment of input.attachments ?? []) {
|
|
94409
94529
|
const attachmentPath = resolveAttachmentPath({
|
|
@@ -94575,9 +94695,11 @@ function makeMuseAdapter(museSettings, options) {
|
|
|
94575
94695
|
});
|
|
94576
94696
|
}).pipe(Effect.orElseSucceed(() => void 0));
|
|
94577
94697
|
const interruptTurn = (threadId, turnId) => Effect.gen(function* () {
|
|
94578
|
-
const
|
|
94698
|
+
const ctx = yield* requireSession(threadId);
|
|
94699
|
+
const active = ctx.activeTurn;
|
|
94579
94700
|
if (!active) return;
|
|
94580
94701
|
if (turnId !== void 0 && turnId !== active.turnId) return;
|
|
94702
|
+
ctx.queueEpoch += 1;
|
|
94581
94703
|
yield* active.run.interrupt;
|
|
94582
94704
|
});
|
|
94583
94705
|
const respondToRequest = (threadId) => Effect.gen(function* () {
|
|
@@ -94618,6 +94740,7 @@ function makeMuseAdapter(museSettings, options) {
|
|
|
94618
94740
|
const stopSessionInternal = (ctx) => Effect.gen(function* () {
|
|
94619
94741
|
if (ctx.stopped) return;
|
|
94620
94742
|
ctx.stopped = true;
|
|
94743
|
+
ctx.queueEpoch += 1;
|
|
94621
94744
|
if (ctx.activeTurn) {
|
|
94622
94745
|
yield* ctx.activeTurn.run.interrupt.pipe(Effect.ignore);
|
|
94623
94746
|
ctx.activeTurn = void 0;
|
|
@@ -129216,7 +129339,7 @@ const mcpToolkit = (toolkit) => Layer.effectDiscard(Effect.gen(function* () {
|
|
|
129216
129339
|
//#endregion
|
|
129217
129340
|
//#region src/mcp/toolkits/computerUse/tools.ts
|
|
129218
129341
|
const ComputerUseJsTool = Tool.make("js", {
|
|
129219
|
-
description: "P4 Code Computer Use: control native apps through P4Code's signed helper. Run JavaScript in a persistent REPL. On the first call, execute exactly one entry-point operation and read its automatic output before continuing. When the user names an app, execute only const app = await cua.getApp(exactNameBundleIdOrPath); this already prints its state and includes a screenshot when AX exposes no app content. Use await cua.getState() only when discovery is needed. Use cua.createBrowserTab('iab', url, {visible:true}) or cua.getTab(tabId) for P4 browser tabs. Tab methods: getState(), goto(url), click({locator}), type({text,locator?,clear?}), press({key,modifiers?}), scroll({deltaY,deltaX?}). Print results with nodeRepl.write(value); emit PNG/JPEG with nodeRepl.emitImage({mimeType,data}) using base64 data. Top-level await and persistent let bindings are supported. Await each operation. Bindings disappear after helper restart, host disconnect, reset, or tray Stop. When resuming a task, guard a remembered binding within the same js call: if (typeof app === 'undefined') { globalThis.app = await cua.getApp('Spotify'); } else { await app.getScreenshot(); }. Substitute the named app and intended operation. The missing-binding branch selects only and prints fresh state; decide the next action after reading it. Never spend a separate tool call checking whether a binding exists. Reset after timeout or host disconnect. For available native apps, use cua.getApp(exactNameBundleIdOrPath), then getAXState(), click(elementIndex), or setValue(elementIndex,text) to replace a field value in the background. Selection already prints numbered accessibility state; reuse the app handle without selecting or reading it again before the first action. Snapshot text is bounded; use getAXState({filter:'Pause'}) for case-insensitive text filtering across the snapshot, including controls omitted from the initial output. Use {emit:false} on getApp(name, options), getAXState(options), or getScreenshot(options) when processing the returned value yourself; do not print auto-emitted output again. Several deterministic actions against distinct unchanged elements may share one snapshot. Each used element index expires after one action. To click the same control again, refresh with getAXState({filter: controlLabel}) first, even inside a batch; never reuse its old index. The host revalidates remaining native handles and rejects changed elements. Read fresh state after the action batch before deciding the next action. If selection includes a screenshot because AX exposes only window controls or menus, read that image immediately and finish if it answers the request. If no image is included, use getScreenshot() to read visual content; do not repeat unchanged snapshots hoping for missing accessibility content. getScreenshot() emits the selected app window; getAXStateAndScreenshot() emits both. Legacy getState(), click({elementId}), type({elementId,text}), windows(), and screenshot(windowId) remain supported. Native control preserves foreground focus and the system pointer. Coordinate, key, drag, scroll, and activation input are unsupported; do not use global input or activate the app as a fallback. P4Code shows the controlled native window in its embedded live view. A persistent independent black pointer marks actions on the host window, outside the preview. Hide closes only the view; use Show live view in the Computer Use control to reopen it. Stop ends thread control; reset clears the view and handles. Google Chrome can be controlled as a native app using cua.getApp('Google Chrome'); Chrome extension/CDP tab APIs are not exposed by this host. Native app availability and macOS permission states are reported by the host; never assume native apps are supported. The host may be a different machine from the provider server. Device hub simulators are scoped to the provider environment: await cua.listDevices(), then await cua.getDevice({hostId,deviceId,platform}) using exact discovered IDs. Selection automatically emits initial AX state (or a screenshot on other platforms); reuse the handle without repeating that capture or printing the handle. A permission or unavailable-control error requires stopping and reporting it, never shell or alternative-tool fallback. The device handle supports getAXState() (raw iOS accessibility state), getScreenshot(), getAXStateAndScreenshot(), click([x,y]) in device coordinates from fresh AX state, typeText(text), and close(). When getAXState() reports adapter apple-xcode or xcodebuildmcp, use semantic refs from capture.elements and only advertised capabilities: click(elementRef), typeText(text,{elementRef,replaceExisting:true}), swipe({withinElementRef,direction}), drag({elementRef,direction}), batch([{action:\"tap\",elementRef},...]), and recordVideo(\"start\"|\"stop\") only when advertised in capabilities. getAXState({sinceScreenHash}) avoids unchanged snapshots. Batch only same-screen taps; action output includes updated capture. On stale-ref errors inspect fresh state and choose a current ref; never replay an action automatically. Physical-device UI control and device key input are unavailable. Device consent must already be enabled in P4 Settings. Use timeout_ms:60000 for initial device startup. Reset invalidates device handles; device viewer sessions remain under Devices until explicitly closed. Never substitute macOS Simulator.app AX for simulated-app state.",
|
|
129342
|
+
description: "P4 Code Computer Use: control native apps through P4Code's signed helper. Run JavaScript in a persistent REPL. On the first call, execute exactly one entry-point operation and read its automatic output before continuing. When the user names an app, execute only const app = await cua.getApp(exactNameBundleIdOrPath); this already prints its state and includes a screenshot when AX exposes no app content. Use await cua.getState() only when discovery is needed. Use cua.createBrowserTab('iab', url, {visible:true}) or cua.getTab(tabId) for P4 browser tabs. Tab methods: getState(), goto(url), click({locator}), type({text,locator?,clear?}), press({key,modifiers?}), scroll({deltaY,deltaX?}), upload({locator,files}). Use upload with absolute browser-host file paths to attach files to a file input; clicking or typing a file input opens the system file dialog and cannot attach files. Print results with nodeRepl.write(value); emit PNG/JPEG with nodeRepl.emitImage({mimeType,data}) using base64 data. Top-level await and persistent let bindings are supported. Await each operation. Bindings disappear after helper restart, host disconnect, reset, or tray Stop. When resuming a task, guard a remembered binding within the same js call: if (typeof app === 'undefined') { globalThis.app = await cua.getApp('Spotify'); } else { await app.getScreenshot(); }. Substitute the named app and intended operation. The missing-binding branch selects only and prints fresh state; decide the next action after reading it. Never spend a separate tool call checking whether a binding exists. Reset after timeout or host disconnect. For available native apps, use cua.getApp(exactNameBundleIdOrPath), then getAXState(), click(elementIndex), or setValue(elementIndex,text) to replace a field value in the background. Selection already prints numbered accessibility state; reuse the app handle without selecting or reading it again before the first action. Snapshot text is bounded; use getAXState({filter:'Pause'}) for case-insensitive text filtering across the snapshot, including controls omitted from the initial output. Use {emit:false} on getApp(name, options), getAXState(options), or getScreenshot(options) when processing the returned value yourself; do not print auto-emitted output again. Several deterministic actions against distinct unchanged elements may share one snapshot. Each used element index expires after one action. To click the same control again, refresh with getAXState({filter: controlLabel}) first, even inside a batch; never reuse its old index. The host revalidates remaining native handles and rejects changed elements. Read fresh state after the action batch before deciding the next action. If selection includes a screenshot because AX exposes only window controls or menus, read that image immediately and finish if it answers the request. If no image is included, use getScreenshot() to read visual content; do not repeat unchanged snapshots hoping for missing accessibility content. getScreenshot() emits the selected app window; getAXStateAndScreenshot() emits both. Legacy getState(), click({elementId}), type({elementId,text}), windows(), and screenshot(windowId) remain supported. Native control preserves foreground focus and the system pointer. Coordinate, key, drag, scroll, and activation input are unsupported; do not use global input or activate the app as a fallback. P4Code shows the controlled native window in its embedded live view. A persistent independent black pointer marks actions on the host window, outside the preview. Hide closes only the view; use Show live view in the Computer Use control to reopen it. Stop ends thread control; reset clears the view and handles. Google Chrome can be controlled as a native app using cua.getApp('Google Chrome'); Chrome extension/CDP tab APIs are not exposed by this host. Native app availability and macOS permission states are reported by the host; never assume native apps are supported. The host may be a different machine from the provider server. Device hub simulators are scoped to the provider environment: await cua.listDevices(), then await cua.getDevice({hostId,deviceId,platform}) using exact discovered IDs. Selection automatically emits initial AX state (or a screenshot on other platforms); reuse the handle without repeating that capture or printing the handle. A permission or unavailable-control error requires stopping and reporting it, never shell or alternative-tool fallback. The device handle supports getAXState() (raw iOS accessibility state), getScreenshot(), getAXStateAndScreenshot(), click([x,y]) in device coordinates from fresh AX state, typeText(text), and close(). When getAXState() reports adapter apple-xcode or xcodebuildmcp, use semantic refs from capture.elements and only advertised capabilities: click(elementRef), typeText(text,{elementRef,replaceExisting:true}), swipe({withinElementRef,direction}), drag({elementRef,direction}), batch([{action:\"tap\",elementRef},...]), and recordVideo(\"start\"|\"stop\") only when advertised in capabilities. getAXState({sinceScreenHash}) avoids unchanged snapshots. Batch only same-screen taps; action output includes updated capture. On stale-ref errors inspect fresh state and choose a current ref; never replay an action automatically. Physical-device UI control and device key input are unavailable. Device consent must already be enabled in P4 Settings. Use timeout_ms:60000 for initial device startup. Reset invalidates device handles; device viewer sessions remain under Devices until explicitly closed. Never substitute macOS Simulator.app AX for simulated-app state.",
|
|
129220
129343
|
parameters: Schema$1.Struct({
|
|
129221
129344
|
...ComputerUseJsInput.fields,
|
|
129222
129345
|
hostId: Schema$1.optional(TrimmedNonEmptyString).annotate({ description: "Select an available host when more than one is connected. Reset before changing hosts." })
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}from"./compiler-runtime-CLAvuQ-D.js";import{$l as i,Ba as a,Et as o,Fa as s,Ga as c,Il as l,Ja as ee,Ka as te,Ma as u,Rr as d,Ur as ne,Uu as f,Ya as p,Yr as re,_n as m,au as h,b as ie,dl as g,fl as _,gt as v,gu as ae,h as y,ht as b,ml as x,pl as oe,qa as S,st as C,uu as se,vt as w,xn as T,za as E}from"./previewAssetResource-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}from"./compiler-runtime-CLAvuQ-D.js";import{$l as i,Ba as a,Et as o,Fa as s,Ga as c,Il as l,Ja as ee,Ka as te,Ma as u,Rr as d,Ur as ne,Uu as f,Ya as p,Yr as re,_n as m,au as h,b as ie,dl as g,fl as _,gt as v,gu as ae,h as y,ht as b,ml as x,pl as oe,qa as S,st as C,uu as se,vt as w,xn as T,za as E}from"./previewAssetResource-CEg07K2Q.js";import{a as D,c as O,i as k,n as A,o as j,r as M,s as ce,t as N}from"./toggle-group-CD_Cy-Mn.js";import{A as le,Fr as ue,J as de,Lr as fe,M as P,Mr as pe,Nr as me,Rr as he,Y as ge,_ as _e,_r as ve,at as ye,cr as be,ct as xe,dr as Se,fr as Ce,h as we,hr as Te,it as Ee,j as De,jr as Oe,k as ke,lr as Ae,lt as je,oi as Me,or as Ne,ot as Pe,pr as Fe,rt as Ie,si as Le,sr as Re,st as ze,ur as Be,yr as Ve}from"./index-eY4vseie.js";import{a as He,n as Ue}from"./fileCommentAnnotations-Cwe1m2tY.js";var We=x(`pilcrow`,[[`path`,{d:`M13 4v16`,key:`8vvj80`}],[`path`,{d:`M17 4v16`,key:`7dpous`}],[`path`,{d:`M19 4H9.5a4.5 4.5 0 0 0 0 9H13`,key:`sh4n9v`}]]),F=e(n(),1);function Ge({threadRef:e,filePath:t,activeCwd:n,openInEditor:r,openFileSurface:i}){if(e){if(i){i(t);return}C.getState().openFile(e,t);return}r(n?y(t,n):t)}var I=r();function Ke(e,t){let n=(0,I.c)(4),r=Te(e,t),i;return n[0]!==r.data||n[1]!==r.error||n[2]!==r.isPending?(i={data:r.data,error:r.error,isPending:r.isPending},n[0]=r.data,n[1]=r.error,n[2]=r.isPending,n[3]=i):i=n[3],i}var L=t(),qe=[];function Je(e){return(e.endSide??e.side)===`deletions`?`deletions`:`additions`}function R(e,t,n){let r=Je(t),i=e.findIndex(e=>e.side===r&&e.lineNumber===t.end);return i<0?[...e,{side:r,lineNumber:t.end,metadata:{entries:[n]}}]:e.map((e,t)=>t===i?{...e,metadata:{entries:[...e.metadata.entries,n]}}:e)}function Ye(e){let t=(0,I.c)(50),{files:n,sectionId:r,sectionTitle:i,composerDraftTarget:a,options:o,viewerRef:s,className:c,renderHeaderPrefix:l}=e,ee=d(Qe),te=d(B),u;t[0]===a?u=t[1]:(u=e=>e.getComposerDraft(a)?.reviewComments??qe,t[0]=a,t[1]=u);let f=d(u),[p,m]=(0,F.useState)(null),[h,ie]=(0,F.useState)(null),g;t[2]===n?g=t[3]:(g=new Map(n.map(Ze)),t[2]=n,t[3]=g);let _=g,v;if(t[4]!==h||t[5]!==n||t[6]!==f||t[7]!==r){let e;t[9]!==h||t[10]!==f||t[11]!==r?(e=e=>{let{fileDiff:t,filePath:n,fileKey:i,collapsed:a}=e,o=f.filter(e=>e.sectionId===r&&e.filePath===n&&(e.fenceLanguage??`diff`)===`diff`).reduce((e,n)=>{let r=re(t,n);return r?R(e,r,{id:n.id,kind:`comment`,range:r,rangeLabel:n.rangeLabel,text:n.text}):e},[]),s=h?.fileKey===i?[...o,h.annotation]:o;return{id:i,type:`diff`,fileDiff:t,annotations:s,collapsed:a,version:Ee(`${a?`1`:`0`}:${s.flatMap(z).join(`:`)}`)}},t[9]=h,t[10]=f,t[11]=r,t[12]=e):e=t[12],v=n.map(e),t[4]=h,t[5]=n,t[6]=f,t[7]=r,t[8]=v}else v=t[8];let ae=v,y;t[13]!==a||t[14]!==h?.annotation||t[15]!==te?(y=e=>{m(null),h?.annotation.metadata.entries.some(t=>t.id===e)?ie(null):te(a,e)},t[13]=a,t[14]=h?.annotation,t[15]=te,t[16]=y):y=t[16];let b=y,x;t[17]!==ee||t[18]!==a||t[19]!==h||t[20]!==_||t[21]!==r||t[22]!==i?(x=(e,t)=>{let n=h?.annotation.metadata.entries.find(t=>t.id===e),o=h?_.get(h.fileKey):void 0;if(!n||!o)return;let s=ne({id:n.id,sectionId:r,sectionTitle:i,filePath:o.filePath,fileDiff:o.fileDiff,range:n.range,text:t});s&&ee(a,s),m(null),ie(null)},t[17]=ee,t[18]=a,t[19]=h,t[20]=_,t[21]=r,t[22]=i,t[23]=x):x=t[23];let oe=x,S;t[24]!==_||t[25]!==r||t[26]!==i?(S=(e,t)=>{if(!e)return;let n=t.item;if(n.type!==`diff`)return;let a=_.get(n.id);if(!a)return;let o=Ue(),s=ne({id:o,sectionId:r,sectionTitle:i,filePath:a.filePath,fileDiff:a.fileDiff,range:e,text:``});s&&ie({fileKey:n.id,annotation:{side:Je(e),lineNumber:e.end,metadata:{entries:[{id:o,kind:`draft`,range:e,rangeLabel:s.rangeLabel,text:``}]}}})},t[24]=_,t[25]=r,t[26]=i,t[27]=S):S=t[27];let C=S,se=h!==null,w;t[28]===s?w=t[29]:(w=s?{ref:s}:{},t[28]=s,t[29]=w);let T;t[30]===c?T=t[31]:(T=c?{className:c}:{},t[30]=c,t[31]=T);let E=!se,O=!se,k;t[32]!==C||t[33]!==o||t[34]!==O||t[35]!==E?(k={...o,enableGutterUtility:E,enableLineSelection:O,onLineSelectionEnd:C},t[32]=C,t[33]=o,t[34]=O,t[35]=E,t[36]=k):k=t[36];let A;t[37]===l?A=t[38]:(A=e=>e.type===`diff`?l(e.fileDiff,e.id,e.collapsed===!0):null,t[37]=l,t[38]=A);let j;t[39]!==b||t[40]!==oe?(j=e=>(0,L.jsx)(`div`,{className:`py-1`,children:e.metadata.entries.map(e=>(0,L.jsx)(He,{kind:e.kind,rangeLabel:e.rangeLabel,text:e.text,onCancel:()=>b(e.id),onComment:t=>oe(e.id,t),onDelete:()=>b(e.id)},e.id))}),t[39]=b,t[40]=oe,t[41]=j):j=t[41];let M;return t[42]!==ae||t[43]!==p||t[44]!==k||t[45]!==A||t[46]!==j||t[47]!==w||t[48]!==T?(M=(0,L.jsx)(D,{...w,...T,items:ae,selectedLines:p,onSelectedLinesChange:m,options:k,renderHeaderPrefix:A,renderAnnotation:j}),t[42]=ae,t[43]=p,t[44]=k,t[45]=A,t[46]=j,t[47]=w,t[48]=T,t[49]=M):M=t[49],M}function z(e){return e.metadata.entries.map(Xe)}function Xe(e){return`${e.id}:${e.rangeLabel}:${e.text}`}function Ze(e){return[e.fileKey,e]}function B(e){return e.removeReviewComment}function Qe(e){return e.addReviewComment}function $e(e){return{diffPreview:i(e,{label:`environment-data:review:diff-preview`,tag:f.reviewGetDiffPreview,staleTimeMs:5e3})}}var et=$e(T);function V(e){return e.remoteName&&e.name.startsWith(`${e.remoteName}/`)?e.name.slice(e.remoteName.length+1):e.name}function tt(e,t){let n=new Set(t),r=e.map(e=>{let r=t.filter(t=>n.has(t)&&V(t)===e.name),i=r.find(e=>e.remoteName===`origin`)??r[0]??null;return i&&n.delete(i),{id:`local:${e.name}`,label:e.name,local:e,remote:i}}),i=t.filter(e=>n.has(e)).map(e=>({id:`remote:${e.name}`,label:e.name,local:null,remote:e}));return[...r,...i]}function nt(e,t){let n=t.trim().toLocaleLowerCase();return n.length===0?e:e.filter(e=>e.label.toLocaleLowerCase().includes(n)||e.local?.name.toLocaleLowerCase().includes(n)===!0||e.remote?.name.toLocaleLowerCase().includes(n)===!0)}var H=`__automatic_base_ref__`,rt=new Set,it=`
|
|
2
2
|
[data-diffs-header],
|
|
3
3
|
[data-diff],
|
|
4
4
|
[data-file],
|
|
@@ -95,4 +95,4 @@ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}f
|
|
|
95
95
|
text-decoration-color: currentColor;
|
|
96
96
|
}
|
|
97
97
|
`;function U({mode:e=`inline`,composerDraftTarget:t,initialGitScope:n,threadRef:r}){let{resolvedTheme:i}=ie(),d=ue(),[ne]=(0,F.useState)(n),[f,re]=(0,F.useState)(`stacked`),[y,x]=(0,F.useState)(d.wordWrap),[C,T]=(0,F.useState)(d.diffIgnoreWhitespace),[D,_e]=(0,F.useState)(``),[Te,Ee]=(0,F.useState)(()=>({scopeKey:null,fileKeys:rt})),He=(0,F.useRef)(null),Ue=r.threadId,I=me(r),qe=I?.projectId??null,Je=pe(I&&qe?{environmentId:I.environmentId,projectId:qe}:null),R=I?.worktreePath??Je?.workspaceRoot,z=l(m.configValueAtom(I?.environmentId??null)),Xe=ve(I?.environmentId??null,z?.availableEditors??[]),Ze=o(I!=null&&R!=null?Oe.status({environmentId:I.environmentId,input:{cwd:R}}):null),B=P(e=>De(e.byThreadKey,r,ne===`unstaged`)),Qe=Ze.data?.isRepo??!0,{turnDiffSummaries:$e,inferredCheckpointTurnCountByTurnId:V}=le(I),U=(0,F.useMemo)(()=>[...$e].toSorted((e,t)=>{let n=e.checkpointTurnCount??V[e.turnId]??0,r=t.checkpointTurnCount??V[t.turnId]??0;return n===r?t.completedAt.localeCompare(e.completedAt):r-n}),[V,$e]);(0,F.useEffect)(()=>{B.kind===`turn`&&P.getState().reconcileTurnSelection(r,U.map(e=>e.turnId))},[B,U,r]);let W=B.kind===`turn`?B.turnId:null,G=B.kind===`unstaged`?`unstaged`:`branch`,K=B.kind===`branch`?B.baseRef:null,at=B.kind===`turn`?B.filePath:null,ot=B.kind===`turn`?B.revealRequestId:0,q=W===null?void 0:U.find(e=>e.turnId===W)??U[0],J=q&&(q.checkpointTurnCount??V[q.turnId]),st=U[0],ct=W===null?G===`unstaged`?`Working tree`:`Branch changes`:q?.turnId===st?.turnId?`Latest turn`:`Turn ${J??`?`}`,lt=q?`turn:${q.turnId}`:G,Y=`${r.environmentId}:${r.threadId}:${lt}`,ut=Te.scopeKey===Y?Te.fileKeys:rt,dt=q?`Turn ${J??`?`}`:G===`unstaged`?`Working tree`:`Branch changes`,ft=(0,F.useMemo)(()=>typeof J==`number`?{fromTurnCount:Math.max(0,J-1),toTurnCount:J}:null,[J]),pt=Ke({environmentId:I?.environmentId??null,threadId:Ue,fromTurnCount:ft?.fromTurnCount??null,toTurnCount:ft?.toTurnCount??null,ignoreWhitespace:C,cacheScope:q?`turn:${q.turnId}`:null},{enabled:Qe&&q!==void 0}),mt=o(W===null&&I&&R?et.diffPreview({environmentId:I.environmentId,input:{cwd:R,...K?{baseRef:K}:{},ignoreWhitespace:C}}):null),ht=W===null&&mt.error?.includes(`configured workspace root`)===!0&&z?.cwd!==void 0&&z.cwd!==R,gt=o(ht&&I&&z?et.diffPreview({environmentId:I.environmentId,input:{cwd:z.cwd,...K?{baseRef:K}:{},ignoreWhitespace:C}}):null),X=ht?gt:mt,Z=X.data?.sources.find(e=>e.kind===(G===`unstaged`?`working-tree`:`branch-range`)),_t=o(W===null&&G===`branch`&&I&&X.data?.cwd?Oe.listRefs({environmentId:I.environmentId,input:{cwd:X.data.cwd,includeMatchingRemoteRefs:!0,refKind:`local`,...D.trim().length>0?{query:D.trim()}:{},limit:100}}):null),vt=o(W===null&&G===`branch`&&I&&X.data?.cwd?Oe.listRefs({environmentId:I.environmentId,input:{cwd:X.data.cwd,includeMatchingRemoteRefs:!0,refKind:`remote`,...D.trim().length>0?{query:D.trim()}:{},limit:100}}):null),yt=tt(_t.data?.refs.filter(e=>e.name!==Z?.headRef)??[],vt.data?.refs??[]),bt=nt(yt,D),xt=e=>K&&K===e.remote?.name?K:e.local?.name??e.remote?.name??e.id,St=[H,...yt.map(xt)],Ct=[...D.trim().length===0?[H]:[],...bt.map(xt)],wt=Z?.diff,Tt=q?pt.data?.diff:wt,Et=!q&&Z?.truncated===!0,Dt=q?pt.isPending:X.isPending,Ot=q?pt.error:X.error,kt=typeof Tt==`string`&&Tt.trim().length===0,Q=(0,F.useMemo)(()=>ze(Tt,`diff-panel:${i}`,{compactPartialHunkOffsets:W===null}),[i,Tt,W]),At=(0,F.useMemo)(()=>!Q||Q.kind!==`files`?[]:Q.files.toSorted((e,t)=>je(e).localeCompare(je(t),void 0,{numeric:!0,sensitivity:`base`})),[Q]),$=(0,F.useMemo)(()=>At.map(e=>{let t=Ie(e);return{fileDiff:e,filePath:je(e),fileKey:t,collapsed:ut.has(t)}}),[ut,At]),jt=(0,F.useMemo)(()=>$.map(e=>e.fileKey),[$]),Mt=M(jt,ut),Nt=(0,F.useMemo)(()=>Pe(At),[At]);(0,F.useEffect)(()=>{if(!at)return;let e=$.find(e=>e.filePath===at);e&&He.current?.scrollTo({type:`item`,id:e.fileKey,align:`start`})},[$,at,ot]);let Pt=ke({threadRef:r,workspaceRoot:R??null}),Ft=(0,F.useCallback)(e=>{Ge({threadRef:r,filePath:e,activeCwd:R,openFileSurface:Pt,openInEditor:e=>{(async()=>{let t=await Xe(e);t._tag===`Failure`&&!h(t)&&console.warn(`Failed to open diff file in editor.`,{operation:`open-diff-file`,environmentId:r.environmentId,threadId:r.threadId,...ae(se(t))})})()}})},[R,Pt,Xe,r]),It=(0,F.useCallback)(e=>{Ee(t=>{let n=new Set(t.scopeKey===Y?t.fileKeys:[]);return n.has(e)?n.delete(e):n.add(e),{scopeKey:Y,fileKeys:n}})},[Y]),Lt=(0,F.useCallback)(()=>{Ee(e=>{let t=e.scopeKey===Y?e.fileKeys:rt;return{scopeKey:Y,fileKeys:k(jt,t)}})},[Y,jt]),Rt=e=>{P.getState().selectTurn(r,e)},zt=e=>{P.getState().selectGitScope(r,e)},Bt=e=>{P.getState().selectBranchBaseRef(r,e)};return(0,L.jsx)(ge,{mode:e,header:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3 [-webkit-app-region:no-drag]`,children:[(0,L.jsxs)(s,{children:[(0,L.jsxs)(ee,{className:`inline-flex h-6 max-w-full items-center gap-1 rounded-md bg-muted/70 px-2 text-xs font-medium text-foreground outline-none transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring`,"aria-label":`Diff scope: ${ct}`,children:[(0,L.jsx)(`span`,{className:`truncate`,children:ct}),(0,L.jsx)(_,{className:`size-3.5 shrink-0 text-muted-foreground`})]}),(0,L.jsxs)(a,{align:`start`,className:`w-60`,children:[(0,L.jsx)(E,{className:W===null&&G===`unstaged`?`bg-foreground/[0.08]`:void 0,onClick:()=>zt(`unstaged`),children:(0,L.jsx)(`span`,{children:`Working tree`})}),(0,L.jsx)(E,{className:W===null&&G===`branch`?`bg-foreground/[0.08]`:void 0,onClick:()=>zt(`branch`),children:(0,L.jsx)(`span`,{children:`Branch changes`})}),(0,L.jsx)(E,{className:W!==null&&q?.turnId===st?.turnId?`bg-foreground/[0.08]`:void 0,onClick:()=>{st&&Rt(st.turnId)},children:(0,L.jsx)(`span`,{children:`Latest turn`})}),(0,L.jsxs)(c,{children:[(0,L.jsx)(S,{children:`Turn`}),(0,L.jsx)(te,{className:`w-64`,children:U.map(e=>{let t=e.checkpointTurnCount??V[e.turnId]??`?`;return(0,L.jsxs)(E,{className:e.turnId===q?.turnId?`bg-foreground/[0.08]`:void 0,onClick:()=>Rt(e.turnId),children:[(0,L.jsxs)(`span`,{children:[`Turn `,t]}),(0,L.jsx)(`span`,{className:`ml-auto text-xs tabular-nums text-muted-foreground`,children:Ve(e.completedAt,d.timestampFormat)})]},e.turnId)})})]})]})]}),W===null&&G===`branch`&&Z?.baseRef&&(0,L.jsxs)(`div`,{className:`flex min-w-0 max-w-full items-center gap-2 overflow-hidden text-xs text-muted-foreground`,title:`${Z.headRef??`HEAD`} → ${Z.baseRef}`,"aria-label":`Comparing ${Z.headRef??`HEAD`} against ${Z.baseRef}`,children:[(0,L.jsx)(`span`,{className:`min-w-0 max-w-48 truncate`,children:Z.headRef??`HEAD`}),(0,L.jsx)(Le,{className:`size-3.5 shrink-0 opacity-70`}),(0,L.jsxs)(Ne,{items:St,filteredItems:Ct,value:K??H,onOpenChange:e=>{e||_e(``)},onValueChange:e=>{e&&Bt(e===H?null:e)},children:[(0,L.jsxs)(Ce,{className:`inline-flex min-w-0 max-w-48 items-center gap-1 overflow-hidden rounded-md px-1.5 py-1 outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,"aria-label":`Change comparison target. Currently ${Z.baseRef}`,children:[(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:Z.baseRef}),(0,L.jsx)(_,{className:`size-3.5 shrink-0 opacity-70`})]}),(0,L.jsxs)(Se,{align:`start`,className:`w-72 min-w-0 max-w-[calc(100vw-1rem)] overflow-hidden [&>[data-slot=combobox-popup]]:min-w-0 [&>[data-slot=combobox-popup]]:overflow-hidden`,children:[(0,L.jsx)(`div`,{className:`min-w-0 shrink-0 px-3 pt-2.5`,children:(0,L.jsxs)(`div`,{className:`relative -translate-y-px border-b border-border/70 pb-1.5 transition-colors focus-within:border-ring`,children:[(0,L.jsx)(he,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1.5 left-0 size-4 shrink-0 text-muted-foreground/55`}),(0,L.jsx)(be,{className:`[&_input]:h-6.5 [&_input]:ps-5 [&_input]:font-sans [&_input]:leading-6.5`,inputClassName:`rounded-none bg-transparent text-sm`,placeholder:`Search refs...`,showTrigger:!1,size:`sm`,unstyled:!0,value:D,onChange:e=>_e(e.target.value)})]})}),(0,L.jsxs)(`div`,{className:`grid shrink-0 grid-cols-[1rem_minmax(0,1fr)] items-center gap-2 border-b border-border/70 ps-3 pe-6.5 pt-2 pb-1.5 font-medium text-[10px] text-muted-foreground uppercase tracking-wide`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`}),(0,L.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_2rem] items-center`,children:[(0,L.jsx)(`span`,{children:`Branch`}),(0,L.jsx)(`span`,{className:`text-right`,children:`Remote`})]})]}),(0,L.jsx)(Re,{children:`No matching refs.`}),(0,L.jsxs)(Be,{className:`max-h-64 min-w-0 overflow-x-hidden`,children:[(0,L.jsx)(Ae,{className:`h-8 w-full min-w-0 grid-cols-[1rem_minmax(0,1fr)] py-0`,contentClassName:`w-full min-w-0 overflow-hidden`,value:H,children:(0,L.jsx)(`span`,{className:`block min-w-0 truncate`,children:`Automatic`})}),yt.map(e=>{let t=xt(e),n=e.local!==null&&e.remote!==null,r=e.remote?.name===t;return(0,L.jsx)(Ae,{className:`h-8 w-full min-w-0 grid-cols-[1rem_minmax(0,1fr)] py-0`,contentClassName:`w-full min-w-0 overflow-hidden`,value:t,children:(0,L.jsxs)(`div`,{className:`grid w-full min-w-0 grid-cols-[minmax(0,1fr)_2rem] items-center overflow-hidden`,children:[(0,L.jsx)(`span`,{className:`block min-w-0 truncate pe-2`,children:e.label}),n?(0,L.jsx)(`div`,{className:`flex justify-end`,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,L.jsx)(Fe,{"aria-label":`Use remote version of ${e.label}`,checked:r,className:`[--thumb-size:--spacing(3)]`,onCheckedChange:t=>{let n=t?e.remote?.name:e.local?.name;n&&Bt(n)}})}):e.remote?(0,L.jsx)(`span`,{className:`flex justify-end text-muted-foreground`,title:`Remote only`,children:(0,L.jsx)(oe,{"aria-hidden":`true`,className:`size-3`})}):null]})},e.id)})]})]})]})]})]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 [-webkit-app-region:no-drag]`,children:[$.length>0&&(0,L.jsx)(we,{additions:Nt.additions,deletions:Nt.deletions,className:`mr-1 text-[11px]`,layout:`inline`}),$.length>0&&(0,L.jsxs)(b,{children:[(0,L.jsx)(w,{render:(0,L.jsx)(u,{type:`button`,size:`icon-xs`,variant:`outline`,"aria-label":Mt?`Expand all files`:`Collapse all files`,onClick:Lt}),children:Mt?(0,L.jsx)(Me,{className:`size-3`}):(0,L.jsx)(O,{className:`size-3`})}),(0,L.jsx)(v,{side:`top`,children:Mt?`Expand all files`:`Collapse all files`})]}),(0,L.jsxs)(A,{className:`shrink-0`,variant:`outline`,size:`xs`,value:[f],onValueChange:e=>{let t=e[0];(t===`stacked`||t===`split`)&&re(t)},children:[(0,L.jsx)(N,{"aria-label":`Stacked diff view`,value:`stacked`,children:(0,L.jsx)(j,{className:`size-3`})}),(0,L.jsx)(N,{"aria-label":`Split diff view`,value:`split`,children:(0,L.jsx)(ce,{className:`size-3`})})]}),(0,L.jsxs)(b,{children:[(0,L.jsx)(w,{render:(0,L.jsx)(N,{"aria-label":y?`Disable diff line wrapping`:`Enable diff line wrapping`,variant:`outline`,size:`xs`,pressed:y,onPressedChange:e=>{x(!!e)}}),children:(0,L.jsx)(fe,{className:`size-3`})}),(0,L.jsx)(v,{side:`top`,children:y?`Disable line wrapping`:`Enable line wrapping`})]}),(0,L.jsxs)(b,{children:[(0,L.jsx)(w,{render:(0,L.jsx)(N,{"aria-label":C?`Show whitespace changes`:`Hide whitespace changes`,variant:`outline`,size:`xs`,pressed:C,onPressedChange:e=>{T(!!e)}}),children:(0,L.jsx)(We,{className:`size-3`})}),(0,L.jsx)(v,{side:`top`,children:C?`Show whitespace changes`:`Hide whitespace changes`})]})]})]}),children:I?Qe?W!==null&&U.length===0?(0,L.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:`No completed turns yet.`}):(0,L.jsx)(L.Fragment,{children:(0,L.jsxs)(`div`,{className:`diff-panel-viewport flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[Et&&(0,L.jsx)(`p`,{className:`shrink-0 border-b border-border/70 bg-muted/40 px-3 py-1.5 text-[11px] text-muted-foreground`,children:`This diff was truncated because it exceeded the preview limit. The changes shown are incomplete.`}),Ot&&!Q&&(0,L.jsx)(`div`,{className:`px-3`,children:(0,L.jsx)(`p`,{className:`mb-2 text-[11px] text-red-500/80`,children:Ot})}),Q?Q.kind===`files`?(0,L.jsx)(`div`,{className:`min-h-0 flex-1`,onClickCapture:e=>{let t=(e.nativeEvent.composedPath?.()??[]).find(e=>e instanceof HTMLElement&&e.hasAttribute(`data-title`))?.textContent?.trim();t&&Ft(t)},children:(0,L.jsx)(Ye,{viewerRef:He,className:`diff-render-surface h-full min-h-0 overflow-auto`,files:$,sectionId:lt,sectionTitle:dt,composerDraftTarget:t,renderHeaderPrefix:(e,t,n)=>{let r=je(e);return(0,L.jsxs)(b,{children:[(0,L.jsx)(w,{render:(0,L.jsx)(`button`,{type:`button`,className:p(`inline-flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-sm border-0 bg-transparent p-0 transition-colors hover:bg-foreground/10 focus-visible:outline-hidden`,ye(e)),"aria-label":n?`Expand ${r}`:`Collapse ${r}`,"aria-expanded":!n,onClick:e=>{e.stopPropagation(),It(t)}}),children:n?(0,L.jsx)(g,{className:`size-4`}):(0,L.jsx)(_,{className:`size-4`})}),(0,L.jsx)(v,{side:`top`,children:n?`Expand diff`:`Collapse diff`})]})},options:{diffStyle:f===`split`?`split`:`unified`,lineDiffType:`none`,overflow:y?`wrap`:`scroll`,theme:xe(i),themeType:i,unsafeCSS:it,stickyHeaders:!0,itemMetrics:{diffHeaderHeight:33},layout:{paddingTop:0,paddingBottom:8,gap:8}}},Y??lt)}):(0,L.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-2`,children:(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(`p`,{className:`text-[11px] text-muted-foreground/75`,children:Q.reason}),(0,L.jsx)(`pre`,{className:p(`max-h-[72vh] rounded-md border border-border/70 bg-background/70 p-3 font-mono text-[11px] leading-relaxed text-muted-foreground/90`,y?`overflow-auto whitespace-pre-wrap wrap-break-word`:`overflow-auto`),children:Q.text})]})}):Dt?(0,L.jsx)(de,{label:q?`Loading checkpoint diff...`:G===`unstaged`?`Loading working tree diff...`:`Loading branch diff...`}):(0,L.jsx)(`div`,{className:`flex h-full items-center justify-center px-3 py-2 text-xs text-muted-foreground/70`,children:(0,L.jsx)(`p`,{children:kt?`No net changes in this selection.`:`No patch available for this selection.`})})]})}):(0,L.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:`Turn diffs are unavailable because this project is not a git repository.`}):(0,L.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:`Select a thread to inspect turn diffs.`})})}export{_e as DiffWorkerPoolProvider,U as default};
|
|
98
|
-
//# sourceMappingURL=DiffPanel-
|
|
98
|
+
//# sourceMappingURL=DiffPanel-D51hS5c1.js.map
|