@cjhyy/code-shell-core 0.8.9 → 0.8.11

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.
Files changed (76) hide show
  1. package/dist/automation/scheduler.js +49 -0
  2. package/dist/automation/store.d.ts +1 -1
  3. package/dist/automation/store.js +184 -10
  4. package/dist/cli/agent-server-stdio.js +7 -0
  5. package/dist/credentials/store.d.ts +14 -0
  6. package/dist/credentials/store.js +245 -42
  7. package/dist/engine/engine.js +45 -6
  8. package/dist/engine/file-history-hook.js +24 -5
  9. package/dist/engine/run-types.d.ts +9 -0
  10. package/dist/engine/turn-loop.js +9 -8
  11. package/dist/goal/lifecycle.d.ts +2 -0
  12. package/dist/goal/lifecycle.js +56 -33
  13. package/dist/index.d.ts +2 -3
  14. package/dist/index.internal.d.ts +1 -0
  15. package/dist/index.internal.js +1 -0
  16. package/dist/index.js +2 -2
  17. package/dist/links/cli.d.ts +2 -0
  18. package/dist/links/cli.js +11 -4
  19. package/dist/model-catalog/index.js +19 -4
  20. package/dist/model-catalog/save-entry.js +122 -61
  21. package/dist/model-catalog/types.js +27 -23
  22. package/dist/panel-apps/installer.js +27 -14
  23. package/dist/panel-apps/registry.js +60 -12
  24. package/dist/plugins/installedPlugins.d.ts +4 -0
  25. package/dist/plugins/installedPlugins.js +70 -30
  26. package/dist/plugins/installer/types.d.ts +12 -12
  27. package/dist/plugins/installer/update.js +37 -38
  28. package/dist/plugins/knownMarketplaces.d.ts +7 -3
  29. package/dist/plugins/knownMarketplaces.js +127 -23
  30. package/dist/plugins/pluginCatalog.js +18 -4
  31. package/dist/plugins/pluginHookApproval.js +56 -60
  32. package/dist/plugins/pluginMcpApproval.js +50 -52
  33. package/dist/profile/catalog-store.js +39 -4
  34. package/dist/profile/catalog.js +55 -15
  35. package/dist/profile/store.js +51 -21
  36. package/dist/protocol/chat-session-manager.d.ts +9 -0
  37. package/dist/protocol/chat-session-manager.js +13 -0
  38. package/dist/protocol/chat-session.d.ts +5 -0
  39. package/dist/protocol/chat-session.js +1 -0
  40. package/dist/protocol/server.d.ts +2 -0
  41. package/dist/protocol/server.js +75 -29
  42. package/dist/protocol/types.d.ts +8 -0
  43. package/dist/run/FileRunStore.d.ts +2 -0
  44. package/dist/run/FileRunStore.js +153 -18
  45. package/dist/run/Heartbeat.js +63 -4
  46. package/dist/services/auto-dream.js +39 -17
  47. package/dist/services/session-memory.js +107 -8
  48. package/dist/session/file-history.d.ts +63 -2
  49. package/dist/session/file-history.js +593 -86
  50. package/dist/session/session-manager.d.ts +1 -0
  51. package/dist/session/session-manager.js +52 -21
  52. package/dist/session/transcript.js +33 -3
  53. package/dist/session/undo-target.d.ts +15 -6
  54. package/dist/session/undo-target.js +26 -9
  55. package/dist/settings/manager.d.ts +22 -3
  56. package/dist/settings/manager.js +185 -50
  57. package/dist/settings/schema.d.ts +3 -3
  58. package/dist/sources/adapters/local-files.js +49 -4
  59. package/dist/sources/catalog.js +64 -18
  60. package/dist/sources/types.d.ts +3 -3
  61. package/dist/sources/types.js +7 -4
  62. package/dist/themes/installer.js +192 -28
  63. package/dist/tool-system/builtin/add-marketplace.js +21 -1
  64. package/dist/tool-system/builtin/cron.d.ts +2 -1
  65. package/dist/tool-system/builtin/cron.js +20 -6
  66. package/dist/tool-system/builtin/index.js +44 -0
  67. package/dist/tool-system/builtin/install-capability.d.ts +52 -0
  68. package/dist/tool-system/builtin/install-capability.js +1057 -0
  69. package/dist/tool-system/builtin/skill.js +3 -1
  70. package/dist/tool-system/executor.js +1 -0
  71. package/dist/tool-system/registry.js +5 -0
  72. package/dist/tool-system/sandbox/index.d.ts +1 -0
  73. package/dist/tool-system/sandbox/index.js +4 -1
  74. package/dist/utils/file-mutex.d.ts +2 -0
  75. package/dist/utils/file-mutex.js +29 -4
  76. package/package.json +2 -1
