@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 CHANGED
@@ -129,7 +129,6 @@ function createAgentJobManager(options) {
129
129
  });
130
130
  const jobs = /* @__PURE__ */ new Map();
131
131
  const capabilityCache = /* @__PURE__ */ new Map();
132
- const providerConsents = /* @__PURE__ */ new Set();
133
132
  let closed = false;
134
133
  const resolveSelection = (providerProfileId, modelProfileId) => {
135
134
  const provider = options.ai.providers[providerProfileId];
@@ -260,15 +259,7 @@ function createAgentJobManager(options) {
260
259
  };
261
260
  const runJob = async (job) => {
262
261
  try {
263
- transition(job, "preparing", "Verifying provider and model capabilities.");
264
- await probeResolved(
265
- Object.freeze({
266
- credential: job.credential,
267
- model: job.model,
268
- provider: job.provider
269
- }),
270
- job.controller.signal
271
- );
262
+ transition(job, "preparing", "Preparing isolated Agent execution.");
272
263
  const callbacks = {
273
264
  onCheck(result) {
274
265
  appendEvent(
@@ -331,7 +322,8 @@ function createAgentJobManager(options) {
331
322
  transition(job, "completed", "No source changes were proposed.");
332
323
  return;
333
324
  }
334
- if (options.ai.execution.applyMode === "auto" && preparedChange.autoApplyEligible) {
325
+ const shouldApplyDirectly = options.ai.execution.applyMode === "auto" && preparedChange.autoApplyEligible || options.ai.execution.applyMode === "trusted-auto" && job.trustedFastModeConsent;
326
+ if (shouldApplyDirectly) {
335
327
  try {
336
328
  await applyChange(job, preparedChange);
337
329
  } catch {
@@ -400,13 +392,16 @@ function createAgentJobManager(options) {
400
392
  [...jobs.values()].map((job) => job.runPromise).filter((promise) => promise !== void 0)
401
393
  );
402
394
  capabilityCache.clear();
403
- providerConsents.clear();
404
395
  jobs.clear();
405
396
  },
406
397
  create(request) {
407
398
  if (closed) {
408
399
  throw new import_shared.SpotPatchError(import_shared.ERROR_CODES.AI_DISABLED);
409
400
  }
401
+ const trustedFastModeConfigured = options.ai.execution.applyMode === "trusted-auto";
402
+ if (trustedFastModeConfigured !== (request.trustedFastModeConsent === true)) {
403
+ throw new import_shared.SpotPatchError(import_shared.ERROR_CODES.INVALID_REQUEST);
404
+ }
410
405
  if (hasActiveJob()) {
411
406
  throw new import_shared.SpotPatchError(import_shared.ERROR_CODES.AGENT_BUSY);
412
407
  }
@@ -418,7 +413,6 @@ function createAgentJobManager(options) {
418
413
  request.providerProfileId,
419
414
  request.modelProfileId
420
415
  );
421
- providerConsents.add(selection.provider.id);
422
416
  const id = dependencies.createJobId();
423
417
  if (!JOB_ID_PATTERN.test(id) || jobs.has(id)) {
424
418
  throw new import_shared.SpotPatchError(import_shared.ERROR_CODES.INTERNAL_ERROR);
@@ -441,6 +435,7 @@ function createAgentJobManager(options) {
441
435
  runPromise: void 0,
442
436
  sequence: 0,
443
437
  status: "queued",
438
+ trustedFastModeConsent: request.trustedFastModeConsent === true,
444
439
  updatedAt: timestamp,
445
440
  workingTreeMode: request.workingTreeMode
446
441
  };
@@ -673,7 +668,7 @@ var aiOptionsSchema = import_zod.z.strictObject({
673
668
  defaultProvider: import_zod.z.string(),
674
669
  execution: import_zod.z.strictObject({
675
670
  isolation: import_zod.z.literal("git-worktree").optional(),
676
- applyMode: import_zod.z.enum(["review", "auto"]).optional(),
671
+ applyMode: import_zod.z.enum(import_shared2.AGENT_APPLY_MODES).optional(),
677
672
  checks: import_zod.z.record(import_zod.z.string(), agentCheckSchema).optional(),
678
673
  limits: agentLimitsSchema
679
674
  }).optional()
@@ -868,8 +863,8 @@ function resolveAiOptions(options) {
868
863
  const limits = resolveLimits(validated.execution?.limits);
869
864
  const checks = resolveChecks(validated.execution?.checks, limits.checkTimeoutMs);
870
865
  const applyMode = validated.execution?.applyMode ?? "review";
871
- if (applyMode === "auto" && !Object.values(checks).some((check) => check.required)) {
872
- throw new RangeError("SpotPatch AI auto mode requires a required check.");
866
+ if (applyMode !== "review" && !Object.values(checks).some((check) => check.required)) {
867
+ throw new RangeError(`SpotPatch AI ${applyMode} mode requires a required check.`);
873
868
  }
874
869
  const providers = resolveProviders(validated.providers);
875
870
  if (!(validated.defaultProvider in providers)) {
@@ -1483,6 +1478,7 @@ async function authorizeAgentJobRequest(input) {
1483
1478
  providerProfileId: input.request.providerProfileId,
1484
1479
  modelProfileId: input.request.modelProfileId,
1485
1480
  providerDataConsent: true,
1481
+ ...input.request.trustedFastModeConsent === true ? { trustedFastModeConsent: true } : {},
1486
1482
  workingTreeMode: input.request.workingTreeMode
1487
1483
  });
1488
1484
  }