@spotpatch/shared 1.12.0 → 1.14.0
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/annotation-Cz-NNgR4.d.cts +102 -0
- package/dist/annotation-Cz-NNgR4.d.ts +102 -0
- package/dist/chunk-CLQ6MIJB.js +586 -0
- package/dist/chunk-CLQ6MIJB.js.map +1 -0
- package/dist/chunk-EWJTKNL4.js +90 -0
- package/dist/chunk-EWJTKNL4.js.map +1 -0
- package/dist/{chunk-JGOIBOFI.js → chunk-FPDSZDP2.js} +16 -2
- package/dist/chunk-FPDSZDP2.js.map +1 -0
- package/dist/{chunk-2LVIH7OA.js → chunk-IX6MSCK6.js} +6 -2
- package/dist/chunk-IX6MSCK6.js.map +1 -0
- package/dist/{chunk-JU5HIWX7.js → chunk-JTZFOTPT.js} +9 -174
- package/dist/chunk-JTZFOTPT.js.map +1 -0
- package/dist/chunk-R6QJFNT2.js +195 -0
- package/dist/chunk-R6QJFNT2.js.map +1 -0
- package/dist/contextual-ask-BpbkpFFf.d.cts +1476 -0
- package/dist/contextual-ask-BpbkpFFf.d.ts +1476 -0
- package/dist/contextual-ask-browser.cjs +201 -0
- package/dist/contextual-ask-browser.cjs.map +1 -0
- package/dist/contextual-ask-browser.d.cts +31 -0
- package/dist/contextual-ask-browser.d.ts +31 -0
- package/dist/contextual-ask-browser.js +66 -0
- package/dist/contextual-ask-browser.js.map +1 -0
- package/dist/contextual-ask-node.cjs +971 -0
- package/dist/contextual-ask-node.cjs.map +1 -0
- package/dist/contextual-ask-node.d.cts +14 -0
- package/dist/contextual-ask-node.d.ts +14 -0
- package/dist/contextual-ask-node.js +122 -0
- package/dist/contextual-ask-node.js.map +1 -0
- package/dist/{data-flow-runtime-BelOgo8s.d.ts → data-flow-runtime-DhWpQoik.d.ts} +26 -13
- package/dist/{data-flow-runtime-oq9m21IP.d.cts → data-flow-runtime-w43iwvGA.d.cts} +26 -13
- package/dist/data-flow-runtime.cjs +2 -0
- package/dist/data-flow-runtime.cjs.map +1 -1
- package/dist/data-flow-runtime.d.cts +2 -2
- package/dist/data-flow-runtime.d.ts +2 -2
- package/dist/data-flow-runtime.js +1 -1
- package/dist/{endpoints-GedF44M2.d.cts → endpoints-O3ohYyAo.d.cts} +7 -1
- package/dist/{endpoints-GedF44M2.d.ts → endpoints-O3ohYyAo.d.ts} +7 -1
- package/dist/error-code-DRz2eqcB.d.cts +63 -0
- package/dist/error-code-DRz2eqcB.d.ts +63 -0
- package/dist/external-agent-node.cjs +320 -141
- package/dist/external-agent-node.cjs.map +1 -1
- package/dist/external-agent-node.d.cts +43 -27
- package/dist/external-agent-node.d.ts +43 -27
- package/dist/external-agent-node.js +174 -20
- package/dist/external-agent-node.js.map +1 -1
- package/dist/{external-handoff-BNUyMfNb.d.ts → external-handoff-5zHu-fz2.d.ts} +41 -131
- package/dist/{external-handoff-BNUyMfNb.d.cts → external-handoff-DeiIvR-2.d.cts} +41 -131
- package/dist/external-handoff-browser.cjs +7 -1
- package/dist/external-handoff-browser.cjs.map +1 -1
- package/dist/external-handoff-browser.d.cts +4 -3
- package/dist/external-handoff-browser.d.ts +4 -3
- package/dist/external-handoff-browser.js +2 -2
- package/dist/index.cjs +1170 -426
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +138 -178
- package/dist/index.d.ts +138 -178
- package/dist/index.js +116 -20
- package/dist/index.js.map +1 -1
- package/package.json +29 -2
- package/dist/chunk-2LVIH7OA.js.map +0 -1
- package/dist/chunk-JGOIBOFI.js.map +0 -1
- package/dist/chunk-JU5HIWX7.js.map +0 -1
- package/dist/{external-agent-control-BMoSq_xI.d.cts → external-agent-control-C79Nl85y.d.cts} +49 -49
- package/dist/{external-agent-control-BMoSq_xI.d.ts → external-agent-control-C79Nl85y.d.ts} +49 -49
|
@@ -33,6 +33,7 @@ __export(external_agent_node_exports, {
|
|
|
33
33
|
EXTERNAL_HANDOFF_PROJECT_KEY_SALT: () => EXTERNAL_HANDOFF_PROJECT_KEY_SALT,
|
|
34
34
|
SPOTPATCH_BRIDGE_PATHS: () => SPOTPATCH_BRIDGE_PATHS,
|
|
35
35
|
SPOTPATCH_BRIDGE_TOKEN_HEADER: () => SPOTPATCH_BRIDGE_TOKEN_HEADER,
|
|
36
|
+
assertPrivateExternalHandoffPath: () => assertPrivateExternalHandoffPath,
|
|
36
37
|
bridgeAckRequestSchema: () => bridgeAckRequestSchema,
|
|
37
38
|
bridgeAckResultSchema: () => bridgeAckResultSchema,
|
|
38
39
|
bridgeActiveClaimRequestSchema: () => bridgeActiveClaimRequestSchema,
|
|
@@ -52,20 +53,23 @@ __export(external_agent_node_exports, {
|
|
|
52
53
|
bridgeWaitResultSchema: () => bridgeWaitResultSchema,
|
|
53
54
|
computeExternalHandoffProjectKey: () => computeExternalHandoffProjectKey,
|
|
54
55
|
externalHandoffDescriptorSchema: () => externalHandoffDescriptorSchema,
|
|
56
|
+
initializePrivateExternalHandoffFile: () => initializePrivateExternalHandoffFile,
|
|
55
57
|
resolveExternalHandoffRuntimeDirectory: () => resolveExternalHandoffRuntimeDirectory
|
|
56
58
|
});
|
|
57
59
|
module.exports = __toCommonJS(external_agent_node_exports);
|
|
58
60
|
var import_node_crypto = require("crypto");
|
|
61
|
+
var import_node_child_process = require("child_process");
|
|
59
62
|
var import_promises = require("fs/promises");
|
|
60
63
|
var import_node_os = __toESM(require("os"), 1);
|
|
61
64
|
var import_node_path = __toESM(require("path"), 1);
|
|
62
|
-
var
|
|
65
|
+
var import_node_util = require("util");
|
|
66
|
+
var import_zod4 = require("zod");
|
|
63
67
|
|
|
64
68
|
// src/protocol/external-handoff.ts
|
|
65
|
-
var
|
|
69
|
+
var import_zod3 = require("zod");
|
|
66
70
|
|
|
67
71
|
// src/protocol/requests.ts
|
|
68
|
-
var
|
|
72
|
+
var import_zod2 = require("zod");
|
|
69
73
|
|
|
70
74
|
// src/model/annotation.ts
|
|
71
75
|
var MAX_ANNOTATION_TARGETS = 20;
|
|
@@ -140,42 +144,15 @@ var AGENT_CHECK_STATUSES = Object.freeze([
|
|
|
140
144
|
"timed-out"
|
|
141
145
|
]);
|
|
142
146
|
|
|
143
|
-
// src/
|
|
144
|
-
var
|
|
145
|
-
var sourceCoordinatesSchema = import_zod.z.strictObject({
|
|
146
|
-
fileId: import_zod.z.string().min(1).max(128),
|
|
147
|
-
line: import_zod.z.number().int().positive(),
|
|
148
|
-
column: import_zod.z.number().int().positive()
|
|
149
|
-
});
|
|
150
|
-
var sourceContextRequestSchema = sourceCoordinatesSchema.extend({
|
|
151
|
-
maxLines: import_zod.z.number().int().positive()
|
|
152
|
-
}).strict();
|
|
153
|
-
var openEditorRequestSchema = sourceCoordinatesSchema.strict();
|
|
154
|
-
var dataFlowSourceCoordinatesRequestSchema = sourceCoordinatesSchema.extend({
|
|
155
|
-
schemaVersion: import_zod.z.literal(1),
|
|
156
|
-
sourceVersion: import_zod.z.string().min(1).max(128).optional()
|
|
157
|
-
}).strict();
|
|
158
|
-
var dataFlowComponentIdentityRequestSchema = import_zod.z.strictObject({
|
|
159
|
-
schemaVersion: import_zod.z.literal(1),
|
|
160
|
-
componentSourceId: import_zod.z.string().min(1).max(128),
|
|
161
|
-
sourceVersion: import_zod.z.string().min(1).max(128)
|
|
162
|
-
});
|
|
163
|
-
var dataFlowComponentReportRequestSchema = import_zod.z.union([
|
|
164
|
-
dataFlowSourceCoordinatesRequestSchema,
|
|
165
|
-
dataFlowComponentIdentityRequestSchema
|
|
166
|
-
]);
|
|
167
|
-
var dataFlowPageReportRequestSchema = import_zod.z.strictObject({
|
|
168
|
-
schemaVersion: import_zod.z.literal(1),
|
|
169
|
-
targets: import_zod.z.array(dataFlowComponentReportRequestSchema).min(1).max(MAX_ANNOTATION_TARGETS)
|
|
170
|
-
});
|
|
171
|
-
var profileIdSchema = import_zod.z.string().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/);
|
|
147
|
+
// src/model/context-schema.ts
|
|
148
|
+
var import_zod = require("zod");
|
|
172
149
|
var boundedString = (maximum) => import_zod.z.string().max(maximum);
|
|
173
150
|
var sourceRefSchema = import_zod.z.strictObject({
|
|
174
151
|
fileId: boundedString(128).optional(),
|
|
175
152
|
relativePath: boundedString(1024).optional(),
|
|
176
153
|
line: import_zod.z.number().int().positive().optional(),
|
|
177
154
|
column: import_zod.z.number().int().positive().optional(),
|
|
178
|
-
origin: import_zod.z.enum(["jsx-host", "react-fiber", "dom-ancestor", "none"]),
|
|
155
|
+
origin: import_zod.z.enum(["jsx-host", "astro-host", "react-fiber", "dom-ancestor", "none"]),
|
|
179
156
|
confidence: import_zod.z.enum(["exact", "probable", "approximate", "unknown"])
|
|
180
157
|
});
|
|
181
158
|
var matchedStyleRuleSchema = import_zod.z.strictObject({
|
|
@@ -186,7 +163,7 @@ var matchedStyleRuleSchema = import_zod.z.strictObject({
|
|
|
186
163
|
});
|
|
187
164
|
var codeContextSchema = import_zod.z.strictObject({
|
|
188
165
|
relativePath: boundedString(1024),
|
|
189
|
-
language: import_zod.z.enum(["tsx", "jsx"]),
|
|
166
|
+
language: import_zod.z.enum(["tsx", "jsx", "astro"]),
|
|
190
167
|
startLine: import_zod.z.number().int().positive(),
|
|
191
168
|
endLine: import_zod.z.number().int().positive(),
|
|
192
169
|
excerpt: boundedString(16e3),
|
|
@@ -200,7 +177,7 @@ var pageContextSchema = import_zod.z.strictObject({
|
|
|
200
177
|
viewportHeight: import_zod.z.number().nonnegative(),
|
|
201
178
|
devicePixelRatio: import_zod.z.number().positive()
|
|
202
179
|
});
|
|
203
|
-
var
|
|
180
|
+
var spotTargetContextSchema = import_zod.z.strictObject({
|
|
204
181
|
instruction: import_zod.z.string().trim().min(1).max(MAX_TARGET_INSTRUCTION_CHARACTERS),
|
|
205
182
|
page: pageContextSchema.optional(),
|
|
206
183
|
source: sourceRefSchema,
|
|
@@ -236,12 +213,12 @@ var spotTargetContextRequestSchema = import_zod.z.strictObject({
|
|
|
236
213
|
code: codeContextSchema.optional(),
|
|
237
214
|
warnings: import_zod.z.array(boundedString(1024)).max(64)
|
|
238
215
|
});
|
|
239
|
-
var
|
|
216
|
+
var spotAnnotationSchema = import_zod.z.strictObject({
|
|
240
217
|
schemaVersion: import_zod.z.literal(3),
|
|
241
218
|
id: boundedString(128),
|
|
242
219
|
locale: import_zod.z.enum(SPOTPATCH_LOCALES),
|
|
243
220
|
page: pageContextSchema,
|
|
244
|
-
targets: import_zod.z.array(
|
|
221
|
+
targets: import_zod.z.array(spotTargetContextSchema).min(1).max(MAX_ANNOTATION_TARGETS),
|
|
245
222
|
createdAt: import_zod.z.iso.datetime()
|
|
246
223
|
}).superRefine((annotation, context) => {
|
|
247
224
|
const total = annotation.targets.reduce(
|
|
@@ -256,21 +233,51 @@ var spotAnnotationRequestSchema = import_zod.z.strictObject({
|
|
|
256
233
|
});
|
|
257
234
|
}
|
|
258
235
|
});
|
|
259
|
-
|
|
236
|
+
|
|
237
|
+
// src/protocol/requests.ts
|
|
238
|
+
var runtimeBootstrapRequestSchema = import_zod2.z.strictObject({});
|
|
239
|
+
var sourceCoordinatesSchema = import_zod2.z.strictObject({
|
|
240
|
+
fileId: import_zod2.z.string().min(1).max(128),
|
|
241
|
+
line: import_zod2.z.number().int().positive(),
|
|
242
|
+
column: import_zod2.z.number().int().positive()
|
|
243
|
+
});
|
|
244
|
+
var sourceContextRequestSchema = sourceCoordinatesSchema.extend({
|
|
245
|
+
maxLines: import_zod2.z.number().int().positive()
|
|
246
|
+
}).strict();
|
|
247
|
+
var openEditorRequestSchema = sourceCoordinatesSchema.strict();
|
|
248
|
+
var dataFlowSourceCoordinatesRequestSchema = sourceCoordinatesSchema.extend({
|
|
249
|
+
schemaVersion: import_zod2.z.literal(1),
|
|
250
|
+
sourceVersion: import_zod2.z.string().min(1).max(128).optional()
|
|
251
|
+
}).strict();
|
|
252
|
+
var dataFlowComponentIdentityRequestSchema = import_zod2.z.strictObject({
|
|
253
|
+
schemaVersion: import_zod2.z.literal(1),
|
|
254
|
+
componentSourceId: import_zod2.z.string().min(1).max(128),
|
|
255
|
+
sourceVersion: import_zod2.z.string().min(1).max(128)
|
|
256
|
+
});
|
|
257
|
+
var dataFlowComponentReportRequestSchema = import_zod2.z.union([
|
|
258
|
+
dataFlowSourceCoordinatesRequestSchema,
|
|
259
|
+
dataFlowComponentIdentityRequestSchema
|
|
260
|
+
]);
|
|
261
|
+
var dataFlowPageReportRequestSchema = import_zod2.z.strictObject({
|
|
262
|
+
schemaVersion: import_zod2.z.literal(1),
|
|
263
|
+
targets: import_zod2.z.array(dataFlowComponentReportRequestSchema).min(1).max(MAX_ANNOTATION_TARGETS)
|
|
264
|
+
});
|
|
265
|
+
var profileIdSchema = import_zod2.z.string().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/);
|
|
266
|
+
var agentCapabilityRequestSchema = import_zod2.z.strictObject({
|
|
260
267
|
providerProfileId: profileIdSchema,
|
|
261
268
|
modelProfileId: profileIdSchema
|
|
262
269
|
});
|
|
263
|
-
var agentWorkspaceHealthRequestSchema =
|
|
264
|
-
var agentJobCreateRequestSchema =
|
|
265
|
-
annotation:
|
|
266
|
-
applyMode:
|
|
270
|
+
var agentWorkspaceHealthRequestSchema = import_zod2.z.strictObject({});
|
|
271
|
+
var agentJobCreateRequestSchema = import_zod2.z.strictObject({
|
|
272
|
+
annotation: spotAnnotationSchema,
|
|
273
|
+
applyMode: import_zod2.z.enum(AGENT_APPLY_MODES).optional(),
|
|
267
274
|
providerProfileId: profileIdSchema,
|
|
268
275
|
modelProfileId: profileIdSchema,
|
|
269
|
-
providerDataConsent:
|
|
270
|
-
trustedFastModeConsent:
|
|
271
|
-
workingTreeMode:
|
|
276
|
+
providerDataConsent: import_zod2.z.literal(true),
|
|
277
|
+
trustedFastModeConsent: import_zod2.z.literal(true).optional(),
|
|
278
|
+
workingTreeMode: import_zod2.z.enum(["require-clean", "include-local-changes"]).default("require-clean")
|
|
272
279
|
});
|
|
273
|
-
var agentJobActionRequestSchema =
|
|
280
|
+
var agentJobActionRequestSchema = import_zod2.z.strictObject({});
|
|
274
281
|
|
|
275
282
|
// src/protocol/external-handoff-constants.ts
|
|
276
283
|
var EXTERNAL_HANDOFF_SNAPSHOT_SCHEMA_VERSION = 1;
|
|
@@ -280,7 +287,11 @@ var EXTERNAL_HANDOFF_STATES = Object.freeze([
|
|
|
280
287
|
"expired",
|
|
281
288
|
"superseded"
|
|
282
289
|
]);
|
|
283
|
-
var EXTERNAL_HANDOFF_FRAMEWORKS = Object.freeze([
|
|
290
|
+
var EXTERNAL_HANDOFF_FRAMEWORKS = Object.freeze([
|
|
291
|
+
"vite",
|
|
292
|
+
"next",
|
|
293
|
+
"astro"
|
|
294
|
+
]);
|
|
284
295
|
var EXTERNAL_HANDOFF_ACTIVE_ADAPTER_KINDS = Object.freeze([
|
|
285
296
|
"claude-channel",
|
|
286
297
|
"codex-app-server"
|
|
@@ -336,44 +347,44 @@ var EXTERNAL_HANDOFF_LIMITS = Object.freeze({
|
|
|
336
347
|
});
|
|
337
348
|
|
|
338
349
|
// src/protocol/external-handoff.ts
|
|
339
|
-
var opaqueIdSchema =
|
|
340
|
-
var isoTimestampSchema =
|
|
341
|
-
var externalHandoffReportableDispatchPhaseSchema =
|
|
350
|
+
var opaqueIdSchema = import_zod3.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/u);
|
|
351
|
+
var isoTimestampSchema = import_zod3.z.iso.datetime();
|
|
352
|
+
var externalHandoffReportableDispatchPhaseSchema = import_zod3.z.enum(
|
|
342
353
|
EXTERNAL_HANDOFF_REPORTABLE_DISPATCH_PHASES
|
|
343
354
|
);
|
|
344
|
-
var externalHandoffPageSummarySchema =
|
|
345
|
-
origin:
|
|
346
|
-
pathname:
|
|
355
|
+
var externalHandoffPageSummarySchema = import_zod3.z.strictObject({
|
|
356
|
+
origin: import_zod3.z.string().min(1).max(2048),
|
|
357
|
+
pathname: import_zod3.z.string().min(1).max(2048)
|
|
347
358
|
});
|
|
348
|
-
var externalHandoffSummarySchema =
|
|
359
|
+
var externalHandoffSummarySchema = import_zod3.z.strictObject({
|
|
349
360
|
sessionId: opaqueIdSchema,
|
|
350
|
-
framework:
|
|
351
|
-
revision:
|
|
361
|
+
framework: import_zod3.z.enum(EXTERNAL_HANDOFF_FRAMEWORKS),
|
|
362
|
+
revision: import_zod3.z.number().int().positive(),
|
|
352
363
|
cursor: opaqueIdSchema,
|
|
353
|
-
targetCount:
|
|
364
|
+
targetCount: import_zod3.z.number().int().positive(),
|
|
354
365
|
page: externalHandoffPageSummarySchema,
|
|
355
366
|
publishedAt: isoTimestampSchema,
|
|
356
367
|
expiresAt: isoTimestampSchema,
|
|
357
|
-
state:
|
|
358
|
-
pickupCount:
|
|
368
|
+
state: import_zod3.z.enum(EXTERNAL_HANDOFF_STATES),
|
|
369
|
+
pickupCount: import_zod3.z.number().int().nonnegative().max(EXTERNAL_HANDOFF_LIMITS.maximumConnectorReceipts),
|
|
359
370
|
pickedUpAt: isoTimestampSchema.optional()
|
|
360
371
|
});
|
|
361
|
-
var externalHandoffSnapshotSchema =
|
|
362
|
-
schemaVersion:
|
|
372
|
+
var externalHandoffSnapshotSchema = import_zod3.z.strictObject({
|
|
373
|
+
schemaVersion: import_zod3.z.literal(EXTERNAL_HANDOFF_SNAPSHOT_SCHEMA_VERSION),
|
|
363
374
|
cursor: opaqueIdSchema,
|
|
364
|
-
session:
|
|
375
|
+
session: import_zod3.z.strictObject({
|
|
365
376
|
id: opaqueIdSchema,
|
|
366
|
-
framework:
|
|
377
|
+
framework: import_zod3.z.enum(EXTERNAL_HANDOFF_FRAMEWORKS)
|
|
367
378
|
}),
|
|
368
|
-
revision:
|
|
379
|
+
revision: import_zod3.z.number().int().positive(),
|
|
369
380
|
publishedAt: isoTimestampSchema,
|
|
370
381
|
expiresAt: isoTimestampSchema,
|
|
371
|
-
annotation:
|
|
382
|
+
annotation: spotAnnotationSchema
|
|
372
383
|
});
|
|
373
|
-
var activeAdapterSummarySchema =
|
|
374
|
-
kind:
|
|
375
|
-
state:
|
|
376
|
-
canDispatch:
|
|
384
|
+
var activeAdapterSummarySchema = import_zod3.z.strictObject({
|
|
385
|
+
kind: import_zod3.z.enum(EXTERNAL_HANDOFF_ACTIVE_ADAPTER_KINDS),
|
|
386
|
+
state: import_zod3.z.enum(EXTERNAL_HANDOFF_ACTIVE_ADAPTER_STATES),
|
|
387
|
+
canDispatch: import_zod3.z.boolean(),
|
|
377
388
|
connectedAt: isoTimestampSchema,
|
|
378
389
|
updatedAt: isoTimestampSchema
|
|
379
390
|
}).superRefine((value, context) => {
|
|
@@ -385,47 +396,47 @@ var activeAdapterSummarySchema = import_zod2.z.strictObject({
|
|
|
385
396
|
});
|
|
386
397
|
}
|
|
387
398
|
});
|
|
388
|
-
var dispatchSummarySchema =
|
|
389
|
-
adapterKind:
|
|
390
|
-
revision:
|
|
391
|
-
phase:
|
|
399
|
+
var dispatchSummarySchema = import_zod3.z.strictObject({
|
|
400
|
+
adapterKind: import_zod3.z.enum(EXTERNAL_HANDOFF_ACTIVE_ADAPTER_KINDS),
|
|
401
|
+
revision: import_zod3.z.number().int().positive(),
|
|
402
|
+
phase: import_zod3.z.enum(EXTERNAL_HANDOFF_DISPATCH_PHASES),
|
|
392
403
|
updatedAt: isoTimestampSchema
|
|
393
404
|
});
|
|
394
|
-
var externalHandoffCapabilityRequestSchema =
|
|
395
|
-
var externalHandoffPublishRequestSchema =
|
|
405
|
+
var externalHandoffCapabilityRequestSchema = import_zod3.z.strictObject({});
|
|
406
|
+
var externalHandoffPublishRequestSchema = import_zod3.z.strictObject({
|
|
396
407
|
requestId: opaqueIdSchema,
|
|
397
|
-
annotation:
|
|
408
|
+
annotation: spotAnnotationSchema
|
|
398
409
|
});
|
|
399
|
-
var externalHandoffStatusRequestSchema =
|
|
410
|
+
var externalHandoffStatusRequestSchema = import_zod3.z.strictObject({
|
|
400
411
|
cursor: opaqueIdSchema.optional()
|
|
401
412
|
});
|
|
402
|
-
var externalHandoffResolveDeliveryRequestSchema =
|
|
413
|
+
var externalHandoffResolveDeliveryRequestSchema = import_zod3.z.strictObject({
|
|
403
414
|
cursor: opaqueIdSchema,
|
|
404
|
-
confirmation:
|
|
405
|
-
});
|
|
406
|
-
var externalHandoffCapabilitySchema =
|
|
407
|
-
enabled:
|
|
408
|
-
brokerReady:
|
|
409
|
-
activeWaitCount:
|
|
410
|
-
snapshotSchemaVersion:
|
|
411
|
-
brokerProtocolVersion:
|
|
415
|
+
confirmation: import_zod3.z.literal("workspace-reviewed")
|
|
416
|
+
});
|
|
417
|
+
var externalHandoffCapabilitySchema = import_zod3.z.strictObject({
|
|
418
|
+
enabled: import_zod3.z.literal(true),
|
|
419
|
+
brokerReady: import_zod3.z.boolean(),
|
|
420
|
+
activeWaitCount: import_zod3.z.number().int().nonnegative().max(EXTERNAL_HANDOFF_LIMITS.maximumWaiters),
|
|
421
|
+
snapshotSchemaVersion: import_zod3.z.literal(EXTERNAL_HANDOFF_SNAPSHOT_SCHEMA_VERSION),
|
|
422
|
+
brokerProtocolVersion: import_zod3.z.literal(EXTERNAL_HANDOFF_BROKER_PROTOCOL_VERSION),
|
|
412
423
|
activeAdapter: activeAdapterSummarySchema.nullable(),
|
|
413
424
|
dispatch: dispatchSummarySchema.nullable()
|
|
414
425
|
});
|
|
415
|
-
var externalHandoffPublishDeliverySchema =
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
mode:
|
|
426
|
+
var externalHandoffPublishDeliverySchema = import_zod3.z.discriminatedUnion("mode", [
|
|
427
|
+
import_zod3.z.strictObject({ mode: import_zod3.z.literal("inbox") }),
|
|
428
|
+
import_zod3.z.strictObject({
|
|
429
|
+
mode: import_zod3.z.literal("active"),
|
|
419
430
|
adapter: activeAdapterSummarySchema,
|
|
420
431
|
dispatch: dispatchSummarySchema
|
|
421
432
|
})
|
|
422
433
|
]);
|
|
423
|
-
var externalHandoffPublishResultSchema =
|
|
434
|
+
var externalHandoffPublishResultSchema = import_zod3.z.strictObject({
|
|
424
435
|
handoff: externalHandoffSummarySchema,
|
|
425
436
|
delivery: externalHandoffPublishDeliverySchema,
|
|
426
|
-
replayed:
|
|
437
|
+
replayed: import_zod3.z.boolean()
|
|
427
438
|
});
|
|
428
|
-
var externalHandoffStatusResultSchema =
|
|
439
|
+
var externalHandoffStatusResultSchema = import_zod3.z.strictObject({
|
|
429
440
|
handoff: externalHandoffSummarySchema,
|
|
430
441
|
activeAdapter: activeAdapterSummarySchema.nullable(),
|
|
431
442
|
dispatch: dispatchSummarySchema.nullable()
|
|
@@ -488,6 +499,24 @@ var ERROR_CODES = {
|
|
|
488
499
|
APPLY_CONFLICT: "APPLY_CONFLICT",
|
|
489
500
|
INTERNAL_ERROR: "INTERNAL_ERROR"
|
|
490
501
|
};
|
|
502
|
+
var CONTEXTUAL_ASK_ERROR_CODES = Object.freeze([
|
|
503
|
+
"ASK_DISABLED",
|
|
504
|
+
"ASK_SELECTION_REQUIRED",
|
|
505
|
+
"ASK_SELECTION_STALE",
|
|
506
|
+
"ASK_QUESTION_INVALID",
|
|
507
|
+
"ASK_EXECUTOR_UNAVAILABLE",
|
|
508
|
+
"ASK_TIMEOUT",
|
|
509
|
+
"ASK_CONSENT_REQUIRED",
|
|
510
|
+
"ASK_BUSY",
|
|
511
|
+
"ASK_IDEMPOTENCY_CONFLICT",
|
|
512
|
+
"ASK_SOURCE_SCOPE_DENIED",
|
|
513
|
+
"ASK_LIMIT_EXCEEDED",
|
|
514
|
+
"ASK_ANSWER_INVALID",
|
|
515
|
+
"ASK_WRITE_ATTEMPTED",
|
|
516
|
+
"ASK_CANCELLED",
|
|
517
|
+
"ASK_RESULT_EXPIRED",
|
|
518
|
+
"ASK_PROTOCOL_INCOMPATIBLE"
|
|
519
|
+
]);
|
|
491
520
|
var ERROR_CODE_VALUES = Object.freeze(Object.values(ERROR_CODES));
|
|
492
521
|
|
|
493
522
|
// src/errors/spotpatch-error.ts
|
|
@@ -513,9 +542,78 @@ var SPOTPATCH_BRIDGE_PATHS = Object.freeze({
|
|
|
513
542
|
activeRelease: "/bridge/v1/active/release"
|
|
514
543
|
});
|
|
515
544
|
var EXTERNAL_HANDOFF_PROJECT_KEY_SALT = "spotpatch-external-agent-project-v1";
|
|
516
|
-
var
|
|
517
|
-
var
|
|
518
|
-
|
|
545
|
+
var execFileAsync = (0, import_node_util.promisify)(import_node_child_process.execFile);
|
|
546
|
+
var WINDOWS_ACL_SCRIPT = String.raw`
|
|
547
|
+
$ErrorActionPreference = 'Stop'
|
|
548
|
+
$target = $env:SPOTPATCH_ACL_TARGET
|
|
549
|
+
$kind = $env:SPOTPATCH_ACL_KIND
|
|
550
|
+
$operation = $env:SPOTPATCH_ACL_OPERATION
|
|
551
|
+
$identity = [System.Security.Principal.WindowsIdentity]::GetCurrent().User
|
|
552
|
+
$allowed = @($identity.Value, 'S-1-5-18', 'S-1-5-32-544')
|
|
553
|
+
if ($kind -eq 'directory') {
|
|
554
|
+
$item = [System.IO.DirectoryInfo]::new($target)
|
|
555
|
+
if ($operation -eq 'initialize') {
|
|
556
|
+
$security = [System.Security.AccessControl.DirectorySecurity]::new()
|
|
557
|
+
$security.SetOwner($identity)
|
|
558
|
+
foreach ($sidValue in $allowed) {
|
|
559
|
+
$sid = [System.Security.Principal.SecurityIdentifier]::new($sidValue)
|
|
560
|
+
$rule = [System.Security.AccessControl.FileSystemAccessRule]::new(
|
|
561
|
+
$sid,
|
|
562
|
+
[System.Security.AccessControl.FileSystemRights]::FullControl,
|
|
563
|
+
[System.Security.AccessControl.InheritanceFlags]'ContainerInherit, ObjectInherit',
|
|
564
|
+
[System.Security.AccessControl.PropagationFlags]::None,
|
|
565
|
+
[System.Security.AccessControl.AccessControlType]::Allow
|
|
566
|
+
)
|
|
567
|
+
[void]$security.AddAccessRule($rule)
|
|
568
|
+
}
|
|
569
|
+
$security.SetAccessRuleProtection($true, $false)
|
|
570
|
+
$item.SetAccessControl($security)
|
|
571
|
+
}
|
|
572
|
+
$acl = $item.GetAccessControl(
|
|
573
|
+
[System.Security.AccessControl.AccessControlSections]'Access, Owner'
|
|
574
|
+
)
|
|
575
|
+
} elseif ($kind -eq 'file') {
|
|
576
|
+
$item = [System.IO.FileInfo]::new($target)
|
|
577
|
+
if ($operation -eq 'initialize') {
|
|
578
|
+
$security = [System.Security.AccessControl.FileSecurity]::new()
|
|
579
|
+
$security.SetOwner($identity)
|
|
580
|
+
foreach ($sidValue in $allowed) {
|
|
581
|
+
$sid = [System.Security.Principal.SecurityIdentifier]::new($sidValue)
|
|
582
|
+
$rule = [System.Security.AccessControl.FileSystemAccessRule]::new(
|
|
583
|
+
$sid,
|
|
584
|
+
[System.Security.AccessControl.FileSystemRights]::FullControl,
|
|
585
|
+
[System.Security.AccessControl.AccessControlType]::Allow
|
|
586
|
+
)
|
|
587
|
+
[void]$security.AddAccessRule($rule)
|
|
588
|
+
}
|
|
589
|
+
$security.SetAccessRuleProtection($true, $false)
|
|
590
|
+
$item.SetAccessControl($security)
|
|
591
|
+
}
|
|
592
|
+
$acl = $item.GetAccessControl(
|
|
593
|
+
[System.Security.AccessControl.AccessControlSections]'Access, Owner'
|
|
594
|
+
)
|
|
595
|
+
} else {
|
|
596
|
+
exit 10
|
|
597
|
+
}
|
|
598
|
+
if ($acl.GetOwner([System.Security.Principal.SecurityIdentifier]).Value -ne $identity.Value) {
|
|
599
|
+
exit 11
|
|
600
|
+
}
|
|
601
|
+
foreach ($rule in $acl.GetAccessRules(
|
|
602
|
+
$true,
|
|
603
|
+
$true,
|
|
604
|
+
[System.Security.Principal.SecurityIdentifier]
|
|
605
|
+
)) {
|
|
606
|
+
if (
|
|
607
|
+
$rule.AccessControlType -eq [System.Security.AccessControl.AccessControlType]::Allow -and
|
|
608
|
+
$allowed -notcontains $rule.IdentityReference.Value
|
|
609
|
+
) {
|
|
610
|
+
exit 12
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
`;
|
|
614
|
+
var opaqueIdSchema2 = import_zod4.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/u);
|
|
615
|
+
var projectKeySchema = import_zod4.z.string().length(64).regex(/^[a-f0-9]+$/u);
|
|
616
|
+
var loopbackEndpointSchema = import_zod4.z.url().refine((value) => {
|
|
519
617
|
const match = /^http:\/\/127\.0\.0\.1:([1-9][0-9]{0,4})$/u.exec(value);
|
|
520
618
|
if (match?.[1] === void 0) {
|
|
521
619
|
return false;
|
|
@@ -523,115 +621,190 @@ var loopbackEndpointSchema = import_zod3.z.url().refine((value) => {
|
|
|
523
621
|
const port = Number(match[1]);
|
|
524
622
|
return Number.isSafeInteger(port) && port <= 65535;
|
|
525
623
|
});
|
|
526
|
-
var externalHandoffDescriptorSchema =
|
|
527
|
-
schemaVersion:
|
|
528
|
-
brokerProtocolVersion:
|
|
624
|
+
var externalHandoffDescriptorSchema = import_zod4.z.strictObject({
|
|
625
|
+
schemaVersion: import_zod4.z.literal(1),
|
|
626
|
+
brokerProtocolVersion: import_zod4.z.literal(EXTERNAL_HANDOFF_BROKER_PROTOCOL_VERSION),
|
|
529
627
|
projectKey: projectKeySchema,
|
|
530
628
|
sessionId: opaqueIdSchema2,
|
|
531
|
-
framework:
|
|
629
|
+
framework: import_zod4.z.enum(EXTERNAL_HANDOFF_FRAMEWORKS),
|
|
532
630
|
endpoint: loopbackEndpointSchema,
|
|
533
|
-
bridgeToken:
|
|
534
|
-
pid:
|
|
535
|
-
createdAt:
|
|
631
|
+
bridgeToken: import_zod4.z.string().min(43).max(128).regex(/^[A-Za-z0-9_-]+$/u),
|
|
632
|
+
pid: import_zod4.z.number().int().positive(),
|
|
633
|
+
createdAt: import_zod4.z.iso.datetime()
|
|
536
634
|
});
|
|
537
|
-
var bridgeStatusRequestSchema =
|
|
538
|
-
var bridgeCurrentRequestSchema =
|
|
635
|
+
var bridgeStatusRequestSchema = import_zod4.z.strictObject({});
|
|
636
|
+
var bridgeCurrentRequestSchema = import_zod4.z.strictObject({
|
|
539
637
|
cursor: opaqueIdSchema2.optional()
|
|
540
638
|
});
|
|
541
|
-
var bridgeWaitRequestSchema =
|
|
639
|
+
var bridgeWaitRequestSchema = import_zod4.z.strictObject({
|
|
542
640
|
afterCursor: opaqueIdSchema2.optional(),
|
|
543
|
-
timeoutMs:
|
|
641
|
+
timeoutMs: import_zod4.z.number().int().positive().max(EXTERNAL_HANDOFF_LIMITS.maximumWaitMs).default(EXTERNAL_HANDOFF_LIMITS.defaultWaitMs)
|
|
544
642
|
});
|
|
545
|
-
var bridgeAckRequestSchema =
|
|
643
|
+
var bridgeAckRequestSchema = import_zod4.z.strictObject({
|
|
546
644
|
cursor: opaqueIdSchema2,
|
|
547
645
|
connectorInstanceId: opaqueIdSchema2
|
|
548
646
|
});
|
|
549
|
-
var bridgeActiveClaimRequestSchema =
|
|
550
|
-
adapterKind:
|
|
647
|
+
var bridgeActiveClaimRequestSchema = import_zod4.z.strictObject({
|
|
648
|
+
adapterKind: import_zod4.z.enum(EXTERNAL_HANDOFF_ACTIVE_ADAPTER_KINDS),
|
|
551
649
|
connectorInstanceId: opaqueIdSchema2
|
|
552
650
|
});
|
|
553
|
-
var bridgeActiveHeartbeatRequestSchema =
|
|
651
|
+
var bridgeActiveHeartbeatRequestSchema = import_zod4.z.strictObject({
|
|
554
652
|
leaseToken: opaqueIdSchema2
|
|
555
653
|
});
|
|
556
|
-
var bridgeActiveReportRequestSchema =
|
|
654
|
+
var bridgeActiveReportRequestSchema = import_zod4.z.strictObject({
|
|
557
655
|
leaseToken: opaqueIdSchema2,
|
|
558
656
|
cursor: opaqueIdSchema2,
|
|
559
657
|
phase: externalHandoffReportableDispatchPhaseSchema
|
|
560
658
|
});
|
|
561
|
-
var bridgeActiveReleaseRequestSchema =
|
|
659
|
+
var bridgeActiveReleaseRequestSchema = import_zod4.z.strictObject({
|
|
562
660
|
leaseToken: opaqueIdSchema2
|
|
563
661
|
});
|
|
564
|
-
var bridgeStatusSchema =
|
|
565
|
-
brokerProtocolVersion:
|
|
662
|
+
var bridgeStatusSchema = import_zod4.z.strictObject({
|
|
663
|
+
brokerProtocolVersion: import_zod4.z.literal(EXTERNAL_HANDOFF_BROKER_PROTOCOL_VERSION),
|
|
566
664
|
projectKey: projectKeySchema,
|
|
567
665
|
sessionId: opaqueIdSchema2,
|
|
568
|
-
framework:
|
|
666
|
+
framework: import_zod4.z.enum(EXTERNAL_HANDOFF_FRAMEWORKS),
|
|
569
667
|
current: externalHandoffSummarySchema.nullable()
|
|
570
668
|
});
|
|
571
|
-
var bridgeCurrentResultSchema =
|
|
572
|
-
outcome:
|
|
669
|
+
var bridgeCurrentResultSchema = import_zod4.z.strictObject({
|
|
670
|
+
outcome: import_zod4.z.literal("handoff"),
|
|
573
671
|
snapshot: externalHandoffSnapshotSchema
|
|
574
672
|
});
|
|
575
|
-
var bridgeWaitResultSchema =
|
|
673
|
+
var bridgeWaitResultSchema = import_zod4.z.discriminatedUnion("outcome", [
|
|
576
674
|
bridgeCurrentResultSchema,
|
|
577
|
-
|
|
675
|
+
import_zod4.z.strictObject({ outcome: import_zod4.z.literal("timeout") })
|
|
578
676
|
]);
|
|
579
|
-
var bridgeAckResultSchema =
|
|
677
|
+
var bridgeAckResultSchema = import_zod4.z.strictObject({
|
|
580
678
|
summary: externalHandoffSummarySchema
|
|
581
679
|
});
|
|
582
|
-
var bridgeActiveClaimResultSchema =
|
|
680
|
+
var bridgeActiveClaimResultSchema = import_zod4.z.strictObject({
|
|
583
681
|
leaseToken: opaqueIdSchema2,
|
|
584
|
-
heartbeatIntervalMs:
|
|
682
|
+
heartbeatIntervalMs: import_zod4.z.literal(EXTERNAL_HANDOFF_LIMITS.activeHeartbeatIntervalMs),
|
|
585
683
|
baselineCursor: opaqueIdSchema2.nullable(),
|
|
586
684
|
activeAdapter: activeAdapterSummarySchema
|
|
587
685
|
});
|
|
588
|
-
var bridgeActiveStateResultSchema =
|
|
686
|
+
var bridgeActiveStateResultSchema = import_zod4.z.strictObject({
|
|
589
687
|
activeAdapter: activeAdapterSummarySchema.nullable(),
|
|
590
688
|
dispatch: dispatchSummarySchema.nullable()
|
|
591
689
|
});
|
|
592
690
|
var bridgeActiveHeartbeatResultSchema = bridgeActiveStateResultSchema;
|
|
593
691
|
var bridgeActiveReportResultSchema = bridgeActiveStateResultSchema;
|
|
594
692
|
var bridgeActiveReleaseResultSchema = bridgeActiveStateResultSchema;
|
|
595
|
-
function
|
|
596
|
-
const
|
|
597
|
-
if (
|
|
693
|
+
function windowsPowerShellExecutable() {
|
|
694
|
+
const systemRoot = process.env.SystemRoot ?? process.env.SYSTEMROOT;
|
|
695
|
+
if (systemRoot === void 0 || !import_node_path.default.win32.isAbsolute(systemRoot)) {
|
|
598
696
|
throw new SpotPatchError(ERROR_CODES.BRIDGE_UNAUTHORIZED);
|
|
599
697
|
}
|
|
600
|
-
return
|
|
698
|
+
return import_node_path.default.win32.join(
|
|
699
|
+
systemRoot,
|
|
700
|
+
"System32",
|
|
701
|
+
"WindowsPowerShell",
|
|
702
|
+
"v1.0",
|
|
703
|
+
"powershell.exe"
|
|
704
|
+
);
|
|
601
705
|
}
|
|
602
|
-
async function
|
|
603
|
-
|
|
604
|
-
|
|
706
|
+
async function verifyWindowsAcl(candidate, kind, initialize) {
|
|
707
|
+
try {
|
|
708
|
+
await execFileAsync(
|
|
709
|
+
windowsPowerShellExecutable(),
|
|
710
|
+
["-NoLogo", "-NoProfile", "-NonInteractive", "-Command", WINDOWS_ACL_SCRIPT],
|
|
711
|
+
{
|
|
712
|
+
encoding: "utf8",
|
|
713
|
+
env: {
|
|
714
|
+
...process.env,
|
|
715
|
+
SPOTPATCH_ACL_KIND: kind,
|
|
716
|
+
SPOTPATCH_ACL_OPERATION: initialize ? "initialize" : "verify",
|
|
717
|
+
SPOTPATCH_ACL_TARGET: candidate
|
|
718
|
+
},
|
|
719
|
+
timeout: 1e4,
|
|
720
|
+
windowsHide: true
|
|
721
|
+
}
|
|
722
|
+
);
|
|
723
|
+
} catch (error) {
|
|
724
|
+
throw new SpotPatchError(ERROR_CODES.BRIDGE_UNAUTHORIZED, void 0, {
|
|
725
|
+
cause: error
|
|
726
|
+
});
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
async function assertPrivateExternalHandoffPath(candidate, kind) {
|
|
730
|
+
const status = await (0, import_promises.lstat)(candidate);
|
|
731
|
+
const correctKind = kind === "directory" ? status.isDirectory() : status.isFile();
|
|
732
|
+
if (!correctKind || status.isSymbolicLink()) {
|
|
605
733
|
throw new SpotPatchError(ERROR_CODES.BRIDGE_UNAUTHORIZED);
|
|
606
734
|
}
|
|
735
|
+
if (process.platform === "win32") {
|
|
736
|
+
await verifyWindowsAcl(candidate, kind, false);
|
|
737
|
+
return status;
|
|
738
|
+
}
|
|
739
|
+
const uid = process.getuid?.();
|
|
740
|
+
if (uid === void 0 || status.uid !== uid || (status.mode & 63) !== 0) {
|
|
741
|
+
throw new SpotPatchError(ERROR_CODES.BRIDGE_UNAUTHORIZED);
|
|
742
|
+
}
|
|
743
|
+
return status;
|
|
607
744
|
}
|
|
608
|
-
async function
|
|
745
|
+
async function initializePrivateExternalHandoffFile(candidate) {
|
|
746
|
+
if (process.platform === "win32") {
|
|
747
|
+
await verifyWindowsAcl(candidate, "file", true);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
async function initializeWindowsDirectory(directory) {
|
|
751
|
+
if (process.platform === "win32") {
|
|
752
|
+
await verifyWindowsAcl(directory, "directory", true);
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
async function ensurePrivateSubdirectory(base, create) {
|
|
609
756
|
const directory = import_node_path.default.join(base, "spotpatch");
|
|
757
|
+
let created = false;
|
|
610
758
|
if (create) {
|
|
611
759
|
try {
|
|
612
760
|
await (0, import_promises.mkdir)(directory, { mode: 448 });
|
|
761
|
+
created = true;
|
|
613
762
|
} catch (error) {
|
|
614
763
|
if (error.code !== "EEXIST") {
|
|
615
764
|
throw error;
|
|
616
765
|
}
|
|
617
766
|
}
|
|
618
767
|
}
|
|
619
|
-
await
|
|
620
|
-
|
|
768
|
+
if (created) await initializeWindowsDirectory(directory);
|
|
769
|
+
await assertPrivateExternalHandoffPath(directory, "directory");
|
|
770
|
+
return (0, import_promises.realpath)(directory);
|
|
621
771
|
}
|
|
622
|
-
async function
|
|
623
|
-
|
|
772
|
+
async function resolveWindowsRuntimeDirectory(create) {
|
|
773
|
+
const configuredBase = process.env.LOCALAPPDATA;
|
|
774
|
+
if (configuredBase !== void 0 && !import_node_path.default.isAbsolute(configuredBase)) {
|
|
624
775
|
throw new SpotPatchError(ERROR_CODES.BRIDGE_UNAUTHORIZED);
|
|
625
776
|
}
|
|
626
|
-
const
|
|
777
|
+
const base = configuredBase ?? import_node_path.default.join(import_node_os.default.homedir(), "AppData", "Local");
|
|
778
|
+
const directory = import_node_path.default.join(base, "SpotPatch", "external-agent-runtime-v1");
|
|
779
|
+
let created = false;
|
|
780
|
+
if (create) {
|
|
781
|
+
created = await (0, import_promises.mkdir)(directory, { mode: 448, recursive: true }) !== void 0;
|
|
782
|
+
}
|
|
783
|
+
if (created) await initializeWindowsDirectory(directory);
|
|
784
|
+
await assertPrivateExternalHandoffPath(directory, "directory");
|
|
785
|
+
return (0, import_promises.realpath)(directory);
|
|
786
|
+
}
|
|
787
|
+
async function resolveExternalHandoffRuntimeDirectory(create) {
|
|
627
788
|
const xdgRuntimeDirectory = process.env.XDG_RUNTIME_DIR;
|
|
628
789
|
if (xdgRuntimeDirectory !== void 0 && !import_node_path.default.isAbsolute(xdgRuntimeDirectory)) {
|
|
629
790
|
throw new SpotPatchError(ERROR_CODES.BRIDGE_UNAUTHORIZED);
|
|
630
791
|
}
|
|
631
792
|
if (xdgRuntimeDirectory !== void 0) {
|
|
632
793
|
try {
|
|
633
|
-
|
|
634
|
-
|
|
794
|
+
if (process.platform !== "win32") {
|
|
795
|
+
await assertPrivateExternalHandoffPath(xdgRuntimeDirectory, "directory");
|
|
796
|
+
}
|
|
797
|
+
return await ensurePrivateSubdirectory(xdgRuntimeDirectory, create);
|
|
798
|
+
} catch (error) {
|
|
799
|
+
if (!create && error.code === "ENOENT") {
|
|
800
|
+
throw new SpotPatchError(ERROR_CODES.SESSION_NOT_FOUND);
|
|
801
|
+
}
|
|
802
|
+
throw error;
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
if (process.platform === "win32") {
|
|
806
|
+
try {
|
|
807
|
+
return await resolveWindowsRuntimeDirectory(create);
|
|
635
808
|
} catch (error) {
|
|
636
809
|
if (!create && error.code === "ENOENT") {
|
|
637
810
|
throw new SpotPatchError(ERROR_CODES.SESSION_NOT_FOUND);
|
|
@@ -639,6 +812,10 @@ async function resolveExternalHandoffRuntimeDirectory(create) {
|
|
|
639
812
|
throw error;
|
|
640
813
|
}
|
|
641
814
|
}
|
|
815
|
+
const uid = process.getuid?.();
|
|
816
|
+
if (uid === void 0) {
|
|
817
|
+
throw new SpotPatchError(ERROR_CODES.BRIDGE_UNAUTHORIZED);
|
|
818
|
+
}
|
|
642
819
|
const fallback = import_node_path.default.join(import_node_os.default.tmpdir(), `spotpatch-${String(uid)}`);
|
|
643
820
|
if (create) {
|
|
644
821
|
try {
|
|
@@ -650,14 +827,14 @@ async function resolveExternalHandoffRuntimeDirectory(create) {
|
|
|
650
827
|
}
|
|
651
828
|
}
|
|
652
829
|
try {
|
|
653
|
-
await
|
|
830
|
+
await assertPrivateExternalHandoffPath(fallback, "directory");
|
|
654
831
|
} catch (error) {
|
|
655
832
|
if (!create && error.code === "ENOENT") {
|
|
656
833
|
throw new SpotPatchError(ERROR_CODES.SESSION_NOT_FOUND);
|
|
657
834
|
}
|
|
658
835
|
throw error;
|
|
659
836
|
}
|
|
660
|
-
return fallback;
|
|
837
|
+
return (0, import_promises.realpath)(fallback);
|
|
661
838
|
}
|
|
662
839
|
async function computeExternalHandoffProjectKey(root) {
|
|
663
840
|
const canonicalRoot = await (0, import_promises.realpath)(root);
|
|
@@ -668,6 +845,7 @@ async function computeExternalHandoffProjectKey(root) {
|
|
|
668
845
|
EXTERNAL_HANDOFF_PROJECT_KEY_SALT,
|
|
669
846
|
SPOTPATCH_BRIDGE_PATHS,
|
|
670
847
|
SPOTPATCH_BRIDGE_TOKEN_HEADER,
|
|
848
|
+
assertPrivateExternalHandoffPath,
|
|
671
849
|
bridgeAckRequestSchema,
|
|
672
850
|
bridgeAckResultSchema,
|
|
673
851
|
bridgeActiveClaimRequestSchema,
|
|
@@ -687,6 +865,7 @@ async function computeExternalHandoffProjectKey(root) {
|
|
|
687
865
|
bridgeWaitResultSchema,
|
|
688
866
|
computeExternalHandoffProjectKey,
|
|
689
867
|
externalHandoffDescriptorSchema,
|
|
868
|
+
initializePrivateExternalHandoffFile,
|
|
690
869
|
resolveExternalHandoffRuntimeDirectory
|
|
691
870
|
});
|
|
692
871
|
//# sourceMappingURL=external-agent-node.cjs.map
|