@spotpatch/shared 1.9.0 → 1.10.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/chunk-2LVIH7OA.js +75 -0
- package/dist/chunk-2LVIH7OA.js.map +1 -0
- package/dist/chunk-MOGITGPP.js +431 -0
- package/dist/chunk-MOGITGPP.js.map +1 -0
- package/dist/{chunk-K2UAPG7T.js → chunk-RK46Y7LD.js} +2 -23
- package/dist/chunk-RK46Y7LD.js.map +1 -0
- package/dist/chunk-ZCG3DLSW.js +28 -0
- package/dist/chunk-ZCG3DLSW.js.map +1 -0
- package/dist/{data-flow-runtime-zwbvImvl.d.cts → data-flow-runtime-BMm3F-eV.d.cts} +2 -16
- package/dist/{data-flow-runtime-zwbvImvl.d.ts → data-flow-runtime-Dp-xznQW.d.ts} +2 -16
- package/dist/data-flow-runtime.cjs +5 -1
- package/dist/data-flow-runtime.cjs.map +1 -1
- package/dist/data-flow-runtime.d.cts +2 -1
- package/dist/data-flow-runtime.d.ts +2 -1
- package/dist/data-flow-runtime.js +4 -2
- package/dist/endpoints-BT-Bl1WS.d.cts +20 -0
- package/dist/endpoints-BT-Bl1WS.d.ts +20 -0
- package/dist/external-agent-node.cjs +692 -0
- package/dist/external-agent-node.cjs.map +1 -0
- package/dist/external-agent-node.d.cts +556 -0
- package/dist/external-agent-node.d.ts +556 -0
- package/dist/external-agent-node.js +210 -0
- package/dist/external-agent-node.js.map +1 -0
- package/dist/external-handoff-CWoooqhp.d.cts +720 -0
- package/dist/external-handoff-CWoooqhp.d.ts +720 -0
- package/dist/external-handoff-browser.cjs +163 -0
- package/dist/external-handoff-browser.cjs.map +1 -0
- package/dist/external-handoff-browser.d.cts +32 -0
- package/dist/external-handoff-browser.d.ts +32 -0
- package/dist/external-handoff-browser.js +58 -0
- package/dist/external-handoff-browser.js.map +1 -0
- package/dist/index.cjs +302 -65
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +139 -105
- package/dist/index.d.ts +139 -105
- package/dist/index.js +165 -340
- package/dist/index.js.map +1 -1
- package/package.json +28 -2
- package/dist/chunk-K2UAPG7T.js.map +0 -1
|
@@ -0,0 +1,692 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/external-agent-node.ts
|
|
31
|
+
var external_agent_node_exports = {};
|
|
32
|
+
__export(external_agent_node_exports, {
|
|
33
|
+
EXTERNAL_HANDOFF_PROJECT_KEY_SALT: () => EXTERNAL_HANDOFF_PROJECT_KEY_SALT,
|
|
34
|
+
SPOTPATCH_BRIDGE_PATHS: () => SPOTPATCH_BRIDGE_PATHS,
|
|
35
|
+
SPOTPATCH_BRIDGE_TOKEN_HEADER: () => SPOTPATCH_BRIDGE_TOKEN_HEADER,
|
|
36
|
+
bridgeAckRequestSchema: () => bridgeAckRequestSchema,
|
|
37
|
+
bridgeAckResultSchema: () => bridgeAckResultSchema,
|
|
38
|
+
bridgeActiveClaimRequestSchema: () => bridgeActiveClaimRequestSchema,
|
|
39
|
+
bridgeActiveClaimResultSchema: () => bridgeActiveClaimResultSchema,
|
|
40
|
+
bridgeActiveHeartbeatRequestSchema: () => bridgeActiveHeartbeatRequestSchema,
|
|
41
|
+
bridgeActiveHeartbeatResultSchema: () => bridgeActiveHeartbeatResultSchema,
|
|
42
|
+
bridgeActiveReleaseRequestSchema: () => bridgeActiveReleaseRequestSchema,
|
|
43
|
+
bridgeActiveReleaseResultSchema: () => bridgeActiveReleaseResultSchema,
|
|
44
|
+
bridgeActiveReportRequestSchema: () => bridgeActiveReportRequestSchema,
|
|
45
|
+
bridgeActiveReportResultSchema: () => bridgeActiveReportResultSchema,
|
|
46
|
+
bridgeActiveStateResultSchema: () => bridgeActiveStateResultSchema,
|
|
47
|
+
bridgeCurrentRequestSchema: () => bridgeCurrentRequestSchema,
|
|
48
|
+
bridgeCurrentResultSchema: () => bridgeCurrentResultSchema,
|
|
49
|
+
bridgeStatusRequestSchema: () => bridgeStatusRequestSchema,
|
|
50
|
+
bridgeStatusSchema: () => bridgeStatusSchema,
|
|
51
|
+
bridgeWaitRequestSchema: () => bridgeWaitRequestSchema,
|
|
52
|
+
bridgeWaitResultSchema: () => bridgeWaitResultSchema,
|
|
53
|
+
computeExternalHandoffProjectKey: () => computeExternalHandoffProjectKey,
|
|
54
|
+
externalHandoffDescriptorSchema: () => externalHandoffDescriptorSchema,
|
|
55
|
+
resolveExternalHandoffRuntimeDirectory: () => resolveExternalHandoffRuntimeDirectory
|
|
56
|
+
});
|
|
57
|
+
module.exports = __toCommonJS(external_agent_node_exports);
|
|
58
|
+
var import_node_crypto = require("crypto");
|
|
59
|
+
var import_promises = require("fs/promises");
|
|
60
|
+
var import_node_os = __toESM(require("os"), 1);
|
|
61
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
62
|
+
var import_zod3 = require("zod");
|
|
63
|
+
|
|
64
|
+
// src/protocol/external-handoff.ts
|
|
65
|
+
var import_zod2 = require("zod");
|
|
66
|
+
|
|
67
|
+
// src/protocol/requests.ts
|
|
68
|
+
var import_zod = require("zod");
|
|
69
|
+
|
|
70
|
+
// src/model/annotation.ts
|
|
71
|
+
var MAX_ANNOTATION_TARGETS = 20;
|
|
72
|
+
var MAX_TARGET_INSTRUCTION_CHARACTERS = 2e3;
|
|
73
|
+
var MAX_ANNOTATION_INSTRUCTION_CHARACTERS = 4e3;
|
|
74
|
+
var SPOTPATCH_LOCALES = Object.freeze(["en-US", "zh-CN"]);
|
|
75
|
+
var SPOTPATCH_LOCALE_PREFERENCES = Object.freeze([
|
|
76
|
+
"auto",
|
|
77
|
+
...SPOTPATCH_LOCALES
|
|
78
|
+
]);
|
|
79
|
+
|
|
80
|
+
// src/model/agent.ts
|
|
81
|
+
var AGENT_APPLY_MODES = Object.freeze([
|
|
82
|
+
"review",
|
|
83
|
+
"auto",
|
|
84
|
+
"trusted-auto"
|
|
85
|
+
]);
|
|
86
|
+
var DEFAULT_AGENT_LIMITS = Object.freeze({
|
|
87
|
+
maxTurns: 20,
|
|
88
|
+
maxToolCalls: 80,
|
|
89
|
+
maxChangedFiles: 20,
|
|
90
|
+
maxDiffBytes: 512e3,
|
|
91
|
+
maxReadBytesPerFile: 256e3,
|
|
92
|
+
maxToolOutputCharacters: 4e4,
|
|
93
|
+
maxProviderResponseBytes: 2e6,
|
|
94
|
+
providerConnectTimeoutMs: 15e3,
|
|
95
|
+
providerFirstByteTimeoutMs: 3e4,
|
|
96
|
+
providerIdleTimeoutMs: 6e4,
|
|
97
|
+
checkTimeoutMs: 12e4,
|
|
98
|
+
jobTimeoutMs: 6e5
|
|
99
|
+
});
|
|
100
|
+
var AGENT_JOB_STATUSES = Object.freeze([
|
|
101
|
+
"queued",
|
|
102
|
+
"preparing",
|
|
103
|
+
"running",
|
|
104
|
+
"validating",
|
|
105
|
+
"awaiting-review",
|
|
106
|
+
"applying",
|
|
107
|
+
"applied",
|
|
108
|
+
"completed",
|
|
109
|
+
"cancelling",
|
|
110
|
+
"cancelled",
|
|
111
|
+
"reverting",
|
|
112
|
+
"reverted",
|
|
113
|
+
"failed"
|
|
114
|
+
]);
|
|
115
|
+
var AGENT_CAPABILITY_STATES = Object.freeze([
|
|
116
|
+
"unknown",
|
|
117
|
+
"probing",
|
|
118
|
+
"agent-ready",
|
|
119
|
+
"prompt-only",
|
|
120
|
+
"unavailable"
|
|
121
|
+
]);
|
|
122
|
+
var AGENT_WORKSPACE_STATES = Object.freeze([
|
|
123
|
+
"ready",
|
|
124
|
+
"consent-required",
|
|
125
|
+
"blocked"
|
|
126
|
+
]);
|
|
127
|
+
var AGENT_WORKSPACE_SNAPSHOT_LIMITS = Object.freeze({
|
|
128
|
+
maxUntrackedFiles: 1e3,
|
|
129
|
+
maxUntrackedBytes: 20 * 1024 * 1024
|
|
130
|
+
});
|
|
131
|
+
var AGENT_FILE_CHANGE_KINDS = Object.freeze([
|
|
132
|
+
"added",
|
|
133
|
+
"modified",
|
|
134
|
+
"deleted"
|
|
135
|
+
]);
|
|
136
|
+
var AGENT_CHECK_STATUSES = Object.freeze([
|
|
137
|
+
"passed",
|
|
138
|
+
"failed",
|
|
139
|
+
"cancelled",
|
|
140
|
+
"timed-out"
|
|
141
|
+
]);
|
|
142
|
+
|
|
143
|
+
// src/protocol/requests.ts
|
|
144
|
+
var runtimeBootstrapRequestSchema = import_zod.z.strictObject({});
|
|
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._-]*$/);
|
|
172
|
+
var boundedString = (maximum) => import_zod.z.string().max(maximum);
|
|
173
|
+
var sourceRefSchema = import_zod.z.strictObject({
|
|
174
|
+
fileId: boundedString(128).optional(),
|
|
175
|
+
relativePath: boundedString(1024).optional(),
|
|
176
|
+
line: import_zod.z.number().int().positive().optional(),
|
|
177
|
+
column: import_zod.z.number().int().positive().optional(),
|
|
178
|
+
origin: import_zod.z.enum(["jsx-host", "react-fiber", "dom-ancestor", "none"]),
|
|
179
|
+
confidence: import_zod.z.enum(["exact", "probable", "approximate", "unknown"])
|
|
180
|
+
});
|
|
181
|
+
var matchedStyleRuleSchema = import_zod.z.strictObject({
|
|
182
|
+
selector: boundedString(2048),
|
|
183
|
+
declarations: boundedString(8192),
|
|
184
|
+
source: boundedString(1024).optional(),
|
|
185
|
+
media: boundedString(1024).optional()
|
|
186
|
+
});
|
|
187
|
+
var codeContextSchema = import_zod.z.strictObject({
|
|
188
|
+
relativePath: boundedString(1024),
|
|
189
|
+
language: import_zod.z.enum(["tsx", "jsx"]),
|
|
190
|
+
startLine: import_zod.z.number().int().positive(),
|
|
191
|
+
endLine: import_zod.z.number().int().positive(),
|
|
192
|
+
excerpt: boundedString(16e3),
|
|
193
|
+
boundary: import_zod.z.enum(["component", "nearby-lines"])
|
|
194
|
+
});
|
|
195
|
+
var pageContextSchema = import_zod.z.strictObject({
|
|
196
|
+
url: boundedString(2048),
|
|
197
|
+
pathname: boundedString(2048),
|
|
198
|
+
title: boundedString(1024),
|
|
199
|
+
viewportWidth: import_zod.z.number().nonnegative(),
|
|
200
|
+
viewportHeight: import_zod.z.number().nonnegative(),
|
|
201
|
+
devicePixelRatio: import_zod.z.number().positive()
|
|
202
|
+
});
|
|
203
|
+
var spotTargetContextRequestSchema = import_zod.z.strictObject({
|
|
204
|
+
instruction: import_zod.z.string().trim().min(1).max(MAX_TARGET_INSTRUCTION_CHARACTERS),
|
|
205
|
+
page: pageContextSchema.optional(),
|
|
206
|
+
source: sourceRefSchema,
|
|
207
|
+
react: import_zod.z.strictObject({
|
|
208
|
+
supported: import_zod.z.boolean(),
|
|
209
|
+
version: boundedString(64).optional(),
|
|
210
|
+
componentName: boundedString(256).optional(),
|
|
211
|
+
componentSourceId: boundedString(128).optional(),
|
|
212
|
+
sourceVersion: boundedString(128).optional(),
|
|
213
|
+
componentStack: import_zod.z.array(boundedString(256)).max(64),
|
|
214
|
+
source: sourceRefSchema.optional()
|
|
215
|
+
}),
|
|
216
|
+
element: import_zod.z.strictObject({
|
|
217
|
+
tagName: boundedString(128),
|
|
218
|
+
selector: boundedString(2048),
|
|
219
|
+
sanitizedHtml: boundedString(8192),
|
|
220
|
+
textPreview: boundedString(2048).optional(),
|
|
221
|
+
role: boundedString(256).optional(),
|
|
222
|
+
rect: import_zod.z.strictObject({
|
|
223
|
+
x: import_zod.z.number(),
|
|
224
|
+
y: import_zod.z.number(),
|
|
225
|
+
width: import_zod.z.number().nonnegative(),
|
|
226
|
+
height: import_zod.z.number().nonnegative()
|
|
227
|
+
})
|
|
228
|
+
}),
|
|
229
|
+
styles: import_zod.z.strictObject({
|
|
230
|
+
classNames: import_zod.z.array(boundedString(512)).max(256),
|
|
231
|
+
inlineStyle: boundedString(8192).optional(),
|
|
232
|
+
matchedRules: import_zod.z.array(matchedStyleRuleSchema).max(256),
|
|
233
|
+
computed: import_zod.z.record(boundedString(256), boundedString(2048)),
|
|
234
|
+
warnings: import_zod.z.array(boundedString(1024)).max(64)
|
|
235
|
+
}),
|
|
236
|
+
code: codeContextSchema.optional(),
|
|
237
|
+
warnings: import_zod.z.array(boundedString(1024)).max(64)
|
|
238
|
+
});
|
|
239
|
+
var spotAnnotationRequestSchema = import_zod.z.strictObject({
|
|
240
|
+
schemaVersion: import_zod.z.literal(3),
|
|
241
|
+
id: boundedString(128),
|
|
242
|
+
locale: import_zod.z.enum(SPOTPATCH_LOCALES),
|
|
243
|
+
page: pageContextSchema,
|
|
244
|
+
targets: import_zod.z.array(spotTargetContextRequestSchema).min(1).max(MAX_ANNOTATION_TARGETS),
|
|
245
|
+
createdAt: import_zod.z.iso.datetime()
|
|
246
|
+
}).superRefine((annotation, context) => {
|
|
247
|
+
const total = annotation.targets.reduce(
|
|
248
|
+
(characters, target) => characters + target.instruction.length,
|
|
249
|
+
0
|
|
250
|
+
);
|
|
251
|
+
if (total > MAX_ANNOTATION_INSTRUCTION_CHARACTERS) {
|
|
252
|
+
context.addIssue({
|
|
253
|
+
code: "custom",
|
|
254
|
+
message: "Combined target instructions exceed the annotation limit.",
|
|
255
|
+
path: ["targets"]
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
var agentCapabilityRequestSchema = import_zod.z.strictObject({
|
|
260
|
+
providerProfileId: profileIdSchema,
|
|
261
|
+
modelProfileId: profileIdSchema
|
|
262
|
+
});
|
|
263
|
+
var agentWorkspaceHealthRequestSchema = import_zod.z.strictObject({});
|
|
264
|
+
var agentJobCreateRequestSchema = import_zod.z.strictObject({
|
|
265
|
+
annotation: spotAnnotationRequestSchema,
|
|
266
|
+
applyMode: import_zod.z.enum(AGENT_APPLY_MODES).optional(),
|
|
267
|
+
providerProfileId: profileIdSchema,
|
|
268
|
+
modelProfileId: profileIdSchema,
|
|
269
|
+
providerDataConsent: import_zod.z.literal(true),
|
|
270
|
+
trustedFastModeConsent: import_zod.z.literal(true).optional(),
|
|
271
|
+
workingTreeMode: import_zod.z.enum(["require-clean", "include-local-changes"]).default("require-clean")
|
|
272
|
+
});
|
|
273
|
+
var agentJobActionRequestSchema = import_zod.z.strictObject({});
|
|
274
|
+
|
|
275
|
+
// src/protocol/external-handoff-constants.ts
|
|
276
|
+
var EXTERNAL_HANDOFF_SNAPSHOT_SCHEMA_VERSION = 1;
|
|
277
|
+
var EXTERNAL_HANDOFF_BROKER_PROTOCOL_VERSION = 2;
|
|
278
|
+
var EXTERNAL_HANDOFF_STATES = Object.freeze([
|
|
279
|
+
"available",
|
|
280
|
+
"expired",
|
|
281
|
+
"superseded"
|
|
282
|
+
]);
|
|
283
|
+
var EXTERNAL_HANDOFF_FRAMEWORKS = Object.freeze(["vite", "next"]);
|
|
284
|
+
var EXTERNAL_HANDOFF_ACTIVE_ADAPTER_KINDS = Object.freeze([
|
|
285
|
+
"claude-channel",
|
|
286
|
+
"codex-app-server"
|
|
287
|
+
]);
|
|
288
|
+
var EXTERNAL_HANDOFF_ACTIVE_ADAPTER_STATES = Object.freeze([
|
|
289
|
+
"ready",
|
|
290
|
+
"busy",
|
|
291
|
+
"blocked"
|
|
292
|
+
]);
|
|
293
|
+
var EXTERNAL_HANDOFF_DISPATCH_PHASES = Object.freeze([
|
|
294
|
+
"queued",
|
|
295
|
+
"dispatching",
|
|
296
|
+
"dispatched",
|
|
297
|
+
"working",
|
|
298
|
+
"completed",
|
|
299
|
+
"failed",
|
|
300
|
+
"delivery-unknown"
|
|
301
|
+
]);
|
|
302
|
+
var EXTERNAL_HANDOFF_REPORTABLE_DISPATCH_PHASES = Object.freeze([
|
|
303
|
+
"dispatching",
|
|
304
|
+
"dispatched",
|
|
305
|
+
"working",
|
|
306
|
+
"completed",
|
|
307
|
+
"failed",
|
|
308
|
+
"delivery-unknown"
|
|
309
|
+
]);
|
|
310
|
+
var EXTERNAL_HANDOFF_LIMITS = Object.freeze({
|
|
311
|
+
maximumSnapshotBytes: 256 * 1024,
|
|
312
|
+
maximumPublishBodyBytes: 256 * 1024,
|
|
313
|
+
maximumBrokerRequestBytes: 8 * 1024,
|
|
314
|
+
maximumDescriptorBytes: 8 * 1024,
|
|
315
|
+
maximumHistorySummaries: 8,
|
|
316
|
+
maximumConnectorReceipts: 64,
|
|
317
|
+
handoffTtlMs: 15 * 60 * 1e3,
|
|
318
|
+
defaultWaitMs: 2e4,
|
|
319
|
+
maximumWaitMs: 25e3,
|
|
320
|
+
maximumWaiters: 8,
|
|
321
|
+
maximumDescriptorsPerScan: 32,
|
|
322
|
+
maximumProjectAncestors: 64,
|
|
323
|
+
maximumBrokerHeaderBytes: 8 * 1024,
|
|
324
|
+
maximumBrokerSockets: 32,
|
|
325
|
+
brokerDiscoveryTimeoutMs: 750,
|
|
326
|
+
brokerRequestTimeoutMs: 2e3,
|
|
327
|
+
brokerWaitGraceMs: 2e3,
|
|
328
|
+
maximumSetupConfigBytes: 1024 * 1024,
|
|
329
|
+
maximumRequestIdRecords: 16,
|
|
330
|
+
requestIdTtlMs: 15 * 60 * 1e3,
|
|
331
|
+
activeHeartbeatIntervalMs: 3e3,
|
|
332
|
+
activeLeaseDurationMs: 1e4,
|
|
333
|
+
activeTransportWriteTimeoutMs: 5e3,
|
|
334
|
+
activeDispatchTimeoutMs: 30 * 60 * 1e3,
|
|
335
|
+
activeStatusPollMs: 1e3
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
// src/protocol/external-handoff.ts
|
|
339
|
+
var opaqueIdSchema = import_zod2.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/u);
|
|
340
|
+
var isoTimestampSchema = import_zod2.z.iso.datetime();
|
|
341
|
+
var externalHandoffReportableDispatchPhaseSchema = import_zod2.z.enum(
|
|
342
|
+
EXTERNAL_HANDOFF_REPORTABLE_DISPATCH_PHASES
|
|
343
|
+
);
|
|
344
|
+
var externalHandoffPageSummarySchema = import_zod2.z.strictObject({
|
|
345
|
+
origin: import_zod2.z.string().min(1).max(2048),
|
|
346
|
+
pathname: import_zod2.z.string().min(1).max(2048)
|
|
347
|
+
});
|
|
348
|
+
var externalHandoffSummarySchema = import_zod2.z.strictObject({
|
|
349
|
+
sessionId: opaqueIdSchema,
|
|
350
|
+
framework: import_zod2.z.enum(EXTERNAL_HANDOFF_FRAMEWORKS),
|
|
351
|
+
revision: import_zod2.z.number().int().positive(),
|
|
352
|
+
cursor: opaqueIdSchema,
|
|
353
|
+
targetCount: import_zod2.z.number().int().positive(),
|
|
354
|
+
page: externalHandoffPageSummarySchema,
|
|
355
|
+
publishedAt: isoTimestampSchema,
|
|
356
|
+
expiresAt: isoTimestampSchema,
|
|
357
|
+
state: import_zod2.z.enum(EXTERNAL_HANDOFF_STATES),
|
|
358
|
+
pickupCount: import_zod2.z.number().int().nonnegative().max(EXTERNAL_HANDOFF_LIMITS.maximumConnectorReceipts),
|
|
359
|
+
pickedUpAt: isoTimestampSchema.optional()
|
|
360
|
+
});
|
|
361
|
+
var externalHandoffSnapshotSchema = import_zod2.z.strictObject({
|
|
362
|
+
schemaVersion: import_zod2.z.literal(EXTERNAL_HANDOFF_SNAPSHOT_SCHEMA_VERSION),
|
|
363
|
+
cursor: opaqueIdSchema,
|
|
364
|
+
session: import_zod2.z.strictObject({
|
|
365
|
+
id: opaqueIdSchema,
|
|
366
|
+
framework: import_zod2.z.enum(EXTERNAL_HANDOFF_FRAMEWORKS)
|
|
367
|
+
}),
|
|
368
|
+
revision: import_zod2.z.number().int().positive(),
|
|
369
|
+
publishedAt: isoTimestampSchema,
|
|
370
|
+
expiresAt: isoTimestampSchema,
|
|
371
|
+
annotation: spotAnnotationRequestSchema
|
|
372
|
+
});
|
|
373
|
+
var activeAdapterSummarySchema = import_zod2.z.strictObject({
|
|
374
|
+
kind: import_zod2.z.enum(EXTERNAL_HANDOFF_ACTIVE_ADAPTER_KINDS),
|
|
375
|
+
state: import_zod2.z.enum(EXTERNAL_HANDOFF_ACTIVE_ADAPTER_STATES),
|
|
376
|
+
canDispatch: import_zod2.z.boolean(),
|
|
377
|
+
connectedAt: isoTimestampSchema,
|
|
378
|
+
updatedAt: isoTimestampSchema
|
|
379
|
+
}).superRefine((value, context) => {
|
|
380
|
+
if (value.canDispatch !== (value.state === "ready")) {
|
|
381
|
+
context.addIssue({
|
|
382
|
+
code: "custom",
|
|
383
|
+
message: "canDispatch must match the ready state.",
|
|
384
|
+
path: ["canDispatch"]
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
var dispatchSummarySchema = import_zod2.z.strictObject({
|
|
389
|
+
adapterKind: import_zod2.z.enum(EXTERNAL_HANDOFF_ACTIVE_ADAPTER_KINDS),
|
|
390
|
+
revision: import_zod2.z.number().int().positive(),
|
|
391
|
+
phase: import_zod2.z.enum(EXTERNAL_HANDOFF_DISPATCH_PHASES),
|
|
392
|
+
updatedAt: isoTimestampSchema
|
|
393
|
+
});
|
|
394
|
+
var externalHandoffCapabilityRequestSchema = import_zod2.z.strictObject({});
|
|
395
|
+
var externalHandoffPublishRequestSchema = import_zod2.z.strictObject({
|
|
396
|
+
requestId: opaqueIdSchema,
|
|
397
|
+
annotation: spotAnnotationRequestSchema
|
|
398
|
+
});
|
|
399
|
+
var externalHandoffStatusRequestSchema = import_zod2.z.strictObject({
|
|
400
|
+
cursor: opaqueIdSchema.optional()
|
|
401
|
+
});
|
|
402
|
+
var externalHandoffResolveDeliveryRequestSchema = import_zod2.z.strictObject({
|
|
403
|
+
cursor: opaqueIdSchema,
|
|
404
|
+
confirmation: import_zod2.z.literal("workspace-reviewed")
|
|
405
|
+
});
|
|
406
|
+
var externalHandoffCapabilitySchema = import_zod2.z.strictObject({
|
|
407
|
+
enabled: import_zod2.z.literal(true),
|
|
408
|
+
brokerReady: import_zod2.z.boolean(),
|
|
409
|
+
activeWaitCount: import_zod2.z.number().int().nonnegative().max(EXTERNAL_HANDOFF_LIMITS.maximumWaiters),
|
|
410
|
+
snapshotSchemaVersion: import_zod2.z.literal(EXTERNAL_HANDOFF_SNAPSHOT_SCHEMA_VERSION),
|
|
411
|
+
brokerProtocolVersion: import_zod2.z.literal(EXTERNAL_HANDOFF_BROKER_PROTOCOL_VERSION),
|
|
412
|
+
activeAdapter: activeAdapterSummarySchema.nullable(),
|
|
413
|
+
dispatch: dispatchSummarySchema.nullable()
|
|
414
|
+
});
|
|
415
|
+
var externalHandoffPublishDeliverySchema = import_zod2.z.discriminatedUnion("mode", [
|
|
416
|
+
import_zod2.z.strictObject({ mode: import_zod2.z.literal("inbox") }),
|
|
417
|
+
import_zod2.z.strictObject({
|
|
418
|
+
mode: import_zod2.z.literal("active"),
|
|
419
|
+
adapter: activeAdapterSummarySchema,
|
|
420
|
+
dispatch: dispatchSummarySchema
|
|
421
|
+
})
|
|
422
|
+
]);
|
|
423
|
+
var externalHandoffPublishResultSchema = import_zod2.z.strictObject({
|
|
424
|
+
handoff: externalHandoffSummarySchema,
|
|
425
|
+
delivery: externalHandoffPublishDeliverySchema,
|
|
426
|
+
replayed: import_zod2.z.boolean()
|
|
427
|
+
});
|
|
428
|
+
var externalHandoffStatusResultSchema = import_zod2.z.strictObject({
|
|
429
|
+
handoff: externalHandoffSummarySchema,
|
|
430
|
+
activeAdapter: activeAdapterSummarySchema.nullable(),
|
|
431
|
+
dispatch: dispatchSummarySchema.nullable()
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
// src/errors/error-code.ts
|
|
435
|
+
var ERROR_CODES = {
|
|
436
|
+
INVALID_REQUEST: "INVALID_REQUEST",
|
|
437
|
+
INVALID_TOKEN: "INVALID_TOKEN",
|
|
438
|
+
ORIGIN_NOT_ALLOWED: "ORIGIN_NOT_ALLOWED",
|
|
439
|
+
SOURCE_NOT_FOUND: "SOURCE_NOT_FOUND",
|
|
440
|
+
SOURCE_OUTSIDE_ROOT: "SOURCE_OUTSIDE_ROOT",
|
|
441
|
+
SOURCE_TOO_LARGE: "SOURCE_TOO_LARGE",
|
|
442
|
+
EDITOR_OPEN_FAILED: "EDITOR_OPEN_FAILED",
|
|
443
|
+
DATA_FLOW_DISABLED: "DATA_FLOW_DISABLED",
|
|
444
|
+
DATA_FLOW_SOURCE_STALE: "DATA_FLOW_SOURCE_STALE",
|
|
445
|
+
DATA_FLOW_ANALYSIS_CANCELLED: "DATA_FLOW_ANALYSIS_CANCELLED",
|
|
446
|
+
AI_DISABLED: "AI_DISABLED",
|
|
447
|
+
PROVIDER_NOT_CONFIGURED: "PROVIDER_NOT_CONFIGURED",
|
|
448
|
+
PROVIDER_AUTH_FAILED: "PROVIDER_AUTH_FAILED",
|
|
449
|
+
PROVIDER_PROTOCOL_UNSUPPORTED: "PROVIDER_PROTOCOL_UNSUPPORTED",
|
|
450
|
+
MODEL_NOT_ALLOWED: "MODEL_NOT_ALLOWED",
|
|
451
|
+
MODEL_TOOL_CALL_UNSUPPORTED: "MODEL_TOOL_CALL_UNSUPPORTED",
|
|
452
|
+
PROVIDER_RATE_LIMITED: "PROVIDER_RATE_LIMITED",
|
|
453
|
+
AGENT_BUSY: "AGENT_BUSY",
|
|
454
|
+
AGENT_LIMIT_EXCEEDED: "AGENT_LIMIT_EXCEEDED",
|
|
455
|
+
AGENT_CANCELLED: "AGENT_CANCELLED",
|
|
456
|
+
EXTERNAL_HANDOFF_DISABLED: "EXTERNAL_HANDOFF_DISABLED",
|
|
457
|
+
EXTERNAL_HANDOFF_UNAVAILABLE: "EXTERNAL_HANDOFF_UNAVAILABLE",
|
|
458
|
+
HANDOFF_VALIDATION_FAILED: "HANDOFF_VALIDATION_FAILED",
|
|
459
|
+
HANDOFF_SOURCE_STALE: "HANDOFF_SOURCE_STALE",
|
|
460
|
+
HANDOFF_NOT_FOUND: "HANDOFF_NOT_FOUND",
|
|
461
|
+
HANDOFF_EXPIRED: "HANDOFF_EXPIRED",
|
|
462
|
+
HANDOFF_CURSOR_INVALID: "HANDOFF_CURSOR_INVALID",
|
|
463
|
+
HANDOFF_RESPONSE_TOO_LARGE: "HANDOFF_RESPONSE_TOO_LARGE",
|
|
464
|
+
BRIDGE_UNAUTHORIZED: "BRIDGE_UNAUTHORIZED",
|
|
465
|
+
BRIDGE_PROTOCOL_MISMATCH: "BRIDGE_PROTOCOL_MISMATCH",
|
|
466
|
+
BRIDGE_BUSY: "BRIDGE_BUSY",
|
|
467
|
+
EXTERNAL_AGENT_BUSY: "EXTERNAL_AGENT_BUSY",
|
|
468
|
+
ACTIVE_ADAPTER_CONFLICT: "ACTIVE_ADAPTER_CONFLICT",
|
|
469
|
+
ACTIVE_ADAPTER_LEASE_INVALID: "ACTIVE_ADAPTER_LEASE_INVALID",
|
|
470
|
+
ACTIVE_DISPATCH_INVALID: "ACTIVE_DISPATCH_INVALID",
|
|
471
|
+
SESSION_NOT_FOUND: "SESSION_NOT_FOUND",
|
|
472
|
+
SESSION_AMBIGUOUS: "SESSION_AMBIGUOUS",
|
|
473
|
+
SESSION_CLOSED: "SESSION_CLOSED",
|
|
474
|
+
WORKTREE_DIRTY: "WORKTREE_DIRTY",
|
|
475
|
+
WORKTREE_NOT_REPOSITORY: "WORKTREE_NOT_REPOSITORY",
|
|
476
|
+
WORKTREE_OPERATION_IN_PROGRESS: "WORKTREE_OPERATION_IN_PROGRESS",
|
|
477
|
+
WORKTREE_CONFLICTED: "WORKTREE_CONFLICTED",
|
|
478
|
+
WORKTREE_LOCAL_CHANGES_TOO_LARGE: "WORKTREE_LOCAL_CHANGES_TOO_LARGE",
|
|
479
|
+
WORKTREE_UNTRACKED_UNSUPPORTED: "WORKTREE_UNTRACKED_UNSUPPORTED",
|
|
480
|
+
WORKTREE_LOCAL_CHANGES_UNSUPPORTED: "WORKTREE_LOCAL_CHANGES_UNSUPPORTED",
|
|
481
|
+
TOOL_DENIED: "TOOL_DENIED",
|
|
482
|
+
TOOL_INPUT_INVALID: "TOOL_INPUT_INVALID",
|
|
483
|
+
TOOL_ARGUMENTS_INVALID: "TOOL_ARGUMENTS_INVALID",
|
|
484
|
+
TOOL_CALL_ID_CONFLICT: "TOOL_CALL_ID_CONFLICT",
|
|
485
|
+
TOOL_PATH_DENIED: "TOOL_PATH_DENIED",
|
|
486
|
+
PATCH_REJECTED: "PATCH_REJECTED",
|
|
487
|
+
VALIDATION_FAILED: "VALIDATION_FAILED",
|
|
488
|
+
APPLY_CONFLICT: "APPLY_CONFLICT",
|
|
489
|
+
INTERNAL_ERROR: "INTERNAL_ERROR"
|
|
490
|
+
};
|
|
491
|
+
var ERROR_CODE_VALUES = Object.freeze(Object.values(ERROR_CODES));
|
|
492
|
+
|
|
493
|
+
// src/errors/spotpatch-error.ts
|
|
494
|
+
var SpotPatchError = class extends Error {
|
|
495
|
+
code;
|
|
496
|
+
constructor(code, message = code, options) {
|
|
497
|
+
super(message, options);
|
|
498
|
+
this.name = "SpotPatchError";
|
|
499
|
+
this.code = code;
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
|
|
503
|
+
// src/external-agent-node.ts
|
|
504
|
+
var SPOTPATCH_BRIDGE_TOKEN_HEADER = "X-SpotPatch-Bridge-Token";
|
|
505
|
+
var SPOTPATCH_BRIDGE_PATHS = Object.freeze({
|
|
506
|
+
status: "/bridge/v1/status",
|
|
507
|
+
current: "/bridge/v1/handoff/current",
|
|
508
|
+
wait: "/bridge/v1/handoff/wait",
|
|
509
|
+
ack: "/bridge/v1/handoff/ack",
|
|
510
|
+
activeClaim: "/bridge/v1/active/claim",
|
|
511
|
+
activeHeartbeat: "/bridge/v1/active/heartbeat",
|
|
512
|
+
activeReport: "/bridge/v1/active/report",
|
|
513
|
+
activeRelease: "/bridge/v1/active/release"
|
|
514
|
+
});
|
|
515
|
+
var EXTERNAL_HANDOFF_PROJECT_KEY_SALT = "spotpatch-external-agent-project-v1";
|
|
516
|
+
var opaqueIdSchema2 = import_zod3.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/u);
|
|
517
|
+
var projectKeySchema = import_zod3.z.string().length(64).regex(/^[a-f0-9]+$/u);
|
|
518
|
+
var loopbackEndpointSchema = import_zod3.z.url().refine((value) => {
|
|
519
|
+
const match = /^http:\/\/127\.0\.0\.1:([1-9][0-9]{0,4})$/u.exec(value);
|
|
520
|
+
if (match?.[1] === void 0) {
|
|
521
|
+
return false;
|
|
522
|
+
}
|
|
523
|
+
const port = Number(match[1]);
|
|
524
|
+
return Number.isSafeInteger(port) && port <= 65535;
|
|
525
|
+
});
|
|
526
|
+
var externalHandoffDescriptorSchema = import_zod3.z.strictObject({
|
|
527
|
+
schemaVersion: import_zod3.z.literal(1),
|
|
528
|
+
brokerProtocolVersion: import_zod3.z.literal(EXTERNAL_HANDOFF_BROKER_PROTOCOL_VERSION),
|
|
529
|
+
projectKey: projectKeySchema,
|
|
530
|
+
sessionId: opaqueIdSchema2,
|
|
531
|
+
framework: import_zod3.z.enum(EXTERNAL_HANDOFF_FRAMEWORKS),
|
|
532
|
+
endpoint: loopbackEndpointSchema,
|
|
533
|
+
bridgeToken: import_zod3.z.string().min(43).max(128).regex(/^[A-Za-z0-9_-]+$/u),
|
|
534
|
+
pid: import_zod3.z.number().int().positive(),
|
|
535
|
+
createdAt: import_zod3.z.iso.datetime()
|
|
536
|
+
});
|
|
537
|
+
var bridgeStatusRequestSchema = import_zod3.z.strictObject({});
|
|
538
|
+
var bridgeCurrentRequestSchema = import_zod3.z.strictObject({
|
|
539
|
+
cursor: opaqueIdSchema2.optional()
|
|
540
|
+
});
|
|
541
|
+
var bridgeWaitRequestSchema = import_zod3.z.strictObject({
|
|
542
|
+
afterCursor: opaqueIdSchema2.optional(),
|
|
543
|
+
timeoutMs: import_zod3.z.number().int().positive().max(EXTERNAL_HANDOFF_LIMITS.maximumWaitMs).default(EXTERNAL_HANDOFF_LIMITS.defaultWaitMs)
|
|
544
|
+
});
|
|
545
|
+
var bridgeAckRequestSchema = import_zod3.z.strictObject({
|
|
546
|
+
cursor: opaqueIdSchema2,
|
|
547
|
+
connectorInstanceId: opaqueIdSchema2
|
|
548
|
+
});
|
|
549
|
+
var bridgeActiveClaimRequestSchema = import_zod3.z.strictObject({
|
|
550
|
+
adapterKind: import_zod3.z.enum(EXTERNAL_HANDOFF_ACTIVE_ADAPTER_KINDS),
|
|
551
|
+
connectorInstanceId: opaqueIdSchema2
|
|
552
|
+
});
|
|
553
|
+
var bridgeActiveHeartbeatRequestSchema = import_zod3.z.strictObject({
|
|
554
|
+
leaseToken: opaqueIdSchema2
|
|
555
|
+
});
|
|
556
|
+
var bridgeActiveReportRequestSchema = import_zod3.z.strictObject({
|
|
557
|
+
leaseToken: opaqueIdSchema2,
|
|
558
|
+
cursor: opaqueIdSchema2,
|
|
559
|
+
phase: externalHandoffReportableDispatchPhaseSchema
|
|
560
|
+
});
|
|
561
|
+
var bridgeActiveReleaseRequestSchema = import_zod3.z.strictObject({
|
|
562
|
+
leaseToken: opaqueIdSchema2
|
|
563
|
+
});
|
|
564
|
+
var bridgeStatusSchema = import_zod3.z.strictObject({
|
|
565
|
+
brokerProtocolVersion: import_zod3.z.literal(EXTERNAL_HANDOFF_BROKER_PROTOCOL_VERSION),
|
|
566
|
+
projectKey: projectKeySchema,
|
|
567
|
+
sessionId: opaqueIdSchema2,
|
|
568
|
+
framework: import_zod3.z.enum(EXTERNAL_HANDOFF_FRAMEWORKS),
|
|
569
|
+
current: externalHandoffSummarySchema.nullable()
|
|
570
|
+
});
|
|
571
|
+
var bridgeCurrentResultSchema = import_zod3.z.strictObject({
|
|
572
|
+
outcome: import_zod3.z.literal("handoff"),
|
|
573
|
+
snapshot: externalHandoffSnapshotSchema
|
|
574
|
+
});
|
|
575
|
+
var bridgeWaitResultSchema = import_zod3.z.discriminatedUnion("outcome", [
|
|
576
|
+
bridgeCurrentResultSchema,
|
|
577
|
+
import_zod3.z.strictObject({ outcome: import_zod3.z.literal("timeout") })
|
|
578
|
+
]);
|
|
579
|
+
var bridgeAckResultSchema = import_zod3.z.strictObject({
|
|
580
|
+
summary: externalHandoffSummarySchema
|
|
581
|
+
});
|
|
582
|
+
var bridgeActiveClaimResultSchema = import_zod3.z.strictObject({
|
|
583
|
+
leaseToken: opaqueIdSchema2,
|
|
584
|
+
heartbeatIntervalMs: import_zod3.z.literal(EXTERNAL_HANDOFF_LIMITS.activeHeartbeatIntervalMs),
|
|
585
|
+
baselineCursor: opaqueIdSchema2.nullable(),
|
|
586
|
+
activeAdapter: activeAdapterSummarySchema
|
|
587
|
+
});
|
|
588
|
+
var bridgeActiveStateResultSchema = import_zod3.z.strictObject({
|
|
589
|
+
activeAdapter: activeAdapterSummarySchema.nullable(),
|
|
590
|
+
dispatch: dispatchSummarySchema.nullable()
|
|
591
|
+
});
|
|
592
|
+
var bridgeActiveHeartbeatResultSchema = bridgeActiveStateResultSchema;
|
|
593
|
+
var bridgeActiveReportResultSchema = bridgeActiveStateResultSchema;
|
|
594
|
+
var bridgeActiveReleaseResultSchema = bridgeActiveStateResultSchema;
|
|
595
|
+
function currentUid() {
|
|
596
|
+
const uid = process.getuid?.();
|
|
597
|
+
if (uid === void 0) {
|
|
598
|
+
throw new SpotPatchError(ERROR_CODES.BRIDGE_UNAUTHORIZED);
|
|
599
|
+
}
|
|
600
|
+
return uid;
|
|
601
|
+
}
|
|
602
|
+
async function assertPrivateDirectory(directory, uid) {
|
|
603
|
+
const status = await (0, import_promises.lstat)(directory);
|
|
604
|
+
if (!status.isDirectory() || status.isSymbolicLink() || status.uid !== uid || (status.mode & 63) !== 0) {
|
|
605
|
+
throw new SpotPatchError(ERROR_CODES.BRIDGE_UNAUTHORIZED);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
async function ensurePrivateSubdirectory(base, uid, create) {
|
|
609
|
+
const directory = import_node_path.default.join(base, "spotpatch");
|
|
610
|
+
if (create) {
|
|
611
|
+
try {
|
|
612
|
+
await (0, import_promises.mkdir)(directory, { mode: 448 });
|
|
613
|
+
} catch (error) {
|
|
614
|
+
if (error.code !== "EEXIST") {
|
|
615
|
+
throw error;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
await assertPrivateDirectory(directory, uid);
|
|
620
|
+
return directory;
|
|
621
|
+
}
|
|
622
|
+
async function resolveExternalHandoffRuntimeDirectory(create) {
|
|
623
|
+
if (process.platform === "win32") {
|
|
624
|
+
throw new SpotPatchError(ERROR_CODES.BRIDGE_UNAUTHORIZED);
|
|
625
|
+
}
|
|
626
|
+
const uid = currentUid();
|
|
627
|
+
const xdgRuntimeDirectory = process.env.XDG_RUNTIME_DIR;
|
|
628
|
+
if (xdgRuntimeDirectory !== void 0 && !import_node_path.default.isAbsolute(xdgRuntimeDirectory)) {
|
|
629
|
+
throw new SpotPatchError(ERROR_CODES.BRIDGE_UNAUTHORIZED);
|
|
630
|
+
}
|
|
631
|
+
if (xdgRuntimeDirectory !== void 0) {
|
|
632
|
+
try {
|
|
633
|
+
await assertPrivateDirectory(xdgRuntimeDirectory, uid);
|
|
634
|
+
return await ensurePrivateSubdirectory(xdgRuntimeDirectory, uid, create);
|
|
635
|
+
} catch (error) {
|
|
636
|
+
if (!create && error.code === "ENOENT") {
|
|
637
|
+
throw new SpotPatchError(ERROR_CODES.SESSION_NOT_FOUND);
|
|
638
|
+
}
|
|
639
|
+
throw error;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
const fallback = import_node_path.default.join(import_node_os.default.tmpdir(), `spotpatch-${String(uid)}`);
|
|
643
|
+
if (create) {
|
|
644
|
+
try {
|
|
645
|
+
await (0, import_promises.mkdir)(fallback, { mode: 448 });
|
|
646
|
+
} catch (error) {
|
|
647
|
+
if (error.code !== "EEXIST") {
|
|
648
|
+
throw error;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
try {
|
|
653
|
+
await assertPrivateDirectory(fallback, uid);
|
|
654
|
+
} catch (error) {
|
|
655
|
+
if (!create && error.code === "ENOENT") {
|
|
656
|
+
throw new SpotPatchError(ERROR_CODES.SESSION_NOT_FOUND);
|
|
657
|
+
}
|
|
658
|
+
throw error;
|
|
659
|
+
}
|
|
660
|
+
return fallback;
|
|
661
|
+
}
|
|
662
|
+
async function computeExternalHandoffProjectKey(root) {
|
|
663
|
+
const canonicalRoot = await (0, import_promises.realpath)(root);
|
|
664
|
+
return (0, import_node_crypto.createHash)("sha256").update(`${EXTERNAL_HANDOFF_PROJECT_KEY_SALT}\0${canonicalRoot}`).digest("hex");
|
|
665
|
+
}
|
|
666
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
667
|
+
0 && (module.exports = {
|
|
668
|
+
EXTERNAL_HANDOFF_PROJECT_KEY_SALT,
|
|
669
|
+
SPOTPATCH_BRIDGE_PATHS,
|
|
670
|
+
SPOTPATCH_BRIDGE_TOKEN_HEADER,
|
|
671
|
+
bridgeAckRequestSchema,
|
|
672
|
+
bridgeAckResultSchema,
|
|
673
|
+
bridgeActiveClaimRequestSchema,
|
|
674
|
+
bridgeActiveClaimResultSchema,
|
|
675
|
+
bridgeActiveHeartbeatRequestSchema,
|
|
676
|
+
bridgeActiveHeartbeatResultSchema,
|
|
677
|
+
bridgeActiveReleaseRequestSchema,
|
|
678
|
+
bridgeActiveReleaseResultSchema,
|
|
679
|
+
bridgeActiveReportRequestSchema,
|
|
680
|
+
bridgeActiveReportResultSchema,
|
|
681
|
+
bridgeActiveStateResultSchema,
|
|
682
|
+
bridgeCurrentRequestSchema,
|
|
683
|
+
bridgeCurrentResultSchema,
|
|
684
|
+
bridgeStatusRequestSchema,
|
|
685
|
+
bridgeStatusSchema,
|
|
686
|
+
bridgeWaitRequestSchema,
|
|
687
|
+
bridgeWaitResultSchema,
|
|
688
|
+
computeExternalHandoffProjectKey,
|
|
689
|
+
externalHandoffDescriptorSchema,
|
|
690
|
+
resolveExternalHandoffRuntimeDirectory
|
|
691
|
+
});
|
|
692
|
+
//# sourceMappingURL=external-agent-node.cjs.map
|