@amaster.ai/employee-runtime-connector 0.1.4 → 0.1.6
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/amaster-runtime-daemon.mjs +809 -547
- package/dist/amaster-runtime.mjs +1 -1
- package/dist/pi-exact-source-read.mjs +213 -0
- package/dist/public-network-scope.mjs +120 -0
- package/package.json +1 -1
|
@@ -4333,7 +4333,8 @@ var ISSUE_RECOVERY_ACTION_KINDS = [
|
|
|
4333
4333
|
"active_run_watchdog",
|
|
4334
4334
|
"issue_graph_liveness",
|
|
4335
4335
|
"finalization_operator",
|
|
4336
|
-
"initialization_no_progress"
|
|
4336
|
+
"initialization_no_progress",
|
|
4337
|
+
"runtime_delivery_exhausted"
|
|
4337
4338
|
];
|
|
4338
4339
|
var ISSUE_PROGRESS_FINDING_CODES = [
|
|
4339
4340
|
"terminal",
|
|
@@ -5345,7 +5346,7 @@ var mirrorxGoalContextDeliveryReceiptSchema = external_exports.object({
|
|
|
5345
5346
|
promptSha256: external_exports.string().regex(/^[a-f0-9]{64}$/)
|
|
5346
5347
|
}).strict();
|
|
5347
5348
|
var amasterRuntimeConnectorCommandResultSchema = external_exports.object({
|
|
5348
|
-
sessionId: external_exports.string().max(2048).optional(),
|
|
5349
|
+
sessionId: external_exports.string().max(2048).nullable().optional(),
|
|
5349
5350
|
goalContextDeliveryReceipt: mirrorxGoalContextDeliveryReceiptSchema.optional()
|
|
5350
5351
|
}).catchall(external_exports.unknown());
|
|
5351
5352
|
var amasterRuntimeConnectorCompleteCommandSchema = external_exports.object({
|
|
@@ -5440,6 +5441,52 @@ var amasterRuntimeConnectorWorkspaceStatusIngestSchema = external_exports.object
|
|
|
5440
5441
|
metadata: external_exports.record(external_exports.unknown()).default({})
|
|
5441
5442
|
});
|
|
5442
5443
|
|
|
5444
|
+
// ../shared/src/external-wait-reasons.ts
|
|
5445
|
+
var EXTERNAL_WAIT_REASON_CODES = {
|
|
5446
|
+
browserMfaRequired: "browser_mfa_required",
|
|
5447
|
+
browserCaptchaRequired: "browser_captcha_required",
|
|
5448
|
+
browserSsoHandoffRequired: "browser_sso_handoff_required",
|
|
5449
|
+
browserHumanSessionHandoffRequired: "browser_human_session_handoff_required",
|
|
5450
|
+
wikiOperationContextMissing: "wiki_operation_context_missing",
|
|
5451
|
+
agentInsufficientBalance: "agent_insufficient_balance",
|
|
5452
|
+
heligeInsufficientBalance: "helige_insufficient_balance",
|
|
5453
|
+
businessDataSourceUnavailable: "business_data_source_unavailable",
|
|
5454
|
+
customerInputPending: "customer_input_pending",
|
|
5455
|
+
externalInputPending: "external_input_pending",
|
|
5456
|
+
externalApprovalPending: "external_approval_pending",
|
|
5457
|
+
externalDependencyPending: "external_dependency_pending",
|
|
5458
|
+
heligeGenerationInProgress: "helige_generation_in_progress",
|
|
5459
|
+
heligeNewTurnNotObserved: "helige_new_turn_not_observed",
|
|
5460
|
+
heligeGenerationStatusUnavailable: "helige_generation_status_unavailable"
|
|
5461
|
+
};
|
|
5462
|
+
var BROWSER_HUMAN_SESSION_HANDOFF_REASON_CODES = [
|
|
5463
|
+
EXTERNAL_WAIT_REASON_CODES.browserMfaRequired,
|
|
5464
|
+
EXTERNAL_WAIT_REASON_CODES.browserCaptchaRequired,
|
|
5465
|
+
EXTERNAL_WAIT_REASON_CODES.browserSsoHandoffRequired,
|
|
5466
|
+
EXTERNAL_WAIT_REASON_CODES.browserHumanSessionHandoffRequired
|
|
5467
|
+
];
|
|
5468
|
+
var GENERIC_EXTERNAL_INPUT_WAIT_REASON_CODES = [
|
|
5469
|
+
EXTERNAL_WAIT_REASON_CODES.customerInputPending,
|
|
5470
|
+
EXTERNAL_WAIT_REASON_CODES.externalInputPending
|
|
5471
|
+
];
|
|
5472
|
+
var GENERIC_EXTERNAL_APPROVAL_WAIT_REASON_CODES = [
|
|
5473
|
+
EXTERNAL_WAIT_REASON_CODES.externalApprovalPending
|
|
5474
|
+
];
|
|
5475
|
+
var GENERIC_EXTERNAL_DEPENDENCY_WAIT_REASON_CODES = [
|
|
5476
|
+
EXTERNAL_WAIT_REASON_CODES.externalDependencyPending
|
|
5477
|
+
];
|
|
5478
|
+
var HELIGE_GENERATION_MONITOR_REASON_CODES = [
|
|
5479
|
+
EXTERNAL_WAIT_REASON_CODES.heligeGenerationInProgress,
|
|
5480
|
+
EXTERNAL_WAIT_REASON_CODES.heligeNewTurnNotObserved,
|
|
5481
|
+
EXTERNAL_WAIT_REASON_CODES.heligeGenerationStatusUnavailable
|
|
5482
|
+
];
|
|
5483
|
+
|
|
5484
|
+
// ../shared/src/amaster-billing-recovery.ts
|
|
5485
|
+
var BILLING_WAIT_REASONS = /* @__PURE__ */ new Set([
|
|
5486
|
+
EXTERNAL_WAIT_REASON_CODES.heligeInsufficientBalance,
|
|
5487
|
+
EXTERNAL_WAIT_REASON_CODES.agentInsufficientBalance
|
|
5488
|
+
]);
|
|
5489
|
+
|
|
5443
5490
|
// ../shared/src/validators/mirrorx-agent-sessions.ts
|
|
5444
5491
|
var mirrorxAgentSessionGroupNameSchema = external_exports.string().trim().min(1).max(80);
|
|
5445
5492
|
var MIRRORX_AGENT_SESSION_GROUP_LIMIT = 100;
|
|
@@ -8742,6 +8789,9 @@ function canonicalizeTaskResourceLocator(value) {
|
|
|
8742
8789
|
if (parsed.username || parsed.password) {
|
|
8743
8790
|
return { ok: false, code: "userinfo_forbidden" };
|
|
8744
8791
|
}
|
|
8792
|
+
if (parsed.toString().length > 2048) {
|
|
8793
|
+
return { ok: false, code: "locator_too_long" };
|
|
8794
|
+
}
|
|
8745
8795
|
if (parsed.hash) {
|
|
8746
8796
|
return { ok: false, code: "fragment_forbidden" };
|
|
8747
8797
|
}
|
|
@@ -9068,8 +9118,212 @@ var mirrorxDiscoveryTriageCandidateInputSchema = external_exports.object({
|
|
|
9068
9118
|
}
|
|
9069
9119
|
});
|
|
9070
9120
|
|
|
9121
|
+
// ../shared/src/task-resource-input.ts
|
|
9122
|
+
var ATTACHMENT_PREPARATION_VERSION = "attachment-preparation-v1";
|
|
9123
|
+
var ORIGINAL_ONLY_PARSER_VERSION = "original-only-v1";
|
|
9124
|
+
var TASK_RESOURCE_INPUT_STATES = [
|
|
9125
|
+
"declared",
|
|
9126
|
+
"preparing",
|
|
9127
|
+
"prepared",
|
|
9128
|
+
"blocked",
|
|
9129
|
+
"retired"
|
|
9130
|
+
];
|
|
9131
|
+
var TASK_RESOURCE_LOCATOR_MAX_LENGTH = 2048;
|
|
9132
|
+
var ATTACHMENT_PREPARATION_FORMATS = ["text", "pdf", "docx", "xlsx", "pptx"];
|
|
9133
|
+
var BROWSER_CREDENTIAL_ROLES = ["username", "password"];
|
|
9134
|
+
var ONBOARDING_RESOURCE_LINK_PROVIDERS = [
|
|
9135
|
+
"feishu",
|
|
9136
|
+
"dingtalk",
|
|
9137
|
+
"wechat_work",
|
|
9138
|
+
"notion",
|
|
9139
|
+
"github_gitlab",
|
|
9140
|
+
"crm",
|
|
9141
|
+
"erp",
|
|
9142
|
+
"custom",
|
|
9143
|
+
"other"
|
|
9144
|
+
];
|
|
9145
|
+
var ONBOARDING_RESOURCE_LINK_CREATED_FROM = [
|
|
9146
|
+
"current_system",
|
|
9147
|
+
"manual_link",
|
|
9148
|
+
"legacy_document_link"
|
|
9149
|
+
];
|
|
9150
|
+
var sha256Schema5 = external_exports.string().regex(/^[a-f0-9]{64}$/u);
|
|
9151
|
+
var exactOriginSchema = external_exports.string().url().superRefine((value, context) => {
|
|
9152
|
+
const url = new URL(value);
|
|
9153
|
+
if (url.protocol !== "https:" || url.username || url.password || url.pathname !== "/" || url.search || url.hash || value !== url.origin) {
|
|
9154
|
+
context.addIssue({
|
|
9155
|
+
code: external_exports.ZodIssueCode.custom,
|
|
9156
|
+
message: "Origin must be an exact credential-free HTTPS origin"
|
|
9157
|
+
});
|
|
9158
|
+
}
|
|
9159
|
+
});
|
|
9160
|
+
var taskResourceLocatorSchema = external_exports.string().trim().min(1).max(TASK_RESOURCE_LOCATOR_MAX_LENGTH).transform((value, context) => {
|
|
9161
|
+
const result2 = canonicalizeTaskResourceLocator(value);
|
|
9162
|
+
if (!result2.ok) {
|
|
9163
|
+
context.addIssue({
|
|
9164
|
+
code: external_exports.ZodIssueCode.custom,
|
|
9165
|
+
message: `Task resource locator rejected: ${result2.code}`
|
|
9166
|
+
});
|
|
9167
|
+
return external_exports.NEVER;
|
|
9168
|
+
}
|
|
9169
|
+
return result2.locator;
|
|
9170
|
+
});
|
|
9171
|
+
var userSuppliedResourceLinkIntakeSchema = external_exports.object({
|
|
9172
|
+
sourceMessageId: external_exports.string().trim().min(1).max(255),
|
|
9173
|
+
targetIssueId: external_exports.string().uuid(),
|
|
9174
|
+
targetKey: external_exports.string().trim().min(1).max(500),
|
|
9175
|
+
body: external_exports.string().max(1e5),
|
|
9176
|
+
primaryLocator: taskResourceLocatorSchema.optional()
|
|
9177
|
+
}).strict();
|
|
9178
|
+
var onboardingResourceLinkSchema = external_exports.object({
|
|
9179
|
+
clientKey: external_exports.string().trim().min(1).max(128),
|
|
9180
|
+
kind: external_exports.literal("web"),
|
|
9181
|
+
provider: external_exports.enum(ONBOARDING_RESOURCE_LINK_PROVIDERS),
|
|
9182
|
+
displayName: external_exports.string().trim().min(1).max(500),
|
|
9183
|
+
locator: taskResourceLocatorSchema,
|
|
9184
|
+
scope: external_exports.string().trim().max(2e3).default(""),
|
|
9185
|
+
accessHint: external_exports.enum(["public", "may_require_auth", "unknown"]),
|
|
9186
|
+
criticality: external_exports.enum(["critical", "supporting"]),
|
|
9187
|
+
declaredPageLocators: external_exports.array(taskResourceLocatorSchema).max(100).default([]),
|
|
9188
|
+
createdFrom: external_exports.enum(ONBOARDING_RESOURCE_LINK_CREATED_FROM)
|
|
9189
|
+
}).strict().superRefine((resource, context) => {
|
|
9190
|
+
if (typeof resource.locator !== "string") return;
|
|
9191
|
+
const resourceOrigin = new URL(resource.locator).origin;
|
|
9192
|
+
resource.declaredPageLocators.forEach((locator, index) => {
|
|
9193
|
+
if (typeof locator === "string" && new URL(locator).origin !== resourceOrigin) {
|
|
9194
|
+
context.addIssue({
|
|
9195
|
+
code: external_exports.ZodIssueCode.custom,
|
|
9196
|
+
path: ["declaredPageLocators", index],
|
|
9197
|
+
message: "Declared page locator must use the same origin as the resource link"
|
|
9198
|
+
});
|
|
9199
|
+
}
|
|
9200
|
+
});
|
|
9201
|
+
});
|
|
9202
|
+
var attachmentPreparationReceiptSchema = external_exports.object({
|
|
9203
|
+
parserVersion: external_exports.literal(ATTACHMENT_PREPARATION_VERSION),
|
|
9204
|
+
originalSha256: sha256Schema5,
|
|
9205
|
+
sidecarSha256: sha256Schema5,
|
|
9206
|
+
originalBytes: external_exports.number().int().nonnegative(),
|
|
9207
|
+
sidecarBytes: external_exports.number().int().positive(),
|
|
9208
|
+
format: external_exports.enum(ATTACHMENT_PREPARATION_FORMATS),
|
|
9209
|
+
truncated: external_exports.boolean(),
|
|
9210
|
+
metadata: external_exports.record(external_exports.string(), external_exports.union([external_exports.string(), external_exports.number(), external_exports.boolean(), external_exports.null()]))
|
|
9211
|
+
}).strict();
|
|
9212
|
+
var taskResourceInputBaseSchema = external_exports.object({
|
|
9213
|
+
inputFingerprint: external_exports.string().trim().min(1).max(255),
|
|
9214
|
+
state: external_exports.enum(TASK_RESOURCE_INPUT_STATES),
|
|
9215
|
+
failureCode: external_exports.string().trim().min(1).max(160).nullable().optional()
|
|
9216
|
+
});
|
|
9217
|
+
var taskResourceInputSchema = external_exports.discriminatedUnion("kind", [
|
|
9218
|
+
taskResourceInputBaseSchema.extend({
|
|
9219
|
+
kind: external_exports.literal("link"),
|
|
9220
|
+
displayName: external_exports.string().trim().min(1).max(255),
|
|
9221
|
+
locator: external_exports.string().url().max(TASK_RESOURCE_LOCATOR_MAX_LENGTH),
|
|
9222
|
+
scope: external_exports.string().trim().min(1).max(2e3),
|
|
9223
|
+
preparationReceipt: external_exports.null().optional()
|
|
9224
|
+
}).strict(),
|
|
9225
|
+
taskResourceInputBaseSchema.extend({
|
|
9226
|
+
kind: external_exports.literal("attachment"),
|
|
9227
|
+
attachmentId: external_exports.string().uuid(),
|
|
9228
|
+
assetId: external_exports.string().uuid(),
|
|
9229
|
+
byteSize: external_exports.number().int().nonnegative(),
|
|
9230
|
+
sha256: sha256Schema5,
|
|
9231
|
+
parserVersion: external_exports.string().trim().min(1).max(120).nullable().optional(),
|
|
9232
|
+
sidecarAssetId: external_exports.string().uuid().nullable().optional(),
|
|
9233
|
+
preparationReceipt: attachmentPreparationReceiptSchema.nullable().optional()
|
|
9234
|
+
}).strict()
|
|
9235
|
+
]).superRefine((value, context) => {
|
|
9236
|
+
if (value.kind !== "attachment") return;
|
|
9237
|
+
const originalOnly = value.parserVersion === ORIGINAL_ONLY_PARSER_VERSION;
|
|
9238
|
+
if (value.state === "prepared" && !value.preparationReceipt && !originalOnly) {
|
|
9239
|
+
context.addIssue({
|
|
9240
|
+
code: external_exports.ZodIssueCode.custom,
|
|
9241
|
+
path: ["preparationReceipt"],
|
|
9242
|
+
message: "Prepared attachment input requires a complete preparation receipt"
|
|
9243
|
+
});
|
|
9244
|
+
}
|
|
9245
|
+
if (originalOnly && (value.preparationReceipt || value.sidecarAssetId)) {
|
|
9246
|
+
context.addIssue({
|
|
9247
|
+
code: external_exports.ZodIssueCode.custom,
|
|
9248
|
+
path: ["preparationReceipt"],
|
|
9249
|
+
message: "Original-only attachment input must not carry a preparation sidecar"
|
|
9250
|
+
});
|
|
9251
|
+
}
|
|
9252
|
+
if (value.preparationReceipt && (value.preparationReceipt.originalSha256 !== value.sha256 || value.preparationReceipt.originalBytes !== value.byteSize)) {
|
|
9253
|
+
context.addIssue({
|
|
9254
|
+
code: external_exports.ZodIssueCode.custom,
|
|
9255
|
+
path: ["preparationReceipt"],
|
|
9256
|
+
message: "Preparation receipt must match the exact original attachment"
|
|
9257
|
+
});
|
|
9258
|
+
}
|
|
9259
|
+
});
|
|
9260
|
+
var browserCredentialRefAuthoritySchema = external_exports.object({
|
|
9261
|
+
version: external_exports.literal(1),
|
|
9262
|
+
companyId: external_exports.string().uuid(),
|
|
9263
|
+
issueId: external_exports.string().uuid(),
|
|
9264
|
+
runId: external_exports.string().uuid(),
|
|
9265
|
+
commandId: external_exports.string().uuid(),
|
|
9266
|
+
interactionId: external_exports.string().uuid(),
|
|
9267
|
+
credentialKey: external_exports.string().trim().min(1).max(255),
|
|
9268
|
+
credentialVersion: external_exports.number().int().positive(),
|
|
9269
|
+
credentialRole: external_exports.enum(BROWSER_CREDENTIAL_ROLES),
|
|
9270
|
+
targetOrigin: exactOriginSchema,
|
|
9271
|
+
authenticationOrigin: exactOriginSchema,
|
|
9272
|
+
bindingId: external_exports.string().uuid(),
|
|
9273
|
+
browserLeaseId: external_exports.string().regex(/^browser-credential-(?:auth-write|agent-read)-[0-9a-f-]{36}$/iu)
|
|
9274
|
+
}).strict();
|
|
9275
|
+
var browserCredentialRefConsumeSchema = browserCredentialRefAuthoritySchema.extend({
|
|
9276
|
+
controlSemantic: external_exports.enum(["username", "email", "password"])
|
|
9277
|
+
}).strict();
|
|
9278
|
+
var runtimeWebEvidenceReceiptSchema = external_exports.object({
|
|
9279
|
+
issueId: external_exports.string().uuid(),
|
|
9280
|
+
runId: external_exports.string().uuid(),
|
|
9281
|
+
commandId: external_exports.string().uuid(),
|
|
9282
|
+
toolCallId: external_exports.string().trim().min(1).max(255),
|
|
9283
|
+
requestedUrl: external_exports.string().url().max(2048),
|
|
9284
|
+
finalUrl: external_exports.string().url().max(2048),
|
|
9285
|
+
capturedAt: external_exports.string().datetime({ offset: true }),
|
|
9286
|
+
mediaType: external_exports.string().trim().min(1).max(255),
|
|
9287
|
+
truncated: external_exports.boolean(),
|
|
9288
|
+
contentSha256: sha256Schema5,
|
|
9289
|
+
observedChars: external_exports.number().int().nonnegative(),
|
|
9290
|
+
observedBytes: external_exports.number().int().nonnegative(),
|
|
9291
|
+
evidenceAssetId: external_exports.string().uuid().nullable().optional(),
|
|
9292
|
+
taskResourceBinding: external_exports.object({
|
|
9293
|
+
inputId: external_exports.string().uuid(),
|
|
9294
|
+
inputFingerprint: external_exports.string().trim().min(1).max(255),
|
|
9295
|
+
retrievalRevision: external_exports.number().int().positive()
|
|
9296
|
+
}).strict().optional()
|
|
9297
|
+
}).strict();
|
|
9298
|
+
var runtimeWebEvidenceIngestSchema = external_exports.object({
|
|
9299
|
+
companyId: external_exports.string().uuid(),
|
|
9300
|
+
issueId: external_exports.string().uuid(),
|
|
9301
|
+
runId: external_exports.string().uuid(),
|
|
9302
|
+
commandId: external_exports.string().uuid(),
|
|
9303
|
+
toolCallId: external_exports.string().trim().min(1).max(255),
|
|
9304
|
+
requestedUrl: external_exports.string().url().max(8192),
|
|
9305
|
+
finalUrl: external_exports.string().url().max(8192),
|
|
9306
|
+
capturedAt: external_exports.string().datetime({ offset: true }),
|
|
9307
|
+
mediaType: external_exports.string().trim().min(1).max(255),
|
|
9308
|
+
normalizedText: external_exports.string().max(2e6),
|
|
9309
|
+
truncated: external_exports.boolean().optional(),
|
|
9310
|
+
taskResourceBinding: external_exports.object({
|
|
9311
|
+
inputId: external_exports.string().uuid(),
|
|
9312
|
+
inputFingerprint: external_exports.string().trim().min(1).max(255),
|
|
9313
|
+
retrievalRevision: external_exports.number().int().positive()
|
|
9314
|
+
}).strict().optional()
|
|
9315
|
+
}).strict();
|
|
9316
|
+
var createTaskResourceLinkRequestSchema = external_exports.object({
|
|
9317
|
+
displayName: external_exports.string().trim().min(1).max(500),
|
|
9318
|
+
locator: taskResourceLocatorSchema,
|
|
9319
|
+
scope: external_exports.string().trim().min(1).max(2e3),
|
|
9320
|
+
criticality: external_exports.enum(["critical", "supporting"]).default("supporting")
|
|
9321
|
+
}).strict();
|
|
9322
|
+
var finalizeTaskResourceAttachmentRequestSchema = external_exports.object({ inputId: external_exports.string().uuid() }).strict();
|
|
9323
|
+
var createTaskResourceAttachmentRequestSchema = external_exports.object({ attachmentId: external_exports.string().uuid() }).strict();
|
|
9324
|
+
|
|
9071
9325
|
// ../shared/src/mirrorx-discovery-governance.ts
|
|
9072
|
-
var
|
|
9326
|
+
var sha256Schema6 = external_exports.string().regex(/^sha256:[a-f0-9]{64}$/);
|
|
9073
9327
|
var positiveBoundedInteger = (max) => external_exports.number().int().positive().max(max);
|
|
9074
9328
|
var mirrorxDiscoveryPromotionModeSchema = external_exports.enum(["shadow", "board_gated"]);
|
|
9075
9329
|
var customerFeedbackSourceBindingV1Schema = external_exports.object({
|
|
@@ -9077,7 +9331,7 @@ var customerFeedbackSourceBindingV1Schema = external_exports.object({
|
|
|
9077
9331
|
connectionId: external_exports.string().uuid(),
|
|
9078
9332
|
providerKey: external_exports.string().trim().min(1).max(160),
|
|
9079
9333
|
objectType: external_exports.literal("customer_feedback"),
|
|
9080
|
-
queryScopeHash:
|
|
9334
|
+
queryScopeHash: sha256Schema6,
|
|
9081
9335
|
wikiId: external_exports.string().trim().min(1).max(160),
|
|
9082
9336
|
wikiSpaceSlug: external_exports.string().trim().min(1).max(120).regex(/^[a-z0-9][a-z0-9._-]*$/),
|
|
9083
9337
|
wikiPagePath: external_exports.string().trim().min(1).max(500)
|
|
@@ -9098,48 +9352,72 @@ var customerFeedbackDiscoveryConfigurationV1Schema = external_exports.object({
|
|
|
9098
9352
|
var openConnectorDiscoverySourceSchema = external_exports.object({
|
|
9099
9353
|
service: external_exports.string().trim().min(1).max(128),
|
|
9100
9354
|
connectionName: external_exports.string().trim().min(1).max(256).nullable(),
|
|
9101
|
-
connectionKeyHash:
|
|
9355
|
+
connectionKeyHash: sha256Schema6,
|
|
9102
9356
|
actions: external_exports.array(external_exports.object({
|
|
9103
9357
|
actionId: external_exports.string().trim().min(1).max(256),
|
|
9104
|
-
guideHash:
|
|
9358
|
+
guideHash: sha256Schema6,
|
|
9105
9359
|
inputSchema: external_exports.record(external_exports.string(), external_exports.unknown())
|
|
9106
9360
|
}).strict()).min(1).max(20)
|
|
9107
9361
|
}).strict();
|
|
9108
9362
|
var discoveryReadGrantsSchema = external_exports.array(external_exports.object({
|
|
9109
9363
|
service: external_exports.string().trim().min(1).max(128),
|
|
9110
9364
|
actionId: external_exports.string().trim().min(1).max(256),
|
|
9111
|
-
guideHash:
|
|
9365
|
+
guideHash: sha256Schema6
|
|
9112
9366
|
}).strict()).max(100);
|
|
9113
9367
|
var discoveryResearchSourceBindingV1Schema = external_exports.object({
|
|
9114
9368
|
version: external_exports.literal(1),
|
|
9115
9369
|
connectionId: external_exports.string().uuid(),
|
|
9116
9370
|
providerKey: external_exports.string().trim().min(1).max(160),
|
|
9117
9371
|
objectType: external_exports.string().trim().min(1).max(160).regex(/^[a-z0-9][a-z0-9._-]*$/),
|
|
9118
|
-
queryScopeHash:
|
|
9372
|
+
queryScopeHash: sha256Schema6,
|
|
9119
9373
|
openConnector: openConnectorDiscoverySourceSchema.optional()
|
|
9120
9374
|
}).strict();
|
|
9121
9375
|
var openConnectorDiscoveryActionV2Schema = external_exports.object({
|
|
9122
9376
|
actionId: external_exports.string().trim().min(1).max(256),
|
|
9123
|
-
guideHash:
|
|
9377
|
+
guideHash: sha256Schema6,
|
|
9124
9378
|
inputSchema: external_exports.record(external_exports.string(), external_exports.unknown()),
|
|
9125
9379
|
outputSchema: external_exports.record(external_exports.string(), external_exports.unknown()),
|
|
9126
9380
|
followUpActions: external_exports.array(external_exports.object({
|
|
9127
9381
|
actionId: external_exports.string().trim().min(1).max(256)
|
|
9128
9382
|
}).strict()).max(20)
|
|
9129
9383
|
}).strict();
|
|
9130
|
-
var
|
|
9384
|
+
var governedProviderDiscoverySourceBindingV2Schema = external_exports.object({
|
|
9131
9385
|
version: external_exports.literal(2),
|
|
9132
9386
|
connectionId: external_exports.string().uuid(),
|
|
9133
9387
|
providerKey: external_exports.string().trim().min(1).max(160),
|
|
9134
9388
|
objectType: external_exports.string().trim().min(1).max(160).regex(/^[a-z0-9][a-z0-9._-]*$/),
|
|
9135
|
-
queryScopeHash:
|
|
9389
|
+
queryScopeHash: sha256Schema6,
|
|
9136
9390
|
openConnector: external_exports.object({
|
|
9137
9391
|
service: external_exports.string().trim().min(1).max(128),
|
|
9138
9392
|
connectionName: external_exports.string().trim().min(1).max(256).nullable(),
|
|
9139
|
-
connectionKeyHash:
|
|
9393
|
+
connectionKeyHash: sha256Schema6,
|
|
9140
9394
|
actions: external_exports.array(openConnectorDiscoveryActionV2Schema).min(1).max(20)
|
|
9141
9395
|
}).strict()
|
|
9142
9396
|
}).strict();
|
|
9397
|
+
var taskResourceDiscoverySourceBindingV1Schema = external_exports.object({
|
|
9398
|
+
version: external_exports.literal(3),
|
|
9399
|
+
sourceKind: external_exports.literal("task_resource"),
|
|
9400
|
+
connectionId: external_exports.string().uuid(),
|
|
9401
|
+
inputId: external_exports.string().uuid(),
|
|
9402
|
+
targetIssueId: external_exports.string().uuid(),
|
|
9403
|
+
inputFingerprint: external_exports.string().trim().min(1).max(255),
|
|
9404
|
+
locator: external_exports.string().url().max(TASK_RESOURCE_LOCATOR_MAX_LENGTH),
|
|
9405
|
+
locatorFingerprint: external_exports.string().regex(/^[a-f0-9]{64}$/u),
|
|
9406
|
+
intent: external_exports.enum(["primary", "supporting"]),
|
|
9407
|
+
sourceMessageId: external_exports.string().trim().min(1).max(255),
|
|
9408
|
+
suppliedBy: external_exports.object({
|
|
9409
|
+
kind: external_exports.literal("user"),
|
|
9410
|
+
id: external_exports.string().trim().min(1).max(200)
|
|
9411
|
+
}).strict(),
|
|
9412
|
+
suppliedAt: external_exports.string().datetime({ offset: true }),
|
|
9413
|
+
retrievalRevision: external_exports.number().int().positive(),
|
|
9414
|
+
authority: external_exports.literal("user_supplied_context_only"),
|
|
9415
|
+
openConnector: external_exports.never().optional()
|
|
9416
|
+
}).strict();
|
|
9417
|
+
var discoveryResearchSourceBindingV2Schema = external_exports.union([
|
|
9418
|
+
governedProviderDiscoverySourceBindingV2Schema,
|
|
9419
|
+
taskResourceDiscoverySourceBindingV1Schema
|
|
9420
|
+
]);
|
|
9143
9421
|
var discoveryResearchBriefV1Schema = external_exports.object({
|
|
9144
9422
|
version: external_exports.literal(1),
|
|
9145
9423
|
objective: external_exports.string().trim().min(1).max(2e3),
|
|
@@ -9167,7 +9445,7 @@ var frozenDiscoveryResearchV1Schema = external_exports.object({
|
|
|
9167
9445
|
goalId: external_exports.string().uuid(),
|
|
9168
9446
|
goalRevision: external_exports.string().trim().min(1).max(160),
|
|
9169
9447
|
criterionIndex: external_exports.number().int().min(0).max(1e3),
|
|
9170
|
-
sourceBindingRevision:
|
|
9448
|
+
sourceBindingRevision: sha256Schema6,
|
|
9171
9449
|
sourceBinding: discoveryResearchSourceBindingV1Schema,
|
|
9172
9450
|
maxRuntimeMs: positiveBoundedInteger(864e5),
|
|
9173
9451
|
maxProviderReads: positiveBoundedInteger(100),
|
|
@@ -9185,7 +9463,7 @@ var discoveryResearchTargetV2Schema = external_exports.object({
|
|
|
9185
9463
|
gapId: external_exports.string().uuid().nullable(),
|
|
9186
9464
|
gapAuthorityRevision: external_exports.number().int().positive().nullable(),
|
|
9187
9465
|
selectionRevision: external_exports.number().int().positive(),
|
|
9188
|
-
candidateSetHash:
|
|
9466
|
+
candidateSetHash: sha256Schema6,
|
|
9189
9467
|
resetReason: external_exports.enum(["goal_revision_changed", "candidate_set_changed"]).nullable()
|
|
9190
9468
|
}).strict().superRefine((value, ctx) => {
|
|
9191
9469
|
if (value.kind === "gap" && (!value.gapId || !value.gapAuthorityRevision)) {
|
|
@@ -9204,7 +9482,7 @@ var frozenDiscoveryResearchV2Schema = external_exports.object({
|
|
|
9204
9482
|
goalId: external_exports.string().uuid(),
|
|
9205
9483
|
goalRevision: external_exports.string().trim().min(1).max(160),
|
|
9206
9484
|
target: discoveryResearchTargetV2Schema,
|
|
9207
|
-
sourceBindingRevision:
|
|
9485
|
+
sourceBindingRevision: sha256Schema6,
|
|
9208
9486
|
sourceBinding: discoveryResearchSourceBindingV2Schema,
|
|
9209
9487
|
coverageMode: external_exports.literal("targeted_goal_criterion"),
|
|
9210
9488
|
maxProviderReads: positiveBoundedInteger(100),
|
|
@@ -9245,12 +9523,12 @@ var frozenDiscoveryResearchSchema = external_exports.union([
|
|
|
9245
9523
|
]);
|
|
9246
9524
|
var discoveryProviderEvidenceReceiptV1Schema = external_exports.object({
|
|
9247
9525
|
version: external_exports.literal(1),
|
|
9248
|
-
sourceBindingRevision:
|
|
9526
|
+
sourceBindingRevision: sha256Schema6,
|
|
9249
9527
|
providerReceipt: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
|
|
9250
9528
|
evidence: external_exports.array(external_exports.object({
|
|
9251
9529
|
externalObjectId: external_exports.string().uuid(),
|
|
9252
9530
|
sourceRevision: external_exports.string().trim().min(1).max(500),
|
|
9253
|
-
contentHash:
|
|
9531
|
+
contentHash: sha256Schema6.optional(),
|
|
9254
9532
|
snapshot: external_exports.object({
|
|
9255
9533
|
displayTitle: external_exports.string().nullable(),
|
|
9256
9534
|
data: external_exports.record(external_exports.string(), external_exports.unknown())
|
|
@@ -9299,7 +9577,7 @@ var completeDiscoveryResearchInputV2Fields = {
|
|
|
9299
9577
|
invocationId: external_exports.string().uuid(),
|
|
9300
9578
|
externalObjectId: external_exports.string().uuid().nullable(),
|
|
9301
9579
|
sourceRevision: external_exports.string().trim().min(1).max(500).nullable(),
|
|
9302
|
-
contentHash:
|
|
9580
|
+
contentHash: sha256Schema6.nullable()
|
|
9303
9581
|
}).strict()).max(1e4),
|
|
9304
9582
|
coverageComplete: external_exports.boolean(),
|
|
9305
9583
|
summary: external_exports.string().trim().min(1).max(4e3),
|
|
@@ -9541,7 +9819,7 @@ var mirrorxDiscoveryCoverageSchema = external_exports.object({
|
|
|
9541
9819
|
currentRun: external_exports.object({
|
|
9542
9820
|
routineRunId: external_exports.string().uuid(),
|
|
9543
9821
|
state: external_exports.enum(["scheduled", "running", "waiting_retry", "finalizing"]),
|
|
9544
|
-
windowKey:
|
|
9822
|
+
windowKey: sha256Schema6,
|
|
9545
9823
|
nextAttemptAt: external_exports.string().datetime({ offset: true }).nullable()
|
|
9546
9824
|
}).strict().nullable(),
|
|
9547
9825
|
lastTerminal: external_exports.object({
|
|
@@ -9631,192 +9909,6 @@ function resolveMirrorxWorkKindPurpose(workKind) {
|
|
|
9631
9909
|
return domain ? resolveMirrorxWorkPurposeSelection({ kind: "activation_domain", domain }) : { status: "unmapped", workKind };
|
|
9632
9910
|
}
|
|
9633
9911
|
|
|
9634
|
-
// ../shared/src/task-resource-input.ts
|
|
9635
|
-
var ATTACHMENT_PREPARATION_VERSION = "attachment-preparation-v1";
|
|
9636
|
-
var ORIGINAL_ONLY_PARSER_VERSION = "original-only-v1";
|
|
9637
|
-
var TASK_RESOURCE_INPUT_STATES = [
|
|
9638
|
-
"declared",
|
|
9639
|
-
"preparing",
|
|
9640
|
-
"prepared",
|
|
9641
|
-
"blocked",
|
|
9642
|
-
"retired"
|
|
9643
|
-
];
|
|
9644
|
-
var ATTACHMENT_PREPARATION_FORMATS = ["text", "pdf", "docx", "xlsx", "pptx"];
|
|
9645
|
-
var BROWSER_CREDENTIAL_ROLES = ["username", "password"];
|
|
9646
|
-
var ONBOARDING_RESOURCE_LINK_PROVIDERS = [
|
|
9647
|
-
"feishu",
|
|
9648
|
-
"dingtalk",
|
|
9649
|
-
"wechat_work",
|
|
9650
|
-
"notion",
|
|
9651
|
-
"github_gitlab",
|
|
9652
|
-
"crm",
|
|
9653
|
-
"erp",
|
|
9654
|
-
"custom",
|
|
9655
|
-
"other"
|
|
9656
|
-
];
|
|
9657
|
-
var ONBOARDING_RESOURCE_LINK_CREATED_FROM = [
|
|
9658
|
-
"current_system",
|
|
9659
|
-
"manual_link",
|
|
9660
|
-
"legacy_document_link"
|
|
9661
|
-
];
|
|
9662
|
-
var sha256Schema6 = external_exports.string().regex(/^[a-f0-9]{64}$/u);
|
|
9663
|
-
var exactOriginSchema = external_exports.string().url().superRefine((value, context) => {
|
|
9664
|
-
const url = new URL(value);
|
|
9665
|
-
if (url.protocol !== "https:" || url.username || url.password || url.pathname !== "/" || url.search || url.hash || value !== url.origin) {
|
|
9666
|
-
context.addIssue({
|
|
9667
|
-
code: external_exports.ZodIssueCode.custom,
|
|
9668
|
-
message: "Origin must be an exact credential-free HTTPS origin"
|
|
9669
|
-
});
|
|
9670
|
-
}
|
|
9671
|
-
});
|
|
9672
|
-
var taskResourceLocatorSchema = external_exports.string().trim().min(1).max(8192).transform((value, context) => {
|
|
9673
|
-
const result2 = canonicalizeTaskResourceLocator(value);
|
|
9674
|
-
if (!result2.ok) {
|
|
9675
|
-
context.addIssue({
|
|
9676
|
-
code: external_exports.ZodIssueCode.custom,
|
|
9677
|
-
message: `Task resource locator rejected: ${result2.code}`
|
|
9678
|
-
});
|
|
9679
|
-
return external_exports.NEVER;
|
|
9680
|
-
}
|
|
9681
|
-
return result2.locator;
|
|
9682
|
-
});
|
|
9683
|
-
var onboardingResourceLinkSchema = external_exports.object({
|
|
9684
|
-
clientKey: external_exports.string().trim().min(1).max(128),
|
|
9685
|
-
kind: external_exports.literal("web"),
|
|
9686
|
-
provider: external_exports.enum(ONBOARDING_RESOURCE_LINK_PROVIDERS),
|
|
9687
|
-
displayName: external_exports.string().trim().min(1).max(500),
|
|
9688
|
-
locator: taskResourceLocatorSchema,
|
|
9689
|
-
scope: external_exports.string().trim().max(2e3).default(""),
|
|
9690
|
-
accessHint: external_exports.enum(["public", "may_require_auth", "unknown"]),
|
|
9691
|
-
criticality: external_exports.enum(["critical", "supporting"]),
|
|
9692
|
-
declaredPageLocators: external_exports.array(taskResourceLocatorSchema).max(100).default([]),
|
|
9693
|
-
createdFrom: external_exports.enum(ONBOARDING_RESOURCE_LINK_CREATED_FROM)
|
|
9694
|
-
}).strict().superRefine((resource, context) => {
|
|
9695
|
-
if (typeof resource.locator !== "string") return;
|
|
9696
|
-
const resourceOrigin = new URL(resource.locator).origin;
|
|
9697
|
-
resource.declaredPageLocators.forEach((locator, index) => {
|
|
9698
|
-
if (typeof locator === "string" && new URL(locator).origin !== resourceOrigin) {
|
|
9699
|
-
context.addIssue({
|
|
9700
|
-
code: external_exports.ZodIssueCode.custom,
|
|
9701
|
-
path: ["declaredPageLocators", index],
|
|
9702
|
-
message: "Declared page locator must use the same origin as the resource link"
|
|
9703
|
-
});
|
|
9704
|
-
}
|
|
9705
|
-
});
|
|
9706
|
-
});
|
|
9707
|
-
var attachmentPreparationReceiptSchema = external_exports.object({
|
|
9708
|
-
parserVersion: external_exports.literal(ATTACHMENT_PREPARATION_VERSION),
|
|
9709
|
-
originalSha256: sha256Schema6,
|
|
9710
|
-
sidecarSha256: sha256Schema6,
|
|
9711
|
-
originalBytes: external_exports.number().int().nonnegative(),
|
|
9712
|
-
sidecarBytes: external_exports.number().int().positive(),
|
|
9713
|
-
format: external_exports.enum(ATTACHMENT_PREPARATION_FORMATS),
|
|
9714
|
-
truncated: external_exports.boolean(),
|
|
9715
|
-
metadata: external_exports.record(external_exports.string(), external_exports.union([external_exports.string(), external_exports.number(), external_exports.boolean(), external_exports.null()]))
|
|
9716
|
-
}).strict();
|
|
9717
|
-
var taskResourceInputBaseSchema = external_exports.object({
|
|
9718
|
-
inputFingerprint: external_exports.string().trim().min(1).max(255),
|
|
9719
|
-
state: external_exports.enum(TASK_RESOURCE_INPUT_STATES),
|
|
9720
|
-
failureCode: external_exports.string().trim().min(1).max(160).nullable().optional()
|
|
9721
|
-
});
|
|
9722
|
-
var taskResourceInputSchema = external_exports.discriminatedUnion("kind", [
|
|
9723
|
-
taskResourceInputBaseSchema.extend({
|
|
9724
|
-
kind: external_exports.literal("link"),
|
|
9725
|
-
displayName: external_exports.string().trim().min(1).max(255),
|
|
9726
|
-
locator: external_exports.string().url().max(2048),
|
|
9727
|
-
scope: external_exports.string().trim().min(1).max(2e3),
|
|
9728
|
-
preparationReceipt: external_exports.null().optional()
|
|
9729
|
-
}).strict(),
|
|
9730
|
-
taskResourceInputBaseSchema.extend({
|
|
9731
|
-
kind: external_exports.literal("attachment"),
|
|
9732
|
-
attachmentId: external_exports.string().uuid(),
|
|
9733
|
-
assetId: external_exports.string().uuid(),
|
|
9734
|
-
byteSize: external_exports.number().int().nonnegative(),
|
|
9735
|
-
sha256: sha256Schema6,
|
|
9736
|
-
parserVersion: external_exports.string().trim().min(1).max(120).nullable().optional(),
|
|
9737
|
-
sidecarAssetId: external_exports.string().uuid().nullable().optional(),
|
|
9738
|
-
preparationReceipt: attachmentPreparationReceiptSchema.nullable().optional()
|
|
9739
|
-
}).strict()
|
|
9740
|
-
]).superRefine((value, context) => {
|
|
9741
|
-
if (value.kind !== "attachment") return;
|
|
9742
|
-
const originalOnly = value.parserVersion === ORIGINAL_ONLY_PARSER_VERSION;
|
|
9743
|
-
if (value.state === "prepared" && !value.preparationReceipt && !originalOnly) {
|
|
9744
|
-
context.addIssue({
|
|
9745
|
-
code: external_exports.ZodIssueCode.custom,
|
|
9746
|
-
path: ["preparationReceipt"],
|
|
9747
|
-
message: "Prepared attachment input requires a complete preparation receipt"
|
|
9748
|
-
});
|
|
9749
|
-
}
|
|
9750
|
-
if (originalOnly && (value.preparationReceipt || value.sidecarAssetId)) {
|
|
9751
|
-
context.addIssue({
|
|
9752
|
-
code: external_exports.ZodIssueCode.custom,
|
|
9753
|
-
path: ["preparationReceipt"],
|
|
9754
|
-
message: "Original-only attachment input must not carry a preparation sidecar"
|
|
9755
|
-
});
|
|
9756
|
-
}
|
|
9757
|
-
if (value.preparationReceipt && (value.preparationReceipt.originalSha256 !== value.sha256 || value.preparationReceipt.originalBytes !== value.byteSize)) {
|
|
9758
|
-
context.addIssue({
|
|
9759
|
-
code: external_exports.ZodIssueCode.custom,
|
|
9760
|
-
path: ["preparationReceipt"],
|
|
9761
|
-
message: "Preparation receipt must match the exact original attachment"
|
|
9762
|
-
});
|
|
9763
|
-
}
|
|
9764
|
-
});
|
|
9765
|
-
var browserCredentialRefAuthoritySchema = external_exports.object({
|
|
9766
|
-
version: external_exports.literal(1),
|
|
9767
|
-
companyId: external_exports.string().uuid(),
|
|
9768
|
-
issueId: external_exports.string().uuid(),
|
|
9769
|
-
runId: external_exports.string().uuid(),
|
|
9770
|
-
commandId: external_exports.string().uuid(),
|
|
9771
|
-
interactionId: external_exports.string().uuid(),
|
|
9772
|
-
credentialKey: external_exports.string().trim().min(1).max(255),
|
|
9773
|
-
credentialVersion: external_exports.number().int().positive(),
|
|
9774
|
-
credentialRole: external_exports.enum(BROWSER_CREDENTIAL_ROLES),
|
|
9775
|
-
targetOrigin: exactOriginSchema,
|
|
9776
|
-
authenticationOrigin: exactOriginSchema,
|
|
9777
|
-
bindingId: external_exports.string().uuid(),
|
|
9778
|
-
browserLeaseId: external_exports.string().regex(/^browser-credential-(?:auth-write|agent-read)-[0-9a-f-]{36}$/iu)
|
|
9779
|
-
}).strict();
|
|
9780
|
-
var browserCredentialRefConsumeSchema = browserCredentialRefAuthoritySchema.extend({
|
|
9781
|
-
controlSemantic: external_exports.enum(["username", "email", "password"])
|
|
9782
|
-
}).strict();
|
|
9783
|
-
var runtimeWebEvidenceReceiptSchema = external_exports.object({
|
|
9784
|
-
issueId: external_exports.string().uuid(),
|
|
9785
|
-
runId: external_exports.string().uuid(),
|
|
9786
|
-
commandId: external_exports.string().uuid(),
|
|
9787
|
-
toolCallId: external_exports.string().trim().min(1).max(255),
|
|
9788
|
-
requestedUrl: external_exports.string().url().max(2048),
|
|
9789
|
-
finalUrl: external_exports.string().url().max(2048),
|
|
9790
|
-
capturedAt: external_exports.string().datetime({ offset: true }),
|
|
9791
|
-
mediaType: external_exports.string().trim().min(1).max(255),
|
|
9792
|
-
truncated: external_exports.boolean(),
|
|
9793
|
-
contentSha256: sha256Schema6,
|
|
9794
|
-
observedChars: external_exports.number().int().nonnegative(),
|
|
9795
|
-
observedBytes: external_exports.number().int().nonnegative(),
|
|
9796
|
-
evidenceAssetId: external_exports.string().uuid().nullable().optional()
|
|
9797
|
-
}).strict();
|
|
9798
|
-
var runtimeWebEvidenceIngestSchema = external_exports.object({
|
|
9799
|
-
companyId: external_exports.string().uuid(),
|
|
9800
|
-
issueId: external_exports.string().uuid(),
|
|
9801
|
-
runId: external_exports.string().uuid(),
|
|
9802
|
-
commandId: external_exports.string().uuid(),
|
|
9803
|
-
toolCallId: external_exports.string().trim().min(1).max(255),
|
|
9804
|
-
requestedUrl: external_exports.string().url().max(8192),
|
|
9805
|
-
finalUrl: external_exports.string().url().max(8192),
|
|
9806
|
-
capturedAt: external_exports.string().datetime({ offset: true }),
|
|
9807
|
-
mediaType: external_exports.string().trim().min(1).max(255),
|
|
9808
|
-
normalizedText: external_exports.string().max(2e6),
|
|
9809
|
-
truncated: external_exports.boolean().optional()
|
|
9810
|
-
}).strict();
|
|
9811
|
-
var createTaskResourceLinkRequestSchema = external_exports.object({
|
|
9812
|
-
displayName: external_exports.string().trim().min(1).max(500),
|
|
9813
|
-
locator: taskResourceLocatorSchema,
|
|
9814
|
-
scope: external_exports.string().trim().min(1).max(2e3),
|
|
9815
|
-
criticality: external_exports.enum(["critical", "supporting"]).default("supporting")
|
|
9816
|
-
}).strict();
|
|
9817
|
-
var finalizeTaskResourceAttachmentRequestSchema = external_exports.object({ inputId: external_exports.string().uuid() }).strict();
|
|
9818
|
-
var createTaskResourceAttachmentRequestSchema = external_exports.object({ attachmentId: external_exports.string().uuid() }).strict();
|
|
9819
|
-
|
|
9820
9912
|
// ../shared/src/types/browser-session-binding.ts
|
|
9821
9913
|
var BROWSER_SESSION_BINDING_STATUSES = [
|
|
9822
9914
|
"preparing",
|
|
@@ -10181,7 +10273,7 @@ var businessDataSourceReadSchema = external_exports.object({
|
|
|
10181
10273
|
evidence: external_exports.string().trim().min(1).max(1e3)
|
|
10182
10274
|
}).strict().describe("Required only for business_data_source_unavailable. Record the actual authorized configuration/access/read failure, observation time and non-secret evidence. A read_succeeded observation (including empty results) cannot create this wait; report source-scoped zero or unknown coverage instead.");
|
|
10183
10275
|
function refineBusinessDataSourceWait(value, ctx) {
|
|
10184
|
-
if (value.reasonCode ===
|
|
10276
|
+
if (value.reasonCode === EXTERNAL_WAIT_REASON_CODES.businessDataSourceUnavailable) {
|
|
10185
10277
|
if (!value.dataSourceRead || value.dataSourceRead.outcome === "read_succeeded") {
|
|
10186
10278
|
ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["dataSourceRead"], message: "business_data_source_unavailable requires an observed access/configuration/read failure. A successful read, including an empty table, cannot block reports; report source-scoped zero or unknown coverage/baseline instead. Do not require non-empty records to restore access." });
|
|
10187
10279
|
}
|
|
@@ -12739,6 +12831,34 @@ var issueDeliveryAcceptanceReferenceSchema = external_exports.object({
|
|
|
12739
12831
|
state: external_exports.enum(ISSUE_DELIVERY_REFERENCE_STATES),
|
|
12740
12832
|
href: external_exports.string().min(1).max(4e3).nullable()
|
|
12741
12833
|
}).strict();
|
|
12834
|
+
var issueExecutionDecisionHistoryRecordSchema = external_exports.object({
|
|
12835
|
+
sequence: external_exports.number().int().positive(),
|
|
12836
|
+
reviewEvidenceStatus: external_exports.enum(["available", "absent", "invalid"]),
|
|
12837
|
+
decision: external_exports.object({
|
|
12838
|
+
id: uuidSchema3,
|
|
12839
|
+
companyId: uuidSchema3,
|
|
12840
|
+
issueId: uuidSchema3,
|
|
12841
|
+
stageId: uuidSchema3,
|
|
12842
|
+
stageType: external_exports.enum(ISSUE_EXECUTION_STAGE_TYPES),
|
|
12843
|
+
actorAgentId: uuidSchema3.nullable(),
|
|
12844
|
+
actorUserId: external_exports.string().min(1).nullable(),
|
|
12845
|
+
outcome: external_exports.enum(ISSUE_EXECUTION_DECISION_OUTCOMES),
|
|
12846
|
+
body: external_exports.string(),
|
|
12847
|
+
reviewEvidence: issueExecutionReviewEvidenceSchema.nullable(),
|
|
12848
|
+
createdByRunId: uuidSchema3.nullable(),
|
|
12849
|
+
createdAt: dateSchema2,
|
|
12850
|
+
updatedAt: dateSchema2
|
|
12851
|
+
}).strict(),
|
|
12852
|
+
inspectedReferences: external_exports.array(issueDeliveryAcceptanceReferenceSchema)
|
|
12853
|
+
}).strict();
|
|
12854
|
+
var issueExecutionDecisionHistoryEnvelopeSchema = external_exports.object({
|
|
12855
|
+
records: external_exports.array(external_exports.unknown()),
|
|
12856
|
+
totalCount: external_exports.number().int().nonnegative()
|
|
12857
|
+
}).strict();
|
|
12858
|
+
var issueExecutionDecisionHistoryResponseSchema = external_exports.object({
|
|
12859
|
+
records: external_exports.array(issueExecutionDecisionHistoryRecordSchema),
|
|
12860
|
+
totalCount: external_exports.number().int().nonnegative()
|
|
12861
|
+
}).strict();
|
|
12742
12862
|
var issueDeliveryAcceptancePendingInteractionSchema = external_exports.object({
|
|
12743
12863
|
interactionId: uuidSchema3,
|
|
12744
12864
|
interactionKind: external_exports.enum(ISSUE_THREAD_INTERACTION_KINDS),
|
|
@@ -13367,12 +13487,36 @@ var ceoPeriodicGoalGapCandidateSchema = external_exports.object({
|
|
|
13367
13487
|
businessSubjectScope: operatingNormalizedBusinessSubjectRefSchema,
|
|
13368
13488
|
targetCondition: external_exports.object({ kind: external_exports.literal("boolean_milestone"), expected: external_exports.literal(true) }).strict(),
|
|
13369
13489
|
window: external_exports.record(external_exports.string().min(1).max(80), external_exports.unknown()),
|
|
13370
|
-
observationRef: goalGapObservationRefSchema
|
|
13371
|
-
|
|
13490
|
+
observationRef: goalGapObservationRefSchema.describe(
|
|
13491
|
+
"Server-governed observation identity. For blocker_state or business_outcome candidates, use kind=governed_business_state and copy the primary sourceRef id/revision exactly; do not copy the primary sourceRef kind."
|
|
13492
|
+
),
|
|
13493
|
+
sourceRefs: external_exports.array(ceoPeriodicWorkSourceRefSchema).min(1).max(20).describe(
|
|
13494
|
+
"Exact leased evidence refs. A provisional Goal Gap candidate must include a primary blocker_state or business_outcome ref whose id/revision exactly match observationRef."
|
|
13495
|
+
),
|
|
13372
13496
|
reasoningSummary: external_exports.string().trim().min(1).max(1e3),
|
|
13373
13497
|
confidenceBand: external_exports.enum(["high", "medium", "low"]),
|
|
13374
13498
|
workClass: external_exports.enum(["internal_enablement", "governed_decision", "external_action", "observed_business_result"])
|
|
13375
13499
|
}).strict();
|
|
13500
|
+
var ceoPeriodicGoalGapCandidatesSchema = external_exports.array(ceoPeriodicGoalGapCandidateSchema).max(10).superRefine((candidates, ctx) => {
|
|
13501
|
+
for (const [index, candidate] of candidates.entries()) {
|
|
13502
|
+
const primarySource = candidate.sourceRefs.find((sourceRef) => ["blocker_state", "business_outcome"].includes(sourceRef.kind) && sourceRef.id === candidate.observationRef.id && sourceRef.revision === candidate.observationRef.revision);
|
|
13503
|
+
if (!primarySource) {
|
|
13504
|
+
ctx.addIssue({
|
|
13505
|
+
code: external_exports.ZodIssueCode.custom,
|
|
13506
|
+
path: [index, "observationRef"],
|
|
13507
|
+
message: "Goal Gap candidate observationRef must identify an exact sourceRef"
|
|
13508
|
+
});
|
|
13509
|
+
continue;
|
|
13510
|
+
}
|
|
13511
|
+
if (candidate.observationRef.kind !== "governed_business_state") {
|
|
13512
|
+
ctx.addIssue({
|
|
13513
|
+
code: external_exports.ZodIssueCode.custom,
|
|
13514
|
+
path: [index, "observationRef"],
|
|
13515
|
+
message: "Goal Gap candidates require a Server-verifiable blocker_state or business_outcome primary source"
|
|
13516
|
+
});
|
|
13517
|
+
}
|
|
13518
|
+
}
|
|
13519
|
+
});
|
|
13376
13520
|
var ceoPeriodicTaskAttentionSchema = external_exports.object({
|
|
13377
13521
|
prerequisiteRequirements: external_exports.array(prerequisiteRequirementProjectionSchema),
|
|
13378
13522
|
prerequisiteBindings: external_exports.array(prerequisiteBindingProjectionSchema),
|
|
@@ -13441,7 +13585,7 @@ var ceoPeriodicDemandCandidatesSchema = external_exports.array(ceoPeriodicDemand
|
|
|
13441
13585
|
var ceoPeriodicWorkDispatchInputSchema = external_exports.object({
|
|
13442
13586
|
observationId: external_exports.string().uuid(),
|
|
13443
13587
|
inputFingerprint: external_exports.string().regex(/^sha256:[a-f0-9]{64}$/u),
|
|
13444
|
-
goalGapCandidates:
|
|
13588
|
+
goalGapCandidates: ceoPeriodicGoalGapCandidatesSchema.default([]),
|
|
13445
13589
|
continuations: external_exports.array(ceoPeriodicContinuationInputSchema).max(20).default([]),
|
|
13446
13590
|
candidates: ceoPeriodicDemandCandidatesSchema.default([]),
|
|
13447
13591
|
noWorkReason: ceoPeriodicNoWorkReasonSchema.optional(),
|
|
@@ -14854,7 +14998,7 @@ var FEEDBACK_TARGET_TYPES = ["issue_comment", "issue_document_revision"];
|
|
|
14854
14998
|
var FEEDBACK_VOTE_VALUES = ["up", "down"];
|
|
14855
14999
|
var FEEDBACK_DATA_SHARING_PREFERENCES = ["allowed", "not_allowed", "prompt"];
|
|
14856
15000
|
var DEFAULT_FEEDBACK_DATA_SHARING_PREFERENCE = "prompt";
|
|
14857
|
-
var FEEDBACK_TRACE_STATUSES = ["local_only", "pending", "sent", "failed"];
|
|
15001
|
+
var FEEDBACK_TRACE_STATUSES = ["local_only", "pending", "sent", "failed", "dead_letter"];
|
|
14858
15002
|
|
|
14859
15003
|
// ../shared/src/validators/feedback.ts
|
|
14860
15004
|
var feedbackTargetTypeSchema = external_exports.enum(FEEDBACK_TARGET_TYPES);
|
|
@@ -18592,9 +18736,9 @@ var wikiMentionListSchema = external_exports.object({
|
|
|
18592
18736
|
});
|
|
18593
18737
|
|
|
18594
18738
|
// src/amaster-runtime-daemon.mjs
|
|
18595
|
-
import { chmodSync as
|
|
18739
|
+
import { chmodSync as chmodSync8, copyFileSync as copyFileSync2, existsSync as existsSync18, lstatSync as lstatSync13, mkdirSync as mkdirSync13, mkdtempSync as mkdtempSync5, readFileSync as readFileSync19, readdirSync as readdirSync12, realpathSync as realpathSync12, renameSync as renameSync11, rmSync as rmSync12, statSync as statSync12, symlinkSync as symlinkSync2, unlinkSync as unlinkSync3, writeFileSync as writeFileSync14 } from "node:fs";
|
|
18596
18740
|
import { arch as arch4, homedir as homedir6, hostname as hostname2, platform as platform4, tmpdir } from "node:os";
|
|
18597
|
-
import { basename as basename8, delimiter as delimiter3, dirname as
|
|
18741
|
+
import { basename as basename8, delimiter as delimiter3, dirname as dirname12, extname as extname3, isAbsolute as isAbsolute12, join as join24, relative as relative9, resolve as resolve19 } from "node:path";
|
|
18598
18742
|
import { spawn, spawnSync as spawnSync5 } from "node:child_process";
|
|
18599
18743
|
|
|
18600
18744
|
// src/amaster-runtime-daemon/common.mjs
|
|
@@ -24955,8 +25099,10 @@ ${result2.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
|
|
|
24955
25099
|
} : {}
|
|
24956
25100
|
}
|
|
24957
25101
|
} : {},
|
|
24958
|
-
//
|
|
25102
|
+
// Normal governed runs preserve user-level tools. An exact task-resource
|
|
25103
|
+
// run narrows this later to direct governed tools plus its bound reader.
|
|
24959
25104
|
toolAllowlist: null,
|
|
25105
|
+
directToolNames,
|
|
24960
25106
|
directCatalogFrozen: Boolean(directCatalog),
|
|
24961
25107
|
protectedValues: [.../* @__PURE__ */ new Set([
|
|
24962
25108
|
sessionToken,
|
|
@@ -25237,7 +25383,9 @@ ${result2.stderr ?? ""}`, "Pi", MINIMUM_PI_VERSION);
|
|
|
25237
25383
|
} : {}
|
|
25238
25384
|
}
|
|
25239
25385
|
} : {},
|
|
25386
|
+
// Exact task-resource runs narrow this after the run-owned reader exists.
|
|
25240
25387
|
toolAllowlist: null,
|
|
25388
|
+
directToolNames,
|
|
25241
25389
|
directCatalogFrozen: Boolean(directCatalog),
|
|
25242
25390
|
protectedValues: [.../* @__PURE__ */ new Set([sessionToken, ...seededRuntime.protectedValues])],
|
|
25243
25391
|
attestation: {
|
|
@@ -25480,6 +25628,180 @@ function selectExecutor(config, command) {
|
|
|
25480
25628
|
return selected;
|
|
25481
25629
|
}
|
|
25482
25630
|
|
|
25631
|
+
// src/amaster-runtime-daemon/web-evidence.mjs
|
|
25632
|
+
import { createHash as createHash10 } from "node:crypto";
|
|
25633
|
+
var SENSITIVE_QUERY_KEY_FRAGMENTS = [
|
|
25634
|
+
"apikey",
|
|
25635
|
+
"accesskey",
|
|
25636
|
+
"privatekey",
|
|
25637
|
+
"token",
|
|
25638
|
+
"secret",
|
|
25639
|
+
"signature",
|
|
25640
|
+
"credential",
|
|
25641
|
+
"password",
|
|
25642
|
+
"authorization",
|
|
25643
|
+
"session",
|
|
25644
|
+
"cookie",
|
|
25645
|
+
"oauth",
|
|
25646
|
+
"ticket",
|
|
25647
|
+
"assertion",
|
|
25648
|
+
"samlresponse",
|
|
25649
|
+
"relaystate",
|
|
25650
|
+
"jwt"
|
|
25651
|
+
];
|
|
25652
|
+
var SENSITIVE_QUERY_KEYS = /* @__PURE__ */ new Set(["auth", "code", "key", "sig", "sid", "state"]);
|
|
25653
|
+
function isSensitiveQueryKey(key) {
|
|
25654
|
+
const compact = key.normalize("NFKC").toLocaleLowerCase("en-US").replace(/[^a-z0-9]/gu, "");
|
|
25655
|
+
return SENSITIVE_QUERY_KEYS.has(compact) || SENSITIVE_QUERY_KEY_FRAGMENTS.some((fragment) => compact.includes(fragment));
|
|
25656
|
+
}
|
|
25657
|
+
function safeUrl(raw) {
|
|
25658
|
+
const url = new URL(raw);
|
|
25659
|
+
if (!["http:", "https:"].includes(url.protocol) || url.username || url.password) {
|
|
25660
|
+
throw new Error("runtime_web_evidence_url_invalid");
|
|
25661
|
+
}
|
|
25662
|
+
for (const key of [...url.searchParams.keys()]) {
|
|
25663
|
+
if (isSensitiveQueryKey(key)) url.searchParams.delete(key);
|
|
25664
|
+
}
|
|
25665
|
+
url.hash = "";
|
|
25666
|
+
return url.toString();
|
|
25667
|
+
}
|
|
25668
|
+
function sanitizeRuntimeWebEvidence(input) {
|
|
25669
|
+
const allowed = /* @__PURE__ */ new Set(["toolCallId", "requestedUrl", "finalUrl", "capturedAt", "mediaType", "normalizedText", "truncated"]);
|
|
25670
|
+
if (!input || typeof input !== "object" || Array.isArray(input) || Object.keys(input).some((key) => !allowed.has(key))) {
|
|
25671
|
+
throw new Error("runtime_web_evidence_invalid");
|
|
25672
|
+
}
|
|
25673
|
+
const cleanedText = typeof input.normalizedText === "string" ? input.normalizedText.replace(/\r\n?/gu, "\n").replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/gu, "") : null;
|
|
25674
|
+
if (!cleanedText || typeof input.toolCallId !== "string" || !input.toolCallId.trim()) {
|
|
25675
|
+
throw new Error("runtime_web_evidence_invalid");
|
|
25676
|
+
}
|
|
25677
|
+
const normalizedText = cleanedText.slice(0, 2e5);
|
|
25678
|
+
const bytes = Buffer.from(normalizedText, "utf8");
|
|
25679
|
+
return {
|
|
25680
|
+
toolCallId: input.toolCallId.trim(),
|
|
25681
|
+
requestedUrl: safeUrl(input.requestedUrl),
|
|
25682
|
+
finalUrl: safeUrl(input.finalUrl),
|
|
25683
|
+
capturedAt: new Date(input.capturedAt).toISOString(),
|
|
25684
|
+
mediaType: typeof input.mediaType === "string" && input.mediaType.trim() ? input.mediaType.trim() : "text/plain",
|
|
25685
|
+
normalizedText,
|
|
25686
|
+
truncated: input.truncated === true || cleanedText.length > 2e5,
|
|
25687
|
+
contentSha256: createHash10("sha256").update(bytes).digest("hex"),
|
|
25688
|
+
observedChars: normalizedText.length,
|
|
25689
|
+
observedBytes: bytes.byteLength
|
|
25690
|
+
};
|
|
25691
|
+
}
|
|
25692
|
+
function assertExactTaskResourceWebEvidence(evidence) {
|
|
25693
|
+
if (evidence?.sourceToolName !== "amaster_exact_source_read") {
|
|
25694
|
+
throw new Error("runtime_exact_source_evidence_untrusted");
|
|
25695
|
+
}
|
|
25696
|
+
return evidence;
|
|
25697
|
+
}
|
|
25698
|
+
function runtimeWebEvidenceTaskResourceBinding(payload) {
|
|
25699
|
+
const binding = payload?.webEvidenceTaskResourceBinding;
|
|
25700
|
+
if (!binding || typeof binding.inputId !== "string" || !binding.inputId.trim() || typeof binding.inputFingerprint !== "string" || !binding.inputFingerprint.trim() || !Number.isInteger(binding.retrievalRevision) || binding.retrievalRevision < 1) return null;
|
|
25701
|
+
return {
|
|
25702
|
+
inputId: binding.inputId.trim(),
|
|
25703
|
+
inputFingerprint: binding.inputFingerprint.trim(),
|
|
25704
|
+
retrievalRevision: binding.retrievalRevision
|
|
25705
|
+
};
|
|
25706
|
+
}
|
|
25707
|
+
function runtimeExactTaskResourceBinding(payload) {
|
|
25708
|
+
const binding = payload?.webEvidenceTaskResourceBinding;
|
|
25709
|
+
if (!runtimeWebEvidenceTaskResourceBinding(payload) || typeof binding.locator !== "string" || !binding.locator.trim() || typeof binding.locatorFingerprint !== "string" || !/^[a-f0-9]{64}$/u.test(binding.locatorFingerprint)) return null;
|
|
25710
|
+
let locator;
|
|
25711
|
+
try {
|
|
25712
|
+
locator = safeUrl(binding.locator.trim());
|
|
25713
|
+
} catch {
|
|
25714
|
+
return null;
|
|
25715
|
+
}
|
|
25716
|
+
if (createHash10("sha256").update(locator).digest("hex") !== binding.locatorFingerprint) return null;
|
|
25717
|
+
return {
|
|
25718
|
+
locator,
|
|
25719
|
+
locatorFingerprint: binding.locatorFingerprint
|
|
25720
|
+
};
|
|
25721
|
+
}
|
|
25722
|
+
|
|
25723
|
+
// src/amaster-runtime-daemon/pi-exact-source-read.mjs
|
|
25724
|
+
import { chmodSync as chmodSync5, mkdirSync as mkdirSync7, renameSync as renameSync4, rmSync as rmSync6, writeFileSync as writeFileSync7, writeSync } from "node:fs";
|
|
25725
|
+
import { dirname as dirname6, join as join11 } from "node:path";
|
|
25726
|
+
|
|
25727
|
+
// src/amaster-runtime-daemon/public-network-scope.mjs
|
|
25728
|
+
import { BlockList, isIP } from "node:net";
|
|
25729
|
+
var blockedV4Addresses = new BlockList();
|
|
25730
|
+
for (const [network, prefix] of [
|
|
25731
|
+
["0.0.0.0", 8],
|
|
25732
|
+
["10.0.0.0", 8],
|
|
25733
|
+
["100.64.0.0", 10],
|
|
25734
|
+
["127.0.0.0", 8],
|
|
25735
|
+
["169.254.0.0", 16],
|
|
25736
|
+
["172.16.0.0", 12],
|
|
25737
|
+
["192.0.0.0", 24],
|
|
25738
|
+
["192.0.2.0", 24],
|
|
25739
|
+
["192.88.99.0", 24],
|
|
25740
|
+
["192.168.0.0", 16],
|
|
25741
|
+
["198.18.0.0", 15],
|
|
25742
|
+
["198.51.100.0", 24],
|
|
25743
|
+
["203.0.113.0", 24],
|
|
25744
|
+
["224.0.0.0", 4],
|
|
25745
|
+
["240.0.0.0", 4]
|
|
25746
|
+
]) {
|
|
25747
|
+
blockedV4Addresses.addSubnet(network, prefix, "ipv4");
|
|
25748
|
+
}
|
|
25749
|
+
var blockedV6Addresses = new BlockList();
|
|
25750
|
+
for (const [network, prefix] of [
|
|
25751
|
+
["::", 128],
|
|
25752
|
+
["::1", 128],
|
|
25753
|
+
["::", 96],
|
|
25754
|
+
["::ffff:0:0", 96],
|
|
25755
|
+
["64:ff9b::", 96],
|
|
25756
|
+
["64:ff9b:1::", 48],
|
|
25757
|
+
["100::", 64],
|
|
25758
|
+
["2001::", 32],
|
|
25759
|
+
["2001:2::", 48],
|
|
25760
|
+
["2001:db8::", 32],
|
|
25761
|
+
["2001:10::", 28],
|
|
25762
|
+
["2001:20::", 28],
|
|
25763
|
+
["2002::", 16],
|
|
25764
|
+
["fc00::", 7],
|
|
25765
|
+
["fe80::", 10],
|
|
25766
|
+
["fec0::", 10],
|
|
25767
|
+
["ff00::", 8]
|
|
25768
|
+
]) {
|
|
25769
|
+
blockedV6Addresses.addSubnet(network, prefix, "ipv6");
|
|
25770
|
+
}
|
|
25771
|
+
|
|
25772
|
+
// src/amaster-runtime-daemon/pi-exact-source-read.mjs
|
|
25773
|
+
var EXACT_SOURCE_READ_TOOL_NAME = "amaster_exact_source_read";
|
|
25774
|
+
var MAX_BYTES2 = 512 * 1024;
|
|
25775
|
+
function exactSourceToolAllowlist(profile) {
|
|
25776
|
+
const governedToolNames = Array.isArray(profile?.directToolNames) ? profile.directToolNames.filter((name) => typeof name === "string" && name) : [];
|
|
25777
|
+
return [.../* @__PURE__ */ new Set([...governedToolNames, EXACT_SOURCE_READ_TOOL_NAME])];
|
|
25778
|
+
}
|
|
25779
|
+
function managedPiExactSourceReadExtensionSource(binding, options = {}) {
|
|
25780
|
+
const runtimeModuleUrl = typeof options.runtimeModuleUrl === "string" && options.runtimeModuleUrl ? options.runtimeModuleUrl : import.meta.url;
|
|
25781
|
+
const readerModuleUrl = new URL("./pi-exact-source-read.mjs", runtimeModuleUrl).href;
|
|
25782
|
+
return `import { registerExactSourceReadTool } from ${JSON.stringify(readerModuleUrl)};
|
|
25783
|
+
const binding = ${JSON.stringify(binding)};
|
|
25784
|
+
export default function amasterExactSourceRead(pi) { registerExactSourceReadTool(pi, binding); }
|
|
25785
|
+
`;
|
|
25786
|
+
}
|
|
25787
|
+
function materializePiExactSourceReadExtension(profileRoot, binding) {
|
|
25788
|
+
const extensionPath = join11(profileRoot, "extensions", "amaster-exact-source-read.js");
|
|
25789
|
+
mkdirSync7(dirname6(extensionPath), { recursive: true, mode: 448 });
|
|
25790
|
+
const temporaryPath = `${extensionPath}.${process.pid}.tmp`;
|
|
25791
|
+
try {
|
|
25792
|
+
writeFileSync7(temporaryPath, managedPiExactSourceReadExtensionSource(binding), {
|
|
25793
|
+
encoding: "utf8",
|
|
25794
|
+
mode: 384,
|
|
25795
|
+
flag: "wx"
|
|
25796
|
+
});
|
|
25797
|
+
renameSync4(temporaryPath, extensionPath);
|
|
25798
|
+
chmodSync5(extensionPath, 384);
|
|
25799
|
+
return extensionPath;
|
|
25800
|
+
} finally {
|
|
25801
|
+
rmSync6(temporaryPath, { force: true });
|
|
25802
|
+
}
|
|
25803
|
+
}
|
|
25804
|
+
|
|
25483
25805
|
// src/amaster-runtime-daemon/model-authority.mjs
|
|
25484
25806
|
var TASK_SESSION_SNAPSHOT_KEY = "mirrorxRuntimeConnectorTaskSessionV1";
|
|
25485
25807
|
function asRecord2(value) {
|
|
@@ -25716,8 +26038,8 @@ function isTerminalResultOutboxStatus(status) {
|
|
|
25716
26038
|
}
|
|
25717
26039
|
|
|
25718
26040
|
// src/amaster-runtime-daemon/run-completion-state.mjs
|
|
25719
|
-
import { existsSync as existsSync8, mkdirSync as
|
|
25720
|
-
import { join as
|
|
26041
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync8, readFileSync as readFileSync8, readdirSync as readdirSync6, renameSync as renameSync5, unlinkSync, writeFileSync as writeFileSync8 } from "node:fs";
|
|
26042
|
+
import { join as join12 } from "node:path";
|
|
25721
26043
|
|
|
25722
26044
|
// src/amaster-runtime-daemon/typed/run-completion-transitions.mjs
|
|
25723
26045
|
var RUN_COMPLETION_PHASES = /* @__PURE__ */ new Set([
|
|
@@ -25979,12 +26301,12 @@ function assertValidRunCompletionState(value) {
|
|
|
25979
26301
|
}
|
|
25980
26302
|
function writeRunCompletionState(directory, state) {
|
|
25981
26303
|
const valid = assertValidRunCompletionState(state);
|
|
25982
|
-
|
|
25983
|
-
const filePath =
|
|
26304
|
+
mkdirSync8(directory, { recursive: true, mode: 448 });
|
|
26305
|
+
const filePath = join12(directory, runCompletionStateFileName(valid.commandId));
|
|
25984
26306
|
const temporaryPath = `${filePath}.${process.pid}.${Date.now()}.tmp`;
|
|
25985
|
-
|
|
26307
|
+
writeFileSync8(temporaryPath, `${JSON.stringify(valid, null, 2)}
|
|
25986
26308
|
`, { mode: 384 });
|
|
25987
|
-
|
|
26309
|
+
renameSync5(temporaryPath, filePath);
|
|
25988
26310
|
return filePath;
|
|
25989
26311
|
}
|
|
25990
26312
|
function readRunCompletionState(filePath) {
|
|
@@ -25992,10 +26314,10 @@ function readRunCompletionState(filePath) {
|
|
|
25992
26314
|
}
|
|
25993
26315
|
function listRunCompletionStateFiles(directory) {
|
|
25994
26316
|
if (!existsSync8(directory)) return [];
|
|
25995
|
-
return readdirSync6(directory).filter((name) => name.endsWith(".json")).sort().map((name) =>
|
|
26317
|
+
return readdirSync6(directory).filter((name) => name.endsWith(".json")).sort().map((name) => join12(directory, name));
|
|
25996
26318
|
}
|
|
25997
26319
|
function removeRunCompletionState(directory, commandId) {
|
|
25998
|
-
const filePath =
|
|
26320
|
+
const filePath = join12(directory, runCompletionStateFileName(commandId));
|
|
25999
26321
|
if (existsSync8(filePath)) unlinkSync(filePath);
|
|
26000
26322
|
}
|
|
26001
26323
|
|
|
@@ -27938,68 +28260,6 @@ function parseCodebuddyStreamJson(stdout, options = {}) {
|
|
|
27938
28260
|
};
|
|
27939
28261
|
}
|
|
27940
28262
|
|
|
27941
|
-
// src/amaster-runtime-daemon/web-evidence.mjs
|
|
27942
|
-
import { createHash as createHash10 } from "node:crypto";
|
|
27943
|
-
var SENSITIVE_QUERY_KEY_FRAGMENTS = [
|
|
27944
|
-
"apikey",
|
|
27945
|
-
"accesskey",
|
|
27946
|
-
"privatekey",
|
|
27947
|
-
"token",
|
|
27948
|
-
"secret",
|
|
27949
|
-
"signature",
|
|
27950
|
-
"credential",
|
|
27951
|
-
"password",
|
|
27952
|
-
"authorization",
|
|
27953
|
-
"session",
|
|
27954
|
-
"cookie",
|
|
27955
|
-
"oauth",
|
|
27956
|
-
"ticket",
|
|
27957
|
-
"assertion",
|
|
27958
|
-
"samlresponse",
|
|
27959
|
-
"relaystate",
|
|
27960
|
-
"jwt"
|
|
27961
|
-
];
|
|
27962
|
-
var SENSITIVE_QUERY_KEYS = /* @__PURE__ */ new Set(["auth", "code", "key", "sig", "sid", "state"]);
|
|
27963
|
-
function isSensitiveQueryKey(key) {
|
|
27964
|
-
const compact = key.normalize("NFKC").toLocaleLowerCase("en-US").replace(/[^a-z0-9]/gu, "");
|
|
27965
|
-
return SENSITIVE_QUERY_KEYS.has(compact) || SENSITIVE_QUERY_KEY_FRAGMENTS.some((fragment) => compact.includes(fragment));
|
|
27966
|
-
}
|
|
27967
|
-
function safeUrl(raw) {
|
|
27968
|
-
const url = new URL(raw);
|
|
27969
|
-
if (!["http:", "https:"].includes(url.protocol) || url.username || url.password) {
|
|
27970
|
-
throw new Error("runtime_web_evidence_url_invalid");
|
|
27971
|
-
}
|
|
27972
|
-
for (const key of [...url.searchParams.keys()]) {
|
|
27973
|
-
if (isSensitiveQueryKey(key)) url.searchParams.delete(key);
|
|
27974
|
-
}
|
|
27975
|
-
url.hash = "";
|
|
27976
|
-
return url.toString();
|
|
27977
|
-
}
|
|
27978
|
-
function sanitizeRuntimeWebEvidence(input) {
|
|
27979
|
-
const allowed = /* @__PURE__ */ new Set(["toolCallId", "requestedUrl", "finalUrl", "capturedAt", "mediaType", "normalizedText", "truncated"]);
|
|
27980
|
-
if (!input || typeof input !== "object" || Array.isArray(input) || Object.keys(input).some((key) => !allowed.has(key))) {
|
|
27981
|
-
throw new Error("runtime_web_evidence_invalid");
|
|
27982
|
-
}
|
|
27983
|
-
const cleanedText = typeof input.normalizedText === "string" ? input.normalizedText.replace(/\r\n?/gu, "\n").replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/gu, "") : null;
|
|
27984
|
-
if (!cleanedText || typeof input.toolCallId !== "string" || !input.toolCallId.trim()) {
|
|
27985
|
-
throw new Error("runtime_web_evidence_invalid");
|
|
27986
|
-
}
|
|
27987
|
-
const normalizedText = cleanedText.slice(0, 2e5);
|
|
27988
|
-
const bytes = Buffer.from(normalizedText, "utf8");
|
|
27989
|
-
return {
|
|
27990
|
-
toolCallId: input.toolCallId.trim(),
|
|
27991
|
-
requestedUrl: safeUrl(input.requestedUrl),
|
|
27992
|
-
finalUrl: safeUrl(input.finalUrl),
|
|
27993
|
-
capturedAt: new Date(input.capturedAt).toISOString(),
|
|
27994
|
-
mediaType: typeof input.mediaType === "string" && input.mediaType.trim() ? input.mediaType.trim() : "text/plain",
|
|
27995
|
-
normalizedText,
|
|
27996
|
-
truncated: input.truncated === true || cleanedText.length > 2e5,
|
|
27997
|
-
contentSha256: createHash10("sha256").update(bytes).digest("hex"),
|
|
27998
|
-
observedChars: normalizedText.length,
|
|
27999
|
-
observedBytes: bytes.byteLength
|
|
28000
|
-
};
|
|
28001
|
-
}
|
|
28002
|
-
|
|
28003
28263
|
// src/amaster-runtime-daemon/executor-protocol/pi.mjs
|
|
28004
28264
|
var PI_PROVIDER_AUTH_RE = /(?:(?:\b401\b|\b403\b)[^\n]*(?:unauthorized|forbidden|auth(?:entication|orization)?|api[_\s-]?key)|(?:invalid|missing|expired|revoked)\s+(?:provider\s+)?api[_\s-]?key|provider\s+authentication\s+required)/i;
|
|
28005
28265
|
var PI_PROVIDER_QUOTA_EXHAUSTED_RE = /(?:\binsufficient[_\s-]?user[_\s-]?quota\b|河狸币余额不足|\b402\b[^\n]*(?:余额不足|insufficient[_\s-]?balance|payment\s+required))/i;
|
|
@@ -28403,7 +28663,10 @@ function piGovernedMcpUnavailableEvidence(event) {
|
|
|
28403
28663
|
function piRuntimeWebEvidence(event) {
|
|
28404
28664
|
if (readString(event?.type) === "amaster_web_evidence" && readString(event?.version) === "runtime_web_evidence_v1") {
|
|
28405
28665
|
try {
|
|
28406
|
-
return [
|
|
28666
|
+
return [{
|
|
28667
|
+
...sanitizeRuntimeWebEvidence(asRecord(event).evidence),
|
|
28668
|
+
sourceToolName: "amaster_exact_source_read"
|
|
28669
|
+
}];
|
|
28407
28670
|
} catch {
|
|
28408
28671
|
return [];
|
|
28409
28672
|
}
|
|
@@ -28442,7 +28705,7 @@ function piRuntimeWebEvidence(event) {
|
|
|
28442
28705
|
const identity = `${item.toolCallId}\0${item.contentSha256}`;
|
|
28443
28706
|
if (!seen.has(identity)) {
|
|
28444
28707
|
seen.add(identity);
|
|
28445
|
-
evidence.push(item);
|
|
28708
|
+
evidence.push({ ...item, sourceToolName: toolName });
|
|
28446
28709
|
}
|
|
28447
28710
|
} catch {
|
|
28448
28711
|
}
|
|
@@ -29252,6 +29515,9 @@ function resolveRuntimeCostModelIdentity({
|
|
|
29252
29515
|
}
|
|
29253
29516
|
|
|
29254
29517
|
// src/amaster-runtime-daemon/execution-lanes.mjs
|
|
29518
|
+
function isRuntimeStopCommand(command) {
|
|
29519
|
+
return command?.commandType === "cancel" || command?.commandType === "terminate";
|
|
29520
|
+
}
|
|
29255
29521
|
function normalizeRuntimeExecutionLane(value) {
|
|
29256
29522
|
return value === "conversation" ? "conversation" : "business";
|
|
29257
29523
|
}
|
|
@@ -29273,6 +29539,10 @@ function selectRuntimeCommandsWithinLaneLimits(input) {
|
|
|
29273
29539
|
}
|
|
29274
29540
|
const selected = [];
|
|
29275
29541
|
for (const command of Array.isArray(input.commands) ? input.commands : []) {
|
|
29542
|
+
if (isRuntimeStopCommand(command)) {
|
|
29543
|
+
selected.push(command);
|
|
29544
|
+
continue;
|
|
29545
|
+
}
|
|
29276
29546
|
const lane = runtimeExecutionLaneForCapabilities(command?.executionLane, input.capabilities);
|
|
29277
29547
|
if (lane === "conversation" && !supportsExecutionLanes) continue;
|
|
29278
29548
|
const total = counts.business + counts.conversation;
|
|
@@ -30326,30 +30596,6 @@ function fixedRules(input, includeIssueLine, runContract = "producer") {
|
|
|
30326
30596
|
"- 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."
|
|
30327
30597
|
].filter(Boolean).join("\n");
|
|
30328
30598
|
}
|
|
30329
|
-
function conversationAgentRosterText(context) {
|
|
30330
|
-
const roster = asRecord(context.paperclipCompanyAgentRoster);
|
|
30331
|
-
const agents = Array.isArray(roster.agents) ? roster.agents : [];
|
|
30332
|
-
if (agents.length === 0) return "";
|
|
30333
|
-
const lines = agents.map((agent) => {
|
|
30334
|
-
const record11 = asRecord(agent);
|
|
30335
|
-
const name = readString(record11.name) ?? "unknown";
|
|
30336
|
-
const id = readString(record11.id) ?? "unknown";
|
|
30337
|
-
const role = readString(record11.role);
|
|
30338
|
-
const title = readString(record11.title);
|
|
30339
|
-
const details = [
|
|
30340
|
-
role ? `role: ${role}` : "",
|
|
30341
|
-
title ? `title: ${title}` : ""
|
|
30342
|
-
].filter(Boolean).join(", ");
|
|
30343
|
-
const status = readString(record11.status);
|
|
30344
|
-
return `- ${name} (agentId: ${id})${details ? ` \u2014 ${details}` : ""}${status && status !== "active" ? ` [${status}]` : ""}`;
|
|
30345
|
-
});
|
|
30346
|
-
return [
|
|
30347
|
-
"Company agent roster:",
|
|
30348
|
-
'When the user refers to a Company employee by name, role, or pronoun (e.g. @-mention or "\u95EE\u4ED6"), resolve them from this roster and invoke them with the invoke_employee runtime action using their exact agentId. Never substitute a local subagent for a Company employee.',
|
|
30349
|
-
...lines,
|
|
30350
|
-
...roster.truncated === true ? ["(roster truncated; use the governed member-list read for the full roster)"] : []
|
|
30351
|
-
].join("\n");
|
|
30352
|
-
}
|
|
30353
30599
|
function compileConversationPrompt(input, context, maxChars) {
|
|
30354
30600
|
const mode = promptContextMode(input);
|
|
30355
30601
|
const taskText = readString(input.taskMarkdown) ?? "";
|
|
@@ -30374,7 +30620,6 @@ function compileConversationPrompt(input, context, maxChars) {
|
|
|
30374
30620
|
{ name: "runtime_safety", title: "Runtime Safety", priority: 100, sourceRef: `command:${input.commandId}`, content: runtimeSafety },
|
|
30375
30621
|
...piGovernedTools ? [{ name: "pi_governed_tools", title: "Pi Governed Tools", priority: 96, sourceRef: "amaster_governed_mcp_direct_typed_contract", content: piGovernedTools }] : [],
|
|
30376
30622
|
{ name: "agent_instructions", title: "Agent Instructions", priority: 100, sourceRef: "agent_instructions_bundle", content: readString(input.agentInstructions) ?? "" },
|
|
30377
|
-
{ name: "agent_roster", title: "Company Agent Roster", priority: 86, sourceRef: "company_agent_roster", content: conversationAgentRosterText(context) },
|
|
30378
30623
|
{ name: "mention_context", title: "Mentioned Context", priority: 85, sourceRef: "paperclip_mention_context", content: readString(input.mentionContextText) ?? "" },
|
|
30379
30624
|
{ name: "attachments", title: "Materialized Inputs", priority: 80, sourceRef: "materialized_attachments", content: readString(input.attachmentsText) ?? "" },
|
|
30380
30625
|
{ name: "raw_snapshot", title: "Raw Context Snapshot", priority: 0, sourceRef: `run:${input.runId ?? "unknown"}`, originalChars: jsonCharLength(context), content: "", truncationReason: "on_demand_large_object" }
|
|
@@ -31066,7 +31311,6 @@ var COMPANY_INITIALIZATION_PRE_AUTHORITY_SECTIONS = /* @__PURE__ */ new Set([
|
|
|
31066
31311
|
"governed_reads",
|
|
31067
31312
|
"optional_task_wiki_context",
|
|
31068
31313
|
"mention_context",
|
|
31069
|
-
"agent_roster",
|
|
31070
31314
|
"attachments"
|
|
31071
31315
|
]);
|
|
31072
31316
|
var COMPANY_INITIALIZATION_POST_AUTHORITY_SECTIONS = /* @__PURE__ */ new Set([
|
|
@@ -31245,7 +31489,6 @@ var CONTEXT_AVAILABILITY_SECTION_TITLES = Object.freeze({
|
|
|
31245
31489
|
optional_task_wiki_context: "Optional Company Wiki Context",
|
|
31246
31490
|
agent_instructions: "Agent Instructions",
|
|
31247
31491
|
mention_context: "Mentioned Context",
|
|
31248
|
-
agent_roster: "Company Agent Roster",
|
|
31249
31492
|
attachments: "Materialized Inputs",
|
|
31250
31493
|
on_demand_refs: "On-demand Context References",
|
|
31251
31494
|
raw_snapshot: "Raw Context Snapshot"
|
|
@@ -31590,12 +31833,12 @@ ${resolvedDependencies.details.content}` : resolvedDependencies.details.content
|
|
|
31590
31833
|
|
|
31591
31834
|
// src/amaster-runtime-daemon/agent-instruction-delivery.mjs
|
|
31592
31835
|
import { createHash as createHash13, randomBytes } from "node:crypto";
|
|
31593
|
-
import { existsSync as existsSync10, lstatSync as lstatSync8, mkdirSync as
|
|
31594
|
-
import { dirname as
|
|
31836
|
+
import { existsSync as existsSync10, lstatSync as lstatSync8, mkdirSync as mkdirSync9, readFileSync as readFileSync10, readdirSync as readdirSync7, realpathSync as realpathSync9, renameSync as renameSync7, rmSync as rmSync8, writeFileSync as writeFileSync10 } from "node:fs";
|
|
31837
|
+
import { dirname as dirname8, isAbsolute as isAbsolute6, join as join14, relative as relative4, resolve as resolve8 } from "node:path";
|
|
31595
31838
|
|
|
31596
31839
|
// src/amaster-runtime-daemon/workspace-manifest.mjs
|
|
31597
|
-
import { chownSync as chownSync3, existsSync as existsSync9, readFileSync as readFileSync9, renameSync as
|
|
31598
|
-
import { basename as basename5, dirname as
|
|
31840
|
+
import { chownSync as chownSync3, existsSync as existsSync9, readFileSync as readFileSync9, renameSync as renameSync6, rmSync as rmSync7, statSync as statSync5, writeFileSync as writeFileSync9 } from "node:fs";
|
|
31841
|
+
import { basename as basename5, dirname as dirname7, join as join13 } from "node:path";
|
|
31599
31842
|
var WORKSPACE_MANIFEST_FILENAME = ".amaster-runtime.json";
|
|
31600
31843
|
function syncManifestDirOwnership(manifestPath, deps = {}) {
|
|
31601
31844
|
const stat = deps.statSync ?? statSync5;
|
|
@@ -31603,7 +31846,7 @@ function syncManifestDirOwnership(manifestPath, deps = {}) {
|
|
|
31603
31846
|
const geteuid = deps.geteuid ?? (typeof process.geteuid === "function" ? process.geteuid.bind(process) : () => null);
|
|
31604
31847
|
try {
|
|
31605
31848
|
if (geteuid() !== 0) return false;
|
|
31606
|
-
const dirStat = stat(
|
|
31849
|
+
const dirStat = stat(dirname7(manifestPath));
|
|
31607
31850
|
if (dirStat.uid === 0 && dirStat.gid === 0) return false;
|
|
31608
31851
|
chown(manifestPath, dirStat.uid, dirStat.gid);
|
|
31609
31852
|
return true;
|
|
@@ -31616,8 +31859,8 @@ function nowIso() {
|
|
|
31616
31859
|
}
|
|
31617
31860
|
function workspaceManifestPath(workspaceOrCwd) {
|
|
31618
31861
|
if (!workspaceOrCwd) return null;
|
|
31619
|
-
if (typeof workspaceOrCwd === "string") return
|
|
31620
|
-
if (typeof workspaceOrCwd.cwd === "string") return
|
|
31862
|
+
if (typeof workspaceOrCwd === "string") return join13(workspaceOrCwd, WORKSPACE_MANIFEST_FILENAME);
|
|
31863
|
+
if (typeof workspaceOrCwd.cwd === "string") return join13(workspaceOrCwd.cwd, WORKSPACE_MANIFEST_FILENAME);
|
|
31621
31864
|
return null;
|
|
31622
31865
|
}
|
|
31623
31866
|
function readWorkspaceManifest(manifestPath) {
|
|
@@ -31630,17 +31873,17 @@ function readWorkspaceManifest(manifestPath) {
|
|
|
31630
31873
|
}
|
|
31631
31874
|
}
|
|
31632
31875
|
function writeWorkspaceManifest(manifestPath, manifest, deps) {
|
|
31633
|
-
const tempPath =
|
|
31634
|
-
|
|
31876
|
+
const tempPath = join13(
|
|
31877
|
+
dirname7(manifestPath),
|
|
31635
31878
|
`.${basename5(manifestPath)}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2)}`
|
|
31636
31879
|
);
|
|
31637
31880
|
try {
|
|
31638
|
-
|
|
31881
|
+
writeFileSync9(tempPath, `${JSON.stringify(manifest, null, 2)}
|
|
31639
31882
|
`, { mode: 384 });
|
|
31640
|
-
|
|
31883
|
+
renameSync6(tempPath, manifestPath);
|
|
31641
31884
|
syncManifestDirOwnership(manifestPath, deps);
|
|
31642
31885
|
} catch (err) {
|
|
31643
|
-
|
|
31886
|
+
rmSync7(tempPath, { force: true });
|
|
31644
31887
|
throw err;
|
|
31645
31888
|
}
|
|
31646
31889
|
return manifest;
|
|
@@ -31728,7 +31971,7 @@ function isManagedExecutionDirectory(directory, managedWorkspacesRoot) {
|
|
|
31728
31971
|
const managedRoot = canonicalExistingPath(managedWorkspacesRoot);
|
|
31729
31972
|
const candidate = canonicalExistingPath(directory);
|
|
31730
31973
|
if (!pathWithin(candidate, managedRoot)) return false;
|
|
31731
|
-
const manifestPath =
|
|
31974
|
+
const manifestPath = join14(candidate, WORKSPACE_MANIFEST_FILENAME);
|
|
31732
31975
|
const manifestStat = lstatIfPresent2(manifestPath);
|
|
31733
31976
|
if (!manifestStat?.isFile() || manifestStat.isSymbolicLink()) return false;
|
|
31734
31977
|
try {
|
|
@@ -31844,7 +32087,7 @@ ${repositoryBlock}
|
|
|
31844
32087
|
}
|
|
31845
32088
|
function assertProjectionTargetAncestors(targetPath, targetRoot) {
|
|
31846
32089
|
const pending = [];
|
|
31847
|
-
let current =
|
|
32090
|
+
let current = dirname8(targetPath);
|
|
31848
32091
|
while (current !== targetRoot) {
|
|
31849
32092
|
if (!pathWithin(current, targetRoot)) {
|
|
31850
32093
|
throw instructionTopologyError(
|
|
@@ -31853,12 +32096,12 @@ function assertProjectionTargetAncestors(targetPath, targetRoot) {
|
|
|
31853
32096
|
);
|
|
31854
32097
|
}
|
|
31855
32098
|
pending.push(current);
|
|
31856
|
-
current =
|
|
32099
|
+
current = dirname8(current);
|
|
31857
32100
|
}
|
|
31858
32101
|
pending.push(targetRoot);
|
|
31859
32102
|
for (const directory of pending.reverse()) {
|
|
31860
32103
|
if (!existsSync10(directory)) {
|
|
31861
|
-
|
|
32104
|
+
mkdirSync9(directory, { mode: 448 });
|
|
31862
32105
|
continue;
|
|
31863
32106
|
}
|
|
31864
32107
|
const stat = lstatSync8(directory);
|
|
@@ -31941,10 +32184,10 @@ function projectExternalWorkspaceProjectInstructions(sourceWorkspacePath, execut
|
|
|
31941
32184
|
assertProjectionTargetAncestors(targetPath, targetRoot);
|
|
31942
32185
|
const temporaryPath = `${targetPath}.mirrorx-${randomBytes(12).toString("hex")}.tmp`;
|
|
31943
32186
|
try {
|
|
31944
|
-
|
|
31945
|
-
|
|
32187
|
+
writeFileSync10(temporaryPath, projectedContent, { encoding: "utf8", flag: "wx", mode: 384 });
|
|
32188
|
+
renameSync7(temporaryPath, targetPath);
|
|
31946
32189
|
} finally {
|
|
31947
|
-
|
|
32190
|
+
rmSync8(temporaryPath, { force: true });
|
|
31948
32191
|
}
|
|
31949
32192
|
modelFacingFile = "AGENTS.md";
|
|
31950
32193
|
modelFacingBytes = Buffer.byteLength(projectedContent, "utf8");
|
|
@@ -32015,9 +32258,9 @@ function agentInstructionDeliveryAudit(bundle, delivery) {
|
|
|
32015
32258
|
}
|
|
32016
32259
|
|
|
32017
32260
|
// src/amaster-runtime-daemon/config-state.mjs
|
|
32018
|
-
import { existsSync as existsSync11, mkdirSync as
|
|
32261
|
+
import { existsSync as existsSync11, mkdirSync as mkdirSync10, readFileSync as readFileSync11, renameSync as renameSync8, rmSync as rmSync9, writeFileSync as writeFileSync11 } from "node:fs";
|
|
32019
32262
|
import { homedir as homedir3, hostname } from "node:os";
|
|
32020
|
-
import { dirname as
|
|
32263
|
+
import { dirname as dirname9, join as join15, parse as parse3, resolve as resolve9 } from "node:path";
|
|
32021
32264
|
|
|
32022
32265
|
// src/amaster-runtime-daemon/capability-registry.mjs
|
|
32023
32266
|
var BUILD_SUPPORTED_CAPABILITIES = Object.freeze([
|
|
@@ -32153,19 +32396,19 @@ function defaultMachineId() {
|
|
|
32153
32396
|
}
|
|
32154
32397
|
function runtimeHome(env) {
|
|
32155
32398
|
return expandHomePath(String(
|
|
32156
|
-
env.AMASTER_RUNTIME_STATE_HOME || env.AMASTER_RUNTIME_HOME ||
|
|
32399
|
+
env.AMASTER_RUNTIME_STATE_HOME || env.AMASTER_RUNTIME_HOME || join15(homedir3(), ".amaster-employee")
|
|
32157
32400
|
));
|
|
32158
32401
|
}
|
|
32159
32402
|
function runtimeTemplatesRoot(env, home) {
|
|
32160
32403
|
const configured = String(env.AMASTER_RUNTIME_TEMPLATES_ROOT ?? "").trim();
|
|
32161
|
-
const resolved = configured ? resolve9(expandHomePath(configured)) : resolve9(String(env.PI_CODING_AGENT_DIR ?? "")) === "/data/.pi" ? "/data/templates" : resolve9(
|
|
32404
|
+
const resolved = configured ? resolve9(expandHomePath(configured)) : resolve9(String(env.PI_CODING_AGENT_DIR ?? "")) === "/data/.pi" ? "/data/templates" : resolve9(join15(home, "templates"));
|
|
32162
32405
|
if (resolved === parse3(resolved).root) {
|
|
32163
32406
|
throw new Error("AMASTER_RUNTIME_TEMPLATES_ROOT must not be a filesystem root");
|
|
32164
32407
|
}
|
|
32165
32408
|
return resolved;
|
|
32166
32409
|
}
|
|
32167
32410
|
function stateFilePath(env) {
|
|
32168
|
-
return env.AMASTER_DAEMON_STATE_FILE ? expandHomePath(String(env.AMASTER_DAEMON_STATE_FILE)) :
|
|
32411
|
+
return env.AMASTER_DAEMON_STATE_FILE ? expandHomePath(String(env.AMASTER_DAEMON_STATE_FILE)) : join15(runtimeHome(env), "runtime-connector-state.json");
|
|
32169
32412
|
}
|
|
32170
32413
|
function corruptStatePath(path) {
|
|
32171
32414
|
const timestamp2 = (/* @__PURE__ */ new Date()).toISOString().replace(/\D/g, "").slice(0, 14);
|
|
@@ -32188,7 +32431,7 @@ function readState(env) {
|
|
|
32188
32431
|
} catch {
|
|
32189
32432
|
const quarantinePath = corruptStatePath(path);
|
|
32190
32433
|
try {
|
|
32191
|
-
|
|
32434
|
+
renameSync8(path, quarantinePath);
|
|
32192
32435
|
process.stderr.write(`AMaster runtime state was invalid and quarantined at ${quarantinePath}
|
|
32193
32436
|
`);
|
|
32194
32437
|
} catch (error) {
|
|
@@ -32202,17 +32445,17 @@ function readState(env) {
|
|
|
32202
32445
|
}
|
|
32203
32446
|
function writeState(env, state) {
|
|
32204
32447
|
const path = stateFilePath(env);
|
|
32205
|
-
|
|
32448
|
+
mkdirSync10(dirname9(path), { recursive: true });
|
|
32206
32449
|
const temporaryPath = `${path}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
32207
32450
|
try {
|
|
32208
|
-
|
|
32451
|
+
writeFileSync11(temporaryPath, `${JSON.stringify(state, null, 2)}
|
|
32209
32452
|
`, {
|
|
32210
32453
|
flag: "wx",
|
|
32211
32454
|
mode: 384
|
|
32212
32455
|
});
|
|
32213
|
-
|
|
32456
|
+
renameSync8(temporaryPath, path);
|
|
32214
32457
|
} finally {
|
|
32215
|
-
|
|
32458
|
+
rmSync9(temporaryPath, { force: true });
|
|
32216
32459
|
}
|
|
32217
32460
|
}
|
|
32218
32461
|
function buildConfig(env = process.env, flags = {}) {
|
|
@@ -32225,10 +32468,10 @@ function buildConfig(env = process.env, flags = {}) {
|
|
|
32225
32468
|
const home = runtimeHome(env);
|
|
32226
32469
|
const templatesRoot = runtimeTemplatesRoot(env, home);
|
|
32227
32470
|
const runtimeWorkspacesRoot = expandHomePath(
|
|
32228
|
-
String(flags.runtimeWorkspacesRoot ?? env.AMASTER_RUNTIME_WORKSPACES_ROOT ??
|
|
32471
|
+
String(flags.runtimeWorkspacesRoot ?? env.AMASTER_RUNTIME_WORKSPACES_ROOT ?? join15(home, "workspaces"))
|
|
32229
32472
|
);
|
|
32230
32473
|
const browserSessionStateRoot = expandHomePath(String(
|
|
32231
|
-
flags.browserSessionStateRoot ?? env.AMASTER_BROWSER_SESSION_STATE_ROOT ??
|
|
32474
|
+
flags.browserSessionStateRoot ?? env.AMASTER_BROWSER_SESSION_STATE_ROOT ?? join15(home, "browser-auth")
|
|
32232
32475
|
));
|
|
32233
32476
|
const piToolArgumentGuardModeValue = String(
|
|
32234
32477
|
flags.piToolArgumentGuardMode ?? env.AMASTER_PI_TOOL_ARGUMENT_GUARD_MODE ?? "shadow"
|
|
@@ -32254,7 +32497,7 @@ function buildConfig(env = process.env, flags = {}) {
|
|
|
32254
32497
|
"Pi tool argument enforce thresholds cannot be more aggressive than 8 MiB transport, 512 KiB materialized, and 16x amplification"
|
|
32255
32498
|
);
|
|
32256
32499
|
}
|
|
32257
|
-
|
|
32500
|
+
mkdirSync10(runtimeWorkspacesRoot, { recursive: true });
|
|
32258
32501
|
const workspaceBindings = splitList(
|
|
32259
32502
|
flags.workspaceAllowlist ?? env.AMASTER_WORKSPACE_ALLOWLIST ?? env.AMASTER_WORKSPACE_BINDINGS ?? runtimeWorkspacesRoot
|
|
32260
32503
|
).map(expandHomePath);
|
|
@@ -32447,7 +32690,7 @@ function createManifestOutputFlusher(opts = {}) {
|
|
|
32447
32690
|
import { randomBytes as randomBytes2, timingSafeEqual } from "node:crypto";
|
|
32448
32691
|
var BROWSER_CREDENTIAL_REQUEST_FD = 5;
|
|
32449
32692
|
var BROWSER_CREDENTIAL_RESPONSE_FD = 6;
|
|
32450
|
-
var
|
|
32693
|
+
var MAX_BYTES3 = 16 * 1024;
|
|
32451
32694
|
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu;
|
|
32452
32695
|
var AUTHORITY_FIELDS = /* @__PURE__ */ new Set([
|
|
32453
32696
|
"version",
|
|
@@ -32466,7 +32709,7 @@ var AUTHORITY_FIELDS = /* @__PURE__ */ new Set([
|
|
|
32466
32709
|
]);
|
|
32467
32710
|
function encodeBrowserCredentialFrame(type, payload) {
|
|
32468
32711
|
if (!/^[ACREV]$/u.test(type) || !Buffer.isBuffer(payload)) throw new Error("browser_credential_frame_invalid");
|
|
32469
|
-
if (payload.length >
|
|
32712
|
+
if (payload.length > MAX_BYTES3) throw new Error("browser_credential_frame_too_large");
|
|
32470
32713
|
return Buffer.concat([Buffer.from(`${type}${payload.length}
|
|
32471
32714
|
`, "ascii"), payload]);
|
|
32472
32715
|
}
|
|
@@ -32482,7 +32725,7 @@ function parseFrames(input, allowPartial) {
|
|
|
32482
32725
|
const match = /^([ACREV])([0-9]{1,6})$/u.exec(input.subarray(offset, newline).toString("ascii"));
|
|
32483
32726
|
if (!match) throw new Error("browser_credential_frame_invalid");
|
|
32484
32727
|
const length = Number(match[2]);
|
|
32485
|
-
if (length >
|
|
32728
|
+
if (length > MAX_BYTES3) throw new Error("browser_credential_frame_too_large");
|
|
32486
32729
|
const end = newline + 1 + length;
|
|
32487
32730
|
if (end > input.length) {
|
|
32488
32731
|
if (allowPartial) break;
|
|
@@ -32586,7 +32829,7 @@ function createBrowserCredentialChannel({ consume }) {
|
|
|
32586
32829
|
};
|
|
32587
32830
|
const handleFrame = async (frame) => {
|
|
32588
32831
|
if (frame.type === "A") return handleReceipt(frame);
|
|
32589
|
-
if (frame.type !== "R" || frame.payload.length >
|
|
32832
|
+
if (frame.type !== "R" || frame.payload.length > MAX_BYTES3) return respondError("browser_credential_request_invalid");
|
|
32590
32833
|
let decoded;
|
|
32591
32834
|
try {
|
|
32592
32835
|
decoded = JSON.parse(frame.payload.toString("utf8"));
|
|
@@ -32604,7 +32847,7 @@ function createBrowserCredentialChannel({ consume }) {
|
|
|
32604
32847
|
try {
|
|
32605
32848
|
const value = await consume(request);
|
|
32606
32849
|
bytes = Buffer.isBuffer(value) ? value : Buffer.from(value, "utf8");
|
|
32607
|
-
if (bytes.length === 0 || bytes.length >
|
|
32850
|
+
if (bytes.length === 0 || bytes.length > MAX_BYTES3) throw new Error("browser_credential_value_invalid");
|
|
32608
32851
|
responseFrame = encodeBrowserCredentialFrame("V", bytes);
|
|
32609
32852
|
responsePipe.write(responseFrame, () => {
|
|
32610
32853
|
responseFrame.fill(0);
|
|
@@ -32625,7 +32868,7 @@ function createBrowserCredentialChannel({ consume }) {
|
|
|
32625
32868
|
requestPipe.on("data", (chunk) => {
|
|
32626
32869
|
if (closed) return;
|
|
32627
32870
|
requestBuffer = Buffer.concat([requestBuffer, Buffer.from(chunk)]);
|
|
32628
|
-
if (requestBuffer.length >
|
|
32871
|
+
if (requestBuffer.length > MAX_BYTES3 * 3) {
|
|
32629
32872
|
closed = true;
|
|
32630
32873
|
responsePipe.end();
|
|
32631
32874
|
return;
|
|
@@ -32658,7 +32901,7 @@ function createBrowserCredentialChannel({ consume }) {
|
|
|
32658
32901
|
// src/amaster-runtime-daemon/browser-credential-readiness.mjs
|
|
32659
32902
|
import { existsSync as existsSync12, readFileSync as readFileSync12, statSync as statSync6 } from "node:fs";
|
|
32660
32903
|
import { homedir as homedir4 } from "node:os";
|
|
32661
|
-
import { isAbsolute as isAbsolute7, join as
|
|
32904
|
+
import { isAbsolute as isAbsolute7, join as join16, relative as relative5, resolve as resolve10 } from "node:path";
|
|
32662
32905
|
var CAPABILITY = "browser_credential_auth_transaction_v1";
|
|
32663
32906
|
var CREDENTIAL_BROWSER_TCB = Object.freeze({
|
|
32664
32907
|
package: "chrome-devtools-mcp",
|
|
@@ -32670,13 +32913,13 @@ var CREDENTIAL_BROWSER_TCB = Object.freeze({
|
|
|
32670
32913
|
var READINESS_CACHE_TTL_MS = 5e3;
|
|
32671
32914
|
var readinessCache = /* @__PURE__ */ new Map();
|
|
32672
32915
|
function inspectBrowserCredentialAuthReadiness(env = process.env) {
|
|
32673
|
-
const home = String(env.PI_CODING_AGENT_DIR ?? env.PI_AGENT_HOME ??
|
|
32916
|
+
const home = String(env.PI_CODING_AGENT_DIR ?? env.PI_AGENT_HOME ?? join16(homedir4(), ".pi", "agent")).trim();
|
|
32674
32917
|
const now = Date.now();
|
|
32675
32918
|
const cached = readinessCache.get(home);
|
|
32676
32919
|
if (cached && cached.expiresAt > now) return { ...cached.readiness };
|
|
32677
32920
|
const candidates = [
|
|
32678
|
-
|
|
32679
|
-
|
|
32921
|
+
join16(home, "npm", "node_modules", "@amaster.ai", "pi-browser-use", "package.json"),
|
|
32922
|
+
join16(home, "node_modules", "@amaster.ai", "pi-browser-use", "package.json")
|
|
32680
32923
|
];
|
|
32681
32924
|
const packageAttested = candidates.some(attestedPackageManifest);
|
|
32682
32925
|
const readiness = {
|
|
@@ -32714,15 +32957,15 @@ function sameCredentialBrowserTcb(value) {
|
|
|
32714
32957
|
// src/amaster-runtime-daemon/browser-credential-env-readiness.mjs
|
|
32715
32958
|
import { lstatSync as lstatSync9, readFileSync as readFileSync13 } from "node:fs";
|
|
32716
32959
|
import { homedir as homedir5 } from "node:os";
|
|
32717
|
-
import { join as
|
|
32960
|
+
import { join as join17 } from "node:path";
|
|
32718
32961
|
var CACHE_TTL_MS = 5e3;
|
|
32719
32962
|
var cache = /* @__PURE__ */ new Map();
|
|
32720
32963
|
function inspectBrowserCredentialEnvReadiness(env = process.env) {
|
|
32721
|
-
const home = String(env.PI_CODING_AGENT_DIR ?? env.PI_AGENT_HOME ??
|
|
32964
|
+
const home = String(env.PI_CODING_AGENT_DIR ?? env.PI_AGENT_HOME ?? join17(homedir5(), ".pi", "agent")).trim();
|
|
32722
32965
|
const now = Date.now();
|
|
32723
32966
|
const cached = cache.get(home);
|
|
32724
32967
|
if (cached && cached.expiresAt > now) return { ...cached.readiness };
|
|
32725
|
-
const extensionPath =
|
|
32968
|
+
const extensionPath = join17(home, "extensions", "browser-credential-env.mjs");
|
|
32726
32969
|
let extension = false;
|
|
32727
32970
|
try {
|
|
32728
32971
|
const stat = lstatSync9(extensionPath);
|
|
@@ -32737,8 +32980,8 @@ function inspectBrowserCredentialEnvReadiness(env = process.env) {
|
|
|
32737
32980
|
}
|
|
32738
32981
|
|
|
32739
32982
|
// src/amaster-runtime-daemon/browser-credential-env.mjs
|
|
32740
|
-
import { chmodSync as
|
|
32741
|
-
import { join as
|
|
32983
|
+
import { chmodSync as chmodSync6, mkdtempSync as mkdtempSync3, renameSync as renameSync9, rmSync as rmSync10, writeFileSync as writeFileSync12 } from "node:fs";
|
|
32984
|
+
import { join as join18, resolve as resolve11 } from "node:path";
|
|
32742
32985
|
var BROWSER_CREDENTIAL_ENV_CAPABILITY = "browser_credential_env_read_v1";
|
|
32743
32986
|
var BROWSER_CREDENTIAL_PRIVATE_CAPABILITY = "browser_credential_auth_transaction_v1";
|
|
32744
32987
|
var BROWSER_CREDENTIAL_ENV_FILE = "PI_AGENT_BROWSER_CREDENTIAL_ENV_FILE";
|
|
@@ -32814,10 +33057,10 @@ async function materializeBrowserCredentialEnv(plan, options) {
|
|
|
32814
33057
|
const rawRunDir = String(options.runDir ?? "").trim();
|
|
32815
33058
|
if (!rawRunDir) fail2("browser_credential_env_run_dir_invalid");
|
|
32816
33059
|
const runDir = resolve11(rawRunDir);
|
|
32817
|
-
const credentialDir = mkdtempSync3(
|
|
32818
|
-
|
|
32819
|
-
const targetPath =
|
|
32820
|
-
const temporaryPath =
|
|
33060
|
+
const credentialDir = mkdtempSync3(join18(runDir, ".browser-credentials-"));
|
|
33061
|
+
chmodSync6(credentialDir, 448);
|
|
33062
|
+
const targetPath = join18(credentialDir, "credentials.env");
|
|
33063
|
+
const temporaryPath = join18(credentialDir, ".credentials.env.tmp");
|
|
32821
33064
|
const buffers = [];
|
|
32822
33065
|
const protectedValues = [];
|
|
32823
33066
|
try {
|
|
@@ -32831,20 +33074,20 @@ async function materializeBrowserCredentialEnv(plan, options) {
|
|
|
32831
33074
|
if (!protectedValues.includes(value)) protectedValues.push(value);
|
|
32832
33075
|
lines.push(`${entry.key}=${dotenvQuotedValue(value)}`);
|
|
32833
33076
|
}
|
|
32834
|
-
|
|
33077
|
+
writeFileSync12(temporaryPath, `${lines.join("\n")}
|
|
32835
33078
|
`, { encoding: "utf8", mode: 384, flag: "wx" });
|
|
32836
|
-
|
|
32837
|
-
|
|
33079
|
+
renameSync9(temporaryPath, targetPath);
|
|
33080
|
+
chmodSync6(targetPath, 384);
|
|
32838
33081
|
return {
|
|
32839
33082
|
dirPath: credentialDir,
|
|
32840
33083
|
filePath: targetPath,
|
|
32841
33084
|
protectedValues,
|
|
32842
33085
|
cleanup() {
|
|
32843
|
-
|
|
33086
|
+
rmSync10(credentialDir, { recursive: true, force: true });
|
|
32844
33087
|
}
|
|
32845
33088
|
};
|
|
32846
33089
|
} catch (error) {
|
|
32847
|
-
|
|
33090
|
+
rmSync10(credentialDir, { recursive: true, force: true });
|
|
32848
33091
|
throw error;
|
|
32849
33092
|
} finally {
|
|
32850
33093
|
for (const buffer of buffers) buffer.fill(0);
|
|
@@ -33232,8 +33475,8 @@ function createRuntimeArtifactIngestQueue({ ingest, onError }) {
|
|
|
33232
33475
|
|
|
33233
33476
|
// src/amaster-runtime-daemon/workspace-guard.mjs
|
|
33234
33477
|
import { createHash as createHash16 } from "node:crypto";
|
|
33235
|
-
import { existsSync as existsSync13, mkdirSync as
|
|
33236
|
-
import { basename as basename6, join as
|
|
33478
|
+
import { existsSync as existsSync13, mkdirSync as mkdirSync11, realpathSync as realpathSync11, statSync as statSync7 } from "node:fs";
|
|
33479
|
+
import { basename as basename6, join as join19, isAbsolute as isAbsolute9, relative as relative7, resolve as resolve13 } from "node:path";
|
|
33237
33480
|
function pathWithin3(candidate, root) {
|
|
33238
33481
|
const rel = relative7(root, candidate);
|
|
33239
33482
|
return rel === "" || !rel.startsWith("..") && !isAbsolute9(rel);
|
|
@@ -33289,7 +33532,7 @@ function workspaceLabel(sourceWorkspacePath, payload) {
|
|
|
33289
33532
|
}
|
|
33290
33533
|
function workspacesRoot(config) {
|
|
33291
33534
|
const root = resolve13(expandHomePath(config.runtimeWorkspacesRoot ?? "~/.amaster-employee/workspaces"));
|
|
33292
|
-
|
|
33535
|
+
mkdirSync11(root, { recursive: true });
|
|
33293
33536
|
return realpathSync11(root);
|
|
33294
33537
|
}
|
|
33295
33538
|
function resolveExecutionWorkspace(config, command, opts = {}) {
|
|
@@ -33302,11 +33545,11 @@ function resolveExecutionWorkspace(config, command, opts = {}) {
|
|
|
33302
33545
|
const workspaceKey = `${safeSegment(workspaceLabel(sourceWorkspacePath, payload), "workspace")}-${shortHash(sourceWorkspacePath)}`;
|
|
33303
33546
|
const issueKey = `${safeSegment(issueLabel(command, payload), "issue")}-${shortHash(issueId, 8)}`;
|
|
33304
33547
|
const runKey = `${safeSegment(runId, "run")}-${shortHash(runId, 8)}`;
|
|
33305
|
-
const runDir =
|
|
33306
|
-
const cwd =
|
|
33307
|
-
const executorHome =
|
|
33308
|
-
|
|
33309
|
-
|
|
33548
|
+
const runDir = join19(root, workspaceKey, issueKey, runKey);
|
|
33549
|
+
const cwd = join19(runDir, "workdir");
|
|
33550
|
+
const executorHome = join19(runDir, "executors", safeSegment(executorKind, "executor"));
|
|
33551
|
+
mkdirSync11(cwd, { recursive: true });
|
|
33552
|
+
mkdirSync11(executorHome, { recursive: true });
|
|
33310
33553
|
const workspace = {
|
|
33311
33554
|
managed: true,
|
|
33312
33555
|
cwd,
|
|
@@ -33329,7 +33572,7 @@ function resolveExecutionWorkspace(config, command, opts = {}) {
|
|
|
33329
33572
|
|
|
33330
33573
|
// src/amaster-runtime-daemon/workspace-gc.mjs
|
|
33331
33574
|
import { existsSync as existsSync14, readdirSync as readdirSync8, statSync as statSync8 } from "node:fs";
|
|
33332
|
-
import { join as
|
|
33575
|
+
import { join as join20, resolve as resolve14 } from "node:path";
|
|
33333
33576
|
function readIsoTime(value) {
|
|
33334
33577
|
if (typeof value !== "string" || !value.trim()) return null;
|
|
33335
33578
|
const time2 = new Date(value).getTime();
|
|
@@ -33352,7 +33595,7 @@ function walkWorkdirs(root) {
|
|
|
33352
33595
|
}
|
|
33353
33596
|
for (const entry of entries) {
|
|
33354
33597
|
if (!entry.isDirectory()) continue;
|
|
33355
|
-
const fullPath =
|
|
33598
|
+
const fullPath = join20(current, entry.name);
|
|
33356
33599
|
if (entry.name === "workdir" && existsSync14(workspaceManifestPath(fullPath))) {
|
|
33357
33600
|
workdirs.push(fullPath);
|
|
33358
33601
|
continue;
|
|
@@ -33384,7 +33627,7 @@ function directorySizeBytes(path) {
|
|
|
33384
33627
|
continue;
|
|
33385
33628
|
}
|
|
33386
33629
|
for (const entry of entries) {
|
|
33387
|
-
stack.push(
|
|
33630
|
+
stack.push(join20(current, entry.name));
|
|
33388
33631
|
}
|
|
33389
33632
|
continue;
|
|
33390
33633
|
}
|
|
@@ -33459,21 +33702,21 @@ function planManagedWorkspaceGcDryRun(input) {
|
|
|
33459
33702
|
import { createHash as createHash17 } from "node:crypto";
|
|
33460
33703
|
import {
|
|
33461
33704
|
accessSync,
|
|
33462
|
-
chmodSync as
|
|
33705
|
+
chmodSync as chmodSync7,
|
|
33463
33706
|
constants as constants4,
|
|
33464
33707
|
existsSync as existsSync15,
|
|
33465
33708
|
lstatSync as lstatSync11,
|
|
33466
|
-
mkdirSync as
|
|
33709
|
+
mkdirSync as mkdirSync12,
|
|
33467
33710
|
mkdtempSync as mkdtempSync4,
|
|
33468
33711
|
readFileSync as readFileSync15,
|
|
33469
33712
|
readdirSync as readdirSync9,
|
|
33470
|
-
renameSync as
|
|
33471
|
-
rmSync as
|
|
33713
|
+
renameSync as renameSync10,
|
|
33714
|
+
rmSync as rmSync11,
|
|
33472
33715
|
statSync as statSync9,
|
|
33473
33716
|
unlinkSync as unlinkSync2,
|
|
33474
|
-
writeFileSync as
|
|
33717
|
+
writeFileSync as writeFileSync13
|
|
33475
33718
|
} from "node:fs";
|
|
33476
|
-
import { dirname as
|
|
33719
|
+
import { dirname as dirname10, extname, isAbsolute as isAbsolute10, join as join21, parse as parse4, resolve as resolve15, sep as sep4 } from "node:path";
|
|
33477
33720
|
import { fileURLToPath } from "node:url";
|
|
33478
33721
|
var PRESET_TEMPLATE_MANIFEST_FILE = ".mirrorx-preset-templates.json";
|
|
33479
33722
|
var MAX_PRESET_TEMPLATE_FILES = 256;
|
|
@@ -33499,7 +33742,7 @@ function modeAllows(stat, identity, ownerBit, groupBit, otherBit) {
|
|
|
33499
33742
|
function assertCatalogReadableByExecutor(targetDir, fileNames, identity) {
|
|
33500
33743
|
if (!identity) {
|
|
33501
33744
|
accessSync(targetDir, constants4.R_OK | constants4.X_OK);
|
|
33502
|
-
for (const name of fileNames) accessSync(
|
|
33745
|
+
for (const name of fileNames) accessSync(join21(targetDir, name), constants4.R_OK);
|
|
33503
33746
|
return;
|
|
33504
33747
|
}
|
|
33505
33748
|
let current = targetDir;
|
|
@@ -33508,7 +33751,7 @@ function assertCatalogReadableByExecutor(targetDir, fileNames, identity) {
|
|
|
33508
33751
|
if (!stat.isDirectory() || !modeAllows(stat, identity, 64, 8, 1)) {
|
|
33509
33752
|
throw new Error(`preset_template_executor_path_unreadable: ${current}`);
|
|
33510
33753
|
}
|
|
33511
|
-
const parent =
|
|
33754
|
+
const parent = dirname10(current);
|
|
33512
33755
|
if (parent === current) break;
|
|
33513
33756
|
current = parent;
|
|
33514
33757
|
}
|
|
@@ -33517,7 +33760,7 @@ function assertCatalogReadableByExecutor(targetDir, fileNames, identity) {
|
|
|
33517
33760
|
throw new Error(`preset_template_executor_catalog_unreadable: ${targetDir}`);
|
|
33518
33761
|
}
|
|
33519
33762
|
for (const name of fileNames) {
|
|
33520
|
-
const path =
|
|
33763
|
+
const path = join21(targetDir, name);
|
|
33521
33764
|
const stat = statSync9(path);
|
|
33522
33765
|
if (!stat.isFile() || !modeAllows(stat, identity, 256, 32, 4)) {
|
|
33523
33766
|
throw new Error(`preset_template_executor_file_unreadable: ${name}`);
|
|
@@ -33561,7 +33804,7 @@ function readManifest(manifestPath, { strict }) {
|
|
|
33561
33804
|
}
|
|
33562
33805
|
function verifiedBundleFiles(sourceDir, manifest) {
|
|
33563
33806
|
return manifest.files.map((entry) => {
|
|
33564
|
-
const sourcePath =
|
|
33807
|
+
const sourcePath = join21(sourceDir, entry.name);
|
|
33565
33808
|
const stat = lstatSync11(sourcePath);
|
|
33566
33809
|
if (!stat.isFile() || stat.isSymbolicLink()) {
|
|
33567
33810
|
throw new Error(`preset_template_bundle_file_unsafe: ${entry.name}`);
|
|
@@ -33576,7 +33819,7 @@ function verifiedBundleFiles(sourceDir, manifest) {
|
|
|
33576
33819
|
function removeRetiredPresetFiles(targetDir, previousManifest, nextNames) {
|
|
33577
33820
|
for (const entry of previousManifest.files) {
|
|
33578
33821
|
if (nextNames.has(entry.name)) continue;
|
|
33579
|
-
const targetPath =
|
|
33822
|
+
const targetPath = join21(targetDir, entry.name);
|
|
33580
33823
|
if (!existsSync15(targetPath)) continue;
|
|
33581
33824
|
const stat = lstatSync11(targetPath);
|
|
33582
33825
|
if (stat.isDirectory()) {
|
|
@@ -33591,36 +33834,36 @@ function materializeBundledPresetTemplates(input) {
|
|
|
33591
33834
|
if (sourceDir === targetDir || sourceDir.startsWith(`${targetDir}${sep4}`) || targetDir.startsWith(`${sourceDir}${sep4}`)) {
|
|
33592
33835
|
throw new Error("preset_template_source_target_overlap");
|
|
33593
33836
|
}
|
|
33594
|
-
const manifest = readManifest(
|
|
33837
|
+
const manifest = readManifest(join21(sourceDir, PRESET_TEMPLATE_MANIFEST_FILE), { strict: true });
|
|
33595
33838
|
const verifiedFiles = verifiedBundleFiles(sourceDir, manifest);
|
|
33596
|
-
|
|
33839
|
+
mkdirSync12(dirname10(targetDir), { recursive: true, mode: 493 });
|
|
33597
33840
|
const targetStat = lstatIfExists(targetDir);
|
|
33598
33841
|
if (targetStat && (!targetStat.isDirectory() || targetStat.isSymbolicLink())) {
|
|
33599
33842
|
throw new Error("preset_template_target_root_unsafe");
|
|
33600
33843
|
}
|
|
33601
|
-
|
|
33602
|
-
const previousManifest = readManifest(
|
|
33603
|
-
const stageDir = mkdtempSync4(
|
|
33844
|
+
mkdirSync12(targetDir, { recursive: true, mode: 493 });
|
|
33845
|
+
const previousManifest = readManifest(join21(targetDir, PRESET_TEMPLATE_MANIFEST_FILE), { strict: false });
|
|
33846
|
+
const stageDir = mkdtempSync4(join21(dirname10(targetDir), ".mirrorx-preset-templates-"));
|
|
33604
33847
|
try {
|
|
33605
33848
|
for (const file of verifiedFiles) {
|
|
33606
|
-
const stagedPath =
|
|
33607
|
-
|
|
33608
|
-
|
|
33609
|
-
|
|
33849
|
+
const stagedPath = join21(stageDir, file.name);
|
|
33850
|
+
writeFileSync13(stagedPath, file.body, { mode: 292 });
|
|
33851
|
+
chmodSync7(stagedPath, 292);
|
|
33852
|
+
renameSync10(stagedPath, join21(targetDir, file.name));
|
|
33610
33853
|
}
|
|
33611
33854
|
removeRetiredPresetFiles(targetDir, previousManifest, new Set(manifest.files.map((file) => file.name)));
|
|
33612
|
-
const stagedManifest =
|
|
33613
|
-
|
|
33855
|
+
const stagedManifest = join21(stageDir, PRESET_TEMPLATE_MANIFEST_FILE);
|
|
33856
|
+
writeFileSync13(stagedManifest, `${JSON.stringify({
|
|
33614
33857
|
schemaVersion: manifest.schemaVersion,
|
|
33615
33858
|
files: manifest.files
|
|
33616
33859
|
}, null, 2)}
|
|
33617
33860
|
`, { mode: 292 });
|
|
33618
|
-
|
|
33619
|
-
|
|
33861
|
+
chmodSync7(stagedManifest, 292);
|
|
33862
|
+
renameSync10(stagedManifest, join21(targetDir, PRESET_TEMPLATE_MANIFEST_FILE));
|
|
33620
33863
|
} finally {
|
|
33621
|
-
|
|
33864
|
+
rmSync11(stageDir, { recursive: true, force: true });
|
|
33622
33865
|
}
|
|
33623
|
-
|
|
33866
|
+
chmodSync7(targetDir, 493);
|
|
33624
33867
|
return {
|
|
33625
33868
|
fileCount: manifest.files.length,
|
|
33626
33869
|
totalBytes: manifest.totalBytes,
|
|
@@ -33634,11 +33877,11 @@ function materializeRuntimePresetTemplates(input) {
|
|
|
33634
33877
|
targetDir: input.targetDir
|
|
33635
33878
|
});
|
|
33636
33879
|
const manifestBody = readFileSync15(
|
|
33637
|
-
|
|
33880
|
+
join21(materialized.targetDir, PRESET_TEMPLATE_MANIFEST_FILE)
|
|
33638
33881
|
);
|
|
33639
33882
|
const manifest = JSON.parse(manifestBody.toString("utf8"));
|
|
33640
33883
|
for (const file of manifest.files) {
|
|
33641
|
-
const body = readFileSync15(
|
|
33884
|
+
const body = readFileSync15(join21(materialized.targetDir, file.name));
|
|
33642
33885
|
if (sha2562(body) !== file.sha256) {
|
|
33643
33886
|
throw new Error(`preset_template_materialized_digest_mismatch: ${file.name}`);
|
|
33644
33887
|
}
|
|
@@ -33662,7 +33905,7 @@ function materializeRuntimePresetTemplates(input) {
|
|
|
33662
33905
|
|
|
33663
33906
|
// src/amaster-runtime-daemon/runtime-status-summary.mjs
|
|
33664
33907
|
import { existsSync as existsSync16, readdirSync as readdirSync10, statSync as statSync10 } from "node:fs";
|
|
33665
|
-
import { dirname as
|
|
33908
|
+
import { dirname as dirname11, join as join22, resolve as resolve16 } from "node:path";
|
|
33666
33909
|
function runtimeStatusDirectoryEntries(path) {
|
|
33667
33910
|
try {
|
|
33668
33911
|
return readdirSync10(path, { withFileTypes: true });
|
|
@@ -33685,7 +33928,7 @@ function runtimeStatusDirectorySizeBytes(path) {
|
|
|
33685
33928
|
if (!stat || stat.isSymbolicLink()) continue;
|
|
33686
33929
|
if (stat.isDirectory()) {
|
|
33687
33930
|
for (const entry of runtimeStatusDirectoryEntries(current)) {
|
|
33688
|
-
stack.push(
|
|
33931
|
+
stack.push(join22(current, entry.name));
|
|
33689
33932
|
}
|
|
33690
33933
|
continue;
|
|
33691
33934
|
}
|
|
@@ -33702,7 +33945,7 @@ function walkRuntimeStatusManagedWorkdirs(root) {
|
|
|
33702
33945
|
if (!current) continue;
|
|
33703
33946
|
for (const entry of runtimeStatusDirectoryEntries(current)) {
|
|
33704
33947
|
if (!entry.isDirectory()) continue;
|
|
33705
|
-
const fullPath =
|
|
33948
|
+
const fullPath = join22(current, entry.name);
|
|
33706
33949
|
if (entry.name === "workdir" && existsSync16(workspaceManifestPath(fullPath))) {
|
|
33707
33950
|
workdirs.push(fullPath);
|
|
33708
33951
|
continue;
|
|
@@ -33744,7 +33987,7 @@ function summarizeRuntimeStatusRecentRun(workdir, manifest) {
|
|
|
33744
33987
|
}
|
|
33745
33988
|
function runtimeStatusOutboxDir(config) {
|
|
33746
33989
|
const statePath = config.AMASTER_DAEMON_STATE_FILE ?? config.daemonStateFile;
|
|
33747
|
-
return
|
|
33990
|
+
return join22(dirname11(stateFilePath({
|
|
33748
33991
|
AMASTER_DAEMON_STATE_FILE: statePath
|
|
33749
33992
|
})), "result-outbox");
|
|
33750
33993
|
}
|
|
@@ -33752,7 +33995,7 @@ function runtimeStatusRunCompletionDir(config) {
|
|
|
33752
33995
|
const explicit = config.AMASTER_RUN_COMPLETION_STATE_DIR ?? config.runCompletionStateDir;
|
|
33753
33996
|
if (typeof explicit === "string" && explicit.trim()) return resolve16(explicit);
|
|
33754
33997
|
const statePath = config.AMASTER_DAEMON_STATE_FILE ?? config.daemonStateFile;
|
|
33755
|
-
return
|
|
33998
|
+
return join22(dirname11(stateFilePath({
|
|
33756
33999
|
AMASTER_DAEMON_STATE_FILE: statePath
|
|
33757
34000
|
})), "run-completion-state");
|
|
33758
34001
|
}
|
|
@@ -33789,9 +34032,9 @@ function summarizeRuntimeLocalState(input) {
|
|
|
33789
34032
|
}
|
|
33790
34033
|
}
|
|
33791
34034
|
const pendingOutboxDir = runtimeStatusOutboxDir(config);
|
|
33792
|
-
const invalidOutboxDir =
|
|
34035
|
+
const invalidOutboxDir = join22(pendingOutboxDir, "invalid");
|
|
33793
34036
|
const pendingRunCompletionDir = runtimeStatusRunCompletionDir(config);
|
|
33794
|
-
const invalidRunCompletionDir =
|
|
34037
|
+
const invalidRunCompletionDir = join22(pendingRunCompletionDir, "invalid");
|
|
33795
34038
|
return {
|
|
33796
34039
|
managedWorkspacesRoot: root,
|
|
33797
34040
|
managedWorkdirCount: workdirs.length,
|
|
@@ -34153,7 +34396,7 @@ export default function amasterProjectInstructions(pi) {
|
|
|
34153
34396
|
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
34154
34397
|
import { createHash as createHash18 } from "node:crypto";
|
|
34155
34398
|
import { existsSync as existsSync17, readdirSync as readdirSync11, readFileSync as readFileSync18, statSync as statSync11 } from "node:fs";
|
|
34156
|
-
import { basename as basename7, extname as extname2, isAbsolute as isAbsolute11, join as
|
|
34399
|
+
import { basename as basename7, extname as extname2, isAbsolute as isAbsolute11, join as join23, relative as relative8, resolve as resolve18 } from "node:path";
|
|
34157
34400
|
var WORKSPACE_RUNTIME_SERVICES_FILENAME = ".amaster-runtime-services.json";
|
|
34158
34401
|
var ARTIFACT_EXTENSIONS = /* @__PURE__ */ new Map([
|
|
34159
34402
|
[".md", "markdown"],
|
|
@@ -34271,7 +34514,7 @@ function scanArtifactCandidates(cwd, opts = {}) {
|
|
|
34271
34514
|
if (entry.name.startsWith(".") && entry.name !== ".amaster-runtime.json") {
|
|
34272
34515
|
if (entry.name === ".git") continue;
|
|
34273
34516
|
}
|
|
34274
|
-
const fullPath =
|
|
34517
|
+
const fullPath = join23(current, entry.name);
|
|
34275
34518
|
const relativePath = normalizeRelativePath(root, fullPath);
|
|
34276
34519
|
if (!isSafeRelativePath(relativePath)) continue;
|
|
34277
34520
|
if (basename7(relativePath) === ".amaster-runtime.json") continue;
|
|
@@ -34349,7 +34592,7 @@ function sanitizeRuntimeService(entry) {
|
|
|
34349
34592
|
};
|
|
34350
34593
|
}
|
|
34351
34594
|
function readRuntimeServicesSnapshot(cwd) {
|
|
34352
|
-
const snapshotPath =
|
|
34595
|
+
const snapshotPath = join23(resolve18(cwd), WORKSPACE_RUNTIME_SERVICES_FILENAME);
|
|
34353
34596
|
if (!existsSync17(snapshotPath)) return [];
|
|
34354
34597
|
try {
|
|
34355
34598
|
const parsed = JSON.parse(readFileSync18(snapshotPath, "utf8"));
|
|
@@ -34454,7 +34697,7 @@ function assertRequiredTaskAttachmentMaterialized(input, materialized) {
|
|
|
34454
34697
|
}
|
|
34455
34698
|
|
|
34456
34699
|
// src/amaster-runtime-daemon.mjs
|
|
34457
|
-
var CONNECTOR_VERSION = "0.1.
|
|
34700
|
+
var CONNECTOR_VERSION = "0.1.6";
|
|
34458
34701
|
var CONNECTOR_CONTRACT_VERSION = "2026-06-04.v1";
|
|
34459
34702
|
var SUPPORTED_TASK_CONTEXT_VERSIONS = Object.freeze([TASK_CONTEXT_MANIFEST_VERSION, TASK_CONTEXT_V2]);
|
|
34460
34703
|
var daemonRequire = createRequire(import.meta.url);
|
|
@@ -34554,7 +34797,7 @@ function resultOutboxPendingCount(config) {
|
|
|
34554
34797
|
try {
|
|
34555
34798
|
let pending = 0;
|
|
34556
34799
|
for (const file of readdirSync12(dir).filter((name) => name.endsWith(".json"))) {
|
|
34557
|
-
if (readValidResultOutboxEntryOrQuarantine(config, file,
|
|
34800
|
+
if (readValidResultOutboxEntryOrQuarantine(config, file, join24(dir, file))) {
|
|
34558
34801
|
pending += 1;
|
|
34559
34802
|
}
|
|
34560
34803
|
}
|
|
@@ -34566,17 +34809,17 @@ function resultOutboxPendingCount(config) {
|
|
|
34566
34809
|
function runCompletionStateDir(config) {
|
|
34567
34810
|
const explicit = readString(process.env.AMASTER_RUN_COMPLETION_STATE_DIR);
|
|
34568
34811
|
if (explicit) return resolve19(expandHomePath(explicit));
|
|
34569
|
-
return
|
|
34812
|
+
return join24(dirname12(stateFilePath(process.env)), "run-completion-state");
|
|
34570
34813
|
}
|
|
34571
34814
|
function runCompletionStateInvalidDir(config) {
|
|
34572
|
-
return
|
|
34815
|
+
return join24(runCompletionStateDir(config), "invalid");
|
|
34573
34816
|
}
|
|
34574
34817
|
function quarantineInvalidRunCompletionState(config, filePath, reason) {
|
|
34575
34818
|
const invalidDir = runCompletionStateInvalidDir(config);
|
|
34576
|
-
|
|
34577
|
-
const destination =
|
|
34819
|
+
mkdirSync13(invalidDir, { recursive: true, mode: 448 });
|
|
34820
|
+
const destination = join24(invalidDir, basename8(filePath));
|
|
34578
34821
|
try {
|
|
34579
|
-
|
|
34822
|
+
renameSync11(filePath, destination);
|
|
34580
34823
|
} catch {
|
|
34581
34824
|
copyFileSync2(filePath, destination);
|
|
34582
34825
|
unlinkSync3(filePath);
|
|
@@ -34632,7 +34875,7 @@ function resultOutboxActiveRunCommands(config) {
|
|
|
34632
34875
|
const outboxPending = resultOutboxPendingCount(config);
|
|
34633
34876
|
const entries = [];
|
|
34634
34877
|
for (const file of readdirSync12(dir).filter((name) => name.endsWith(".json")).sort()) {
|
|
34635
|
-
const entry = readValidResultOutboxEntryOrQuarantine(config, file,
|
|
34878
|
+
const entry = readValidResultOutboxEntryOrQuarantine(config, file, join24(dir, file));
|
|
34636
34879
|
if (!entry) continue;
|
|
34637
34880
|
const activeRun = asRecord(entry.activeRun);
|
|
34638
34881
|
const commandId = readString(activeRun.commandId) ?? readString(entry.commandId);
|
|
@@ -34668,7 +34911,7 @@ function resultOutboxFailedRunCommands(config) {
|
|
|
34668
34911
|
for (const file of readdirSync12(dir).filter((name) => name.endsWith(".json")).sort().slice(-100)) {
|
|
34669
34912
|
let entry;
|
|
34670
34913
|
try {
|
|
34671
|
-
entry = asRecord(JSON.parse(readFileSync19(
|
|
34914
|
+
entry = asRecord(JSON.parse(readFileSync19(join24(dir, file), "utf8")));
|
|
34672
34915
|
} catch {
|
|
34673
34916
|
continue;
|
|
34674
34917
|
}
|
|
@@ -34778,10 +35021,10 @@ function safeSkillRootSummary(kind, source, pathValue) {
|
|
|
34778
35021
|
try {
|
|
34779
35022
|
for (const name of readdirSync12(pathValue)) {
|
|
34780
35023
|
if (name.startsWith(".")) continue;
|
|
34781
|
-
const skillDir =
|
|
35024
|
+
const skillDir = join24(pathValue, name);
|
|
34782
35025
|
try {
|
|
34783
35026
|
if (!statSync12(skillDir).isDirectory()) continue;
|
|
34784
|
-
if (!existsSync18(
|
|
35027
|
+
if (!existsSync18(join24(skillDir, "SKILL.md"))) continue;
|
|
34785
35028
|
skillCount += 1;
|
|
34786
35029
|
if (skillCount >= MAX_PI_CAPABILITY_SOURCE_ENTRIES) {
|
|
34787
35030
|
truncated = true;
|
|
@@ -34832,7 +35075,7 @@ function objectKeyCount(value) {
|
|
|
34832
35075
|
return value && typeof value === "object" && !Array.isArray(value) ? Object.keys(value).length : 0;
|
|
34833
35076
|
}
|
|
34834
35077
|
function defaultPiCodingAgentDir() {
|
|
34835
|
-
return
|
|
35078
|
+
return join24(homedir6(), ".pi", "agent");
|
|
34836
35079
|
}
|
|
34837
35080
|
function piCapabilitySourcesDiagnostics() {
|
|
34838
35081
|
const configuredPiCodingAgentDir = safeExpandPath(process.env.PI_CODING_AGENT_DIR);
|
|
@@ -34841,14 +35084,14 @@ function piCapabilitySourcesDiagnostics() {
|
|
|
34841
35084
|
const configuredPiAgentHome = safeExpandPath(process.env.PI_AGENT_HOME);
|
|
34842
35085
|
const piAgentHome = configuredPiAgentHome ?? piCodingAgentDir;
|
|
34843
35086
|
const piAgentHomeSource = configuredPiAgentHome ? "PI_AGENT_HOME" : piCodingAgentDirSource;
|
|
34844
|
-
const userSkillsPath = piAgentHome ?
|
|
35087
|
+
const userSkillsPath = piAgentHome ? join24(piAgentHome, "skills") : null;
|
|
34845
35088
|
const configuredMarketplaceSkillsPath = safeExpandPath(
|
|
34846
35089
|
process.env.PI_AGENT_MARKETPLACE_SKILLS_DIR
|
|
34847
35090
|
);
|
|
34848
|
-
const marketplaceSkillsPath = configuredMarketplaceSkillsPath ?? (piAgentHome ?
|
|
35091
|
+
const marketplaceSkillsPath = configuredMarketplaceSkillsPath ?? (piAgentHome ? join24(piAgentHome, "marketplace", "skills") : null);
|
|
34849
35092
|
const builtinSkillsPath = safeExpandPath(process.env.PI_AGENT_BUILTIN_SKILLS_DIR) ?? safeExpandPath(process.env.AMASTER_BUILTIN_SKILLS);
|
|
34850
|
-
const mcpConfigPath = safeExpandPath(process.env.PI_AGENT_MCP_SERVERS_FILE) ?? (piAgentHome ?
|
|
34851
|
-
const settingsConfigPath = piCodingAgentDir ?
|
|
35093
|
+
const mcpConfigPath = safeExpandPath(process.env.PI_AGENT_MCP_SERVERS_FILE) ?? (piAgentHome ? join24(piAgentHome, "mcp.json") : null);
|
|
35094
|
+
const settingsConfigPath = piCodingAgentDir ? join24(piCodingAgentDir, "settings.json") : null;
|
|
34852
35095
|
const skillRoots = [
|
|
34853
35096
|
safeSkillRootSummary("user", `${piAgentHomeSource}/skills`, userSkillsPath),
|
|
34854
35097
|
safeSkillRootSummary(
|
|
@@ -35144,25 +35387,25 @@ function materializePiRuntimeSystemPrompt(config, promptRoot, commandId, content
|
|
|
35144
35387
|
const normalizedCommandId = readString(commandId);
|
|
35145
35388
|
if (!normalizedCommandId) throw new Error("pi_runtime_system_prompt_command_id_missing");
|
|
35146
35389
|
const promptIdentity = createHash19("sha256").update(normalizedCommandId).digest("hex");
|
|
35147
|
-
const promptDir =
|
|
35148
|
-
|
|
35390
|
+
const promptDir = join24(promptRoot, "tmp");
|
|
35391
|
+
mkdirSync13(promptDir, { recursive: true, mode: 448 });
|
|
35149
35392
|
const promptDirStat = lstatSync13(promptDir);
|
|
35150
35393
|
if (!promptDirStat.isDirectory() || promptDirStat.isSymbolicLink()) {
|
|
35151
35394
|
throw new Error("pi_runtime_system_prompt_directory_invalid");
|
|
35152
35395
|
}
|
|
35153
|
-
|
|
35154
|
-
const promptPath =
|
|
35155
|
-
const temporaryPath =
|
|
35396
|
+
chmodSync8(promptDir, 448);
|
|
35397
|
+
const promptPath = join24(promptDir, `runtime-system-${promptIdentity}.md`);
|
|
35398
|
+
const temporaryPath = join24(promptDir, `.runtime-system.${process.pid}.${randomUUID2()}.tmp`);
|
|
35156
35399
|
try {
|
|
35157
|
-
|
|
35158
|
-
|
|
35159
|
-
|
|
35400
|
+
writeFileSync14(temporaryPath, contents, { encoding: "utf8", mode: 384, flag: "wx" });
|
|
35401
|
+
renameSync11(temporaryPath, promptPath);
|
|
35402
|
+
chmodSync8(promptPath, 384);
|
|
35160
35403
|
const promptMode = statSync12(promptPath).mode & 511;
|
|
35161
35404
|
if (promptMode !== 384) {
|
|
35162
35405
|
throw new Error(`pi_runtime_system_prompt_permissions_failed: mode=${promptMode.toString(8)}`);
|
|
35163
35406
|
}
|
|
35164
35407
|
} finally {
|
|
35165
|
-
|
|
35408
|
+
rmSync12(temporaryPath, { force: true });
|
|
35166
35409
|
}
|
|
35167
35410
|
handoffPiRunPathsToChild(config, [promptDir, promptPath]);
|
|
35168
35411
|
return promptPath;
|
|
@@ -35328,7 +35571,7 @@ AMASTER_MACHINE_ID=${quoteShell(config.machineId)}
|
|
|
35328
35571
|
AMASTER_WORKSPACE_ALLOWLIST=${quoteShell(config.workspaceBindings.join(","))}
|
|
35329
35572
|
AMASTER_EXECUTORS=${quoteShell(executorEnv)}
|
|
35330
35573
|
AMASTER_NETWORK_DOMAINS=${quoteShell(config.networkDomains.join(","))}
|
|
35331
|
-
AMASTER_DAEMON_STATE_FILE=${quoteShell(
|
|
35574
|
+
AMASTER_DAEMON_STATE_FILE=${quoteShell(join24(homedir6(), ".amaster-employee", "runtime-connector-state.json"))}
|
|
35332
35575
|
EOF
|
|
35333
35576
|
|
|
35334
35577
|
set -a
|
|
@@ -35806,21 +36049,21 @@ function browserSessionProfileIdentity(config, session) {
|
|
|
35806
36049
|
function ensureBrowserSessionProfile(config, session) {
|
|
35807
36050
|
const identity = browserSessionProfileIdentity(config, session);
|
|
35808
36051
|
const profileRoot = resolve19(config.browserSessionStateRoot);
|
|
35809
|
-
|
|
36052
|
+
mkdirSync13(profileRoot, { recursive: true, mode: 448 });
|
|
35810
36053
|
if (lstatSync13(profileRoot).isSymbolicLink() || !lstatSync13(profileRoot).isDirectory()) {
|
|
35811
36054
|
throw new Error("browser_session_profile_path_invalid");
|
|
35812
36055
|
}
|
|
35813
|
-
|
|
36056
|
+
chmodSync8(profileRoot, 448);
|
|
35814
36057
|
const userDataDir = resolve19(profileRoot, identity.localOpaqueRef);
|
|
35815
36058
|
if (!pathWithin3(userDataDir, profileRoot)) {
|
|
35816
36059
|
throw new Error("browser_session_profile_path_invalid");
|
|
35817
36060
|
}
|
|
35818
|
-
|
|
36061
|
+
mkdirSync13(userDataDir, { recursive: true, mode: 448 });
|
|
35819
36062
|
if (lstatSync13(userDataDir).isSymbolicLink() || !lstatSync13(userDataDir).isDirectory()) {
|
|
35820
36063
|
throw new Error("browser_session_profile_path_invalid");
|
|
35821
36064
|
}
|
|
35822
|
-
|
|
35823
|
-
const markerPath =
|
|
36065
|
+
chmodSync8(userDataDir, 448);
|
|
36066
|
+
const markerPath = join24(userDataDir, BROWSER_SESSION_PROFILE_OWNER_MARKER);
|
|
35824
36067
|
if (existsSync18(markerPath)) {
|
|
35825
36068
|
if (lstatSync13(markerPath).isSymbolicLink()) {
|
|
35826
36069
|
throw new Error("browser_session_profile_identity_invalid");
|
|
@@ -35830,15 +36073,15 @@ function ensureBrowserSessionProfile(config, session) {
|
|
|
35830
36073
|
throw new Error("browser_session_profile_identity_invalid");
|
|
35831
36074
|
}
|
|
35832
36075
|
} else {
|
|
35833
|
-
const temporaryPath =
|
|
36076
|
+
const temporaryPath = join24(
|
|
35834
36077
|
userDataDir,
|
|
35835
36078
|
`.${BROWSER_SESSION_PROFILE_OWNER_MARKER}.${process.pid}.${createHash19("sha256").update(randomUUID2()).digest("hex")}`
|
|
35836
36079
|
);
|
|
35837
|
-
|
|
36080
|
+
writeFileSync14(temporaryPath, `${JSON.stringify(identity)}
|
|
35838
36081
|
`, { mode: 384, flag: "wx" });
|
|
35839
|
-
|
|
36082
|
+
renameSync11(temporaryPath, markerPath);
|
|
35840
36083
|
}
|
|
35841
|
-
|
|
36084
|
+
chmodSync8(markerPath, 384);
|
|
35842
36085
|
return { profileRoot, userDataDir, identity };
|
|
35843
36086
|
}
|
|
35844
36087
|
function cleanupBrowserSessionProfile(config, value) {
|
|
@@ -35852,14 +36095,14 @@ function cleanupBrowserSessionProfile(config, value) {
|
|
|
35852
36095
|
if (lstatSync13(userDataDir).isSymbolicLink() || !lstatSync13(userDataDir).isDirectory()) {
|
|
35853
36096
|
throw new Error("browser_session_profile_cleanup_invalid");
|
|
35854
36097
|
}
|
|
35855
|
-
const markerPath =
|
|
36098
|
+
const markerPath = join24(userDataDir, BROWSER_SESSION_PROFILE_OWNER_MARKER);
|
|
35856
36099
|
if (!existsSync18(markerPath) || lstatSync13(markerPath).isSymbolicLink()) {
|
|
35857
36100
|
throw new Error("browser_session_profile_cleanup_invalid");
|
|
35858
36101
|
}
|
|
35859
36102
|
if (JSON.stringify(readJsonFile2(markerPath)) !== JSON.stringify(identity)) {
|
|
35860
36103
|
throw new Error("browser_session_profile_cleanup_invalid");
|
|
35861
36104
|
}
|
|
35862
|
-
|
|
36105
|
+
rmSync12(userDataDir, { recursive: true, force: false });
|
|
35863
36106
|
return { outcome: "deleted", identity };
|
|
35864
36107
|
}
|
|
35865
36108
|
function readJsonFile2(filePath) {
|
|
@@ -35875,8 +36118,8 @@ function syncPiExecutorProviderConfig(config, agentDir, providerConfig) {
|
|
|
35875
36118
|
const { modelsSynced, settingsSynced } = syncAmasterProviderFiles(agentDir, providerConfig);
|
|
35876
36119
|
if (!modelsSynced && !settingsSynced) return null;
|
|
35877
36120
|
handoffPiRunPathsToChild(config, [
|
|
35878
|
-
modelsSynced ?
|
|
35879
|
-
settingsSynced ?
|
|
36121
|
+
modelsSynced ? join24(agentDir, "models.json") : null,
|
|
36122
|
+
settingsSynced ? join24(agentDir, "settings.json") : null
|
|
35880
36123
|
]);
|
|
35881
36124
|
return { modelsSynced, settingsSynced };
|
|
35882
36125
|
}
|
|
@@ -35993,17 +36236,17 @@ async function materializeEffectiveAgentInstructions(config, command, workspace,
|
|
|
35993
36236
|
}
|
|
35994
36237
|
const target = safeAgentInstructionMaterializationTarget(workspace, filePath);
|
|
35995
36238
|
if (!target) throw new Error(`context_envelope_instruction_path_invalid: ${filePath}`);
|
|
35996
|
-
|
|
36239
|
+
mkdirSync13(dirname12(target.targetPath), { recursive: true });
|
|
35997
36240
|
const temporaryPath = `${target.targetPath}.mirrorx-${command.commandId}.tmp`;
|
|
35998
36241
|
try {
|
|
35999
|
-
|
|
36242
|
+
writeFileSync14(temporaryPath, content, { encoding: "utf8", mode: 384 });
|
|
36000
36243
|
const readBack = readFileSync19(temporaryPath, "utf8");
|
|
36001
36244
|
if (readBack !== content) {
|
|
36002
36245
|
throw new Error(`context_envelope_instruction_readback_mismatch: ${filePath}`);
|
|
36003
36246
|
}
|
|
36004
|
-
|
|
36247
|
+
renameSync11(temporaryPath, target.targetPath);
|
|
36005
36248
|
} finally {
|
|
36006
|
-
|
|
36249
|
+
rmSync12(temporaryPath, { force: true });
|
|
36007
36250
|
}
|
|
36008
36251
|
materialized.push({
|
|
36009
36252
|
path: target.relativePath,
|
|
@@ -36037,7 +36280,7 @@ function wikiTreePathForCommand(command, workspaceBindings) {
|
|
|
36037
36280
|
const candidates = [];
|
|
36038
36281
|
if (root.endsWith("paperclipai.plugin-llm-wiki")) candidates.push(root);
|
|
36039
36282
|
if (basename8(root) === "plugin-data" && companyId) {
|
|
36040
|
-
candidates.push(
|
|
36283
|
+
candidates.push(join24(root, companyId, "paperclipai.plugin-llm-wiki"));
|
|
36041
36284
|
}
|
|
36042
36285
|
for (const candidate of candidates) {
|
|
36043
36286
|
try {
|
|
@@ -36276,13 +36519,13 @@ function attachPiProjectInstructionExtension(profile, input) {
|
|
|
36276
36519
|
"managed Pi profile is missing"
|
|
36277
36520
|
);
|
|
36278
36521
|
}
|
|
36279
|
-
const projectInstructionExtensionPath =
|
|
36522
|
+
const projectInstructionExtensionPath = join24(
|
|
36280
36523
|
profile.profileRoot,
|
|
36281
36524
|
"extensions",
|
|
36282
36525
|
MANAGED_PI_PROJECT_INSTRUCTION_FILENAME
|
|
36283
36526
|
);
|
|
36284
36527
|
const contract = { projectInstructionPath: resolve19(input.cwd, "AGENTS.md") };
|
|
36285
|
-
|
|
36528
|
+
writeFileSync14(projectInstructionExtensionPath, managedPiProjectInstructionExtensionSource(contract), { mode: 384 });
|
|
36286
36529
|
return projectInstructionExtensionPath;
|
|
36287
36530
|
}
|
|
36288
36531
|
function commandUsesPiExecutor(command) {
|
|
@@ -36325,18 +36568,18 @@ function buildExecutorEnv(config, command, workspace) {
|
|
|
36325
36568
|
};
|
|
36326
36569
|
}
|
|
36327
36570
|
function preparePiModelCallProfile(commandId, baseEnv, options = {}) {
|
|
36328
|
-
const profileRoot = mkdtempSync5(
|
|
36329
|
-
const home =
|
|
36330
|
-
const sessionsDir =
|
|
36331
|
-
const tempDir =
|
|
36571
|
+
const profileRoot = mkdtempSync5(join24(tmpdir(), "amaster-pi-model-call-"));
|
|
36572
|
+
const home = join24(profileRoot, "home");
|
|
36573
|
+
const sessionsDir = join24(profileRoot, "sessions");
|
|
36574
|
+
const tempDir = join24(profileRoot, "tmp");
|
|
36332
36575
|
for (const directory of [home, sessionsDir, tempDir]) {
|
|
36333
|
-
|
|
36576
|
+
mkdirSync13(directory, { recursive: true, mode: 448 });
|
|
36334
36577
|
}
|
|
36335
36578
|
try {
|
|
36336
36579
|
const extensionArgs = [];
|
|
36337
36580
|
if (options.responseContract) {
|
|
36338
|
-
const extensionPath =
|
|
36339
|
-
|
|
36581
|
+
const extensionPath = join24(profileRoot, "model-call-output-contract.js");
|
|
36582
|
+
writeFileSync14(
|
|
36340
36583
|
extensionPath,
|
|
36341
36584
|
modelCallOutputContractExtensionSource(options.responseContract.maxOutputTokens),
|
|
36342
36585
|
{ mode: 384 }
|
|
@@ -36356,12 +36599,12 @@ function preparePiModelCallProfile(commandId, baseEnv, options = {}) {
|
|
|
36356
36599
|
}
|
|
36357
36600
|
};
|
|
36358
36601
|
} catch (error) {
|
|
36359
|
-
|
|
36602
|
+
rmSync12(profileRoot, { recursive: true, force: true });
|
|
36360
36603
|
throw error;
|
|
36361
36604
|
}
|
|
36362
36605
|
}
|
|
36363
36606
|
function cleanupPiModelCallProfile(profile) {
|
|
36364
|
-
if (profile?.profileRoot)
|
|
36607
|
+
if (profile?.profileRoot) rmSync12(profile.profileRoot, { recursive: true, force: true });
|
|
36365
36608
|
}
|
|
36366
36609
|
function splitExtraArgs(value) {
|
|
36367
36610
|
return splitList(value).flatMap((entry) => entry.split(/\s+/).filter(Boolean));
|
|
@@ -37355,7 +37598,7 @@ function walkManagedWorkdirs(root) {
|
|
|
37355
37598
|
}
|
|
37356
37599
|
for (const entry of entries) {
|
|
37357
37600
|
if (!entry.isDirectory()) continue;
|
|
37358
|
-
const fullPath =
|
|
37601
|
+
const fullPath = join24(current, entry.name);
|
|
37359
37602
|
if (entry.name === "workdir" && existsSync18(workspaceManifestPath(fullPath))) {
|
|
37360
37603
|
workdirs.push(fullPath);
|
|
37361
37604
|
continue;
|
|
@@ -38358,14 +38601,14 @@ async function completeCommand(config, command, status, result2, error) {
|
|
|
38358
38601
|
function resultOutboxDir(config) {
|
|
38359
38602
|
const explicit = readString(process.env.AMASTER_RESULT_OUTBOX_DIR);
|
|
38360
38603
|
if (explicit) return resolve19(expandHomePath(explicit));
|
|
38361
|
-
return
|
|
38604
|
+
return join24(dirname12(stateFilePath(process.env)), "result-outbox");
|
|
38362
38605
|
}
|
|
38363
38606
|
function resultOutboxInvalidDir(config) {
|
|
38364
|
-
return
|
|
38607
|
+
return join24(resultOutboxDir(config), "invalid");
|
|
38365
38608
|
}
|
|
38366
38609
|
function writeResultOutboxEntry(config, entry) {
|
|
38367
38610
|
const dir = resultOutboxDir(config);
|
|
38368
|
-
|
|
38611
|
+
mkdirSync13(dir, { recursive: true });
|
|
38369
38612
|
const pendingLogEntries = takeDeferredLiveLogEntries(entry.commandId);
|
|
38370
38613
|
const body = {
|
|
38371
38614
|
version: 1,
|
|
@@ -38375,16 +38618,16 @@ function writeResultOutboxEntry(config, entry) {
|
|
|
38375
38618
|
...entry,
|
|
38376
38619
|
...pendingLogEntries.length > 0 ? { pendingLogEntries } : {}
|
|
38377
38620
|
};
|
|
38378
|
-
|
|
38621
|
+
writeFileSync14(join24(dir, resultOutboxFileName(entry.commandId)), `${JSON.stringify(body, null, 2)}
|
|
38379
38622
|
`, { mode: 384 });
|
|
38380
38623
|
}
|
|
38381
38624
|
function moveResultOutboxEntryToInvalid(config, file, fullPath, reason, detail, original) {
|
|
38382
38625
|
const invalidDir = resultOutboxInvalidDir(config);
|
|
38383
|
-
|
|
38384
|
-
const invalidPath =
|
|
38626
|
+
mkdirSync13(invalidDir, { recursive: true });
|
|
38627
|
+
const invalidPath = join24(invalidDir, file);
|
|
38385
38628
|
if (original === void 0) {
|
|
38386
38629
|
try {
|
|
38387
|
-
|
|
38630
|
+
renameSync11(fullPath, invalidPath);
|
|
38388
38631
|
} catch {
|
|
38389
38632
|
copyFileSync2(fullPath, invalidPath);
|
|
38390
38633
|
unlinkSync3(fullPath);
|
|
@@ -38397,7 +38640,7 @@ function moveResultOutboxEntryToInvalid(config, file, fullPath, reason, detail,
|
|
|
38397
38640
|
...detail ? { detail: truncateText(detail, 1e3) } : {},
|
|
38398
38641
|
original
|
|
38399
38642
|
};
|
|
38400
|
-
|
|
38643
|
+
writeFileSync14(invalidPath, `${JSON.stringify(evidence, null, 2)}
|
|
38401
38644
|
`, { mode: 384 });
|
|
38402
38645
|
unlinkSync3(fullPath);
|
|
38403
38646
|
}
|
|
@@ -38437,13 +38680,13 @@ function updateResultOutboxAttempt(fullPath, entry, err) {
|
|
|
38437
38680
|
...typeof err?.httpStatus === "number" ? { httpStatus: err.httpStatus } : {},
|
|
38438
38681
|
lastError: truncateText(err instanceof Error ? err.message : String(err), 1e3)
|
|
38439
38682
|
};
|
|
38440
|
-
|
|
38683
|
+
writeFileSync14(fullPath, `${JSON.stringify(next, null, 2)}
|
|
38441
38684
|
`, { mode: 384 });
|
|
38442
38685
|
return next;
|
|
38443
38686
|
}
|
|
38444
38687
|
function quarantineResultOutboxEntry(config, fullPath, file, entry, reason, err) {
|
|
38445
38688
|
const invalidDir = resultOutboxInvalidDir(config);
|
|
38446
|
-
|
|
38689
|
+
mkdirSync13(invalidDir, { recursive: true });
|
|
38447
38690
|
const body = {
|
|
38448
38691
|
...entry,
|
|
38449
38692
|
invalidReason: reason,
|
|
@@ -38451,8 +38694,8 @@ function quarantineResultOutboxEntry(config, fullPath, file, entry, reason, err)
|
|
|
38451
38694
|
...typeof err?.httpStatus === "number" ? { httpStatus: err.httpStatus } : {},
|
|
38452
38695
|
lastError: truncateText(err instanceof Error ? err.message : String(err), 1e3)
|
|
38453
38696
|
};
|
|
38454
|
-
const invalidPath =
|
|
38455
|
-
|
|
38697
|
+
const invalidPath = join24(invalidDir, file);
|
|
38698
|
+
writeFileSync14(invalidPath, `${JSON.stringify(body, null, 2)}
|
|
38456
38699
|
`, { mode: 384 });
|
|
38457
38700
|
try {
|
|
38458
38701
|
unlinkSync3(fullPath);
|
|
@@ -38470,7 +38713,7 @@ async function flushResultOutbox(config) {
|
|
|
38470
38713
|
const files = readdirSync12(dir).filter((name) => name.endsWith(".json")).sort();
|
|
38471
38714
|
let completed = 0;
|
|
38472
38715
|
for (const file of files) {
|
|
38473
|
-
const fullPath =
|
|
38716
|
+
const fullPath = join24(dir, file);
|
|
38474
38717
|
let entry = readValidResultOutboxEntryOrQuarantine(config, file, fullPath);
|
|
38475
38718
|
if (!entry) continue;
|
|
38476
38719
|
const pendingLogEntries = Array.isArray(entry.pendingLogEntries) ? entry.pendingLogEntries.filter((logEntry) => typeof asRecord(logEntry).message === "string") : [];
|
|
@@ -38485,7 +38728,7 @@ async function flushResultOutbox(config) {
|
|
|
38485
38728
|
if (!isTerminalResultOutboxStatus(logHttpStatus)) {
|
|
38486
38729
|
const logAttemptCount = readNumber(entry.logAttemptCount, 0) + 1;
|
|
38487
38730
|
if (logAttemptCount < maxResultOutboxAttempts()) {
|
|
38488
|
-
|
|
38731
|
+
writeFileSync14(fullPath, `${JSON.stringify({ ...entry, logAttemptCount }, null, 2)}
|
|
38489
38732
|
`, { mode: 384 });
|
|
38490
38733
|
process.stderr.write(`AMaster daemon deferred live log delivery retry failed for ${entry.commandId ?? file}: ${logMessage}
|
|
38491
38734
|
`);
|
|
@@ -38498,7 +38741,7 @@ async function flushResultOutbox(config) {
|
|
|
38498
38741
|
entry = { ...entry };
|
|
38499
38742
|
delete entry.pendingLogEntries;
|
|
38500
38743
|
delete entry.logAttemptCount;
|
|
38501
|
-
|
|
38744
|
+
writeFileSync14(fullPath, `${JSON.stringify(entry, null, 2)}
|
|
38502
38745
|
`, { mode: 384 });
|
|
38503
38746
|
}
|
|
38504
38747
|
try {
|
|
@@ -38709,8 +38952,8 @@ async function materializeIssueAttachments(config, command, workspace) {
|
|
|
38709
38952
|
runtimeAuth,
|
|
38710
38953
|
issueId
|
|
38711
38954
|
);
|
|
38712
|
-
const targetDir =
|
|
38713
|
-
|
|
38955
|
+
const targetDir = join24(workspace.cwd, "input-attachments");
|
|
38956
|
+
mkdirSync13(targetDir, { recursive: true });
|
|
38714
38957
|
const usedFilenames = /* @__PURE__ */ new Set();
|
|
38715
38958
|
const materialized = [];
|
|
38716
38959
|
for (const [index, rawAttachment] of attachments.entries()) {
|
|
@@ -38723,12 +38966,12 @@ async function materializeIssueAttachments(config, command, workspace) {
|
|
|
38723
38966
|
let filename = safeMaterializedAttachmentFilename(attachment, index);
|
|
38724
38967
|
filename = dedupeMaterializedFilename(filename, index, usedFilenames);
|
|
38725
38968
|
usedFilenames.add(filename);
|
|
38726
|
-
const targetPath =
|
|
38969
|
+
const targetPath = join24(targetDir, filename);
|
|
38727
38970
|
const body = await runtimeApiBuffer(runtimeAuth, contentPath);
|
|
38728
38971
|
if (attachment.initializationInput === true && (body.byteLength !== attachment.byteSize || createHash19("sha256").update(body).digest("hex") !== attachment.sha256)) {
|
|
38729
38972
|
throw new Error("Initialization input content does not match its preparation receipt");
|
|
38730
38973
|
}
|
|
38731
|
-
|
|
38974
|
+
writeFileSync14(targetPath, body);
|
|
38732
38975
|
const attachmentId = readString(attachment.id);
|
|
38733
38976
|
const actualSha256 = createHash19("sha256").update(body).digest("hex");
|
|
38734
38977
|
const lineageCandidates = lineageCandidatesByAttachmentId.get(attachmentId) ?? [];
|
|
@@ -38795,9 +39038,9 @@ async function materializeRequiredArtifactInputs(config, command, workspace) {
|
|
|
38795
39038
|
if (manifest.version !== 1 || !Array.isArray(manifest.entries)) {
|
|
38796
39039
|
throw new Error("artifact_input_manifest_invalid: expected version 1 entries array");
|
|
38797
39040
|
}
|
|
38798
|
-
const targetRoot =
|
|
38799
|
-
|
|
38800
|
-
|
|
39041
|
+
const targetRoot = join24(workspace.cwd, "input-artifacts");
|
|
39042
|
+
rmSync12(targetRoot, { recursive: true, force: true });
|
|
39043
|
+
mkdirSync13(targetRoot, { recursive: true });
|
|
38801
39044
|
const usedPaths = /* @__PURE__ */ new Set();
|
|
38802
39045
|
const materialized = [];
|
|
38803
39046
|
for (const [index, rawEntry] of manifest.entries.entries()) {
|
|
@@ -38826,18 +39069,18 @@ async function materializeRequiredArtifactInputs(config, command, workspace) {
|
|
|
38826
39069
|
id: attachmentId,
|
|
38827
39070
|
originalFilename: readString(entry.originalFilename)
|
|
38828
39071
|
}, index);
|
|
38829
|
-
let relativePath =
|
|
39072
|
+
let relativePath = join24("input-artifacts", sourceDir, filename).split(/[\\/]+/).join("/");
|
|
38830
39073
|
if (usedPaths.has(relativePath)) {
|
|
38831
39074
|
const ext = extname3(filename);
|
|
38832
39075
|
const stem = ext ? filename.slice(0, -ext.length) : filename;
|
|
38833
39076
|
filename = `${stem}-${index + 1}${ext}`;
|
|
38834
|
-
relativePath =
|
|
39077
|
+
relativePath = join24("input-artifacts", sourceDir, filename).split(/[\\/]+/).join("/");
|
|
38835
39078
|
}
|
|
38836
39079
|
usedPaths.add(relativePath);
|
|
38837
|
-
const targetPath =
|
|
38838
|
-
|
|
38839
|
-
|
|
38840
|
-
|
|
39080
|
+
const targetPath = join24(workspace.cwd, relativePath);
|
|
39081
|
+
mkdirSync13(dirname12(targetPath), { recursive: true });
|
|
39082
|
+
writeFileSync14(targetPath, body);
|
|
39083
|
+
chmodSync8(targetPath, 292);
|
|
38841
39084
|
materialized.push({
|
|
38842
39085
|
id: attachmentId,
|
|
38843
39086
|
workProductId,
|
|
@@ -38856,9 +39099,9 @@ async function materializeRequiredArtifactInputs(config, command, workspace) {
|
|
|
38856
39099
|
version: 1,
|
|
38857
39100
|
entries: materialized.map(({ path: _path, relativePath, ...entry }) => ({ ...entry, path: relativePath }))
|
|
38858
39101
|
};
|
|
38859
|
-
const manifestPath =
|
|
38860
|
-
|
|
38861
|
-
|
|
39102
|
+
const manifestPath = join24(targetRoot, "artifact-input-manifest.json");
|
|
39103
|
+
writeFileSync14(manifestPath, JSON.stringify(localManifest, null, 2) + "\n");
|
|
39104
|
+
chmodSync8(manifestPath, 292);
|
|
38862
39105
|
updateWorkspaceManifest(workspaceManifestPath(workspace), { artifactInputManifest: localManifest });
|
|
38863
39106
|
return materialized;
|
|
38864
39107
|
}
|
|
@@ -38869,9 +39112,9 @@ async function materializeMentionedArtifactFiles(config, command, workspace) {
|
|
|
38869
39112
|
const runtimeAuth = commandRuntimeAuth(command);
|
|
38870
39113
|
const files = Array.isArray(mention.files) ? mention.files : [];
|
|
38871
39114
|
if (files.length === 0 || !readString(runtimeAuth.apiUrl) || !readString(runtimeAuth.apiKey)) return empty;
|
|
38872
|
-
const targetDir =
|
|
38873
|
-
|
|
38874
|
-
|
|
39115
|
+
const targetDir = join24(workspace.cwd, "input-artifacts", "mentioned");
|
|
39116
|
+
rmSync12(targetDir, { recursive: true, force: true });
|
|
39117
|
+
mkdirSync13(targetDir, { recursive: true });
|
|
38875
39118
|
const usedFilenames = /* @__PURE__ */ new Set();
|
|
38876
39119
|
const materialized = [];
|
|
38877
39120
|
const skipped = [];
|
|
@@ -38915,9 +39158,9 @@ async function materializeMentionedArtifactFiles(config, command, workspace) {
|
|
|
38915
39158
|
}, index);
|
|
38916
39159
|
filename = dedupeMaterializedFilename(filename, index, usedFilenames);
|
|
38917
39160
|
usedFilenames.add(filename);
|
|
38918
|
-
const targetPath =
|
|
38919
|
-
|
|
38920
|
-
|
|
39161
|
+
const targetPath = join24(targetDir, filename);
|
|
39162
|
+
writeFileSync14(targetPath, body);
|
|
39163
|
+
chmodSync8(targetPath, 292);
|
|
38921
39164
|
materialized.push({
|
|
38922
39165
|
id: artifactId,
|
|
38923
39166
|
name: readString(entry.title) ?? readString(entry.originalFilename) ?? filename,
|
|
@@ -38933,7 +39176,7 @@ async function materializeMentionedArtifactFiles(config, command, workspace) {
|
|
|
38933
39176
|
return { materialized, skipped };
|
|
38934
39177
|
}
|
|
38935
39178
|
function issueCheckpointDir(workspace) {
|
|
38936
|
-
return
|
|
39179
|
+
return join24(dirname12(workspace.runDir), "checkpoint");
|
|
38937
39180
|
}
|
|
38938
39181
|
async function clearIssueCheckpoint(config, command, workspace, reason, consumedSource = null) {
|
|
38939
39182
|
const checkpointDir = issueCheckpointDir(workspace);
|
|
@@ -38943,13 +39186,13 @@ async function clearIssueCheckpoint(config, command, workspace, reason, consumed
|
|
|
38943
39186
|
if (!sourceRunId) return false;
|
|
38944
39187
|
let manifest;
|
|
38945
39188
|
try {
|
|
38946
|
-
manifest = asRecord(JSON.parse(readFileSync19(
|
|
39189
|
+
manifest = asRecord(JSON.parse(readFileSync19(join24(checkpointDir, "manifest.json"), "utf8")));
|
|
38947
39190
|
} catch {
|
|
38948
39191
|
return false;
|
|
38949
39192
|
}
|
|
38950
39193
|
if (readString(manifest.issueId) !== commandIssueId(command) || readString(manifest.sourceRunId) !== sourceRunId) return false;
|
|
38951
39194
|
}
|
|
38952
|
-
|
|
39195
|
+
rmSync12(checkpointDir, { recursive: true, force: true });
|
|
38953
39196
|
await ingestLog(config, command, "system", "info", "Cleared issue continuation checkpoint", { reason });
|
|
38954
39197
|
return true;
|
|
38955
39198
|
}
|
|
@@ -38988,7 +39231,7 @@ function expectedContinuationCheckpoint(command) {
|
|
|
38988
39231
|
}
|
|
38989
39232
|
async function materializeIssueCheckpoint(config, command, workspace) {
|
|
38990
39233
|
const checkpointDir = issueCheckpointDir(workspace);
|
|
38991
|
-
const manifestPath =
|
|
39234
|
+
const manifestPath = join24(checkpointDir, "manifest.json");
|
|
38992
39235
|
const expectedContinuation = expectedContinuationCheckpoint(command);
|
|
38993
39236
|
const nativeRequest = asRecord(asRecord(command.payload).nativeSession);
|
|
38994
39237
|
let portableNativeSession;
|
|
@@ -39020,12 +39263,12 @@ async function materializeIssueCheckpoint(config, command, workspace) {
|
|
|
39020
39263
|
try {
|
|
39021
39264
|
manifest = asRecord(JSON.parse(readFileSync19(manifestPath, "utf8")));
|
|
39022
39265
|
} catch (err) {
|
|
39023
|
-
|
|
39266
|
+
rmSync12(checkpointDir, { recursive: true, force: true });
|
|
39024
39267
|
throw new Error(`invalid issue checkpoint manifest: ${err instanceof Error ? err.message : String(err)}`);
|
|
39025
39268
|
}
|
|
39026
39269
|
const expiresAt = Date.parse(readString(manifest.expiresAt) ?? "");
|
|
39027
39270
|
if (!Number.isFinite(expiresAt) || expiresAt <= Date.now() || readString(manifest.issueId) !== commandIssueId(command)) {
|
|
39028
|
-
|
|
39271
|
+
rmSync12(checkpointDir, { recursive: true, force: true });
|
|
39029
39272
|
if (expectedContinuation) throw new Error("continuation_checkpoint_unavailable: manifest_expired_or_mismatched");
|
|
39030
39273
|
return unavailable2;
|
|
39031
39274
|
}
|
|
@@ -39049,7 +39292,7 @@ async function materializeIssueCheckpoint(config, command, workspace) {
|
|
|
39049
39292
|
throw new Error("continuation_checkpoint_lineage_mismatch");
|
|
39050
39293
|
}
|
|
39051
39294
|
}
|
|
39052
|
-
const filesRoot = files.length > 0 ? realpathSync12(
|
|
39295
|
+
const filesRoot = files.length > 0 ? realpathSync12(join24(checkpointDir, "files")) : null;
|
|
39053
39296
|
const workspaceRoot = realpathSync12(workspace.cwd);
|
|
39054
39297
|
const validated = [];
|
|
39055
39298
|
let totalBytes = 0;
|
|
@@ -39087,8 +39330,8 @@ async function materializeIssueCheckpoint(config, command, workspace) {
|
|
|
39087
39330
|
}
|
|
39088
39331
|
const materialized = [];
|
|
39089
39332
|
for (const { relativePath, source, target, expectedSha256, expectedByteSize } of validated) {
|
|
39090
|
-
|
|
39091
|
-
const targetParent = realpathSync12(
|
|
39333
|
+
mkdirSync13(dirname12(target), { recursive: true });
|
|
39334
|
+
const targetParent = realpathSync12(dirname12(target));
|
|
39092
39335
|
if (!pathWithin3(targetParent, workspaceRoot)) {
|
|
39093
39336
|
throw new Error(`issue checkpoint target escapes its workspace: ${relativePath}`);
|
|
39094
39337
|
}
|
|
@@ -39105,16 +39348,16 @@ async function materializeIssueCheckpoint(config, command, workspace) {
|
|
|
39105
39348
|
materialized.push(relativePath);
|
|
39106
39349
|
continue;
|
|
39107
39350
|
}
|
|
39108
|
-
const temporaryTarget =
|
|
39351
|
+
const temporaryTarget = join24(targetParent, `.${basename8(target)}.checkpoint-${randomUUID2()}.tmp`);
|
|
39109
39352
|
try {
|
|
39110
39353
|
copyFileSync2(source, temporaryTarget);
|
|
39111
39354
|
const temporaryStat = lstatSync13(temporaryTarget);
|
|
39112
39355
|
if (!temporaryStat.isFile() || temporaryStat.size !== expectedByteSize || hashFileSha256(temporaryTarget) !== expectedSha256) {
|
|
39113
39356
|
throw new Error(`issue checkpoint target verification failed: ${relativePath}`);
|
|
39114
39357
|
}
|
|
39115
|
-
|
|
39358
|
+
renameSync11(temporaryTarget, target);
|
|
39116
39359
|
} finally {
|
|
39117
|
-
|
|
39360
|
+
rmSync12(temporaryTarget, { force: true });
|
|
39118
39361
|
}
|
|
39119
39362
|
materialized.push(relativePath);
|
|
39120
39363
|
}
|
|
@@ -39141,10 +39384,10 @@ async function saveIssueCheckpoint(config, command, workspace, candidates, optio
|
|
|
39141
39384
|
const commandKey = readString(command.commandId)?.replace(/[^A-Za-z0-9_-]/g, "-") ?? randomUUID2();
|
|
39142
39385
|
const stagingDir = `${checkpointDir}.tmp-${commandKey}`;
|
|
39143
39386
|
const backupDir = `${checkpointDir}.previous-${commandKey}`;
|
|
39144
|
-
const filesDir =
|
|
39145
|
-
|
|
39146
|
-
|
|
39147
|
-
|
|
39387
|
+
const filesDir = join24(stagingDir, "files");
|
|
39388
|
+
rmSync12(stagingDir, { recursive: true, force: true });
|
|
39389
|
+
rmSync12(backupDir, { recursive: true, force: true });
|
|
39390
|
+
mkdirSync13(filesDir, { recursive: true });
|
|
39148
39391
|
try {
|
|
39149
39392
|
const files = [];
|
|
39150
39393
|
let totalBytes = 0;
|
|
@@ -39195,7 +39438,7 @@ async function saveIssueCheckpoint(config, command, workspace, candidates, optio
|
|
|
39195
39438
|
}
|
|
39196
39439
|
const target = resolve19(filesDir, relativePath);
|
|
39197
39440
|
if (!pathWithin3(target, filesDir)) continue;
|
|
39198
|
-
|
|
39441
|
+
mkdirSync13(dirname12(target), { recursive: true });
|
|
39199
39442
|
copyFileSync2(ownedSource, target);
|
|
39200
39443
|
const storedStat = lstatSync13(target);
|
|
39201
39444
|
if (!storedStat.isFile() || storedStat.size !== byteSize) {
|
|
@@ -39205,8 +39448,8 @@ async function saveIssueCheckpoint(config, command, workspace, candidates, optio
|
|
|
39205
39448
|
files.push({ path: relativePath, byteSize, sha256: hashFileSha256(target) });
|
|
39206
39449
|
}
|
|
39207
39450
|
if (files.length === 0 && !options.taskSession) {
|
|
39208
|
-
|
|
39209
|
-
|
|
39451
|
+
rmSync12(stagingDir, { recursive: true, force: true });
|
|
39452
|
+
rmSync12(checkpointDir, { recursive: true, force: true });
|
|
39210
39453
|
return null;
|
|
39211
39454
|
}
|
|
39212
39455
|
const checkpointCreatedAt = Date.now();
|
|
@@ -39231,26 +39474,26 @@ async function saveIssueCheckpoint(config, command, workspace, candidates, optio
|
|
|
39231
39474
|
totalBytes,
|
|
39232
39475
|
files
|
|
39233
39476
|
};
|
|
39234
|
-
|
|
39477
|
+
writeFileSync14(join24(stagingDir, "manifest.json"), `${JSON.stringify(manifest, null, 2)}
|
|
39235
39478
|
`);
|
|
39236
39479
|
const replacingExistingCheckpoint = existsSync18(checkpointDir);
|
|
39237
|
-
if (replacingExistingCheckpoint)
|
|
39480
|
+
if (replacingExistingCheckpoint) renameSync11(checkpointDir, backupDir);
|
|
39238
39481
|
try {
|
|
39239
|
-
|
|
39482
|
+
renameSync11(stagingDir, checkpointDir);
|
|
39240
39483
|
} catch (err) {
|
|
39241
39484
|
if (replacingExistingCheckpoint && existsSync18(backupDir) && !existsSync18(checkpointDir)) {
|
|
39242
|
-
|
|
39485
|
+
renameSync11(backupDir, checkpointDir);
|
|
39243
39486
|
}
|
|
39244
39487
|
throw err;
|
|
39245
39488
|
}
|
|
39246
|
-
|
|
39489
|
+
rmSync12(backupDir, { recursive: true, force: true });
|
|
39247
39490
|
if (config.checkpointUploadEnabled) {
|
|
39248
39491
|
await uploadCheckpoint(config, command, checkpointDir, manifest, void 0, options.nativeSession);
|
|
39249
39492
|
}
|
|
39250
39493
|
await ingestLog(config, command, "system", "info", `Saved ${files.length} issue checkpoint file(s) for continuation`, manifest);
|
|
39251
39494
|
return manifest;
|
|
39252
39495
|
} catch (err) {
|
|
39253
|
-
|
|
39496
|
+
rmSync12(stagingDir, { recursive: true, force: true });
|
|
39254
39497
|
throw err;
|
|
39255
39498
|
}
|
|
39256
39499
|
}
|
|
@@ -39543,7 +39786,7 @@ async function executeRunCommand(config, command) {
|
|
|
39543
39786
|
executorCommand: invocation.command,
|
|
39544
39787
|
executorHome: workspace.executorHome,
|
|
39545
39788
|
runDir: workspace.runDir,
|
|
39546
|
-
runtimeCacheRoot:
|
|
39789
|
+
runtimeCacheRoot: join24(dirname12(config.daemonStateFile), "cache"),
|
|
39547
39790
|
cwd,
|
|
39548
39791
|
runtimeAuth: commandRuntimeAuth(command),
|
|
39549
39792
|
nativeSession: asRecord(asRecord(executionCommand.payload).nativeSession),
|
|
@@ -39759,6 +40002,25 @@ async function executeRunCommand(config, command) {
|
|
|
39759
40002
|
invocation.args = [...invocation.args, "--extension", projectInstructionExtensionPath];
|
|
39760
40003
|
handoffPiRunPathsToChild(config, [projectInstructionExtensionPath]);
|
|
39761
40004
|
}
|
|
40005
|
+
const taskResourceReceiptBinding = runtimeWebEvidenceTaskResourceBinding(command.payload);
|
|
40006
|
+
const exactTaskResourceBinding = runtimeExactTaskResourceBinding(command.payload);
|
|
40007
|
+
if (taskResourceReceiptBinding && !exactTaskResourceBinding) {
|
|
40008
|
+
throw new Error("runtime_exact_source_binding_invalid");
|
|
40009
|
+
}
|
|
40010
|
+
if (exactTaskResourceBinding) {
|
|
40011
|
+
if (executor.kind !== "pi" || !managedMcpProfile) {
|
|
40012
|
+
throw new Error("runtime_exact_source_reader_unavailable");
|
|
40013
|
+
}
|
|
40014
|
+
const exactSourceExtensionPath = materializePiExactSourceReadExtension(
|
|
40015
|
+
managedMcpProfile.profileRoot,
|
|
40016
|
+
exactTaskResourceBinding
|
|
40017
|
+
);
|
|
40018
|
+
invocation.args = [...invocation.args, "--extension", exactSourceExtensionPath];
|
|
40019
|
+
invocation.args = applyManagedPiToolAllowlist(invocation.args, {
|
|
40020
|
+
toolAllowlist: exactSourceToolAllowlist(managedMcpProfile)
|
|
40021
|
+
});
|
|
40022
|
+
handoffPiRunPathsToChild(config, [exactSourceExtensionPath]);
|
|
40023
|
+
}
|
|
39762
40024
|
const promptBudgetSummary = contextManifest.budget.totalChars === null ? `${contextManifest.budget.usedChars} characters (unbounded)` : `${contextManifest.budget.usedChars}/${contextManifest.budget.totalChars} characters`;
|
|
39763
40025
|
enqueuePreparationLog("system", "info", `Compiled ${contextManifest.mode} prompt using ${promptBudgetSummary}`, {
|
|
39764
40026
|
presentationKind: "context_manifest",
|
|
@@ -39863,11 +40125,10 @@ async function executeRunCommand(config, command) {
|
|
|
39863
40125
|
},
|
|
39864
40126
|
{
|
|
39865
40127
|
piToolArgumentGuard: config.piToolArgumentGuard,
|
|
39866
|
-
onWebEvidence: (evidence) => Promise.all(evidence.map((entry) =>
|
|
39867
|
-
|
|
39868
|
-
|
|
39869
|
-
command.commandId,
|
|
39870
|
-
{
|
|
40128
|
+
onWebEvidence: (evidence) => Promise.all(evidence.map((entry) => {
|
|
40129
|
+
const taskResourceBinding = runtimeWebEvidenceTaskResourceBinding(command.payload);
|
|
40130
|
+
if (taskResourceBinding) assertExactTaskResourceWebEvidence(entry);
|
|
40131
|
+
return postRuntimeWebEvidence(config, requireConnectorId(config), command.commandId, {
|
|
39871
40132
|
companyId: readString(command.payload?.companyId),
|
|
39872
40133
|
issueId: commandIssueId(command),
|
|
39873
40134
|
runId: commandRunId(command),
|
|
@@ -39878,9 +40139,10 @@ async function executeRunCommand(config, command) {
|
|
|
39878
40139
|
capturedAt: entry.capturedAt,
|
|
39879
40140
|
mediaType: entry.mediaType,
|
|
39880
40141
|
normalizedText: entry.normalizedText,
|
|
39881
|
-
truncated: entry.truncated
|
|
39882
|
-
|
|
39883
|
-
|
|
40142
|
+
truncated: entry.truncated,
|
|
40143
|
+
...taskResourceBinding ? { taskResourceBinding } : {}
|
|
40144
|
+
});
|
|
40145
|
+
})),
|
|
39884
40146
|
codebuddyAuthorizedMcpToolNames: executor.kind === "codebuddy" ? asRecord(managedMcpProfile?.attestation).authorizedMcpToolNames : void 0
|
|
39885
40147
|
}
|
|
39886
40148
|
);
|
|
@@ -40486,7 +40748,7 @@ async function executeRunCommand(config, command) {
|
|
|
40486
40748
|
} finally {
|
|
40487
40749
|
await preparationLogChain;
|
|
40488
40750
|
if (piRuntimeSystemPromptCleanupPath) {
|
|
40489
|
-
|
|
40751
|
+
rmSync12(piRuntimeSystemPromptCleanupPath, { force: true });
|
|
40490
40752
|
}
|
|
40491
40753
|
browserCredentialEnvMaterialization?.cleanup();
|
|
40492
40754
|
if (managedMcpProfile && !managedMcpCleanup && !completionOwnsManagedMcpProfile) {
|
|
@@ -40671,7 +40933,7 @@ async function dispatchAvailableCommands(config, options = {}) {
|
|
|
40671
40933
|
);
|
|
40672
40934
|
for (const command of commands) {
|
|
40673
40935
|
const commandId = readString(command.commandId) ?? readString(command.id);
|
|
40674
|
-
if (commandId) {
|
|
40936
|
+
if (commandId && !isRuntimeStopCommand(command)) {
|
|
40675
40937
|
localDispatchCommands.set(commandId, {
|
|
40676
40938
|
commandId,
|
|
40677
40939
|
executionLane: normalizeRuntimeExecutionLane(command.executionLane),
|
|
@@ -40715,7 +40977,7 @@ async function waitForConversationCommand(config) {
|
|
|
40715
40977
|
);
|
|
40716
40978
|
for (const command of commands) {
|
|
40717
40979
|
const commandId = readString(command.commandId) ?? readString(command.id);
|
|
40718
|
-
if (commandId) {
|
|
40980
|
+
if (commandId && !isRuntimeStopCommand(command)) {
|
|
40719
40981
|
localDispatchCommands.set(commandId, {
|
|
40720
40982
|
commandId,
|
|
40721
40983
|
executionLane: "conversation",
|