@spotpatch/dev-server 0.1.1 → 0.2.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/index.cjs +12 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +13 -16
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -87,7 +87,6 @@ function createAgentJobManager(options) {
|
|
|
87
87
|
});
|
|
88
88
|
const jobs = /* @__PURE__ */ new Map();
|
|
89
89
|
const capabilityCache = /* @__PURE__ */ new Map();
|
|
90
|
-
const providerConsents = /* @__PURE__ */ new Set();
|
|
91
90
|
let closed = false;
|
|
92
91
|
const resolveSelection = (providerProfileId, modelProfileId) => {
|
|
93
92
|
const provider = options.ai.providers[providerProfileId];
|
|
@@ -218,15 +217,7 @@ function createAgentJobManager(options) {
|
|
|
218
217
|
};
|
|
219
218
|
const runJob = async (job) => {
|
|
220
219
|
try {
|
|
221
|
-
transition(job, "preparing", "
|
|
222
|
-
await probeResolved(
|
|
223
|
-
Object.freeze({
|
|
224
|
-
credential: job.credential,
|
|
225
|
-
model: job.model,
|
|
226
|
-
provider: job.provider
|
|
227
|
-
}),
|
|
228
|
-
job.controller.signal
|
|
229
|
-
);
|
|
220
|
+
transition(job, "preparing", "Preparing isolated Agent execution.");
|
|
230
221
|
const callbacks = {
|
|
231
222
|
onCheck(result) {
|
|
232
223
|
appendEvent(
|
|
@@ -289,7 +280,8 @@ function createAgentJobManager(options) {
|
|
|
289
280
|
transition(job, "completed", "No source changes were proposed.");
|
|
290
281
|
return;
|
|
291
282
|
}
|
|
292
|
-
|
|
283
|
+
const shouldApplyDirectly = options.ai.execution.applyMode === "auto" && preparedChange.autoApplyEligible || options.ai.execution.applyMode === "trusted-auto" && job.trustedFastModeConsent;
|
|
284
|
+
if (shouldApplyDirectly) {
|
|
293
285
|
try {
|
|
294
286
|
await applyChange(job, preparedChange);
|
|
295
287
|
} catch {
|
|
@@ -358,13 +350,16 @@ function createAgentJobManager(options) {
|
|
|
358
350
|
[...jobs.values()].map((job) => job.runPromise).filter((promise) => promise !== void 0)
|
|
359
351
|
);
|
|
360
352
|
capabilityCache.clear();
|
|
361
|
-
providerConsents.clear();
|
|
362
353
|
jobs.clear();
|
|
363
354
|
},
|
|
364
355
|
create(request) {
|
|
365
356
|
if (closed) {
|
|
366
357
|
throw new SpotPatchError(ERROR_CODES.AI_DISABLED);
|
|
367
358
|
}
|
|
359
|
+
const trustedFastModeConfigured = options.ai.execution.applyMode === "trusted-auto";
|
|
360
|
+
if (trustedFastModeConfigured !== (request.trustedFastModeConsent === true)) {
|
|
361
|
+
throw new SpotPatchError(ERROR_CODES.INVALID_REQUEST);
|
|
362
|
+
}
|
|
368
363
|
if (hasActiveJob()) {
|
|
369
364
|
throw new SpotPatchError(ERROR_CODES.AGENT_BUSY);
|
|
370
365
|
}
|
|
@@ -376,7 +371,6 @@ function createAgentJobManager(options) {
|
|
|
376
371
|
request.providerProfileId,
|
|
377
372
|
request.modelProfileId
|
|
378
373
|
);
|
|
379
|
-
providerConsents.add(selection.provider.id);
|
|
380
374
|
const id = dependencies.createJobId();
|
|
381
375
|
if (!JOB_ID_PATTERN.test(id) || jobs.has(id)) {
|
|
382
376
|
throw new SpotPatchError(ERROR_CODES.INTERNAL_ERROR);
|
|
@@ -399,6 +393,7 @@ function createAgentJobManager(options) {
|
|
|
399
393
|
runPromise: void 0,
|
|
400
394
|
sequence: 0,
|
|
401
395
|
status: "queued",
|
|
396
|
+
trustedFastModeConsent: request.trustedFastModeConsent === true,
|
|
402
397
|
updatedAt: timestamp,
|
|
403
398
|
workingTreeMode: request.workingTreeMode
|
|
404
399
|
};
|
|
@@ -556,6 +551,7 @@ function resolveEnvironmentAiConfiguration(environment) {
|
|
|
556
551
|
|
|
557
552
|
// src/options.ts
|
|
558
553
|
import {
|
|
554
|
+
AGENT_APPLY_MODES,
|
|
559
555
|
DEFAULT_AGENT_LIMITS,
|
|
560
556
|
MAX_ANNOTATION_TARGETS,
|
|
561
557
|
SPOTPATCH_EDITOR_PREFERENCES,
|
|
@@ -636,7 +632,7 @@ var aiOptionsSchema = z.strictObject({
|
|
|
636
632
|
defaultProvider: z.string(),
|
|
637
633
|
execution: z.strictObject({
|
|
638
634
|
isolation: z.literal("git-worktree").optional(),
|
|
639
|
-
applyMode: z.enum(
|
|
635
|
+
applyMode: z.enum(AGENT_APPLY_MODES).optional(),
|
|
640
636
|
checks: z.record(z.string(), agentCheckSchema).optional(),
|
|
641
637
|
limits: agentLimitsSchema
|
|
642
638
|
}).optional()
|
|
@@ -831,8 +827,8 @@ function resolveAiOptions(options) {
|
|
|
831
827
|
const limits = resolveLimits(validated.execution?.limits);
|
|
832
828
|
const checks = resolveChecks(validated.execution?.checks, limits.checkTimeoutMs);
|
|
833
829
|
const applyMode = validated.execution?.applyMode ?? "review";
|
|
834
|
-
if (applyMode
|
|
835
|
-
throw new RangeError(
|
|
830
|
+
if (applyMode !== "review" && !Object.values(checks).some((check) => check.required)) {
|
|
831
|
+
throw new RangeError(`SpotPatch AI ${applyMode} mode requires a required check.`);
|
|
836
832
|
}
|
|
837
833
|
const providers = resolveProviders(validated.providers);
|
|
838
834
|
if (!(validated.defaultProvider in providers)) {
|
|
@@ -1470,6 +1466,7 @@ async function authorizeAgentJobRequest(input) {
|
|
|
1470
1466
|
providerProfileId: input.request.providerProfileId,
|
|
1471
1467
|
modelProfileId: input.request.modelProfileId,
|
|
1472
1468
|
providerDataConsent: true,
|
|
1469
|
+
...input.request.trustedFastModeConsent === true ? { trustedFastModeConsent: true } : {},
|
|
1473
1470
|
workingTreeMode: input.request.workingTreeMode
|
|
1474
1471
|
});
|
|
1475
1472
|
}
|