@amaster.ai/employee-runtime-connector 0.1.13-beta.2 → 0.1.13
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.
|
@@ -9719,6 +9719,12 @@ var selectMirrorXInternalDiscoveryTargetSchema = external_exports.object({
|
|
|
9719
9719
|
expectedGapContractId: external_exports.string().uuid(),
|
|
9720
9720
|
expectedGapAuthorityRevision: external_exports.number().int().positive()
|
|
9721
9721
|
}).strict();
|
|
9722
|
+
var mirrorXInternalDiscoveryTargetCandidateSchema = selectMirrorXInternalDiscoveryTargetSchema.extend({
|
|
9723
|
+
routineTitle: external_exports.string().min(1),
|
|
9724
|
+
criterionText: external_exports.string().min(1),
|
|
9725
|
+
gapKey: external_exports.string().min(1),
|
|
9726
|
+
currentSelectionId: external_exports.string().uuid().nullable()
|
|
9727
|
+
}).strict();
|
|
9722
9728
|
var mirrorXInternalDiscoveryTargetSelectionSchema = external_exports.object({
|
|
9723
9729
|
id: external_exports.string().uuid(),
|
|
9724
9730
|
companyId: external_exports.string().uuid(),
|
|
@@ -17419,11 +17425,15 @@ var companyArtifactKindFilterSchema = external_exports.enum([
|
|
|
17419
17425
|
"file"
|
|
17420
17426
|
]);
|
|
17421
17427
|
var companyArtifactGroupBySchema = external_exports.enum(["none", "task", "parent_task"]);
|
|
17428
|
+
var companyArtifactDeliveryStatusSchema = external_exports.enum(["recorded", "ready", "accepted"]);
|
|
17422
17429
|
var companyArtifactsQuerySchema = external_exports.object({
|
|
17423
17430
|
kind: companyArtifactKindFilterSchema.optional().default("all"),
|
|
17431
|
+
deliveryStatus: companyArtifactDeliveryStatusSchema.optional(),
|
|
17424
17432
|
projectId: external_exports.string().uuid().optional(),
|
|
17425
17433
|
createdByAgentId: external_exports.string().uuid().optional(),
|
|
17426
17434
|
q: external_exports.string().trim().max(COMPANY_ARTIFACTS_MAX_QUERY_LENGTH).optional(),
|
|
17435
|
+
/** Absent keeps the standalone timeline flat; an empty value opens the library folder root. */
|
|
17436
|
+
folder: external_exports.string().max(160).optional(),
|
|
17427
17437
|
groupBy: companyArtifactGroupBySchema.optional().default("none"),
|
|
17428
17438
|
groupIssueId: external_exports.string().uuid().optional(),
|
|
17429
17439
|
limit: external_exports.coerce.number().int().min(1).max(COMPANY_ARTIFACTS_MAX_LIMIT).optional().default(COMPANY_ARTIFACTS_DEFAULT_LIMIT),
|
|
@@ -17444,6 +17454,7 @@ var companyArtifactSchema = external_exports.object({
|
|
|
17444
17454
|
workProductType: external_exports.string().nullable(),
|
|
17445
17455
|
provider: external_exports.string().nullable(),
|
|
17446
17456
|
status: external_exports.string().nullable(),
|
|
17457
|
+
deliveryStatus: companyArtifactDeliveryStatusSchema.optional(),
|
|
17447
17458
|
externalUrl: companyArtifactHttpUrlSchema.nullable(),
|
|
17448
17459
|
thumbnailUrl: companyArtifactThumbnailUrlSchema.nullable(),
|
|
17449
17460
|
platform: external_exports.string().nullable(),
|
|
@@ -17499,6 +17510,7 @@ var companyArtifactKindCountsSchema = external_exports.object({
|
|
|
17499
17510
|
});
|
|
17500
17511
|
var companyArtifactsResponseSchema = external_exports.object({
|
|
17501
17512
|
artifacts: external_exports.array(companyArtifactSchema),
|
|
17513
|
+
folders: external_exports.array(external_exports.object({ path: external_exports.string(), name: external_exports.string() })).optional(),
|
|
17502
17514
|
groups: external_exports.array(companyArtifactGroupSchema).optional(),
|
|
17503
17515
|
selectedGroup: companyArtifactGroupSchema.nullable().optional(),
|
|
17504
17516
|
kindCounts: companyArtifactKindCountsSchema.optional(),
|
|
@@ -19206,17 +19218,17 @@ var driveMutationSchema = external_exports.discriminatedUnion("operation", [
|
|
|
19206
19218
|
})
|
|
19207
19219
|
]);
|
|
19208
19220
|
var MIRRORX_DRIVE_AGENT_RULES = [
|
|
19209
|
-
"\
|
|
19221
|
+
"\u4E0D\u786E\u5B9A\u8D44\u6599\u5728\u54EA\u4E2A\u76EE\u5F55\u65F6\uFF0C\u5148\u7528 library_search(scope=all) \u67E5\u5168\u5E93\uFF0C\u518D\u628A\u7ED3\u679C\u7684 resourceRef \u4EA4\u7ED9 library_read\uFF1B\u4F7F\u7528\u8FD4\u56DE\u7684\u6765\u6E90\u548C\u7248\u672C\u5F15\u7528\u3002",
|
|
19210
19222
|
"\u6587\u4EF6\u4FDD\u5B58\u5230\u672C\u4EFB\u52A1\u5DE5\u4F5C\u6587\u4EF6\uFF0C\u7EE7\u7EED\u4FEE\u6539\u540C\u4E00\u6587\u4EF6\uFF0C\u4E0D\u9020\u7248\u672C\u540E\u7F00\u3002",
|
|
19211
19223
|
"\u66F4\u65B0\u5171\u4EAB\u8D44\u6599\u63D0\u4EA4\u5019\u9009\uFF0C\u7B49\u4EBA\u91C7\u7EB3\uFF0C\u4E0D\u76F4\u63A5\u6539\u539F\u4EF6\u6216\u6574\u7406\u76EE\u5F55\u3002",
|
|
19212
|
-
"\u6210\u679C\u8D70\u4EFB\u52A1\u4EA4\u4ED8\u5DE5\u5177\uFF0C\u77E5\u8BC6\u66F4\u65B0\u8D70\u4E13\u7528\u77E5\u8BC6\u7EF4\u62A4\u8BF7\u6C42\u3002",
|
|
19224
|
+
"\u6210\u679C\u7684\u63D0\u4EA4\u4E0E\u9A8C\u6536\u8D70\u4EFB\u52A1\u4EA4\u4ED8\u5DE5\u5177\uFF0C\u77E5\u8BC6\u66F4\u65B0\u8D70\u4E13\u7528\u77E5\u8BC6\u7EF4\u62A4\u8BF7\u6C42\u3002",
|
|
19213
19225
|
"\u51B2\u7A81\u6309\u63D0\u793A\u8BFB\u53D6\u6700\u65B0\u7248\u5E76\u91CD\u65B0\u6574\u7406\uFF1B\u65E0\u6743\u9650\u505C\u6B62\uFF1B\u5F52\u6863\u6210\u529F\u56DE\u6267\u624D\u4EE3\u8868\u5DF2\u4FDD\u5B58\u3002"
|
|
19214
19226
|
].join("\n");
|
|
19215
19227
|
|
|
19216
19228
|
// src/amaster-runtime-daemon.mjs
|
|
19217
|
-
import { chmodSync as chmodSync9, copyFileSync as copyFileSync2, existsSync as
|
|
19229
|
+
import { chmodSync as chmodSync9, copyFileSync as copyFileSync2, existsSync as existsSync19, lstatSync as lstatSync16, mkdirSync as mkdirSync14, mkdtempSync as mkdtempSync5, readFileSync as readFileSync21, readdirSync as readdirSync14, realpathSync as realpathSync12, renameSync as renameSync12, rmSync as rmSync12, statSync as statSync12, symlinkSync as symlinkSync2, unlinkSync as unlinkSync4, writeFileSync as writeFileSync15 } from "node:fs";
|
|
19218
19230
|
import { arch as arch4, homedir as homedir7, hostname as hostname2, platform as platform4, tmpdir } from "node:os";
|
|
19219
|
-
import { basename as basename8, delimiter as delimiter3, dirname as dirname14, extname as extname3, isAbsolute as
|
|
19231
|
+
import { basename as basename8, delimiter as delimiter3, dirname as dirname14, extname as extname3, isAbsolute as isAbsolute14, join as join26, relative as relative9, resolve as resolve20 } from "node:path";
|
|
19220
19232
|
import { spawn, spawnSync as spawnSync6 } from "node:child_process";
|
|
19221
19233
|
|
|
19222
19234
|
// src/amaster-runtime-daemon/common.mjs
|
|
@@ -19478,14 +19490,21 @@ function createPiOutputRetentionCompactor() {
|
|
|
19478
19490
|
const emitPendingDelta = ({ finalizeText = false } = {}) => {
|
|
19479
19491
|
if (!pendingDelta) return [];
|
|
19480
19492
|
const assistantEvent = pendingDelta.assistantMessageEvent;
|
|
19493
|
+
const combinedDelta = pendingDelta.deltas.join("");
|
|
19481
19494
|
const retainedEvent = finalizeText && assistantEvent.type === "text_delta" ? {
|
|
19482
19495
|
type: "message_update",
|
|
19483
19496
|
assistantMessageEvent: {
|
|
19484
19497
|
type: "text_end",
|
|
19485
19498
|
...Number.isSafeInteger(assistantEvent.contentIndex) ? { contentIndex: assistantEvent.contentIndex } : {},
|
|
19486
|
-
content:
|
|
19499
|
+
content: combinedDelta
|
|
19500
|
+
}
|
|
19501
|
+
} : {
|
|
19502
|
+
type: "message_update",
|
|
19503
|
+
assistantMessageEvent: {
|
|
19504
|
+
...assistantEvent,
|
|
19505
|
+
...pendingDelta.deltas.length > 0 ? { delta: combinedDelta } : {}
|
|
19487
19506
|
}
|
|
19488
|
-
}
|
|
19507
|
+
};
|
|
19489
19508
|
const retained = JSON.stringify(retainedEvent);
|
|
19490
19509
|
pendingDelta = null;
|
|
19491
19510
|
return [retained];
|
|
@@ -19507,11 +19526,14 @@ function createPiOutputRetentionCompactor() {
|
|
|
19507
19526
|
const pendingAssistantEvent = pendingDelta?.assistantMessageEvent;
|
|
19508
19527
|
if (pendingAssistantEvent?.type !== assistantEvent.type || pendingAssistantEvent?.contentIndex !== assistantEvent.contentIndex) {
|
|
19509
19528
|
const emitted = emitPendingDelta();
|
|
19510
|
-
pendingDelta =
|
|
19529
|
+
pendingDelta = {
|
|
19530
|
+
...compact,
|
|
19531
|
+
deltas: typeof assistantEvent.delta === "string" ? [assistantEvent.delta] : []
|
|
19532
|
+
};
|
|
19511
19533
|
return emitted;
|
|
19512
19534
|
}
|
|
19513
19535
|
if (typeof assistantEvent.delta === "string") {
|
|
19514
|
-
pendingDelta.
|
|
19536
|
+
pendingDelta.deltas.push(assistantEvent.delta);
|
|
19515
19537
|
}
|
|
19516
19538
|
if (typeof assistantEvent.content === "string") {
|
|
19517
19539
|
pendingDelta.assistantMessageEvent.content = assistantEvent.content;
|
|
@@ -19520,8 +19542,8 @@ function createPiOutputRetentionCompactor() {
|
|
|
19520
19542
|
}
|
|
19521
19543
|
const matchingDeltaType = `${assistantEvent.type.slice(0, -4)}_delta`;
|
|
19522
19544
|
if (pendingDelta?.assistantMessageEvent?.type === matchingDeltaType && pendingDelta.assistantMessageEvent.contentIndex === assistantEvent.contentIndex) {
|
|
19523
|
-
if (assistantEvent.type === "text_end" && !assistantEvent.content && pendingDelta.
|
|
19524
|
-
assistantEvent.content = pendingDelta.
|
|
19545
|
+
if (assistantEvent.type === "text_end" && !assistantEvent.content && pendingDelta.deltas.length > 0) {
|
|
19546
|
+
assistantEvent.content = pendingDelta.deltas.join("");
|
|
19525
19547
|
}
|
|
19526
19548
|
pendingDelta = null;
|
|
19527
19549
|
}
|
|
@@ -24849,16 +24871,17 @@ function createManagedPiMcpProfileApi(options = {}) {
|
|
|
24849
24871
|
}
|
|
24850
24872
|
return version;
|
|
24851
24873
|
}
|
|
24852
|
-
function managedPiTelemetryExtension(sharedRuntime) {
|
|
24874
|
+
function managedPiTelemetryExtension(sharedRuntime, packageHome = sharedRuntime.home) {
|
|
24853
24875
|
const settings = record11(sharedRuntime.settings);
|
|
24854
|
-
const
|
|
24876
|
+
const packageSettings = packageHome === sharedRuntime.home ? settings : record11(JSON.parse(readFileSync7(join11(packageHome, "settings.json"), "utf8")));
|
|
24877
|
+
const packages = Array.isArray(packageSettings.packages) ? packageSettings.packages : [];
|
|
24855
24878
|
const configuredSources = packages.filter((source) => typeof source === "string" && (source === MANAGED_PI_TELEMETRY_PACKAGE_SOURCE || source.startsWith(`${MANAGED_PI_TELEMETRY_PACKAGE_SOURCE}@`)));
|
|
24856
24879
|
if (configuredSources.length === 0) return null;
|
|
24857
24880
|
if (configuredSources.length !== 1) {
|
|
24858
24881
|
throw new Error("pi_managed_mcp_telemetry_package_source_invalid");
|
|
24859
24882
|
}
|
|
24860
24883
|
const packageRoot = resolve8(
|
|
24861
|
-
|
|
24884
|
+
packageHome,
|
|
24862
24885
|
"npm",
|
|
24863
24886
|
"node_modules",
|
|
24864
24887
|
"@amaster.ai",
|
|
@@ -25636,7 +25659,7 @@ ${result2.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
|
|
|
25636
25659
|
extensionArgs,
|
|
25637
25660
|
writeProfileExtension
|
|
25638
25661
|
});
|
|
25639
|
-
const telemetryExtension = managedPiTelemetryExtension(sharedRuntime);
|
|
25662
|
+
const telemetryExtension = managedPiTelemetryExtension(sharedRuntime, input.browserRuntimePackageHome);
|
|
25640
25663
|
let enabledRoleSkillMetadataBytes = 0;
|
|
25641
25664
|
const skillProfiles = roleSkillProfilesForRun(input);
|
|
25642
25665
|
const managedSkillProjection = materializeManagedSkillBundle(profileRoot, input.managedSkillBundle);
|
|
@@ -29113,6 +29136,22 @@ function piMessageHasToolCall(message) {
|
|
|
29113
29136
|
return block.type === "toolCall" && Boolean(readString(block.name));
|
|
29114
29137
|
});
|
|
29115
29138
|
}
|
|
29139
|
+
function piReasoningOnlyLengthEvent(event) {
|
|
29140
|
+
const record11 = asRecord(event);
|
|
29141
|
+
if (readString(record11.type) !== "message_end") return null;
|
|
29142
|
+
const message = asRecord(record11.message);
|
|
29143
|
+
if (message.role !== "assistant" || (piMessageStopReason(message) ?? readString(record11.stopReason)) !== "length") return null;
|
|
29144
|
+
const content = Array.isArray(message.content) ? message.content : [];
|
|
29145
|
+
if (!content.some((part) => asRecord(part).type === "thinking")) return null;
|
|
29146
|
+
if (piMessageText(message) || piMessageHasToolCall(message)) return null;
|
|
29147
|
+
const usage = piMessageUsage(message);
|
|
29148
|
+
return {
|
|
29149
|
+
stopReason: "length",
|
|
29150
|
+
outputTokens: usage.outputTokens,
|
|
29151
|
+
inputTokens: usage.inputTokens,
|
|
29152
|
+
contentBlockTypes: [...new Set(content.map((part) => readString(asRecord(part).type)).filter(Boolean))]
|
|
29153
|
+
};
|
|
29154
|
+
}
|
|
29116
29155
|
function appendUniqueText(values, text2) {
|
|
29117
29156
|
const normalized = typeof text2 === "string" ? text2.trim() : "";
|
|
29118
29157
|
if (!normalized) return false;
|
|
@@ -30407,7 +30446,6 @@ function resolveTaskWikiPolicy(context) {
|
|
|
30407
30446
|
}
|
|
30408
30447
|
|
|
30409
30448
|
// src/amaster-runtime-daemon/prompt-compiler.mjs
|
|
30410
|
-
var DEADLINE_POSTURE_GUARD = "If a named time window or milestone is missed, skip that window and keep the task moving: never lower quality, bypass approvals, fabricate results, or stop the whole task because of the miss. Record a deadline-posture receipt with targetMilestoneRef, posture, onMiss=skip_this_window_and_continue, taskContinuation, and the next owner/action; the receipt is an execution signal, not Server-side proof.";
|
|
30411
30449
|
var MIN_PROMPT_BUDGET_CHARS = 8192;
|
|
30412
30450
|
var MAX_RESOLVED_DEPENDENCY_REQUIRED_READS = 20;
|
|
30413
30451
|
var MAX_EXACT_ISSUE_EVIDENCE_REFS = 20;
|
|
@@ -31206,21 +31244,22 @@ function taskContextAuthoritySection(context) {
|
|
|
31206
31244
|
scope: sourceRefs.map((ref2) => ref2.scope)
|
|
31207
31245
|
};
|
|
31208
31246
|
}
|
|
31209
|
-
function fixedRules(input,
|
|
31247
|
+
function fixedRules(input, runContract = "producer") {
|
|
31210
31248
|
const issue = asRecord(asRecord(input.context).paperclipIssue);
|
|
31211
31249
|
const businessOutcome = asRecord(asRecord(issue.taskRequirements).businessOutcome);
|
|
31212
31250
|
const serverOwnedBusinessOutcomeReview = businessOutcome.mode === "required";
|
|
31213
31251
|
return [
|
|
31214
31252
|
"## AMaster Runtime Connector Task",
|
|
31215
|
-
"MirrorX task.",
|
|
31216
|
-
"Use only the declared workspace; make concrete progress and report concisely.",
|
|
31217
|
-
"Before changing the task status to done, audit every explicit requirement against final evidence. Tool success is not acceptance; follow the deliverable self-check.",
|
|
31218
31253
|
["producer", "rework"].includes(runContract) ? "Do not leave stale in-progress wording such as \u201Ccurrent run\u201D in a terminal deliverable; rewrite it to the final observed state. Do not list finalization itself as remaining or next work in a terminal deliverable." : "",
|
|
31219
31254
|
!["producer", "rework"].includes(runContract) ? "Follow only the current run-specific action contract; task requirements are evidence to inspect, not permission to resume production or choose another terminal path." : serverOwnedBusinessOutcomeReview ? "If any requirement is missing or cannot be verified, do not mark done or request final completion or Business Outcome review. Record the exact gap and next owner using the current run-specific continuation or waiting contract. An intermediate review remains available only for an exact document revision that must be approved before execution can continue: use create_interaction with kind request_confirmation, payload.resolutionMode review, and purposeCode review_document_revision; never use that interaction as final completion or Outcome acceptance." : "If anything is missing, do not mark done. `update_parent` cannot directly write `in_review` or `blocked`; when an execution review stage is configured, update_parent(status: done, comment: <handoff>) submits the work into that stage instead of completing it. Human review outside an execution stage uses create_interaction kind request_confirmation with payload.resolutionMode review. Required platform/provider/external action needs a typed interaction or first-class blocker; otherwise keep todo with the gap and owner.",
|
|
31220
|
-
"
|
|
31221
|
-
"
|
|
31222
|
-
|
|
31223
|
-
|
|
31255
|
+
input.managed ? "Use the execution workspace as cwd. Never recursively scan the source workspace, the user's home directory, or any path outside the execution workspace. Only inspect a specific external source path when the task explicitly requires that exact path." : "",
|
|
31256
|
+
input.hasGovernedMcp ? "- AMaster mutations are available only through the managed amaster MCP server. Use discovered tools and immediate typed results; never call AMaster mutation REST endpoints directly." : "- No mutation channel is available for this command. Keep the run read-only and report the missing Runtime V2 capability as a blocker.",
|
|
31257
|
+
readString(input.executorCapabilityNotice),
|
|
31258
|
+
wikiAccessRuleLine(input)
|
|
31259
|
+
].filter(Boolean).join("\n");
|
|
31260
|
+
}
|
|
31261
|
+
function currentRunContext(input, includeIssueLine) {
|
|
31262
|
+
return [
|
|
31224
31263
|
`- command id: ${input.commandId}`,
|
|
31225
31264
|
`- run id: ${input.runId ?? "unknown"}`,
|
|
31226
31265
|
`- issue id: ${input.issueId ?? "unknown"}`,
|
|
@@ -31228,17 +31267,7 @@ function fixedRules(input, includeIssueLine, runContract = "producer") {
|
|
|
31228
31267
|
includeIssueLine && input.issueLine ? `- issue: ${input.issueLine}` : "",
|
|
31229
31268
|
`- workspace: ${input.cwd}`,
|
|
31230
31269
|
input.managed ? `- source workspace: ${input.sourceWorkspacePath}` : "",
|
|
31231
|
-
input.
|
|
31232
|
-
input.wakeReason ? `- wake reason: ${input.wakeReason}` : "",
|
|
31233
|
-
input.hasGovernedMcp ? "- AMaster mutations are available only through the managed amaster MCP server. Use discovered tools and immediate typed results; never call AMaster mutation REST endpoints directly." : "- No mutation channel is available for this command. Keep the run read-only and report the missing Runtime V2 capability as a blocker.",
|
|
31234
|
-
readString(input.executorCapabilityNotice),
|
|
31235
|
-
wikiAccessRuleLine(input),
|
|
31236
|
-
"- Runtime Artifact lineage fields sourceWorkProductId and sourceWorkProductIds accept only current artifact work product ids returned as result.effectResult.workProductId by a succeeded upload_artifact action. Never pass a documentId or revisionId as artifact lineage.",
|
|
31237
|
-
"- When all inputs are issue documents and there is no source artifact work product, persist the derived result using an available Issue document action and do not call upload_artifact for a derived or review artifact.",
|
|
31238
|
-
"- When this task creates, deploys, publishes, or otherwise delivers a user-openable non-file result, call upsert_work_product before final disposition. Use application for apps/sites/mini programs/dashboards, published_content for posts/videos/articles, external_link for other URL results, and the existing code/runtime types for pull requests, branches, commits, previews, and services.",
|
|
31239
|
-
"- For a Helige application created with the helige-app-builder skill, call upsert_work_product immediately after the preview or deployment is verified and before upsert_document, add_comment, or update_parent. Use provider helige, applicationId as externalId, the actual preview or production URL, and preserve applicationId, appCode, releaseId, releaseVersion, environment, applicationKind, platform, observedAt, and publishedAt metadata when available.",
|
|
31240
|
-
"- upsert_work_product records an agent-reported result for collection; it does not prove provider verification, health, approval, or business Acceptance. Those states remain Server/provider owned.",
|
|
31241
|
-
"- A URL mentioned only in an Issue document, comment, assistant message, or provider tool output is not a collected work product. Persist the typed work product and use its returned workProductId as the durable receipt before marking the task done."
|
|
31270
|
+
input.wakeReason ? `- wake reason: ${input.wakeReason}` : ""
|
|
31242
31271
|
].filter(Boolean).join("\n");
|
|
31243
31272
|
}
|
|
31244
31273
|
function compileConversationPrompt(input, context, maxChars) {
|
|
@@ -31248,7 +31277,6 @@ function compileConversationPrompt(input, context, maxChars) {
|
|
|
31248
31277
|
companyId: readString(asRecord(context.paperclipCompany).id),
|
|
31249
31278
|
issueId: input.issueId ?? null
|
|
31250
31279
|
};
|
|
31251
|
-
const piGovernedTools = piDirectTypedToolsText(input);
|
|
31252
31280
|
const runtimeSafety = [
|
|
31253
31281
|
"Use only the declared execution workspace. Do not recursively scan the source workspace, the user's home directory, or unrelated paths.",
|
|
31254
31282
|
"Do not install operating-system or user-global packages. Use existing tools or workspace-local dependencies.",
|
|
@@ -31263,7 +31291,6 @@ function compileConversationPrompt(input, context, maxChars) {
|
|
|
31263
31291
|
{ name: "task", title: "Conversation History", priority: 90, sourceRef: "conversation", originalContent: taskText, content: mode === "cold" ? taskText : "", truncationReason: mode === "cold" ? null : "mode_selection" },
|
|
31264
31292
|
...readString(input.browserCredentialEnv) ? [{ name: "browser_credential_env", title: "Browser Credential Access", priority: 100, sourceRef: `command:${input.commandId}:browser-credentials`, content: readString(input.browserCredentialEnv) }] : [],
|
|
31265
31293
|
{ name: "runtime_safety", title: "Runtime Safety", priority: 100, sourceRef: `command:${input.commandId}`, content: runtimeSafety },
|
|
31266
|
-
...piGovernedTools ? [{ name: "pi_governed_tools", title: "Pi Governed Tools", priority: 96, sourceRef: "amaster_governed_mcp_direct_typed_contract", content: piGovernedTools }] : [],
|
|
31267
31294
|
{ name: "agent_instructions", title: "Agent Instructions", priority: 100, sourceRef: "agent_instructions_bundle", content: readString(input.agentInstructions) ?? "" },
|
|
31268
31295
|
{ name: "mention_context", title: "Mentioned Context", priority: 85, sourceRef: "paperclip_mention_context", content: readString(input.mentionContextText) ?? "" },
|
|
31269
31296
|
{ name: "attachments", title: "Materialized Inputs", priority: 80, sourceRef: "materialized_attachments", content: readString(input.attachmentsText) ?? "" },
|
|
@@ -31921,18 +31948,6 @@ function taskCommentRefGuidance(input, taskText) {
|
|
|
31921
31948
|
}
|
|
31922
31949
|
return guidance.join(" ");
|
|
31923
31950
|
}
|
|
31924
|
-
function piDirectTypedToolsText(input) {
|
|
31925
|
-
if (!input.hasGovernedMcp || input.executorKind !== "pi" || input.managedMcpToolMode !== "direct_typed") return "";
|
|
31926
|
-
const catalog = asRecord(input.managedMcpToolCatalog);
|
|
31927
|
-
const tools = (Array.isArray(catalog.tools) ? catalog.tools : []).map(asRecord).map((tool) => ({ name: readString(tool.exposedName), description: readString(tool.description) })).filter((tool) => tool.name);
|
|
31928
|
-
if (tools.length === 0) {
|
|
31929
|
-
return "Direct typed tools are unavailable because the run catalog snapshot is empty. Do not guess a proxy or tool name.";
|
|
31930
|
-
}
|
|
31931
|
-
return [
|
|
31932
|
-
"Use only the attested direct typed tools already present in the provider tool definitions. Call their exact names with object arguments; do not call the `mcp` proxy and do not stringify an inner argument envelope.",
|
|
31933
|
-
"A tool absent from the provider tool definitions is unavailable in this run. Do not infer a namespace or fall back to REST/bare MCP."
|
|
31934
|
-
].join("\n");
|
|
31935
|
-
}
|
|
31936
31951
|
function sectionText(section) {
|
|
31937
31952
|
if (!section.content) return "";
|
|
31938
31953
|
return section.title ? `## ${section.title}
|
|
@@ -31961,10 +31976,10 @@ var COMPANY_INITIALIZATION_PRE_AUTHORITY_SECTIONS = /* @__PURE__ */ new Set([
|
|
|
31961
31976
|
var COMPANY_INITIALIZATION_POST_AUTHORITY_SECTIONS = /* @__PURE__ */ new Set([
|
|
31962
31977
|
"browser_credential_env",
|
|
31963
31978
|
"runtime_rules",
|
|
31979
|
+
"current_run_context",
|
|
31964
31980
|
"runtime_authorization",
|
|
31965
31981
|
"runtime_decomposition_requirement",
|
|
31966
31982
|
"task_context_authority",
|
|
31967
|
-
"pi_governed_tools",
|
|
31968
31983
|
"runtime_template_catalog",
|
|
31969
31984
|
"agent_instructions",
|
|
31970
31985
|
"on_demand_refs",
|
|
@@ -32129,7 +32144,6 @@ var CONTEXT_AVAILABILITY_SECTION_TITLES = Object.freeze({
|
|
|
32129
32144
|
runtime_decomposition_requirement: "Required Task Decomposition",
|
|
32130
32145
|
task_context_authority: "Task Context Authority",
|
|
32131
32146
|
verified_company_context: "Verified Company Context",
|
|
32132
|
-
pi_governed_tools: "Pi Governed Tools",
|
|
32133
32147
|
governed_reads: "Governed External Reads",
|
|
32134
32148
|
optional_task_wiki_context: "Optional Company Wiki Context",
|
|
32135
32149
|
agent_instructions: "Agent Instructions",
|
|
@@ -32204,10 +32218,10 @@ function buildManifest(mode, maxChars, sections, governedReadProvenance, usedCha
|
|
|
32204
32218
|
governedReadProvenance
|
|
32205
32219
|
};
|
|
32206
32220
|
}
|
|
32207
|
-
var RUNTIME_SYSTEM_SECTIONS = /* @__PURE__ */ new Set(["
|
|
32221
|
+
var RUNTIME_SYSTEM_SECTIONS = /* @__PURE__ */ new Set(["agent_instructions"]);
|
|
32208
32222
|
function deliverCompiledPrompt(prompt, manifest, sections, separateRuntimeRules) {
|
|
32209
32223
|
if (!separateRuntimeRules) return { prompt, manifest };
|
|
32210
|
-
const inSystem = (section) => RUNTIME_SYSTEM_SECTIONS.has(section.name)
|
|
32224
|
+
const inSystem = (section) => RUNTIME_SYSTEM_SECTIONS.has(section.name);
|
|
32211
32225
|
const userPrompt = renderPrompt(sections.filter((section) => !inSystem(section)));
|
|
32212
32226
|
const systemPrompt = renderPrompt(sections.filter(inSystem));
|
|
32213
32227
|
if (!userPrompt.trim() || !systemPrompt.trim()) return { prompt, manifest };
|
|
@@ -32368,7 +32382,6 @@ ${resolvedDependencies.details.content}` : resolvedDependencies.details.content
|
|
|
32368
32382
|
content: resolvedDependencyContent,
|
|
32369
32383
|
mandatoryContent: resolvedDependencies.required.content
|
|
32370
32384
|
} : null;
|
|
32371
|
-
const piGovernedTools = piDirectTypedToolsText(input);
|
|
32372
32385
|
const deliveryReadinessContent = runtimeDeliveryReadinessText(context, input);
|
|
32373
32386
|
const executionReviewContract = ["reviewer", "approver", "invalid_execution_stage"].includes(runContract) ? executionReviewContractSection(context, input) : null;
|
|
32374
32387
|
const producerExecutionHandoff = producerExecutionHandoffSection(input, runContract, pendingExecutionStages);
|
|
@@ -32409,7 +32422,8 @@ ${resolvedDependencies.details.content}` : resolvedDependencies.details.content
|
|
|
32409
32422
|
...deliveryReadinessContent ? [{ name: "runtime_delivery_readiness", title: "Current Delivery Readiness", priority: 99, sourceRef: `issue:${input.issueId ?? "unknown"}:delivery`, content: deliveryReadinessContent }] : [],
|
|
32410
32423
|
...companyInitializationAuthority && !includeTask ? [companyInitializationAuthority] : [],
|
|
32411
32424
|
...!hasTask && readString(input.issueLine) && options.separateRuntimeRules === true ? [{ name: "issue_line", title: "", priority: 100, sourceRef: `issue:${input.issueId ?? "unknown"}`, content: `- issue: ${input.issueLine}` }] : [],
|
|
32412
|
-
{ name: "runtime_rules", title: "", priority: 100, sourceRef: `command:${input.commandId}`, content: fixedRules(input,
|
|
32425
|
+
{ name: "runtime_rules", title: "", priority: 100, sourceRef: `command:${input.commandId}`, content: fixedRules(input, runContract) },
|
|
32426
|
+
{ name: "current_run_context", title: "", priority: 100, sourceRef: `command:${input.commandId}`, content: currentRunContext(input, !hasTask && options.separateRuntimeRules !== true) },
|
|
32413
32427
|
{ name: "runtime_authorization", title: "Runtime Action Contract", priority: 98, sourceRef: `run:${input.runId ?? "unknown"}`, content: runtimeAuthorizationText(context, mode, {
|
|
32414
32428
|
replayAlreadyInTask: includeTask && taskText.includes(EXACT_ORGANIZATION_INTENT_REPLAY_MARKER),
|
|
32415
32429
|
runContract,
|
|
@@ -32420,13 +32434,6 @@ ${resolvedDependencies.details.content}` : resolvedDependencies.details.content
|
|
|
32420
32434
|
{ name: "runtime_decomposition_requirement", title: "Required Task Decomposition", priority: 98, sourceRef: `issue:${input.issueId ?? "unknown"}`, content: runtimeDecompositionRequirementText(context) },
|
|
32421
32435
|
...taskContextAuthority ? [{ name: "task_context_authority", title: "Task Context Authority", priority: 100, ...taskContextAuthority, mandatoryContent: taskContextAuthority.content }] : [],
|
|
32422
32436
|
...verifiedCompanyContext.content ? [{ name: "verified_company_context", title: "Verified Company Context", priority: 96, sourceRef: verifiedCompanyContext.sourceRef, observedAt: verifiedCompanyContext.observedAt, freshness: { kind: "run_snapshot" }, content: verifiedCompanyContext.content }] : [],
|
|
32423
|
-
...piGovernedTools ? [{
|
|
32424
|
-
name: "pi_governed_tools",
|
|
32425
|
-
title: "Pi Governed Tools",
|
|
32426
|
-
priority: 96,
|
|
32427
|
-
sourceRef: "amaster_governed_mcp_direct_typed_contract",
|
|
32428
|
-
content: piGovernedTools
|
|
32429
|
-
}] : [],
|
|
32430
32437
|
{ name: "governed_reads", title: "Governed External Reads", priority: 88, sourceRef: governedReads.provenance.map((entry) => entry.sourceRef), observedAt: governedReads.provenance.map((entry) => entry.observedAt), freshness: governedReads.provenance.map((entry) => entry.freshness), scope: governedReads.provenance.map((entry) => entry.scope), content: governedReads.content },
|
|
32431
32438
|
...optionalTaskWikiContext ? [optionalTaskWikiContext] : [],
|
|
32432
32439
|
...runtimeTemplateCatalog ? [{ name: "runtime_template_catalog", title: "Runtime Template Catalog", priority: 100, ...runtimeTemplateCatalog }] : [],
|
|
@@ -32933,14 +32940,9 @@ var BUILD_SUPPORTED_CAPABILITIES = Object.freeze([
|
|
|
32933
32940
|
"mirrorx_initialization_context_v1",
|
|
32934
32941
|
"mirrorx_initialization_completion_v1",
|
|
32935
32942
|
"native_session_checkpoint_v1",
|
|
32936
|
-
"pi_web_public_search_v1"
|
|
32937
|
-
"pi_web_public_fetch_v1"
|
|
32943
|
+
"pi_web_public_search_v1"
|
|
32938
32944
|
]);
|
|
32939
32945
|
var DYNAMIC_READINESS = Object.freeze({
|
|
32940
|
-
pi_web_public_fetch_v1: {
|
|
32941
|
-
reasonCode: "pi_web_fetch_extension_unavailable",
|
|
32942
|
-
ready: (input) => input.executors.some((executor) => executor.kind === "pi") && input.piWebFetchReady === true
|
|
32943
|
-
},
|
|
32944
32946
|
pi_web_public_search_v1: {
|
|
32945
32947
|
reasonCode: "pi_web_search_extension_unavailable",
|
|
32946
32948
|
ready: (input) => input.executors.some((executor) => executor.kind === "pi") && input.piWebSearchReady === true
|
|
@@ -32951,10 +32953,7 @@ var DYNAMIC_READINESS = Object.freeze({
|
|
|
32951
32953
|
},
|
|
32952
32954
|
browser_credential_auth_transaction_v1: {
|
|
32953
32955
|
reasonCode: "browser_credential_auth_runtime_incomplete",
|
|
32954
|
-
ready: (input) =>
|
|
32955
|
-
const readiness = input.browserCredentialAuth;
|
|
32956
|
-
return input.executors.some((executor) => executor.kind === "pi") && readiness?.privateChannel === true && readiness?.executorClient === true && readiness?.sealedGate === true && readiness?.atomicTransaction === true && readiness?.trustedProfileInjection === true;
|
|
32957
|
-
}
|
|
32956
|
+
ready: (input) => input.executors.some((executor) => executor.kind === "pi") && input.browserCredentialAuth?.extension === true
|
|
32958
32957
|
},
|
|
32959
32958
|
native_session_checkpoint_v1: {
|
|
32960
32959
|
reasonCode: "managed_pi_checkpoint_required",
|
|
@@ -33584,7 +33583,6 @@ import { existsSync as existsSync12, lstatSync as lstatSync10, readFileSync as r
|
|
|
33584
33583
|
import { createHash as createHash14 } from "node:crypto";
|
|
33585
33584
|
import { homedir as homedir4 } from "node:os";
|
|
33586
33585
|
import { dirname as dirname11, isAbsolute as isAbsolute7, join as join17, relative as relative5, resolve as resolve11 } from "node:path";
|
|
33587
|
-
var CAPABILITY = "browser_credential_auth_transaction_v1";
|
|
33588
33586
|
var CREDENTIAL_BROWSER_TCB = Object.freeze({
|
|
33589
33587
|
package: "chrome-devtools-mcp",
|
|
33590
33588
|
version: "1.6.0",
|
|
@@ -33592,13 +33590,17 @@ var CREDENTIAL_BROWSER_TCB = Object.freeze({
|
|
|
33592
33590
|
buildTreeSha256: "5bd07cd7ea92141441db12d1e84c4829dd4e2a45ea77f719878be9f4a42925d7"
|
|
33593
33591
|
});
|
|
33594
33592
|
var CREDENTIAL_BROWSER_PACKAGE_FILES = Object.freeze({
|
|
33595
|
-
"dist/config.js": "
|
|
33596
|
-
"dist/index.js": "
|
|
33593
|
+
"dist/config.js": "01da4c975a050dc1860a5115b244020be741100bff3c426f601642a6f757f370",
|
|
33594
|
+
"dist/index.js": "9cf0dac303552cbfb7f87c9499dbd8c1d88565e0145825ca222424e1123b70e2"
|
|
33597
33595
|
});
|
|
33598
|
-
var
|
|
33596
|
+
var CREDENTIAL_BROWSER_DIST_TREE_SHA256 = "fcf1abd578c519b7ab7cec921d1abe36992aab84b4f713e0b89587e6254145a9";
|
|
33597
|
+
var CREDENTIAL_AUTH_EXTENSION_SHA256 = "48f36d0c1c5c46f07bd447c2bc2000595d17f109ce6963865870d88f42c60598";
|
|
33599
33598
|
var CREDENTIAL_BROWSER_PACKAGE_VERSION = "0.1.2-beta.80";
|
|
33600
33599
|
var IMAGE_PI_HOME = "/opt/pi-cli-runtime/.pi";
|
|
33600
|
+
var BROWSER_AUTH_IMAGE_HOME = IMAGE_PI_HOME;
|
|
33601
33601
|
var IMAGE_AUTH_EXTENSION_PATH = join17(IMAGE_PI_HOME, "extensions", "browser-credential-auth.mjs");
|
|
33602
|
+
var MANAGED_BROWSER_EXCLUDED_PACKAGES = /* @__PURE__ */ new Set(["@amaster.ai/pi-browser-use", "pi-mcp-adapter"]);
|
|
33603
|
+
var RUNTIME_PACKAGE_SOURCE = /^npm:((?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*)$/u;
|
|
33602
33604
|
var BROWSER_AUTH_IMAGE_NODE_PATH = join17(IMAGE_PI_HOME, "npm", "node_modules");
|
|
33603
33605
|
var READINESS_CACHE_TTL_MS = 5e3;
|
|
33604
33606
|
var readinessCache = /* @__PURE__ */ new Map();
|
|
@@ -33618,6 +33620,7 @@ function inspectBrowserCredentialAuthReadiness(env = process.env, expected = {},
|
|
|
33618
33620
|
const packageAttestation = candidates.map((manifestPath) => attestedPackageManifest(manifestPath, {
|
|
33619
33621
|
browserTcb: expected.browserTcb ?? CREDENTIAL_BROWSER_TCB,
|
|
33620
33622
|
packageFiles: expected.packageFiles ?? CREDENTIAL_BROWSER_PACKAGE_FILES,
|
|
33623
|
+
packageDistTreeSha256: expected.packageDistTreeSha256 ?? CREDENTIAL_BROWSER_DIST_TREE_SHA256,
|
|
33621
33624
|
authExtensionSha256: expected.authExtensionSha256 ?? CREDENTIAL_AUTH_EXTENSION_SHA256
|
|
33622
33625
|
}, requireImageOwnership)).find(Boolean) ?? null;
|
|
33623
33626
|
const packageAttested = Boolean(packageAttestation);
|
|
@@ -33626,23 +33629,86 @@ function inspectBrowserCredentialAuthReadiness(env = process.env, expected = {},
|
|
|
33626
33629
|
packageAttestation ? expected.authExtensionSha256 ?? CREDENTIAL_AUTH_EXTENSION_SHA256 : null,
|
|
33627
33630
|
requireImageOwnership
|
|
33628
33631
|
);
|
|
33632
|
+
let runtimeExtensionsAttested = false;
|
|
33633
|
+
if (packageAttested && authExtensionAttested) {
|
|
33634
|
+
try {
|
|
33635
|
+
managedBrowserRuntimeExtensionArgs(packageHome, requireImageOwnership);
|
|
33636
|
+
runtimeExtensionsAttested = true;
|
|
33637
|
+
} catch {
|
|
33638
|
+
runtimeExtensionsAttested = false;
|
|
33639
|
+
}
|
|
33640
|
+
}
|
|
33641
|
+
const ready = packageAttested && authExtensionAttested && runtimeExtensionsAttested;
|
|
33629
33642
|
const readiness = {
|
|
33643
|
+
extension: ready,
|
|
33630
33644
|
privateChannel: true,
|
|
33631
|
-
executorClient:
|
|
33632
|
-
sealedGate:
|
|
33633
|
-
atomicTransaction:
|
|
33634
|
-
trustedProfileInjection:
|
|
33645
|
+
executorClient: ready,
|
|
33646
|
+
sealedGate: ready,
|
|
33647
|
+
atomicTransaction: ready,
|
|
33648
|
+
trustedProfileInjection: ready
|
|
33635
33649
|
};
|
|
33636
33650
|
readinessCache.set(cacheKey, { readiness, expiresAt: now + READINESS_CACHE_TTL_MS });
|
|
33637
33651
|
return { ...readiness };
|
|
33638
33652
|
}
|
|
33639
33653
|
function browserCredentialAuthExtensionArgs(authority, env = process.env, expected = {}, options = {}) {
|
|
33640
|
-
if (!
|
|
33654
|
+
if (authority && !env.AMASTER_BROWSER_SESSION_USER_DATA_DIR) {
|
|
33655
|
+
throw new Error("browser_credential_authority_profile_required");
|
|
33656
|
+
}
|
|
33657
|
+
if (!env.AMASTER_BROWSER_SESSION_USER_DATA_DIR && !authority) return [];
|
|
33641
33658
|
const readiness = inspectBrowserCredentialAuthReadiness(env, expected, { ...options, fresh: true });
|
|
33642
33659
|
if (!readiness.atomicTransaction || !readiness.sealedGate) {
|
|
33643
33660
|
throw new Error("browser_credential_auth_extension_unavailable");
|
|
33644
33661
|
}
|
|
33645
|
-
return [
|
|
33662
|
+
return [
|
|
33663
|
+
"--no-extensions",
|
|
33664
|
+
...managedBrowserRuntimeExtensionArgs(expected.packageHome ?? IMAGE_PI_HOME, options.requireImageOwnership !== false),
|
|
33665
|
+
"--extension",
|
|
33666
|
+
expected.authExtensionPath ?? IMAGE_AUTH_EXTENSION_PATH
|
|
33667
|
+
];
|
|
33668
|
+
}
|
|
33669
|
+
function managedBrowserRuntimeExtensionArgs(packageHome, requireImageOwnership) {
|
|
33670
|
+
const settingsPath = join17(packageHome, "settings.json");
|
|
33671
|
+
if (requireImageOwnership && !immutableImageFile(settingsPath)) {
|
|
33672
|
+
throw new Error("browser_credential_runtime_extensions_unsafe");
|
|
33673
|
+
}
|
|
33674
|
+
let packageSources;
|
|
33675
|
+
try {
|
|
33676
|
+
packageSources = JSON.parse(readFileSync13(settingsPath, "utf8")).packages;
|
|
33677
|
+
} catch {
|
|
33678
|
+
throw new Error("browser_credential_runtime_extensions_invalid");
|
|
33679
|
+
}
|
|
33680
|
+
if (!Array.isArray(packageSources)) throw new Error("browser_credential_runtime_extensions_invalid");
|
|
33681
|
+
const args = [];
|
|
33682
|
+
const seen = /* @__PURE__ */ new Set();
|
|
33683
|
+
for (const source of packageSources) {
|
|
33684
|
+
const packageName = typeof source === "string" ? RUNTIME_PACKAGE_SOURCE.exec(source)?.[1] : null;
|
|
33685
|
+
if (!packageName || seen.has(packageName)) throw new Error("browser_credential_runtime_extensions_invalid");
|
|
33686
|
+
seen.add(packageName);
|
|
33687
|
+
if (MANAGED_BROWSER_EXCLUDED_PACKAGES.has(packageName)) continue;
|
|
33688
|
+
const packageDir = join17(packageHome, "npm", "node_modules", packageName);
|
|
33689
|
+
const manifestPath = join17(packageDir, "package.json");
|
|
33690
|
+
if (requireImageOwnership && !immutableImageFile(manifestPath)) {
|
|
33691
|
+
throw new Error("browser_credential_runtime_extensions_unsafe");
|
|
33692
|
+
}
|
|
33693
|
+
let manifest;
|
|
33694
|
+
try {
|
|
33695
|
+
manifest = JSON.parse(readFileSync13(manifestPath, "utf8"));
|
|
33696
|
+
} catch {
|
|
33697
|
+
throw new Error("browser_credential_runtime_extensions_invalid");
|
|
33698
|
+
}
|
|
33699
|
+
if (manifest.name !== packageName || !Array.isArray(manifest.pi?.extensions) || manifest.pi.extensions.length === 0) throw new Error("browser_credential_runtime_extensions_invalid");
|
|
33700
|
+
for (const relativePath of manifest.pi.extensions) {
|
|
33701
|
+
if (typeof relativePath !== "string" || !relativePath.startsWith("./")) {
|
|
33702
|
+
throw new Error("browser_credential_runtime_extensions_invalid");
|
|
33703
|
+
}
|
|
33704
|
+
const path = resolve11(packageDir, relativePath);
|
|
33705
|
+
if (!relative5(packageDir, path) || relative5(packageDir, path).startsWith("..") || isAbsolute7(relative5(packageDir, path)) || !existsSync12(path) || !lstatSync10(path).isFile() || requireImageOwnership && !immutableImageFile(path)) {
|
|
33706
|
+
throw new Error("browser_credential_runtime_extensions_unsafe");
|
|
33707
|
+
}
|
|
33708
|
+
args.push("--extension", path);
|
|
33709
|
+
}
|
|
33710
|
+
}
|
|
33711
|
+
return args;
|
|
33646
33712
|
}
|
|
33647
33713
|
function attestedAuthExtension(extensionPath, expectedSha256, requireImageOwnership) {
|
|
33648
33714
|
try {
|
|
@@ -33693,18 +33759,13 @@ function attestedPackageManifest(manifestPath, expected, requireImageOwnership)
|
|
|
33693
33759
|
if (requireImageOwnership && !immutableImageFile(manifestPath)) return null;
|
|
33694
33760
|
const manifest = JSON.parse(readFileSync13(manifestPath, "utf8"));
|
|
33695
33761
|
if (manifest?.name !== "@amaster.ai/pi-browser-use" || manifest.version !== CREDENTIAL_BROWSER_PACKAGE_VERSION) return null;
|
|
33696
|
-
if (!Array.isArray(manifest.
|
|
33697
|
-
return null;
|
|
33698
|
-
}
|
|
33699
|
-
if (!sameCredentialBrowserTcb(manifest.mirrorxCredentialBrowserTcb, expected.browserTcb)) return null;
|
|
33700
|
-
if (manifest.mirrorxCredentialAuthExtensionSha256 !== expected.authExtensionSha256) return null;
|
|
33701
|
-
if (typeof manifest.main !== "string" || !manifest.main.trim()) return null;
|
|
33762
|
+
if (manifest.main !== "./dist/index.js" || !Array.isArray(manifest.pi?.extensions) || manifest.pi.extensions.length !== 1 || manifest.pi.extensions[0] !== "./dist/index.js") return null;
|
|
33702
33763
|
const packageDir = resolve11(manifestPath, "..");
|
|
33703
33764
|
if (Object.entries(expected.packageFiles).some(([relativePath, sha2563]) => {
|
|
33704
33765
|
const path = resolve11(packageDir, relativePath);
|
|
33705
33766
|
const relativePathFromPackage = relative5(packageDir, path);
|
|
33706
33767
|
return !relativePathFromPackage || relativePathFromPackage.startsWith("..") || isAbsolute7(relativePathFromPackage) || !statSync6(path).isFile() || requireImageOwnership && !immutableImageFile(path) || fileSha256(path) !== sha2563;
|
|
33707
|
-
})) return null;
|
|
33768
|
+
}) || treeAttestation(join17(packageDir, "dist"), requireImageOwnership) !== expected.packageDistTreeSha256) return null;
|
|
33708
33769
|
const browserPackageDir = resolve11(packageDir, "..", "..", "chrome-devtools-mcp");
|
|
33709
33770
|
const browserManifestPath = join17(browserPackageDir, "package.json");
|
|
33710
33771
|
if (requireImageOwnership && !immutableImageFile(browserManifestPath)) return null;
|
|
@@ -33718,9 +33779,6 @@ function attestedPackageManifest(manifestPath, expected, requireImageOwnership)
|
|
|
33718
33779
|
return null;
|
|
33719
33780
|
}
|
|
33720
33781
|
}
|
|
33721
|
-
function sameCredentialBrowserTcb(value, expected) {
|
|
33722
|
-
return value && typeof value === "object" && Object.entries(expected).every(([key, expectedValue]) => value[key] === expectedValue) && Object.keys(value).length === Object.keys(expected).length;
|
|
33723
|
-
}
|
|
33724
33782
|
|
|
33725
33783
|
// src/amaster-runtime-daemon/browser-credential-env-readiness.mjs
|
|
33726
33784
|
import { lstatSync as lstatSync11, readFileSync as readFileSync14 } from "node:fs";
|
|
@@ -33787,15 +33845,10 @@ function inspectPiWebSearchReadiness(env = process.env) {
|
|
|
33787
33845
|
const providers = settings?.["pi-web-access"]?.providers;
|
|
33788
33846
|
return Boolean(installed && providers && typeof providers === "object" && !Array.isArray(providers) && Object.keys(providers).length > 0);
|
|
33789
33847
|
}
|
|
33790
|
-
function inspectPiWebFetchReadiness(env = process.env) {
|
|
33791
|
-
const { settings, installed } = installedPiWebAccess(env);
|
|
33792
|
-
const fetch2 = settings?.["pi-web-access"]?.fetch;
|
|
33793
|
-
return Boolean(installed && fetch2?.mode === "direct" && fetch2?.dnsOverHttps === "google");
|
|
33794
|
-
}
|
|
33795
33848
|
|
|
33796
33849
|
// src/amaster-runtime-daemon/browser-credential-env.mjs
|
|
33797
|
-
import { chmodSync as chmodSync7, mkdtempSync as mkdtempSync3, renameSync as renameSync10, rmSync as rmSync10, writeFileSync as writeFileSync13 } from "node:fs";
|
|
33798
|
-
import { join as join20, resolve as resolve12 } from "node:path";
|
|
33850
|
+
import { chmodSync as chmodSync7, existsSync as existsSync13, mkdtempSync as mkdtempSync3, renameSync as renameSync10, rmSync as rmSync10, writeFileSync as writeFileSync13 } from "node:fs";
|
|
33851
|
+
import { isAbsolute as isAbsolute9, join as join20, resolve as resolve12 } from "node:path";
|
|
33799
33852
|
var BROWSER_CREDENTIAL_ENV_CAPABILITY = "browser_credential_env_read_v1";
|
|
33800
33853
|
var BROWSER_CREDENTIAL_PRIVATE_CAPABILITY = "browser_credential_auth_transaction_v1";
|
|
33801
33854
|
var BROWSER_CREDENTIAL_ENV_FILE = "PI_AGENT_BROWSER_CREDENTIAL_ENV_FILE";
|
|
@@ -33890,6 +33943,19 @@ function attachTrustedBrowserExecutorEnv(env, { authority = null, userDataDir =
|
|
|
33890
33943
|
if (authority) result2[BROWSER_CREDENTIAL_AUTHORITY_ENV] = JSON.stringify(authority);
|
|
33891
33944
|
return result2;
|
|
33892
33945
|
}
|
|
33946
|
+
function companyBrowserProfileDir(companyId, root = "/data/companies") {
|
|
33947
|
+
const id = companyId || "shared";
|
|
33948
|
+
if (!isAbsolute9(root) || !/^[A-Za-z0-9_-]+$/u.test(id)) fail3("browser_company_profile_invalid");
|
|
33949
|
+
return join20(root, id, ".pi", "browser-profile");
|
|
33950
|
+
}
|
|
33951
|
+
function browserCredentialExtensionArgs(presentation, env, { managedBrowserSession = false } = {}) {
|
|
33952
|
+
if (managedBrowserSession) return [];
|
|
33953
|
+
if (presentation !== "private_channel") return [];
|
|
33954
|
+
const home = env.PI_CODING_AGENT_DIR || env.PI_AGENT_HOME;
|
|
33955
|
+
const extension = home && join20(home, "extensions", "browser-credential-auth.mjs");
|
|
33956
|
+
if (!extension || !existsSync13(extension)) fail3("browser_credential_auth_extension_missing");
|
|
33957
|
+
return ["--no-extensions", "--extension", extension];
|
|
33958
|
+
}
|
|
33893
33959
|
function dotenvQuotedValue(value) {
|
|
33894
33960
|
if (value.includes("\0")) fail3("browser_credential_env_value_invalid");
|
|
33895
33961
|
return `"${value.replace(/[\\"\n\r\t$`]/gu, (char) => ({
|
|
@@ -33947,7 +34013,7 @@ async function materializeBrowserCredentialEnv(plan, options) {
|
|
|
33947
34013
|
// src/amaster-runtime-daemon/runtime-artifact-upload.mjs
|
|
33948
34014
|
import { createHash as createHash15 } from "node:crypto";
|
|
33949
34015
|
import { closeSync as closeSync4, constants as constants3, fstatSync as fstatSync4, lstatSync as lstatSync13, openSync as openSync4, readFileSync as readFileSync16, realpathSync as realpathSync10 } from "node:fs";
|
|
33950
|
-
import { isAbsolute as
|
|
34016
|
+
import { isAbsolute as isAbsolute10, relative as relative6, resolve as resolve13 } from "node:path";
|
|
33951
34017
|
var SHA256_PATTERN = /^[a-f0-9]{64}$/;
|
|
33952
34018
|
function requiredString2(value, name) {
|
|
33953
34019
|
if (typeof value !== "string" || !value.trim()) throw new Error(`Runtime Artifact ${name} is required`);
|
|
@@ -33960,7 +34026,7 @@ function ownedRelativePath(value) {
|
|
|
33960
34026
|
}
|
|
33961
34027
|
function pathWithin2(candidate, root) {
|
|
33962
34028
|
const rel = relative6(root, candidate);
|
|
33963
|
-
return rel === "" || !rel.startsWith("..") && !
|
|
34029
|
+
return rel === "" || !rel.startsWith("..") && !isAbsolute10(rel);
|
|
33964
34030
|
}
|
|
33965
34031
|
function sameFileSnapshot(left, right) {
|
|
33966
34032
|
return left.dev === right.dev && left.ino === right.ino && left.size === right.size && left.mtimeMs === right.mtimeMs && left.ctimeMs === right.ctimeMs;
|
|
@@ -34325,11 +34391,11 @@ function createRuntimeArtifactIngestQueue({ ingest, onError }) {
|
|
|
34325
34391
|
|
|
34326
34392
|
// src/amaster-runtime-daemon/workspace-guard.mjs
|
|
34327
34393
|
import { createHash as createHash17 } from "node:crypto";
|
|
34328
|
-
import { existsSync as
|
|
34329
|
-
import { basename as basename6, join as join21, isAbsolute as
|
|
34394
|
+
import { existsSync as existsSync14, mkdirSync as mkdirSync12, realpathSync as realpathSync11, statSync as statSync7 } from "node:fs";
|
|
34395
|
+
import { basename as basename6, join as join21, isAbsolute as isAbsolute11, relative as relative7, resolve as resolve14 } from "node:path";
|
|
34330
34396
|
function pathWithin3(candidate, root) {
|
|
34331
34397
|
const rel = relative7(root, candidate);
|
|
34332
|
-
return rel === "" || !rel.startsWith("..") && !
|
|
34398
|
+
return rel === "" || !rel.startsWith("..") && !isAbsolute11(rel);
|
|
34333
34399
|
}
|
|
34334
34400
|
function resolveWorkspaceCwd(config, command) {
|
|
34335
34401
|
const payload = asRecord(command.payload);
|
|
@@ -34347,7 +34413,7 @@ function resolveWorkspaceCwd(config, command) {
|
|
|
34347
34413
|
if (!allowed) {
|
|
34348
34414
|
throw new Error(`Workspace path is outside AMASTER_WORKSPACE_ALLOWLIST: ${cwd}`);
|
|
34349
34415
|
}
|
|
34350
|
-
if (!
|
|
34416
|
+
if (!existsSync14(cwd) || !statSync7(cwd).isDirectory()) {
|
|
34351
34417
|
throw new Error(`Workspace path does not exist or is not a directory: ${cwd}`);
|
|
34352
34418
|
}
|
|
34353
34419
|
return cwd;
|
|
@@ -34421,7 +34487,7 @@ function resolveExecutionWorkspace(config, command, opts = {}) {
|
|
|
34421
34487
|
}
|
|
34422
34488
|
|
|
34423
34489
|
// src/amaster-runtime-daemon/workspace-gc.mjs
|
|
34424
|
-
import { existsSync as
|
|
34490
|
+
import { existsSync as existsSync15, readdirSync as readdirSync10, statSync as statSync8 } from "node:fs";
|
|
34425
34491
|
import { join as join22, resolve as resolve15 } from "node:path";
|
|
34426
34492
|
function readIsoTime(value) {
|
|
34427
34493
|
if (typeof value !== "string" || !value.trim()) return null;
|
|
@@ -34446,7 +34512,7 @@ function walkWorkdirs(root) {
|
|
|
34446
34512
|
for (const entry of entries) {
|
|
34447
34513
|
if (!entry.isDirectory()) continue;
|
|
34448
34514
|
const fullPath = join22(current, entry.name);
|
|
34449
|
-
if (entry.name === "workdir" &&
|
|
34515
|
+
if (entry.name === "workdir" && existsSync15(workspaceManifestPath(fullPath))) {
|
|
34450
34516
|
workdirs.push(fullPath);
|
|
34451
34517
|
continue;
|
|
34452
34518
|
}
|
|
@@ -34521,7 +34587,7 @@ function planManagedWorkspaceGcDryRun(input) {
|
|
|
34521
34587
|
candidates: [],
|
|
34522
34588
|
protected: []
|
|
34523
34589
|
};
|
|
34524
|
-
if (!root || !
|
|
34590
|
+
if (!root || !existsSync15(root)) return result2;
|
|
34525
34591
|
for (const workdir of walkWorkdirs(root)) {
|
|
34526
34592
|
const manifest = readWorkspaceManifest(workspaceManifestPath(workdir));
|
|
34527
34593
|
if (!manifest || manifest.managed !== true) continue;
|
|
@@ -34554,7 +34620,7 @@ import {
|
|
|
34554
34620
|
accessSync,
|
|
34555
34621
|
chmodSync as chmodSync8,
|
|
34556
34622
|
constants as constants4,
|
|
34557
|
-
existsSync as
|
|
34623
|
+
existsSync as existsSync16,
|
|
34558
34624
|
lstatSync as lstatSync14,
|
|
34559
34625
|
mkdirSync as mkdirSync13,
|
|
34560
34626
|
mkdtempSync as mkdtempSync4,
|
|
@@ -34566,7 +34632,7 @@ import {
|
|
|
34566
34632
|
unlinkSync as unlinkSync3,
|
|
34567
34633
|
writeFileSync as writeFileSync14
|
|
34568
34634
|
} from "node:fs";
|
|
34569
|
-
import { dirname as dirname12, extname, isAbsolute as
|
|
34635
|
+
import { dirname as dirname12, extname, isAbsolute as isAbsolute12, join as join23, parse as parse5, resolve as resolve16, sep as sep4 } from "node:path";
|
|
34570
34636
|
import { fileURLToPath } from "node:url";
|
|
34571
34637
|
var PRESET_TEMPLATE_MANIFEST_FILE = ".mirrorx-preset-templates.json";
|
|
34572
34638
|
var MAX_PRESET_TEMPLATE_FILES = 256;
|
|
@@ -34622,7 +34688,7 @@ function hasAllowedTemplateExtension(name) {
|
|
|
34622
34688
|
return ALLOWED_TEMPLATE_EXTENSIONS.has(extname(name).toLowerCase());
|
|
34623
34689
|
}
|
|
34624
34690
|
function validTemplateName(value) {
|
|
34625
|
-
return typeof value === "string" && value.length > 0 && value !== "." && value !== ".." && !value.includes("\0") && !value.includes("/") && !value.includes("\\") && !
|
|
34691
|
+
return typeof value === "string" && value.length > 0 && value !== "." && value !== ".." && !value.includes("\0") && !value.includes("/") && !value.includes("\\") && !isAbsolute12(value) && parse5(value).base === value && hasAllowedTemplateExtension(value);
|
|
34626
34692
|
}
|
|
34627
34693
|
function readManifest(manifestPath, { strict }) {
|
|
34628
34694
|
try {
|
|
@@ -34670,7 +34736,7 @@ function removeRetiredPresetFiles(targetDir, previousManifest, nextNames) {
|
|
|
34670
34736
|
for (const entry of previousManifest.files) {
|
|
34671
34737
|
if (nextNames.has(entry.name)) continue;
|
|
34672
34738
|
const targetPath = join23(targetDir, entry.name);
|
|
34673
|
-
if (!
|
|
34739
|
+
if (!existsSync16(targetPath)) continue;
|
|
34674
34740
|
const stat = lstatSync14(targetPath);
|
|
34675
34741
|
if (stat.isDirectory()) {
|
|
34676
34742
|
throw new Error(`preset_template_target_conflict: ${entry.name}`);
|
|
@@ -34754,7 +34820,7 @@ function materializeRuntimePresetTemplates(input) {
|
|
|
34754
34820
|
}
|
|
34755
34821
|
|
|
34756
34822
|
// src/amaster-runtime-daemon/runtime-status-summary.mjs
|
|
34757
|
-
import { existsSync as
|
|
34823
|
+
import { existsSync as existsSync17, readdirSync as readdirSync12, statSync as statSync10 } from "node:fs";
|
|
34758
34824
|
import { dirname as dirname13, join as join24, resolve as resolve17 } from "node:path";
|
|
34759
34825
|
function runtimeStatusDirectoryEntries(path) {
|
|
34760
34826
|
try {
|
|
@@ -34788,7 +34854,7 @@ function runtimeStatusDirectorySizeBytes(path) {
|
|
|
34788
34854
|
}
|
|
34789
34855
|
function walkRuntimeStatusManagedWorkdirs(root) {
|
|
34790
34856
|
const workdirs = [];
|
|
34791
|
-
if (!root || !
|
|
34857
|
+
if (!root || !existsSync17(root)) return workdirs;
|
|
34792
34858
|
const stack = [root];
|
|
34793
34859
|
while (stack.length > 0) {
|
|
34794
34860
|
const current = stack.pop();
|
|
@@ -34796,7 +34862,7 @@ function walkRuntimeStatusManagedWorkdirs(root) {
|
|
|
34796
34862
|
for (const entry of runtimeStatusDirectoryEntries(current)) {
|
|
34797
34863
|
if (!entry.isDirectory()) continue;
|
|
34798
34864
|
const fullPath = join24(current, entry.name);
|
|
34799
|
-
if (entry.name === "workdir" &&
|
|
34865
|
+
if (entry.name === "workdir" && existsSync17(workspaceManifestPath(fullPath))) {
|
|
34800
34866
|
workdirs.push(fullPath);
|
|
34801
34867
|
continue;
|
|
34802
34868
|
}
|
|
@@ -34850,7 +34916,7 @@ function runtimeStatusRunCompletionDir(config) {
|
|
|
34850
34916
|
})), "run-completion-state");
|
|
34851
34917
|
}
|
|
34852
34918
|
function countRuntimeStatusJsonEntries(dir) {
|
|
34853
|
-
if (!
|
|
34919
|
+
if (!existsSync17(dir)) return 0;
|
|
34854
34920
|
return runtimeStatusDirectoryEntries(dir).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).length;
|
|
34855
34921
|
}
|
|
34856
34922
|
function summarizeRuntimeLocalState(input) {
|
|
@@ -35245,8 +35311,8 @@ export default function amasterProjectInstructions(pi) {
|
|
|
35245
35311
|
// src/amaster-runtime-daemon/workspace-status.mjs
|
|
35246
35312
|
import { spawnSync as spawnSync5 } from "node:child_process";
|
|
35247
35313
|
import { createHash as createHash19 } from "node:crypto";
|
|
35248
|
-
import { existsSync as
|
|
35249
|
-
import { basename as basename7, extname as extname2, isAbsolute as
|
|
35314
|
+
import { existsSync as existsSync18, readdirSync as readdirSync13, readFileSync as readFileSync20, statSync as statSync11 } from "node:fs";
|
|
35315
|
+
import { basename as basename7, extname as extname2, isAbsolute as isAbsolute13, join as join25, relative as relative8, resolve as resolve19 } from "node:path";
|
|
35250
35316
|
var WORKSPACE_RUNTIME_SERVICES_FILENAME = ".amaster-runtime-services.json";
|
|
35251
35317
|
var ARTIFACT_EXTENSIONS = /* @__PURE__ */ new Map([
|
|
35252
35318
|
[".md", "markdown"],
|
|
@@ -35292,7 +35358,7 @@ var SAFE_RUNTIME_SERVICE_HEALTH_STATUSES = /* @__PURE__ */ new Set(["unknown", "
|
|
|
35292
35358
|
var SAFE_RUNTIME_SERVICE_LIFECYCLES = /* @__PURE__ */ new Set(["shared", "ephemeral"]);
|
|
35293
35359
|
function statusPathWithin(candidate, root) {
|
|
35294
35360
|
const rel = relative8(root, candidate);
|
|
35295
|
-
return rel === "" || !rel.startsWith("..") && !
|
|
35361
|
+
return rel === "" || !rel.startsWith("..") && !isAbsolute13(rel);
|
|
35296
35362
|
}
|
|
35297
35363
|
function normalizeRelativePath(root, filePath) {
|
|
35298
35364
|
return relative8(root, filePath).split(/[\\/]+/).join("/");
|
|
@@ -35443,7 +35509,7 @@ function sanitizeRuntimeService(entry) {
|
|
|
35443
35509
|
}
|
|
35444
35510
|
function readRuntimeServicesSnapshot(cwd) {
|
|
35445
35511
|
const snapshotPath = join25(resolve19(cwd), WORKSPACE_RUNTIME_SERVICES_FILENAME);
|
|
35446
|
-
if (!
|
|
35512
|
+
if (!existsSync18(snapshotPath)) return [];
|
|
35447
35513
|
try {
|
|
35448
35514
|
const parsed = JSON.parse(readFileSync20(snapshotPath, "utf8"));
|
|
35449
35515
|
const rawServices = Array.isArray(parsed) ? parsed : Array.isArray(parsed?.services) ? parsed.services : [];
|
|
@@ -35547,7 +35613,7 @@ function assertRequiredTaskAttachmentMaterialized(input, materialized) {
|
|
|
35547
35613
|
}
|
|
35548
35614
|
|
|
35549
35615
|
// src/amaster-runtime-daemon.mjs
|
|
35550
|
-
var CONNECTOR_VERSION = "0.1.13
|
|
35616
|
+
var CONNECTOR_VERSION = "0.1.13";
|
|
35551
35617
|
var CONNECTOR_CONTRACT_VERSION = "2026-06-04.v1";
|
|
35552
35618
|
var SUPPORTED_TASK_CONTEXT_VERSIONS = Object.freeze([TASK_CONTEXT_MANIFEST_VERSION, TASK_CONTEXT_V2]);
|
|
35553
35619
|
var daemonRequire = createRequire(import.meta.url);
|
|
@@ -35643,7 +35709,7 @@ function updateActiveRunWorkspaceManifest(commandId, manifestPath, patch = {}) {
|
|
|
35643
35709
|
}
|
|
35644
35710
|
function resultOutboxPendingCount(config) {
|
|
35645
35711
|
const dir = resultOutboxDir(config);
|
|
35646
|
-
if (!
|
|
35712
|
+
if (!existsSync19(dir)) return 0;
|
|
35647
35713
|
try {
|
|
35648
35714
|
let pending = 0;
|
|
35649
35715
|
for (const file of readdirSync14(dir).filter((name) => name.endsWith(".json"))) {
|
|
@@ -35721,7 +35787,7 @@ function piCompletionOutputType(event) {
|
|
|
35721
35787
|
}
|
|
35722
35788
|
function resultOutboxActiveRunCommands(config) {
|
|
35723
35789
|
const dir = resultOutboxDir(config);
|
|
35724
|
-
if (!
|
|
35790
|
+
if (!existsSync19(dir)) return [];
|
|
35725
35791
|
const outboxPending = resultOutboxPendingCount(config);
|
|
35726
35792
|
const entries = [];
|
|
35727
35793
|
for (const file of readdirSync14(dir).filter((name) => name.endsWith(".json")).sort()) {
|
|
@@ -35756,7 +35822,7 @@ function resultOutboxActiveRunCommands(config) {
|
|
|
35756
35822
|
}
|
|
35757
35823
|
function resultOutboxFailedRunCommands(config) {
|
|
35758
35824
|
const dir = resultOutboxInvalidDir(config);
|
|
35759
|
-
if (!
|
|
35825
|
+
if (!existsSync19(dir)) return [];
|
|
35760
35826
|
const entries = [];
|
|
35761
35827
|
for (const file of readdirSync14(dir).filter((name) => name.endsWith(".json")).sort().slice(-100)) {
|
|
35762
35828
|
let entry;
|
|
@@ -35874,7 +35940,7 @@ function safeSkillRootSummary(kind, source, pathValue) {
|
|
|
35874
35940
|
const skillDir = join26(pathValue, name);
|
|
35875
35941
|
try {
|
|
35876
35942
|
if (!statSync12(skillDir).isDirectory()) continue;
|
|
35877
|
-
if (!
|
|
35943
|
+
if (!existsSync19(join26(skillDir, "SKILL.md"))) continue;
|
|
35878
35944
|
skillCount += 1;
|
|
35879
35945
|
if (skillCount >= MAX_PI_CAPABILITY_SOURCE_ENTRIES) {
|
|
35880
35946
|
truncated = true;
|
|
@@ -36105,8 +36171,7 @@ function runtimeAdvertisedCapabilities(config) {
|
|
|
36105
36171
|
executors: config.executors,
|
|
36106
36172
|
browserCredentialAuth: inspectBrowserCredentialAuthReadiness(),
|
|
36107
36173
|
browserCredentialEnv: inspectBrowserCredentialEnvReadiness(),
|
|
36108
|
-
piWebSearchReady: inspectPiWebSearchReadiness()
|
|
36109
|
-
piWebFetchReady: inspectPiWebFetchReadiness()
|
|
36174
|
+
piWebSearchReady: inspectPiWebSearchReadiness()
|
|
36110
36175
|
});
|
|
36111
36176
|
}
|
|
36112
36177
|
function buildRegisterPayload(config) {
|
|
@@ -36693,10 +36758,10 @@ function buildActiveRunCommandStatus(config, entry) {
|
|
|
36693
36758
|
const base = {
|
|
36694
36759
|
...entry,
|
|
36695
36760
|
phase: readString(entry.phase) ?? "executing",
|
|
36696
|
-
managedWorkdirPresent: entry.workspacePath ?
|
|
36761
|
+
managedWorkdirPresent: entry.workspacePath ? existsSync19(entry.workspacePath) : false,
|
|
36697
36762
|
outboxPending: resultOutboxPendingCount(config)
|
|
36698
36763
|
};
|
|
36699
|
-
if (!entry.workspacePath || !
|
|
36764
|
+
if (!entry.workspacePath || !existsSync19(entry.workspacePath)) return base;
|
|
36700
36765
|
const manifestPath = entry.manifestPath ?? workspaceManifestPath(entry.workspacePath);
|
|
36701
36766
|
const status = readWorkspaceStatus(entry.workspacePath, { hashCache: workspaceStatusHashCache });
|
|
36702
36767
|
const artifactCandidates = status.artifacts.slice(0, 20);
|
|
@@ -36924,7 +36989,7 @@ function ensureBrowserSessionProfile(config, session) {
|
|
|
36924
36989
|
}
|
|
36925
36990
|
chmodSync9(userDataDir, 448);
|
|
36926
36991
|
const markerPath2 = join26(userDataDir, BROWSER_SESSION_PROFILE_OWNER_MARKER);
|
|
36927
|
-
if (
|
|
36992
|
+
if (existsSync19(markerPath2)) {
|
|
36928
36993
|
if (lstatSync16(markerPath2).isSymbolicLink()) {
|
|
36929
36994
|
throw new Error("browser_session_profile_identity_invalid");
|
|
36930
36995
|
}
|
|
@@ -36959,12 +37024,12 @@ function cleanupBrowserSessionProfile(config, value) {
|
|
|
36959
37024
|
if (!pathWithin3(userDataDir, profileRoot)) {
|
|
36960
37025
|
throw new Error("browser_session_profile_cleanup_invalid");
|
|
36961
37026
|
}
|
|
36962
|
-
if (!
|
|
37027
|
+
if (!existsSync19(userDataDir)) return { outcome: "absent", identity };
|
|
36963
37028
|
if (lstatSync16(userDataDir).isSymbolicLink() || !lstatSync16(userDataDir).isDirectory()) {
|
|
36964
37029
|
throw new Error("browser_session_profile_cleanup_invalid");
|
|
36965
37030
|
}
|
|
36966
37031
|
const markerPath2 = join26(userDataDir, BROWSER_SESSION_PROFILE_OWNER_MARKER);
|
|
36967
|
-
if (!
|
|
37032
|
+
if (!existsSync19(markerPath2) || lstatSync16(markerPath2).isSymbolicLink()) {
|
|
36968
37033
|
throw new Error("browser_session_profile_cleanup_invalid");
|
|
36969
37034
|
}
|
|
36970
37035
|
if (JSON.stringify(readJsonFile2(markerPath2)) !== JSON.stringify(identity)) {
|
|
@@ -37014,7 +37079,7 @@ function safeAgentInstructionMaterializationTarget(workspace, filePath) {
|
|
|
37014
37079
|
const raw = readString(filePath);
|
|
37015
37080
|
if (!raw || raw.includes("\0")) return null;
|
|
37016
37081
|
const normalized = raw.replace(/\\/g, "/");
|
|
37017
|
-
if (
|
|
37082
|
+
if (isAbsolute14(normalized)) return null;
|
|
37018
37083
|
const segments = normalized.split("/").filter(Boolean);
|
|
37019
37084
|
if (segments.length === 0 || segments.some((segment) => segment === "." || segment === "..")) return null;
|
|
37020
37085
|
const relativePath = segments.join("/");
|
|
@@ -37152,7 +37217,7 @@ function wikiTreePathForCommand(command, workspaceBindings) {
|
|
|
37152
37217
|
}
|
|
37153
37218
|
for (const candidate of candidates) {
|
|
37154
37219
|
try {
|
|
37155
|
-
if (
|
|
37220
|
+
if (existsSync19(candidate)) return candidate;
|
|
37156
37221
|
} catch {
|
|
37157
37222
|
}
|
|
37158
37223
|
}
|
|
@@ -37837,6 +37902,12 @@ function createLiveOutputLogger(config, command, executorKind, protectedValues =
|
|
|
37837
37902
|
let incrementalEventCount = 0;
|
|
37838
37903
|
let nonProgressEventCount = 0;
|
|
37839
37904
|
let unparsedLineCount = 0;
|
|
37905
|
+
const piDeltaCounts = { thinking: 0, text: 0, toolcall: 0 };
|
|
37906
|
+
const piDeltaBytes = { thinking: 0, text: 0, toolcall: 0 };
|
|
37907
|
+
let piAssistantMessageEndCount = 0;
|
|
37908
|
+
let piObservedAssistantOutputTokens = 0;
|
|
37909
|
+
let piMaxAssistantOutputTokens = 0;
|
|
37910
|
+
let piLengthStopCount = 0;
|
|
37840
37911
|
let lastPiAgentMessage = null;
|
|
37841
37912
|
let piTerminalOutput = null;
|
|
37842
37913
|
let executorSessionId = null;
|
|
@@ -37922,6 +37993,23 @@ function createLiveOutputLogger(config, command, executorKind, protectedValues =
|
|
|
37922
37993
|
jsonlEventCount += 1;
|
|
37923
37994
|
const eventType = countEventType(event);
|
|
37924
37995
|
const deltaType = asRecord(asRecord(event).assistantMessageEvent).type;
|
|
37996
|
+
if (executorKind === "pi") {
|
|
37997
|
+
const deltaKind = typeof deltaType === "string" && deltaType.endsWith("_delta") ? deltaType.slice(0, -"_delta".length) : null;
|
|
37998
|
+
if (deltaKind && Object.hasOwn(piDeltaCounts, deltaKind)) {
|
|
37999
|
+
piDeltaCounts[deltaKind] += 1;
|
|
38000
|
+
const delta = asRecord(asRecord(event).assistantMessageEvent).delta;
|
|
38001
|
+
if (typeof delta === "string") piDeltaBytes[deltaKind] += Buffer.byteLength(delta);
|
|
38002
|
+
}
|
|
38003
|
+
if (eventType === "message_end" && asRecord(asRecord(event).message).role === "assistant") {
|
|
38004
|
+
piAssistantMessageEndCount += 1;
|
|
38005
|
+
const message = asRecord(asRecord(event).message);
|
|
38006
|
+
const usage = asRecord(message.usage);
|
|
38007
|
+
const outputTokens = readNumber(usage.output ?? usage.outputTokens ?? usage.output_tokens, 0);
|
|
38008
|
+
piObservedAssistantOutputTokens += outputTokens;
|
|
38009
|
+
piMaxAssistantOutputTokens = Math.max(piMaxAssistantOutputTokens, outputTokens);
|
|
38010
|
+
if (readString(message.stopReason ?? message.stop_reason) === "length") piLengthStopCount += 1;
|
|
38011
|
+
}
|
|
38012
|
+
}
|
|
37925
38013
|
if (eventType === "message_update" && ["text_delta", "thinking_delta"].includes(deltaType) && !observedTimingEvents.has(deltaType)) {
|
|
37926
38014
|
observedTimingEvents.add(deltaType);
|
|
37927
38015
|
timing(deltaType === "text_delta" ? "first_text_delta" : "first_thinking_delta");
|
|
@@ -38271,7 +38359,7 @@ function createLiveOutputLogger(config, command, executorKind, protectedValues =
|
|
|
38271
38359
|
const rawOutputBytes = rawBytesByStream.stdout + rawBytesByStream.stderr;
|
|
38272
38360
|
const retainedBytes = retainedBytesByStream.stdout + retainedBytesByStream.stderr;
|
|
38273
38361
|
const retentionCompactedBytes = Math.max(0, rawOutputBytes - retainedBytes);
|
|
38274
|
-
const maxStreamBytes = Math.max(rawBytesByStream.stdout, rawBytesByStream.stderr);
|
|
38362
|
+
const maxStreamBytes = executorKind === "pi" ? Math.max(retainedBytesByStream.stdout, rawBytesByStream.stderr) : Math.max(rawBytesByStream.stdout, rawBytesByStream.stderr);
|
|
38275
38363
|
const normalizedFloodLimitBytes = readNumber(floodLimitBytes, 0);
|
|
38276
38364
|
return {
|
|
38277
38365
|
liveLogDelivery: {
|
|
@@ -38300,14 +38388,28 @@ function createLiveOutputLogger(config, command, executorKind, protectedValues =
|
|
|
38300
38388
|
unparsedLineCount,
|
|
38301
38389
|
...piToolArgumentTracker && piToolArgumentTracker.snapshot().mode !== "off" ? { toolArgumentAmplification: piToolArgumentTracker.snapshot() } : {},
|
|
38302
38390
|
eventTypeCounts: Object.fromEntries([...eventTypeCounts.entries()].sort(([left], [right]) => left.localeCompare(right))),
|
|
38391
|
+
...executorKind === "pi" ? {
|
|
38392
|
+
piGenerationSummary: {
|
|
38393
|
+
assistantMessageEndCount: piAssistantMessageEndCount,
|
|
38394
|
+
observedAssistantOutputTokens: piObservedAssistantOutputTokens,
|
|
38395
|
+
maxAssistantOutputTokens: piMaxAssistantOutputTokens,
|
|
38396
|
+
lengthStopCount: piLengthStopCount,
|
|
38397
|
+
deltaCounts: { ...piDeltaCounts },
|
|
38398
|
+
deltaBytes: { ...piDeltaBytes }
|
|
38399
|
+
}
|
|
38400
|
+
} : {},
|
|
38303
38401
|
...outputTokens > 0 ? {
|
|
38304
38402
|
outputTokens,
|
|
38305
38403
|
rawBytesPerOutputToken: Math.round(rawOutputBytes / outputTokens)
|
|
38306
38404
|
} : {},
|
|
38307
38405
|
...normalizedFloodLimitBytes > 0 ? {
|
|
38308
38406
|
floodLimitBytesPerStream: normalizedFloodLimitBytes,
|
|
38407
|
+
floodBasis: executorKind === "pi" ? "retained_stdout_and_raw_stderr" : "raw",
|
|
38309
38408
|
floodUtilization: Number((maxStreamBytes / normalizedFloodLimitBytes).toFixed(4)),
|
|
38310
|
-
floodHeadroomBytes: Math.max(0, normalizedFloodLimitBytes - maxStreamBytes)
|
|
38409
|
+
floodHeadroomBytes: Math.max(0, normalizedFloodLimitBytes - maxStreamBytes),
|
|
38410
|
+
...executorKind === "pi" ? {
|
|
38411
|
+
rawStdoutSafetyLimitBytes: Math.min(512 * 1024 * 1024, normalizedFloodLimitBytes * 8)
|
|
38412
|
+
} : {}
|
|
38311
38413
|
} : {}
|
|
38312
38414
|
};
|
|
38313
38415
|
}
|
|
@@ -38348,7 +38450,7 @@ function realOrResolvedPath(value) {
|
|
|
38348
38450
|
return resolve20(value);
|
|
38349
38451
|
}
|
|
38350
38452
|
}
|
|
38351
|
-
var LSOF_COMMAND = process.platform === "darwin" &&
|
|
38453
|
+
var LSOF_COMMAND = process.platform === "darwin" && existsSync19("/usr/sbin/lsof") ? "/usr/sbin/lsof" : "lsof";
|
|
38352
38454
|
function processCwdForPid(pid) {
|
|
38353
38455
|
if (process.platform === "linux") {
|
|
38354
38456
|
try {
|
|
@@ -38460,7 +38562,7 @@ function killWorkspaceResidentProcesses(cwd, processGroupId, options = {}) {
|
|
|
38460
38562
|
}
|
|
38461
38563
|
function walkManagedWorkdirs(root) {
|
|
38462
38564
|
const workdirs = [];
|
|
38463
|
-
if (!root || !
|
|
38565
|
+
if (!root || !existsSync19(root)) return workdirs;
|
|
38464
38566
|
const stack = [root];
|
|
38465
38567
|
while (stack.length > 0) {
|
|
38466
38568
|
const current = stack.pop();
|
|
@@ -38474,7 +38576,7 @@ function walkManagedWorkdirs(root) {
|
|
|
38474
38576
|
for (const entry of entries) {
|
|
38475
38577
|
if (!entry.isDirectory()) continue;
|
|
38476
38578
|
const fullPath = join26(current, entry.name);
|
|
38477
|
-
if (entry.name === "workdir" &&
|
|
38579
|
+
if (entry.name === "workdir" && existsSync19(workspaceManifestPath(fullPath))) {
|
|
38478
38580
|
workdirs.push(fullPath);
|
|
38479
38581
|
continue;
|
|
38480
38582
|
}
|
|
@@ -38513,7 +38615,7 @@ function manifestMatchesActiveRuntimeRef(manifest, refs, workdir = null) {
|
|
|
38513
38615
|
function buildOrphanReaperSample(root, workdir, manifest, residents) {
|
|
38514
38616
|
const relativeWorkdir = (() => {
|
|
38515
38617
|
const value = relative9(root, workdir);
|
|
38516
|
-
return value && !value.startsWith("..") && !
|
|
38618
|
+
return value && !value.startsWith("..") && !isAbsolute14(value) ? value : basename8(workdir);
|
|
38517
38619
|
})();
|
|
38518
38620
|
return {
|
|
38519
38621
|
workdir: relativeWorkdir,
|
|
@@ -38595,6 +38697,8 @@ function runExecutor(command, args, options) {
|
|
|
38595
38697
|
let completionOutputType = null;
|
|
38596
38698
|
let completionOutputHasFinalAssistantText = null;
|
|
38597
38699
|
let outputFlood = null;
|
|
38700
|
+
let piReasoningExhaustion = null;
|
|
38701
|
+
let piReasoningOnlyLengthCount = 0;
|
|
38598
38702
|
let argumentAmplification = null;
|
|
38599
38703
|
let toolExecutionGuard = null;
|
|
38600
38704
|
let memoryLimit = null;
|
|
@@ -38624,6 +38728,7 @@ function runExecutor(command, args, options) {
|
|
|
38624
38728
|
const retainedOutputBytes = { stdout: 0, stderr: 0 };
|
|
38625
38729
|
const piOutputRetentionCompactor = options.executorKind === "pi" ? createPiOutputRetentionCompactor() : null;
|
|
38626
38730
|
const maxOutputBytes = parsePositiveInteger(options.maxOutputBytes, 50 * 1024 * 1024);
|
|
38731
|
+
const maxRawStdoutBytes = options.executorKind === "pi" ? Math.min(512 * 1024 * 1024, maxOutputBytes * 8) : maxOutputBytes;
|
|
38627
38732
|
const maxRssMb = parsePositiveInteger(options.maxRssMb, 0);
|
|
38628
38733
|
const maxRssBytes = maxRssMb * 1024 * 1024;
|
|
38629
38734
|
const browserCredentialChannel = typeof options.browserCredentialConsumer === "function" ? createBrowserCredentialChannel({
|
|
@@ -38660,14 +38765,20 @@ function runExecutor(command, args, options) {
|
|
|
38660
38765
|
const retainedText = piOutputRetentionCompactor?.write(text2) ?? text2;
|
|
38661
38766
|
retainedOutputBytes.stdout += Buffer.byteLength(retainedText);
|
|
38662
38767
|
stdout = appendBounded(stdout, retainedText);
|
|
38663
|
-
if (
|
|
38768
|
+
if (piOutputRetentionCompactor && retainedOutputBytes.stdout > maxOutputBytes) {
|
|
38769
|
+
killForOutputFlood("stdout", "retained", retainedOutputBytes.stdout, maxOutputBytes);
|
|
38770
|
+
} else if (outputBytes.stdout > maxRawStdoutBytes) {
|
|
38771
|
+
killForOutputFlood("stdout", "raw", outputBytes.stdout, maxRawStdoutBytes);
|
|
38772
|
+
}
|
|
38664
38773
|
};
|
|
38665
38774
|
const handleStderrText = (text2, rawBytes) => {
|
|
38666
38775
|
outputBytes.stderr += rawBytes;
|
|
38667
38776
|
retainedOutputBytes.stderr += rawBytes;
|
|
38668
38777
|
stderr = appendBounded(stderr, text2);
|
|
38669
38778
|
options.onOutput?.("stderr", text2, rawBytes);
|
|
38670
|
-
if (outputBytes.stderr > maxOutputBytes)
|
|
38779
|
+
if (outputBytes.stderr > maxOutputBytes) {
|
|
38780
|
+
killForOutputFlood("stderr", "raw", outputBytes.stderr, maxOutputBytes);
|
|
38781
|
+
}
|
|
38671
38782
|
};
|
|
38672
38783
|
const stdoutDecoder = createUtf8StreamDecoder(handleStdoutText);
|
|
38673
38784
|
const stderrDecoder = createUtf8StreamDecoder(handleStderrText);
|
|
@@ -38680,6 +38791,16 @@ function runExecutor(command, args, options) {
|
|
|
38680
38791
|
const retainedTail = piOutputRetentionCompactor.flush();
|
|
38681
38792
|
retainedOutputBytes.stdout += Buffer.byteLength(retainedTail);
|
|
38682
38793
|
stdout = appendBounded(stdout, retainedTail);
|
|
38794
|
+
if (!outputFlood && retainedOutputBytes.stdout > maxOutputBytes) {
|
|
38795
|
+
outputFlood = {
|
|
38796
|
+
stream: "stdout",
|
|
38797
|
+
basis: "retained",
|
|
38798
|
+
bytes: retainedOutputBytes.stdout,
|
|
38799
|
+
limitBytes: maxOutputBytes,
|
|
38800
|
+
rawBytes: outputBytes.stdout,
|
|
38801
|
+
retainedBytes: retainedOutputBytes.stdout
|
|
38802
|
+
};
|
|
38803
|
+
}
|
|
38683
38804
|
}
|
|
38684
38805
|
if (timer) clearTimeout(timer);
|
|
38685
38806
|
if (rssTimer) clearInterval(rssTimer);
|
|
@@ -38697,6 +38818,7 @@ function runExecutor(command, args, options) {
|
|
|
38697
38818
|
outputBytes: { ...outputBytes },
|
|
38698
38819
|
retainedOutputBytes: { ...retainedOutputBytes },
|
|
38699
38820
|
outputFlood,
|
|
38821
|
+
piReasoningExhaustion,
|
|
38700
38822
|
argumentAmplification,
|
|
38701
38823
|
toolExecutionGuard,
|
|
38702
38824
|
memoryLimit,
|
|
@@ -38827,6 +38949,17 @@ function runExecutor(command, args, options) {
|
|
|
38827
38949
|
try {
|
|
38828
38950
|
const event = JSON.parse(trimmed);
|
|
38829
38951
|
const eventType = readString(asRecord(event).type);
|
|
38952
|
+
const reasoningExhaustion = piReasoningOnlyLengthEvent(event);
|
|
38953
|
+
if (reasoningExhaustion) {
|
|
38954
|
+
piReasoningOnlyLengthCount += 1;
|
|
38955
|
+
piReasoningExhaustion = reasoningExhaustion;
|
|
38956
|
+
if (piReasoningOnlyLengthCount > 1) {
|
|
38957
|
+
requestStop("pi_reasoning_output_exhausted");
|
|
38958
|
+
return;
|
|
38959
|
+
}
|
|
38960
|
+
} else if (eventType === "message_end" && asRecord(event.message).role === "assistant") {
|
|
38961
|
+
piReasoningExhaustion = null;
|
|
38962
|
+
}
|
|
38830
38963
|
if (eventType === "turn_end") {
|
|
38831
38964
|
latestPiTurnEndHasFinalAssistantText = piTurnEndHasFinalAssistantText(event);
|
|
38832
38965
|
}
|
|
@@ -38850,12 +38983,15 @@ function runExecutor(command, args, options) {
|
|
|
38850
38983
|
}
|
|
38851
38984
|
}
|
|
38852
38985
|
};
|
|
38853
|
-
const killForOutputFlood = (stream) => {
|
|
38986
|
+
const killForOutputFlood = (stream, basis, bytes, limitBytes) => {
|
|
38854
38987
|
if (settled || outputFlood) return;
|
|
38855
38988
|
outputFlood = {
|
|
38856
38989
|
stream,
|
|
38857
|
-
|
|
38858
|
-
|
|
38990
|
+
basis,
|
|
38991
|
+
bytes,
|
|
38992
|
+
limitBytes,
|
|
38993
|
+
rawBytes: outputBytes[stream],
|
|
38994
|
+
retainedBytes: retainedOutputBytes[stream]
|
|
38859
38995
|
};
|
|
38860
38996
|
requestStop("output_flood");
|
|
38861
38997
|
};
|
|
@@ -39252,7 +39388,7 @@ function runCompletionCoordinator(config) {
|
|
|
39252
39388
|
persist: (state) => persistPendingRunCompletion(configRef.current, state),
|
|
39253
39389
|
clear: (commandId) => clearPendingRunCompletion(configRef.current, commandId),
|
|
39254
39390
|
list: () => runCompletionStateEntries(configRef.current),
|
|
39255
|
-
exists: (filePath) =>
|
|
39391
|
+
exists: (filePath) => existsSync19(filePath),
|
|
39256
39392
|
read: (filePath) => readValidRunCompletionStateOrQuarantine(configRef.current, filePath),
|
|
39257
39393
|
snapshot: (state) => pendingRunCompletionSnapshot(configRef.current, state)
|
|
39258
39394
|
},
|
|
@@ -39591,7 +39727,7 @@ function quarantineResultOutboxEntry(config, fullPath, file, entry, reason, err)
|
|
|
39591
39727
|
}
|
|
39592
39728
|
async function flushResultOutbox(config) {
|
|
39593
39729
|
const dir = resultOutboxDir(config);
|
|
39594
|
-
if (!
|
|
39730
|
+
if (!existsSync19(dir)) return { attempted: 0, completed: 0 };
|
|
39595
39731
|
const files = readdirSync14(dir).filter((name) => name.endsWith(".json")).sort();
|
|
39596
39732
|
let completed = 0;
|
|
39597
39733
|
for (const file of files) {
|
|
@@ -40062,7 +40198,7 @@ function issueCheckpointDir(workspace) {
|
|
|
40062
40198
|
}
|
|
40063
40199
|
async function clearIssueCheckpoint(config, command, workspace, reason, consumedSource = null) {
|
|
40064
40200
|
const checkpointDir = issueCheckpointDir(workspace);
|
|
40065
|
-
if (!
|
|
40201
|
+
if (!existsSync19(checkpointDir)) return false;
|
|
40066
40202
|
if (consumedSource !== null) {
|
|
40067
40203
|
const sourceRunId = readString(consumedSource.sourceRunId);
|
|
40068
40204
|
if (!sourceRunId) return false;
|
|
@@ -40080,7 +40216,7 @@ async function clearIssueCheckpoint(config, command, workspace, reason, consumed
|
|
|
40080
40216
|
}
|
|
40081
40217
|
function safeCheckpointRelativePath(rawPath) {
|
|
40082
40218
|
const raw = String(rawPath ?? "").trim();
|
|
40083
|
-
if (
|
|
40219
|
+
if (isAbsolute14(raw) || /^[A-Za-z]:[\\/]/.test(raw)) return null;
|
|
40084
40220
|
const normalized = raw.split(/[\\/]+/).filter(Boolean).join("/");
|
|
40085
40221
|
if (!normalized || normalized.startsWith("../") || normalized.split("/").some((segment) => segment.startsWith("."))) return null;
|
|
40086
40222
|
if (normalized.startsWith("input-attachments/") || isRuntimeMetadataArtifactPath(normalized)) return null;
|
|
@@ -40137,7 +40273,7 @@ async function materializeIssueCheckpoint(config, command, workspace) {
|
|
|
40137
40273
|
});
|
|
40138
40274
|
}
|
|
40139
40275
|
const unavailable2 = { files: [], taskSessionRestored: false, checkpointExpiresAt: null };
|
|
40140
|
-
if (!
|
|
40276
|
+
if (!existsSync19(manifestPath)) {
|
|
40141
40277
|
if (expectedContinuation) throw new Error("continuation_checkpoint_unavailable: manifest_missing");
|
|
40142
40278
|
return unavailable2;
|
|
40143
40279
|
}
|
|
@@ -40187,7 +40323,7 @@ async function materializeIssueCheckpoint(config, command, workspace) {
|
|
|
40187
40323
|
if (!pathWithin3(sourceCandidate, filesRoot) || !pathWithin3(target, workspaceRoot)) {
|
|
40188
40324
|
throw new Error(`issue checkpoint path escapes its workspace: ${relativePath}`);
|
|
40189
40325
|
}
|
|
40190
|
-
if (!
|
|
40326
|
+
if (!existsSync19(sourceCandidate)) throw new Error(`issue checkpoint file is missing: ${relativePath}`);
|
|
40191
40327
|
const source = realpathSync12(sourceCandidate);
|
|
40192
40328
|
if (!pathWithin3(source, filesRoot) || !statSync12(source).isFile()) {
|
|
40193
40329
|
throw new Error(`issue checkpoint source escapes its storage root: ${relativePath}`);
|
|
@@ -40305,7 +40441,7 @@ async function saveIssueCheckpoint(config, command, workspace, candidates, optio
|
|
|
40305
40441
|
for (const candidate of selectedCandidates) {
|
|
40306
40442
|
const relativePath = safeCheckpointRelativePath(candidate.rawPath);
|
|
40307
40443
|
const source = readString(candidate.filePath);
|
|
40308
|
-
if (!relativePath || !source || !
|
|
40444
|
+
if (!relativePath || !source || !existsSync19(source) || !statSync12(source).isFile()) {
|
|
40309
40445
|
if (requiredPaths.length > 0 || options.taskSession) throw new Error(`continuation_checkpoint_file_unavailable: ${candidate.rawPath}`);
|
|
40310
40446
|
continue;
|
|
40311
40447
|
}
|
|
@@ -40358,12 +40494,12 @@ async function saveIssueCheckpoint(config, command, workspace, candidates, optio
|
|
|
40358
40494
|
};
|
|
40359
40495
|
writeFileSync15(join26(stagingDir, "manifest.json"), `${JSON.stringify(manifest, null, 2)}
|
|
40360
40496
|
`);
|
|
40361
|
-
const replacingExistingCheckpoint =
|
|
40497
|
+
const replacingExistingCheckpoint = existsSync19(checkpointDir);
|
|
40362
40498
|
if (replacingExistingCheckpoint) renameSync12(checkpointDir, backupDir);
|
|
40363
40499
|
try {
|
|
40364
40500
|
renameSync12(stagingDir, checkpointDir);
|
|
40365
40501
|
} catch (err) {
|
|
40366
|
-
if (replacingExistingCheckpoint &&
|
|
40502
|
+
if (replacingExistingCheckpoint && existsSync19(backupDir) && !existsSync19(checkpointDir)) {
|
|
40367
40503
|
renameSync12(backupDir, checkpointDir);
|
|
40368
40504
|
}
|
|
40369
40505
|
throw err;
|
|
@@ -40697,6 +40833,7 @@ async function executeRunCommand(config, command) {
|
|
|
40697
40833
|
nativeSession: asRecord(asRecord(executionCommand.payload).nativeSession),
|
|
40698
40834
|
portableNativeSession: restoredCheckpoint.portableNativeSession,
|
|
40699
40835
|
baseEnv: executorEnv,
|
|
40836
|
+
...browserSessionUserDataDir ? { browserRuntimePackageHome: BROWSER_AUTH_IMAGE_HOME } : {},
|
|
40700
40837
|
commandEnv: piProfileCommandEnv,
|
|
40701
40838
|
extraArgs: splitExtraArgs(process.env.AMASTER_PI_EXTRA_ARGS),
|
|
40702
40839
|
skillProfiles: readStringArray(asRecord(command.payload).skillProfiles),
|
|
@@ -40762,7 +40899,11 @@ async function executeRunCommand(config, command) {
|
|
|
40762
40899
|
if (executor.kind === "pi" && Array.isArray(managedMcpProfile.extensionArgs) && managedMcpProfile.extensionArgs.length > 0) {
|
|
40763
40900
|
invocation.args = [...invocation.args, ...managedMcpProfile.extensionArgs];
|
|
40764
40901
|
}
|
|
40765
|
-
|
|
40902
|
+
executorEnv = attachTrustedBrowserExecutorEnv(executorEnv, {
|
|
40903
|
+
authority: browserCredentialAuthority,
|
|
40904
|
+
userDataDir: browserSessionUserDataDir ?? (config.runnerKind === RUNNER_KIND_CLOUD_MANAGED ? companyBrowserProfileDir(executorEnv.PAPERCLIP_COMPANY_ID, process.env.AMASTER_COMPANY_PI_HOME_ROOT || "/data/companies") : null)
|
|
40905
|
+
});
|
|
40906
|
+
if (executor.kind === "pi" && browserSessionUserDataDir) {
|
|
40766
40907
|
invocation.args = [...invocation.args, ...browserCredentialAuthExtensionArgs(browserCredentialAuthority, executorEnv)];
|
|
40767
40908
|
executorEnv = { ...executorEnv, NODE_PATH: BROWSER_AUTH_IMAGE_NODE_PATH };
|
|
40768
40909
|
}
|
|
@@ -40774,10 +40915,15 @@ async function executeRunCommand(config, command) {
|
|
|
40774
40915
|
...managedMcpProfile.attestation
|
|
40775
40916
|
});
|
|
40776
40917
|
}
|
|
40777
|
-
|
|
40778
|
-
|
|
40779
|
-
|
|
40780
|
-
|
|
40918
|
+
if (!managedMcpProfile) {
|
|
40919
|
+
executorEnv = attachTrustedBrowserExecutorEnv(executorEnv, {
|
|
40920
|
+
authority: browserCredentialAuthority,
|
|
40921
|
+
userDataDir: browserSessionUserDataDir ?? (executor.kind === "pi" && config.runnerKind === RUNNER_KIND_CLOUD_MANAGED ? companyBrowserProfileDir(executorEnv.PAPERCLIP_COMPANY_ID, process.env.AMASTER_COMPANY_PI_HOME_ROOT || "/data/companies") : null)
|
|
40922
|
+
});
|
|
40923
|
+
}
|
|
40924
|
+
invocation.args.push(...browserCredentialExtensionArgs(browserCredentialPresentationKind, executorEnv, {
|
|
40925
|
+
managedBrowserSession: executor.kind === "pi" && Boolean(browserSessionUserDataDir)
|
|
40926
|
+
}));
|
|
40781
40927
|
executorEnv = withAuditCorrelationEnvironment(executorEnv, command);
|
|
40782
40928
|
if (Object.keys(trustedPiRuntimeAssertion).length > 0) {
|
|
40783
40929
|
throw new Error("pi_trusted_runtime_unsupported");
|
|
@@ -41392,6 +41538,8 @@ async function executeRunCommand(config, command) {
|
|
|
41392
41538
|
const argumentAmplificationError = hasArgumentAmplification ? `Pi Agent tool argument stream amplification stopped before execution: ${readNumber(argumentAmplification.transportArgumentBytes, 0)} transported byte(s), ${readNumber(argumentAmplification.materializedArgumentBytes, 0)} materialized byte(s)` : null;
|
|
41393
41539
|
const memoryLimitError = hasMemoryLimit ? `${executor.kind === "pi" ? "Pi Agent" : "Executor"} memory limit exceeded: RSS ${readNumber(memoryLimit.rssBytes, 0)} bytes exceeded ${readNumber(memoryLimit.limitBytes, config.executorMaxRssMb * 1024 * 1024)} bytes` : null;
|
|
41394
41540
|
const piUsageDiagnostic = executor.kind === "pi" && !hasOutputFlood && !hasArgumentAmplification && piOutputUsageMetadataMissing(parsed) ? "Pi Agent exited without usage metadata" : null;
|
|
41541
|
+
const piReasoningExhaustion = asRecord(execution.piReasoningExhaustion);
|
|
41542
|
+
const hasPiReasoningExhaustion = piReasoningExhaustion.stopReason === "length" && !cancelled && !hasOutputFlood && !hasArgumentAmplification && !hasMemoryLimit && execution.timedOut !== true && !execution.spawnError;
|
|
41395
41543
|
const completionOutputStopped = executor.kind === "pi" && piCompletionOutputStopped(execution);
|
|
41396
41544
|
const cleanupDisposition = executor.kind === "pi" && !cancelled && !hasOutputFlood && !hasArgumentAmplification && !hasMemoryLimit && execution.timedOut !== true && !execution.spawnError && execution.signal === null ? classifyPiTerminalCleanupDisposition(
|
|
41397
41545
|
{ ...parsed, mcpToolResults },
|
|
@@ -41412,7 +41560,7 @@ async function executeRunCommand(config, command) {
|
|
|
41412
41560
|
}
|
|
41413
41561
|
const parsedForValidation = parsed;
|
|
41414
41562
|
const effectiveCompletionOutputHasFinalAssistantText = terminalTextRepair?.succeeded === true ? true : execution.completionOutputHasFinalAssistantText;
|
|
41415
|
-
const piTurnLimitFailure = executor.kind === "pi" && !cancelled && !hasOutputFlood && !hasArgumentAmplification && !hasMemoryLimit && execution.timedOut !== true && !execution.spawnError ? classifyPiTurnLimitResult(parsedForValidation, {
|
|
41563
|
+
const piTurnLimitFailure = executor.kind === "pi" && !cancelled && !hasOutputFlood && !hasArgumentAmplification && !hasMemoryLimit && !hasPiReasoningExhaustion && execution.timedOut !== true && !execution.spawnError ? classifyPiTurnLimitResult(parsedForValidation, {
|
|
41416
41564
|
authoritativeTerminalDisposition: Boolean(terminalRunDisposition)
|
|
41417
41565
|
}) : null;
|
|
41418
41566
|
const piInvalidOutputError = executor.kind === "pi" ? piOutputValidationError(parsedForValidation, {
|
|
@@ -41423,13 +41571,13 @@ async function executeRunCommand(config, command) {
|
|
|
41423
41571
|
completionOutputType: execution.completionOutputType,
|
|
41424
41572
|
completionOutputHasFinalAssistantText: effectiveCompletionOutputHasFinalAssistantText
|
|
41425
41573
|
}) : null;
|
|
41426
|
-
const piOutputFailure = executor.kind === "pi" && !cancelled && !hasOutputFlood && !hasArgumentAmplification && !hasMemoryLimit && execution.timedOut !== true && !execution.spawnError ? classifyPiOutputFailure(parsedForValidation, {
|
|
41574
|
+
const piOutputFailure = executor.kind === "pi" && !cancelled && !hasOutputFlood && !hasArgumentAmplification && !hasMemoryLimit && !hasPiReasoningExhaustion && execution.timedOut !== true && !execution.spawnError ? classifyPiOutputFailure(parsedForValidation, {
|
|
41427
41575
|
exitCode: execution.exitCode,
|
|
41428
41576
|
stderr: execution.stderr,
|
|
41429
41577
|
invalidOutputError: piInvalidOutputError
|
|
41430
41578
|
}) : null;
|
|
41431
41579
|
const piProviderFailure = piOutputFailure?.errorCode !== "pi_executor_invalid_output" ? piOutputFailure : null;
|
|
41432
|
-
const parsedErrorMessage = outputFloodError ?? argumentAmplificationError ?? memoryLimitError ?? piTurnLimitFailure?.message ?? piInvalidOutputError ?? nativeSessionRolloutError ?? nativeSessionRolloutCleanupError ?? parsedForValidation.errorMessage;
|
|
41580
|
+
const parsedErrorMessage = outputFloodError ?? argumentAmplificationError ?? memoryLimitError ?? (hasPiReasoningExhaustion ? "Pi model exhausted its output on reasoning without a text answer or tool call" : null) ?? piTurnLimitFailure?.message ?? piInvalidOutputError ?? nativeSessionRolloutError ?? nativeSessionRolloutCleanupError ?? parsedForValidation.errorMessage;
|
|
41433
41581
|
const codexTransientFailure = executor.kind === "codex" && (execution.exitCode ?? 0) !== 0 ? classifyCodexTransientUpstreamError({
|
|
41434
41582
|
stdout: execution.stdout,
|
|
41435
41583
|
stderr: execution.stderr,
|
|
@@ -41509,8 +41657,11 @@ async function executeRunCommand(config, command) {
|
|
|
41509
41657
|
errorFamily: "validation",
|
|
41510
41658
|
outputFlood: {
|
|
41511
41659
|
stream: readString(outputFlood.stream),
|
|
41660
|
+
basis: readString(outputFlood.basis),
|
|
41512
41661
|
bytes: readNumber(outputFlood.bytes, 0),
|
|
41513
|
-
limitBytes: readNumber(outputFlood.limitBytes, config.executorMaxOutputBytes)
|
|
41662
|
+
limitBytes: readNumber(outputFlood.limitBytes, config.executorMaxOutputBytes),
|
|
41663
|
+
rawBytes: readNumber(outputFlood.rawBytes, 0),
|
|
41664
|
+
retainedBytes: readNumber(outputFlood.retainedBytes, 0)
|
|
41514
41665
|
}
|
|
41515
41666
|
} : {},
|
|
41516
41667
|
...hasArgumentAmplification ? {
|
|
@@ -41528,6 +41679,11 @@ async function executeRunCommand(config, command) {
|
|
|
41528
41679
|
limitBytes: readNumber(memoryLimit.limitBytes, config.executorMaxRssMb * 1024 * 1024)
|
|
41529
41680
|
}
|
|
41530
41681
|
} : {},
|
|
41682
|
+
...hasPiReasoningExhaustion ? {
|
|
41683
|
+
errorCode: "pi_reasoning_output_exhausted",
|
|
41684
|
+
errorFamily: "execution_limit",
|
|
41685
|
+
reasoningExhaustion: piReasoningExhaustion
|
|
41686
|
+
} : {},
|
|
41531
41687
|
...Array.isArray(execution.killedWorkspaceResidents) && execution.killedWorkspaceResidents.length > 0 ? {
|
|
41532
41688
|
killedWorkspaceResidents: execution.killedWorkspaceResidents
|
|
41533
41689
|
} : {},
|