@spotpatch/runtime 1.2.0 → 1.3.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
@@ -104,7 +104,6 @@ var CAPABILITY_STATE_VALUES = new Set(import_shared2.AGENT_CAPABILITY_STATES);
104
104
  var CHECK_STATUS_VALUES = new Set(import_shared2.AGENT_CHECK_STATUSES);
105
105
  var FILE_CHANGE_KIND_VALUES = new Set(import_shared2.AGENT_FILE_CHANGE_KINDS);
106
106
  var JOB_STATUS_VALUES = new Set(import_shared2.AGENT_JOB_STATUSES);
107
- var WORKSPACE_STATE_VALUES = new Set(import_shared2.AGENT_WORKSPACE_STATES);
108
107
  var PROFILE_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
109
108
  var JOB_ID_PATTERN = /^[A-Za-z0-9_-]+$/;
110
109
  var ISO_TIMESTAMP_PATTERN = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?Z$/;
@@ -165,7 +164,7 @@ function isAgentWorkspaceHealthSnapshot(value) {
165
164
  "changes",
166
165
  "canIncludeLocalChanges",
167
166
  "errorCode"
168
- ]) || typeof value.state !== "string" || !WORKSPACE_STATE_VALUES.has(value.state) || !isIsoTimestamp(value.checkedAt) || typeof value.canIncludeLocalChanges !== "boolean" || value.errorCode !== void 0 && !isAgentErrorCode(value.errorCode) || !isRecord(value.changes) || !hasOnlyKeys(value.changes, [
167
+ ]) || value.state !== "ready" && value.state !== "consent-required" && value.state !== "blocked" || !isIsoTimestamp(value.checkedAt) || typeof value.canIncludeLocalChanges !== "boolean" || value.errorCode !== void 0 && !isAgentErrorCode(value.errorCode) || !isRecord(value.changes) || !hasOnlyKeys(value.changes, [
169
168
  "staged",
170
169
  "unstaged",
171
170
  "untracked",
@@ -228,7 +227,7 @@ function isAgentEventBase(value) {
228
227
  "timestamp",
229
228
  "type",
230
229
  "data"
231
- ]) && value.schemaVersion === 1 && isPositiveInteger(value.sequence) && isJobId(value.jobId) && typeof value.status === "string" && JOB_STATUS_VALUES.has(value.status) && isIsoTimestamp(value.timestamp) && typeof value.type === "string" && isRecord(value.data);
230
+ ]) && value.schemaVersion === 2 && isPositiveInteger(value.sequence) && isJobId(value.jobId) && typeof value.status === "string" && JOB_STATUS_VALUES.has(value.status) && isIsoTimestamp(value.timestamp) && typeof value.type === "string" && isRecord(value.data);
232
231
  }