@@ -10,6 +10,10 @@ export interface FileSnapshot {
10
10
  backupPath: string;
11
11
  hash: string;
12
12
  size: number;
13
+ /** Original POSIX permission bits, restored independently of backup privacy. */
14
+ mode?: number;
15
+ /** Canonical location at capture time, used to detect parent symlink swaps. */
16
+ realPath?: string;
13
17
  /**
14
18
  * The conversation turn (one user message = one turn) this snapshot was taken
15
19
  * in. Powers turn-level undo (`latestTurnUndoTargets`). Optional so snapshots
@@ -37,6 +41,12 @@ export interface RedoRecord {
37
41
  turnSeq: number;
38
42
  /** Backup of the post-turn content to re-apply on redo. */
39
43
  backupPath: string;
44
+ /** False when the turn's result was file absence (for example a delete). */
45
+ existedAfter?: boolean;
46
+ /** Post-turn POSIX permission bits to restore on redo. */
47
+ mode?: number;
48
+ /** Canonical location of the target at capture time. */
49
+ realPath?: string;
40
50
  /**
41
51
  * Whether the file EXISTED before this turn (had a pre-turn snapshot). False
42
52
  * means the turn CREATED it — undo deleted it, so redo must recreate it (and
@@ -55,10 +65,20 @@ export interface RedoRecord {
55
65
  export interface CreatedMarker {
56
66
  filePath: string;
57
67
  turnSeq: number;
68
+ /** Canonical destination planned before the creating tool ran. */
69
+ realPath?: string;
58
70
  undone?: boolean;
59
71
  }
72
+ export interface TurnUndoPlan {
73
+ /** Undefined denotes a legacy, pre-turnSeq history bucket. */
74
+ turnSeq?: number;
75
+ snapshots: FileSnapshot[];
76
+ createdPaths: string[];
77
+ filePaths: string[];
78
+ }
60
79
  export declare class FileHistory {
61
80
  private readonly historyDir;
81
+ private lockDepth;
62
82
  private snapshots;
63
83
  /**
64
84
  * Redo material for undone turns, kept SEPARATE from `snapshots` so it never
@@ -77,6 +97,7 @@ export declare class FileHistory {
77
97
  * latestTurnUndoTargets). Omit it for callers without turn context.
78
98
  */
79
99
  saveSnapshot(filePath: string, turnSeq?: number): FileSnapshot | null;
100
+ private saveSnapshotUnlocked;
80
101
  /**
81
102
  * Record that `filePath` was CREATED in `turnSeq` — called by the engine hook
82
103
  * when the pre-edit saveSnapshot returns null (file did not exist yet). Idempotent
@@ -86,8 +107,27 @@ export declare class FileHistory {
86
107
  * re-armed) — only fresh turns create new markers.
87
108
  */
88
109
  recordCreated(filePath: string, turnSeq: number): void;
110
+ private recordCreatedUnlocked;
111
+ /**
112
+ * Capture a create marker before the tool runs, but do not persist it yet.
113
+ * `lstat` (rather than `existsSync`) deliberately treats dangling symlinks as
114
+ * existing: a failed/no-follow Write must never turn such a path into a
115
+ * create marker that a later undo would remove.
116
+ */
117
+ prepareCreated(filePath: string, turnSeq: number): CreatedMarker | null;
118
+ /** Persist a marker previously returned by prepareCreated after tool success. */
119
+ commitCreated(marker: CreatedMarker): void;
120
+ private commitCreatedUnlocked;
89
121
  /** Redo material captured by past undos (see RedoRecord). Returns a copy. */
90
122
  getRedoRecords(): RedoRecord[];
123
+ /** Latest redo records after accounting for create-only live turns. */
124
+ getLatestRedoRecords(): RedoRecord[];
125
+ /**
126
+ * Authoritative latest-turn plan, including turns that only created files.
127
+ * Keeping this decision in FileHistory prevents UI callers from accidentally
128
+ * selecting an older snapshot-only turn.
129
+ */
130
+ getLatestTurnUndoPlan(): TurnUndoPlan | null;
91
131
  /**
92
132
  * Get all snapshots for a specific file.
93
133
  */
@@ -138,8 +178,7 @@ export declare class FileHistory {
138
178
  filePath: string;
139
179
  ok: boolean;
140
180
  }>;
141
- /** Greatest turnSeq among not-yet-undone created markers, or undefined. */
142
- private latestLiveCreatedTurn;
181
+ private undoLatestTurnUnlocked;
143
182
  /**
144
183
  * Turn-level redo: re-apply a previously undone turn. For each redo target,
145
184
  * write the stashed post-turn content back to disk (existedBefore:false
@@ -153,6 +192,7 @@ export declare class FileHistory {
153
192
  filePath: string;
154
193
  ok: boolean;
155
194
  }>;
195
+ private redoLatestTurnUnlocked;
156
196
  /**
157
197
  * All snapshots in record (chronological) order. Used by undo to pick the
158
198
  * single most-recent modification across every file (see latestUndoTarget).
@@ -161,4 +201,25 @@ export declare class FileHistory {
161
201
  getAllSnapshots(): FileSnapshot[];
162
202
  private saveIndex;
163
203
  static loadFromDir(sessionDir: string): FileHistory;
204
+ /** Serialize every read-modify-write and refresh after taking the lock. */
205
+ private withCurrentIndex;
206
+ private reloadIndex;
207
+ private isSafeBackup;
208
+ private isContainedBackupPath;
209
+ /** Never follow a destination symlink while restoring an old file version. */
210
+ private isSafeDestination;
211
+ private canonicalizeNewPath;
212
+ private matchesRecordedLocation;
213
+ private restoreSnapshot;
214
+ private readMode;
215
+ private restoreMode;
216
+ private discardRedoTurn;
217
+ private turnKey;
218
+ private latestTurnUndoPlanInternal;
219
+ private isExactSnapshotSet;
220
+ private sameSnapshot;
221
+ private findSnapshot;
222
+ private findRedoRecord;
223
+ private isSnapshot;
224
+ private isRedoRecord;
164
225
  }