233
232
  function isAgentJobEvent(value) {
234
233
  if (!isAgentEventBase(value)) {
@@ -242,12 +241,13 @@ function isAgentJobEvent(value) {
242
241
  return hasOnlyKeys(data, ["message"]) && isBoundedString(data.message, 1024);
243
242
  case "tool":
244
243
  return hasOnlyKeys(data, [
244
+ "turn",
245
245
  "toolCallId",
246
246
  "toolName",
247
247
  "state",
248
248
  "relativePath",
249
249
  "checkLabel"
250
- ]) && isBoundedString(data.toolCallId, 256) && isBoundedString(data.toolName, 100) && (data.state === "started" || data.state === "succeeded" || data.state === "failed") && isOptionalBoundedString(data.relativePath, 1024) && isOptionalBoundedString(data.checkLabel, 100);
250
+ ]) && isPositiveInteger(data.turn) && isBoundedString(data.toolCallId, 256) && isBoundedString(data.toolName, 100) && (data.state === "started" || data.state === "succeeded" || data.state === "failed") && isOptionalBoundedString(data.relativePath, 1024) && isOptionalBoundedString(data.checkLabel, 100);
251
251
  case "check":
252
252
  return hasOnlyKeys(data, ["result"]) && isAgentCheckResult(data.result);
253
253
  case "result-ready":
@@ -1617,7 +1617,7 @@ var AGENT_PANEL_STYLES = `
1617
1617
  font-weight: 560;
1618
1618
  line-height: 1.35;
1619
1619
  outline: none;
1620
- transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
1620
+ transition: 160ms ease;
1621
1621
  }
1622
1622
  .spotpatch-agent select:hover { border-color: rgb(148 163 184 / 38%); background-color: rgb(255 255 255 / 5%); }
1623
1623
  .spotpatch-agent select:focus-visible { border-color: rgb(139 124 247 / 76%); box-shadow: 0 0 0 3px rgb(109 93 246 / 18%); }
@@ -1628,7 +1628,7 @@ var AGENT_PANEL_STYLES = `
1628
1628
  .spotpatch-agent select { padding: 10px 13px; }
1629
1629
  .spotpatch-agent select::picker-icon {
1630
1630
  color: #9da6b5;
1631
- transition: rotate 180ms cubic-bezier(.2, .8, .2, 1), color 160ms ease;
1631
+ transition: rotate 180ms cubic-bezier(.2, .8, .2, 1);
1632
1632
  }
1633
1633
  .spotpatch-agent select:open::picker-icon { rotate: 180deg; color: #c4b5fd; }
1634
1634
  .spotpatch-agent select::picker(select) {
@@ -1641,12 +1641,10 @@ var AGENT_PANEL_STYLES = `
1641
1641
  border: 1px solid rgb(139 124 247 / 28%);
1642
1642
  border-radius: 12px;
1643
1643
  padding: 6px;
1644
- color: #e8ebf2;
1645
1644
  background: #10151e;
1646
- box-shadow: 0 18px 50px rgb(0 0 0 / 38%), 0 0 0 1px rgb(255 255 255 / 3%);
1645
+ box-shadow: 0 18px 50px rgb(0 0 0 / 38%);
1647
1646
  opacity: 0;
1648
1647
  transform: translateY(-5px) scale(.985);
1649
- transform-origin: top center;
1650
1648
  transition: opacity 150ms ease, transform 180ms cubic-bezier(.2, .8, .2, 1), overlay 180ms allow-discrete, display 180ms allow-discrete;
1651
1649
  }
1652
1650
  ::picker(select):popover-open { opacity: 1; transform: translateY(0) scale(1); }
@@ -1660,7 +1658,6 @@ var AGENT_PANEL_STYLES = `
1660
1658
  color: #dfe4ee;
1661
1659
  background: transparent;
1662
1660
  cursor: pointer;
1663
- transition: color 120ms ease, background-color 120ms ease;
1664
1661
  }
1665
1662
  .spotpatch-agent select option:hover,
1666
1663
  .spotpatch-agent select option:focus { color: #fff; background: rgb(109 93 246 / 16%); }
@@ -2344,20 +2341,22 @@ var ERROR_MESSAGES_EN = Object.freeze({
2344
2341
  [import_shared6.ERROR_CODES.AGENT_BUSY]: "Another write Agent job is still active.",
2345
2342
  [import_shared6.ERROR_CODES.AGENT_LIMIT_EXCEEDED]: "The Agent stopped at a configured time, turn, output, or size limit.",
2346
2343
  [import_shared6.ERROR_CODES.AGENT_CANCELLED]: "The Agent job was cancelled.",
2347
- [import_shared6.ERROR_CODES.WORKTREE_DIRTY]: "Local changes require explicit inclusion consent before running AI.",
2348
- [import_shared6.ERROR_CODES.WORKTREE_NOT_REPOSITORY]: "The Vite root is not the top level of an initialized Git repository.",
2349
- [import_shared6.ERROR_CODES.WORKTREE_OPERATION_IN_PROGRESS]: "Finish the active merge, rebase, cherry-pick, or revert before running AI.",
2350
- [import_shared6.ERROR_CODES.WORKTREE_CONFLICTED]: "Resolve all merge conflicts before running AI; SpotPatch will not guess a resolution.",
2351
- [import_shared6.ERROR_CODES.WORKTREE_LOCAL_CHANGES_TOO_LARGE]: "Local untracked files exceed the safe isolation limit. Reduce their count or total size.",
2352
- [import_shared6.ERROR_CODES.WORKTREE_UNTRACKED_UNSUPPORTED]: "An untracked item is missing, linked, or not a regular file and cannot be isolated safely.",
2353
- [import_shared6.ERROR_CODES.WORKTREE_LOCAL_CHANGES_UNSUPPORTED]: "Local changes include conflicts, unsupported files, or exceed the safe baseline limit.",
2354
- [import_shared6.ERROR_CODES.TOOL_DENIED]: "A model tool request violated the local safety policy.",
2355
- [import_shared6.ERROR_CODES.TOOL_INPUT_INVALID]: "The model sent invalid tool arguments or reused a tool call ID inconsistently.",
2356
- [import_shared6.ERROR_CODES.TOOL_PATH_DENIED]: "The model tried to access a protected, non-text, linked, or out-of-project path.",
2357
- [import_shared6.ERROR_CODES.PATCH_REJECTED]: "The proposed patch did not pass local policy.",
2358
- [import_shared6.ERROR_CODES.VALIDATION_FAILED]: "Required project checks failed. The change cannot be applied.",
2359
- [import_shared6.ERROR_CODES.APPLY_CONFLICT]: "Project files changed after the Agent baseline; no overwrite was performed.",
2360
- [import_shared6.ERROR_CODES.INTERNAL_ERROR]: "The Agent job failed without exposing private details."
2344
+ [import_shared6.ERROR_CODES.WORKTREE_DIRTY]: "Confirm inclusion of local changes before running AI.",
2345
+ [import_shared6.ERROR_CODES.WORKTREE_NOT_REPOSITORY]: "Vite root must be an initialized Git repository root.",
2346
+ [import_shared6.ERROR_CODES.WORKTREE_OPERATION_IN_PROGRESS]: "Finish the active merge, rebase, cherry-pick, or revert.",
2347
+ [import_shared6.ERROR_CODES.WORKTREE_CONFLICTED]: "Resolve all Git conflicts before running AI.",
2348
+ [import_shared6.ERROR_CODES.WORKTREE_LOCAL_CHANGES_TOO_LARGE]: "Reduce untracked files below the safe count and size limits.",
2349
+ [import_shared6.ERROR_CODES.WORKTREE_UNTRACKED_UNSUPPORTED]: "An untracked path is missing, linked, or not a regular file.",
2350
+ [import_shared6.ERROR_CODES.WORKTREE_LOCAL_CHANGES_UNSUPPORTED]: "Local changes cannot be isolated safely.",
2351
+ [import_shared6.ERROR_CODES.TOOL_DENIED]: "A tool request violated local safety policy.",
2352
+ [import_shared6.ERROR_CODES.TOOL_INPUT_INVALID]: "Invalid tool request.",
2353
+ [import_shared6.ERROR_CODES.TOOL_ARGUMENTS_INVALID]: "Tool arguments are invalid.",
2354
+ [import_shared6.ERROR_CODES.TOOL_CALL_ID_CONFLICT]: "Tool ID conflicts in this turn.",
2355
+ [import_shared6.ERROR_CODES.TOOL_PATH_DENIED]: "The model requested a protected or external path.",
2356
+ [import_shared6.ERROR_CODES.PATCH_REJECTED]: "The patch violated local policy.",
2357
+ [import_shared6.ERROR_CODES.VALIDATION_FAILED]: "Required checks failed; changes cannot be applied.",
2358
+ [import_shared6.ERROR_CODES.APPLY_CONFLICT]: "Agent-touched files changed; nothing was overwritten.",
2359
+ [import_shared6.ERROR_CODES.INTERNAL_ERROR]: "The Agent failed without exposing private details."
2361
2360
  });
2362
2361
  var ERROR_MESSAGES_ZH = Object.freeze({
2363
2362
  [import_shared6.ERROR_CODES.INVALID_REQUEST]: "Agent \u8BF7\u6C42\u65E0\u6548\uFF0C\u5DF2\u88AB\u62D2\u7EDD\u3002",
@@ -2380,17 +2379,19 @@ var ERROR_MESSAGES_ZH = Object.freeze({
2380
2379
  [import_shared6.ERROR_CODES.WORKTREE_DIRTY]: "\u8FD0\u884C AI \u524D\uFF0C\u8BF7\u660E\u786E\u540C\u610F\u5C06\u5F53\u524D\u672C\u5730\u4FEE\u6539\u7EB3\u5165\u9694\u79BB\u57FA\u7EBF\u3002",
2381
2380
  [import_shared6.ERROR_CODES.WORKTREE_NOT_REPOSITORY]: "Vite \u6839\u76EE\u5F55\u4E0D\u662F\u5DF2\u521D\u59CB\u5316 Git \u4ED3\u5E93\u7684\u9876\u5C42\u76EE\u5F55\u3002",
2382
2381
  [import_shared6.ERROR_CODES.WORKTREE_OPERATION_IN_PROGRESS]: "\u8BF7\u5148\u5B8C\u6210\u5F53\u524D merge\u3001rebase\u3001cherry-pick \u6216 revert\uFF0C\u518D\u8FD0\u884C AI\u3002",
2383
- [import_shared6.ERROR_CODES.WORKTREE_CONFLICTED]: "\u8BF7\u5148\u89E3\u51B3\u5168\u90E8\u5408\u5E76\u51B2\u7A81\uFF1BSpotPatch \u4E0D\u4F1A\u731C\u6D4B\u51B2\u7A81\u89E3\u51B3\u65B9\u5F0F\u3002",
2384
- [import_shared6.ERROR_CODES.WORKTREE_LOCAL_CHANGES_TOO_LARGE]: "\u672C\u5730\u672A\u8DDF\u8E2A\u6587\u4EF6\u8D85\u8FC7\u5B89\u5168\u9694\u79BB\u4E0A\u9650\uFF0C\u8BF7\u51CF\u5C11\u6587\u4EF6\u6570\u91CF\u6216\u603B\u4F53\u79EF\u3002",
2385
- [import_shared6.ERROR_CODES.WORKTREE_UNTRACKED_UNSUPPORTED]: "\u67D0\u4E2A\u672A\u8DDF\u8E2A\u9879\u5DF2\u4E22\u5931\u3001\u662F\u7B26\u53F7\u94FE\u63A5\u6216\u4E0D\u662F\u666E\u901A\u6587\u4EF6\uFF0C\u65E0\u6CD5\u5B89\u5168\u9694\u79BB\u3002",
2386
- [import_shared6.ERROR_CODES.WORKTREE_LOCAL_CHANGES_UNSUPPORTED]: "\u672C\u5730\u4FEE\u6539\u5B58\u5728\u51B2\u7A81\u3001\u4E0D\u652F\u6301\u7684\u6587\u4EF6\uFF0C\u6216\u8D85\u8FC7\u5B89\u5168\u57FA\u7EBF\u9650\u5236\u3002",
2387
- [import_shared6.ERROR_CODES.TOOL_DENIED]: "\u6A21\u578B\u5DE5\u5177\u8BF7\u6C42\u8FDD\u53CD\u672C\u5730\u5B89\u5168\u7B56\u7565\u3002",
2388
- [import_shared6.ERROR_CODES.TOOL_INPUT_INVALID]: "\u6A21\u578B\u53D1\u9001\u4E86\u65E0\u6548\u5DE5\u5177\u53C2\u6570\uFF0C\u6216\u4E0D\u4E00\u81F4\u5730\u590D\u7528\u4E86\u5DE5\u5177\u8C03\u7528 ID\u3002",
2389
- [import_shared6.ERROR_CODES.TOOL_PATH_DENIED]: "\u6A21\u578B\u5C1D\u8BD5\u8BBF\u95EE\u53D7\u4FDD\u62A4\u3001\u975E\u6587\u672C\u3001\u7B26\u53F7\u94FE\u63A5\u6216\u9879\u76EE\u5916\u8DEF\u5F84\u3002",
2390
- [import_shared6.ERROR_CODES.PATCH_REJECTED]: "\u5EFA\u8BAE\u8865\u4E01\u672A\u901A\u8FC7\u672C\u5730\u7B56\u7565\u68C0\u67E5\u3002",
2391
- [import_shared6.ERROR_CODES.VALIDATION_FAILED]: "\u9879\u76EE\u5FC5\u9700\u68C0\u67E5\u5931\u8D25\uFF0C\u4E0D\u80FD\u5E94\u7528\u672C\u6B21\u53D8\u66F4\u3002",
2392
- [import_shared6.ERROR_CODES.APPLY_CONFLICT]: "Agent \u5EFA\u7ACB\u57FA\u7EBF\u540E\u9879\u76EE\u6587\u4EF6\u5DF2\u53D8\u5316\uFF0C\u672A\u6267\u884C\u8986\u76D6\u3002",
2393
- [import_shared6.ERROR_CODES.INTERNAL_ERROR]: "Agent \u4EFB\u52A1\u5931\u8D25\uFF0C\u79C1\u6709\u7EC6\u8282\u672A\u66B4\u9732\u5230\u6D4F\u89C8\u5668\u3002"
2382
+ [import_shared6.ERROR_CODES.WORKTREE_CONFLICTED]: "\u8BF7\u5148\u89E3\u51B3\u5168\u90E8 Git \u51B2\u7A81\uFF0C\u518D\u8FD0\u884C AI\u3002",
2383
+ [import_shared6.ERROR_CODES.WORKTREE_LOCAL_CHANGES_TOO_LARGE]: "\u672A\u8DDF\u8E2A\u6587\u4EF6\u8D85\u8FC7\u5B89\u5168\u6570\u91CF\u6216\u4F53\u79EF\u4E0A\u9650\uFF0C\u8BF7\u5148\u7CBE\u7B80\u3002",
2384
+ [import_shared6.ERROR_CODES.WORKTREE_UNTRACKED_UNSUPPORTED]: "\u672A\u8DDF\u8E2A\u9879\u5DF2\u4E22\u5931\u3001\u662F\u7B26\u53F7\u94FE\u63A5\u6216\u4E0D\u662F\u666E\u901A\u6587\u4EF6\u3002",
2385
+ [import_shared6.ERROR_CODES.WORKTREE_LOCAL_CHANGES_UNSUPPORTED]: "\u5F53\u524D\u672C\u5730\u4FEE\u6539\u65E0\u6CD5\u5B89\u5168\u9694\u79BB\u3002",
2386
+ [import_shared6.ERROR_CODES.TOOL_DENIED]: "\u5DE5\u5177\u8BF7\u6C42\u8FDD\u53CD\u672C\u5730\u5B89\u5168\u7B56\u7565\u3002",
2387
+ [import_shared6.ERROR_CODES.TOOL_INPUT_INVALID]: "\u5DE5\u5177\u8BF7\u6C42\u65E0\u6548\u3002",
2388
+ [import_shared6.ERROR_CODES.TOOL_ARGUMENTS_INVALID]: "\u5DE5\u5177\u53C2\u6570\u65E0\u6548\u3002",
2389
+ [import_shared6.ERROR_CODES.TOOL_CALL_ID_CONFLICT]: "\u672C\u8F6E\u5DE5\u5177 ID \u51B2\u7A81\u3002",
2390
+ [import_shared6.ERROR_CODES.TOOL_PATH_DENIED]: "\u6A21\u578B\u8BF7\u6C42\u4E86\u53D7\u4FDD\u62A4\u6216\u9879\u76EE\u5916\u8DEF\u5F84\u3002",
2391
+ [import_shared6.ERROR_CODES.PATCH_REJECTED]: "\u8865\u4E01\u8FDD\u53CD\u672C\u5730\u7B56\u7565\u3002",
2392
+ [import_shared6.ERROR_CODES.VALIDATION_FAILED]: "\u5FC5\u9700\u68C0\u67E5\u5931\u8D25\uFF0C\u65E0\u6CD5\u5E94\u7528\u53D8\u66F4\u3002",
2393
+ [import_shared6.ERROR_CODES.APPLY_CONFLICT]: "Agent \u89E6\u53CA\u6587\u4EF6\u5DF2\u53D8\u5316\uFF0C\u672A\u8986\u76D6\u3002",
2394
+ [import_shared6.ERROR_CODES.INTERNAL_ERROR]: "Agent \u5931\u8D25\uFF0C\u672A\u66B4\u9732\u79C1\u6709\u7EC6\u8282\u3002"
2394
2395
  });
2395
2396
  var SUMMARY_MESSAGES_EN = Object.freeze({
2396
2397
  adapter: "React adapter",
@@ -4164,7 +4165,7 @@ function capabilityKey(providerProfileId, modelProfileId) {
4164
4165
  function activityFromEvent(event) {
4165
4166
  if (event.type === "tool") {
4166
4167
  return Object.freeze({
4167
- key: `tool:${event.data.toolCallId}`,
4168
+ key: `tool:${String(event.data.turn)}:${event.data.toolCallId}`,
4168
4169
  label: `${event.data.toolName} \xB7 ${event.data.state}`,
4169
4170
  state: event.data.state === "started" ? "active" : event.data.state === "succeeded" ? "success" : "failure"
4170
4171
  });