@superblocksteam/vite-plugin-file-sync 2.0.175-next.0 → 2.0.176
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/ai-service/agent/prompts/build-base-system-prompt.d.ts.map +1 -1
- package/dist/ai-service/agent/prompts/build-base-system-prompt.js +1 -11
- package/dist/ai-service/agent/prompts/build-base-system-prompt.js.map +1 -1
- package/dist/ai-service/agent/tools/apis/get-api-docs.d.ts +3 -3
- package/dist/ai-service/agent/tools/apis/test-api.d.ts +13 -78
- package/dist/ai-service/agent/tools/apis/test-api.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/apis/test-api.js +50 -52
- package/dist/ai-service/agent/tools/apis/test-api.js.map +1 -1
- package/dist/ai-service/agent/tools/build-capture-screenshot.d.ts +3 -11
- package/dist/ai-service/agent/tools/build-capture-screenshot.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-capture-screenshot.js +8 -13
- package/dist/ai-service/agent/tools/build-capture-screenshot.js.map +1 -1
- package/dist/ai-service/agent/tools/build-navigate-preview.d.ts +0 -6
- package/dist/ai-service/agent/tools/build-navigate-preview.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-navigate-preview.js +4 -5
- package/dist/ai-service/agent/tools/build-navigate-preview.js.map +1 -1
- package/dist/ai-service/agent/tools/databases/destructive-migration-prompt.d.ts +1 -4
- package/dist/ai-service/agent/tools/databases/destructive-migration-prompt.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/databases/destructive-migration-prompt.js +3 -6
- package/dist/ai-service/agent/tools/databases/destructive-migration-prompt.js.map +1 -1
- package/dist/ai-service/agent/tools/databases/dev-database-tasks.d.ts +4 -11
- package/dist/ai-service/agent/tools/databases/dev-database-tasks.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/databases/dev-database-tasks.js +3 -21
- package/dist/ai-service/agent/tools/databases/dev-database-tasks.js.map +1 -1
- package/dist/ai-service/agent/tools/databases/dev-database-tools.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/databases/dev-database-tools.js +5 -32
- package/dist/ai-service/agent/tools/databases/dev-database-tools.js.map +1 -1
- package/dist/ai-service/agent/tools/get-logs.d.ts +2 -5
- package/dist/ai-service/agent/tools/get-logs.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/get-logs.js +3 -6
- package/dist/ai-service/agent/tools/get-logs.js.map +1 -1
- package/dist/ai-service/agent/tools/get-runtime-errors.d.ts +0 -2
- package/dist/ai-service/agent/tools/get-runtime-errors.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/get-runtime-errors.js +2 -3
- package/dist/ai-service/agent/tools/get-runtime-errors.js.map +1 -1
- package/dist/ai-service/agent/tools/get-security-findings.js +1 -1
- package/dist/ai-service/agent/tools/integrations/execute-request.d.ts +5 -5
- package/dist/ai-service/agent/tools/integrations/metadata.d.ts +1 -1
- package/dist/ai-service/agent/tools/integrations/metadata.js.map +1 -1
- package/dist/ai-service/agent/tools/report-security-findings.d.ts +3 -3
- package/dist/ai-service/agent/tools.d.ts +5 -1
- package/dist/ai-service/agent/tools.d.ts.map +1 -1
- package/dist/ai-service/agent/tools.js +42 -7
- package/dist/ai-service/agent/tools.js.map +1 -1
- package/dist/ai-service/agent/tools2/tools/grep-metadata.d.ts +3 -4
- package/dist/ai-service/agent/tools2/tools/grep-metadata.d.ts.map +1 -1
- package/dist/ai-service/agent/tools2/tools/grep-metadata.js +2 -4
- package/dist/ai-service/agent/tools2/tools/grep-metadata.js.map +1 -1
- package/dist/ai-service/agent/tools2/tools/grep.d.ts.map +1 -1
- package/dist/ai-service/agent/tools2/tools/grep.js +5 -27
- package/dist/ai-service/agent/tools2/tools/grep.js.map +1 -1
- package/dist/ai-service/app-interface/file-system-interface.d.ts +1 -1
- package/dist/ai-service/app-interface/filesystem/handlers/skill-handler.d.ts +1 -2
- package/dist/ai-service/app-interface/filesystem/handlers/skill-handler.d.ts.map +1 -1
- package/dist/ai-service/app-interface/filesystem/handlers/skill-handler.js +2 -9
- package/dist/ai-service/app-interface/filesystem/handlers/skill-handler.js.map +1 -1
- package/dist/ai-service/app-interface/filesystem/virtual-file-system.d.ts +0 -1
- package/dist/ai-service/app-interface/filesystem/virtual-file-system.d.ts.map +1 -1
- package/dist/ai-service/app-interface/filesystem/virtual-file-system.js +1 -1
- package/dist/ai-service/app-interface/filesystem/virtual-file-system.js.map +1 -1
- package/dist/ai-service/app-interface/npm-registry.d.ts +0 -1
- package/dist/ai-service/app-interface/npm-registry.d.ts.map +1 -1
- package/dist/ai-service/app-interface/npm-registry.js +6 -45
- package/dist/ai-service/app-interface/npm-registry.js.map +1 -1
- package/dist/ai-service/app-interface/shell.d.ts +1 -4
- package/dist/ai-service/app-interface/shell.d.ts.map +1 -1
- package/dist/ai-service/app-interface/shell.js +8 -26
- package/dist/ai-service/app-interface/shell.js.map +1 -1
- package/dist/ai-service/chat/chat-session-store.d.ts +1 -10
- package/dist/ai-service/chat/chat-session-store.d.ts.map +1 -1
- package/dist/ai-service/chat/chat-session-store.js +1 -30
- package/dist/ai-service/chat/chat-session-store.js.map +1 -1
- package/dist/ai-service/dev-database-client.d.ts +0 -1
- package/dist/ai-service/dev-database-client.d.ts.map +1 -1
- package/dist/ai-service/dev-database-client.js +0 -1
- package/dist/ai-service/dev-database-client.js.map +1 -1
- package/dist/ai-service/dev-database-file-sync.d.ts +1 -3
- package/dist/ai-service/dev-database-file-sync.d.ts.map +1 -1
- package/dist/ai-service/dev-database-file-sync.js.map +1 -1
- package/dist/ai-service/features.d.ts +8 -15
- package/dist/ai-service/features.d.ts.map +1 -1
- package/dist/ai-service/features.js +8 -15
- package/dist/ai-service/features.js.map +1 -1
- package/dist/ai-service/index.d.ts +19 -34
- package/dist/ai-service/index.d.ts.map +1 -1
- package/dist/ai-service/index.js +738 -474
- package/dist/ai-service/index.js.map +1 -1
- package/dist/ai-service/llm/context-v2/context-metrics.js +2 -2
- package/dist/ai-service/llm/context-v2/manager.d.ts +1 -3
- package/dist/ai-service/llm/context-v2/manager.d.ts.map +1 -1
- package/dist/ai-service/llm/context-v2/manager.js +0 -5
- package/dist/ai-service/llm/context-v2/manager.js.map +1 -1
- package/dist/ai-service/llm/context-v2/types.d.ts +1 -1
- package/dist/ai-service/llm/context-v2/types.d.ts.map +1 -1
- package/dist/ai-service/llm/context-v2/types.js.map +1 -1
- package/dist/ai-service/llm/stream/config.d.ts +1 -1
- package/dist/ai-service/llm/stream/config.d.ts.map +1 -1
- package/dist/ai-service/llm/stream/config.js.map +1 -1
- package/dist/ai-service/llm/stream/errors.d.ts +1 -4
- package/dist/ai-service/llm/stream/errors.d.ts.map +1 -1
- package/dist/ai-service/llm/stream/errors.js +2 -8
- package/dist/ai-service/llm/stream/errors.js.map +1 -1
- package/dist/ai-service/llm/stream/orchestrator.d.ts.map +1 -1
- package/dist/ai-service/llm/stream/orchestrator.js +6 -3
- package/dist/ai-service/llm/stream/orchestrator.js.map +1 -1
- package/dist/ai-service/llmobs/tracer.d.ts.map +1 -1
- package/dist/ai-service/llmobs/tracer.js +21 -4
- package/dist/ai-service/llmobs/tracer.js.map +1 -1
- package/dist/ai-service/managed-native-db-availability.d.ts +1 -1
- package/dist/ai-service/managed-native-db-availability.d.ts.map +1 -1
- package/dist/ai-service/managed-native-db-availability.js +2 -4
- package/dist/ai-service/managed-native-db-availability.js.map +1 -1
- package/dist/ai-service/policy-gate-remediation-usage.d.ts +1 -2
- package/dist/ai-service/policy-gate-remediation-usage.d.ts.map +1 -1
- package/dist/ai-service/policy-gate-remediation-usage.js +1 -2
- package/dist/ai-service/policy-gate-remediation-usage.js.map +1 -1
- package/dist/ai-service/skills/system/materialized.d.ts +1 -3
- package/dist/ai-service/skills/system/materialized.d.ts.map +1 -1
- package/dist/ai-service/skills/system/materialized.js +3 -3
- package/dist/ai-service/skills/system/materialized.js.map +1 -1
- package/dist/ai-service/state-machine/handlers/llm-generating.d.ts.map +1 -1
- package/dist/ai-service/state-machine/handlers/llm-generating.js +4 -6
- package/dist/ai-service/state-machine/handlers/llm-generating.js.map +1 -1
- package/dist/ai-service/state-machine/helpers/policy-gate-usage-metrics.d.ts +1 -1
- package/dist/ai-service/state-machine/helpers/policy-gate-usage-metrics.d.ts.map +1 -1
- package/dist/ai-service/state-machine/helpers/policy-gate-usage-metrics.js +1 -1
- package/dist/ai-service/state-machine/helpers/policy-gate-usage-metrics.js.map +1 -1
- package/dist/ai-service/state-machine/helpers/user-response-message.d.ts.map +1 -1
- package/dist/ai-service/state-machine/helpers/user-response-message.js +2 -4
- package/dist/ai-service/state-machine/helpers/user-response-message.js.map +1 -1
- package/dist/ai-service/types.d.ts +0 -3
- package/dist/ai-service/types.d.ts.map +1 -1
- package/dist/ai-service/types.js.map +1 -1
- package/dist/extract-api-integrations.d.ts +91 -52
- package/dist/extract-api-integrations.d.ts.map +1 -1
- package/dist/extract-api-integrations.js +487 -512
- package/dist/extract-api-integrations.js.map +1 -1
- package/dist/file-sync-vite-plugin.d.ts.map +1 -1
- package/dist/file-sync-vite-plugin.js +5 -53
- package/dist/file-sync-vite-plugin.js.map +1 -1
- package/dist/file-system-helpers.d.ts.map +1 -1
- package/dist/file-system-helpers.js +2 -3
- package/dist/file-system-helpers.js.map +1 -1
- package/dist/git-service/index.d.ts +0 -1
- package/dist/git-service/index.d.ts.map +1 -1
- package/dist/git-service/index.js +38 -6
- package/dist/git-service/index.js.map +1 -1
- package/dist/git-service/managed-excludes.d.ts.map +1 -1
- package/dist/git-service/managed-excludes.js +0 -2
- package/dist/git-service/managed-excludes.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/injected-index.d.ts +3 -1
- package/dist/injected-index.d.ts.map +1 -1
- package/dist/injected-index.js +8 -3
- package/dist/injected-index.js.map +1 -1
- package/dist/lock-service/index.d.ts +0 -3
- package/dist/lock-service/index.d.ts.map +1 -1
- package/dist/lock-service/index.js +0 -7
- package/dist/lock-service/index.js.map +1 -1
- package/dist/migration/get-fullstack-template-dir.d.ts +5 -2
- package/dist/migration/get-fullstack-template-dir.d.ts.map +1 -1
- package/dist/migration/get-fullstack-template-dir.js +8 -5
- package/dist/migration/get-fullstack-template-dir.js.map +1 -1
- package/dist/migration-templates/app-fullstack/.gitignore +50 -0
- package/dist/plugin-options.d.ts +1 -1
- package/dist/plugin-options.d.ts.map +1 -1
- package/dist/policy-gate-runner.d.ts +7 -32
- package/dist/policy-gate-runner.d.ts.map +1 -1
- package/dist/policy-gate-runner.js +6 -23
- package/dist/policy-gate-runner.js.map +1 -1
- package/dist/socket-manager.d.ts +2 -9
- package/dist/socket-manager.d.ts.map +1 -1
- package/dist/socket-manager.js +19 -160
- package/dist/socket-manager.js.map +1 -1
- package/dist/sync-service/draft-helpers.d.ts +0 -9
- package/dist/sync-service/draft-helpers.d.ts.map +1 -1
- package/dist/sync-service/draft-helpers.js +0 -135
- package/dist/sync-service/draft-helpers.js.map +1 -1
- package/dist/sync-service/index.d.ts +1 -24
- package/dist/sync-service/index.d.ts.map +1 -1
- package/dist/sync-service/index.js +9 -197
- package/dist/sync-service/index.js.map +1 -1
- package/dist/sync-service/list-dir.d.ts +1 -3
- package/dist/sync-service/list-dir.d.ts.map +1 -1
- package/dist/sync-service/list-dir.js +1 -7
- package/dist/sync-service/list-dir.js.map +1 -1
- package/dist/util/log-sanitizer.d.ts +0 -4
- package/dist/util/log-sanitizer.d.ts.map +1 -1
- package/dist/util/log-sanitizer.js +0 -7
- package/dist/util/log-sanitizer.js.map +1 -1
- package/package.json +52 -57
- package/dist/agent-tool-executor/codex-drafts.d.ts +0 -12
- package/dist/agent-tool-executor/codex-drafts.d.ts.map +0 -1
- package/dist/agent-tool-executor/codex-drafts.js +0 -48
- package/dist/agent-tool-executor/codex-drafts.js.map +0 -1
- package/dist/agent-tool-executor/codex-exec-server.d.ts +0 -42
- package/dist/agent-tool-executor/codex-exec-server.d.ts.map +0 -1
- package/dist/agent-tool-executor/codex-exec-server.js +0 -405
- package/dist/agent-tool-executor/codex-exec-server.js.map +0 -1
- package/dist/agent-tool-executor/codex-execution-policy.d.ts +0 -12
- package/dist/agent-tool-executor/codex-execution-policy.d.ts.map +0 -1
- package/dist/agent-tool-executor/codex-execution-policy.js +0 -201
- package/dist/agent-tool-executor/codex-execution-policy.js.map +0 -1
- package/dist/agent-tool-executor/native-dotenv-watch-scope.d.ts +0 -12
- package/dist/agent-tool-executor/native-dotenv-watch-scope.d.ts.map +0 -1
- package/dist/agent-tool-executor/native-dotenv-watch-scope.js +0 -74
- package/dist/agent-tool-executor/native-dotenv-watch-scope.js.map +0 -1
- package/dist/ai-service/agent/security-scan-tools.d.ts +0 -12
- package/dist/ai-service/agent/security-scan-tools.d.ts.map +0 -1
- package/dist/ai-service/agent/security-scan-tools.js +0 -44
- package/dist/ai-service/agent/security-scan-tools.js.map +0 -1
- package/dist/ai-service/builder-conversation.d.ts +0 -70
- package/dist/ai-service/builder-conversation.d.ts.map +0 -1
- package/dist/ai-service/builder-conversation.js +0 -660
- package/dist/ai-service/builder-conversation.js.map +0 -1
- package/dist/ai-service/builder-inference-auth.d.ts +0 -11
- package/dist/ai-service/builder-inference-auth.d.ts.map +0 -1
- package/dist/ai-service/builder-inference-auth.js +0 -48
- package/dist/ai-service/builder-inference-auth.js.map +0 -1
- package/dist/ai-service/builder-runtime.d.ts +0 -181
- package/dist/ai-service/builder-runtime.d.ts.map +0 -1
- package/dist/ai-service/builder-runtime.js +0 -337
- package/dist/ai-service/builder-runtime.js.map +0 -1
- package/dist/ai-service/builder-session-store.d.ts +0 -26
- package/dist/ai-service/builder-session-store.d.ts.map +0 -1
- package/dist/ai-service/builder-session-store.js +0 -66
- package/dist/ai-service/builder-session-store.js.map +0 -1
- package/dist/ai-service/builder-tool-callbacks.d.ts +0 -26
- package/dist/ai-service/builder-tool-callbacks.d.ts.map +0 -1
- package/dist/ai-service/builder-tool-callbacks.js +0 -114
- package/dist/ai-service/builder-tool-callbacks.js.map +0 -1
- package/dist/ai-service/builder-tools.d.ts +0 -46
- package/dist/ai-service/builder-tools.d.ts.map +0 -1
- package/dist/ai-service/builder-tools.js +0 -181
- package/dist/ai-service/builder-tools.js.map +0 -1
- package/dist/ai-service/chat/switch-chat-seed.d.ts +0 -8
- package/dist/ai-service/chat/switch-chat-seed.d.ts.map +0 -1
- package/dist/ai-service/chat/switch-chat-seed.js +0 -47
- package/dist/ai-service/chat/switch-chat-seed.js.map +0 -1
- package/dist/ai-service/llm/request-settings.d.ts +0 -6
- package/dist/ai-service/llm/request-settings.d.ts.map +0 -1
- package/dist/ai-service/llm/request-settings.js +0 -21
- package/dist/ai-service/llm/request-settings.js.map +0 -1
- package/dist/ai-service/native-callback-order.d.ts +0 -7
- package/dist/ai-service/native-callback-order.d.ts.map +0 -1
- package/dist/ai-service/native-callback-order.js +0 -39
- package/dist/ai-service/native-callback-order.js.map +0 -1
- package/dist/ai-service/native-secret-redactor.d.ts +0 -4
- package/dist/ai-service/native-secret-redactor.d.ts.map +0 -1
- package/dist/ai-service/native-secret-redactor.js +0 -34
- package/dist/ai-service/native-secret-redactor.js.map +0 -1
- package/dist/ai-service/policy-gate-review.d.ts +0 -42
- package/dist/ai-service/policy-gate-review.d.ts.map +0 -1
- package/dist/ai-service/policy-gate-review.js +0 -664
- package/dist/ai-service/policy-gate-review.js.map +0 -1
- package/dist/ai-service/skills/system/native.d.ts +0 -7
- package/dist/ai-service/skills/system/native.d.ts.map +0 -1
- package/dist/ai-service/skills/system/native.js +0 -25
- package/dist/ai-service/skills/system/native.js.map +0 -1
- package/dist/ai-service/skills/system/paths.d.ts +0 -2
- package/dist/ai-service/skills/system/paths.d.ts.map +0 -1
- package/dist/ai-service/skills/system/paths.js +0 -2
- package/dist/ai-service/skills/system/paths.js.map +0 -1
- package/dist/git-service/credential-scope.d.ts +0 -16
- package/dist/git-service/credential-scope.d.ts.map +0 -1
- package/dist/git-service/credential-scope.js +0 -91
- package/dist/git-service/credential-scope.js.map +0 -1
- package/dist/review-runner.d.ts +0 -25
- package/dist/review-runner.d.ts.map +0 -1
- package/dist/review-runner.js +0 -196
- package/dist/review-runner.js.map +0 -1
- package/dist/sync-service/draft-mutation.d.ts +0 -11
- package/dist/sync-service/draft-mutation.d.ts.map +0 -1
- package/dist/sync-service/draft-mutation.js +0 -121
- package/dist/sync-service/draft-mutation.js.map +0 -1
- package/dist/sync-service/native-draft-session.d.ts +0 -22
- package/dist/sync-service/native-draft-session.d.ts.map +0 -1
- package/dist/sync-service/native-draft-session.js +0 -229
- package/dist/sync-service/native-draft-session.js.map +0 -1
- package/dist/sync-service/safe-directory-reader.d.ts +0 -24
- package/dist/sync-service/safe-directory-reader.d.ts.map +0 -1
- package/dist/sync-service/safe-directory-reader.js +0 -124
- package/dist/sync-service/safe-directory-reader.js.map +0 -1
|
@@ -23,7 +23,6 @@ export declare enum SyncServiceStatus {
|
|
|
23
23
|
}
|
|
24
24
|
/** Configuration for the SyncService passed to the constructor */
|
|
25
25
|
export interface SyncServiceConfig {
|
|
26
|
-
nativeDraftJournalDirectory?: string;
|
|
27
26
|
superblocksBaseUrl: string;
|
|
28
27
|
fsOperationQueue: OperationQueue;
|
|
29
28
|
appRootDirPath: string;
|
|
@@ -57,7 +56,6 @@ export type UploadDirectoryResult = {
|
|
|
57
56
|
localNoPending?: true;
|
|
58
57
|
};
|
|
59
58
|
interface EventMap extends ErrorEventMap, DraftEventMap {
|
|
60
|
-
nativeDraftSessionSynced: [];
|
|
61
59
|
/** Emitted when the sync service status changes, which indicates what the service is currently doing */
|
|
62
60
|
statusChange: [
|
|
63
61
|
status: SyncServiceStatus,
|
|
@@ -90,8 +88,6 @@ interface EventMap extends ErrorEventMap, DraftEventMap {
|
|
|
90
88
|
commitId: string;
|
|
91
89
|
commitMessage?: string;
|
|
92
90
|
}];
|
|
93
|
-
/** Emitted when the server merged an upload with a newer tree and left conflict markers in these files. */
|
|
94
|
-
serverMergeConflicts: [paths: string[]];
|
|
95
91
|
}
|
|
96
92
|
/**
|
|
97
93
|
* Whether `downloadDirectory()` should seed `lastCommitId` from the server's
|
|
@@ -143,11 +139,6 @@ export declare class SyncService extends TracedEventEmitter<EventMap> implements
|
|
|
143
139
|
/** When true, `uploadDirectory()` short-circuits so the migration can
|
|
144
140
|
* run `flipTemplate()` without waiting behind autosave queue entries. */
|
|
145
141
|
private _autoSyncPaused;
|
|
146
|
-
private canReloadFromServer;
|
|
147
|
-
private nativeDraftSession?;
|
|
148
|
-
private nativeDraftSessionCompletion?;
|
|
149
|
-
private nativeDraftRecoveryFailed;
|
|
150
|
-
private readonly nativeDraftJournalDirectory?;
|
|
151
142
|
private lockService;
|
|
152
143
|
private _status;
|
|
153
144
|
private _synchronizationStatus;
|
|
@@ -186,11 +177,6 @@ export declare class SyncService extends TracedEventEmitter<EventMap> implements
|
|
|
186
177
|
* Pulls the application down from the server.
|
|
187
178
|
*/
|
|
188
179
|
downloadDirectory(): Promise<void>;
|
|
189
|
-
setReloadGuard(canReload: () => Promise<boolean>): void;
|
|
190
|
-
reloadFromServer(): Promise<void>;
|
|
191
|
-
/** Pulls a newer server tree into a user branch pod, so the pod stays fresh without a browser. */
|
|
192
|
-
private checkServerFreshness;
|
|
193
|
-
private downloadDirectoryOrThrow;
|
|
194
180
|
/**
|
|
195
181
|
* Rebuilds a draft that a replaced pod lost. Never throws, so a failure
|
|
196
182
|
* cannot block startup. Resolves to true when it restored a draft.
|
|
@@ -233,9 +219,7 @@ export declare class SyncService extends TracedEventEmitter<EventMap> implements
|
|
|
233
219
|
* `uploadDirectoryNowIfNeeded` is only an autosync drain; it can legally
|
|
234
220
|
* return the last synced hash when no autosync is pending.
|
|
235
221
|
*/
|
|
236
|
-
syncCurrentDirectoryWithDraftsNow(source: ApplicationHashChangeSource
|
|
237
|
-
waitForNativeSession?: boolean;
|
|
238
|
-
}): Promise<UploadDirectoryResult>;
|
|
222
|
+
syncCurrentDirectoryWithDraftsNow(source: ApplicationHashChangeSource): Promise<UploadDirectoryResult>;
|
|
239
223
|
/**
|
|
240
224
|
* Flushes the current directory for teardown without creating a redundant
|
|
241
225
|
* setApplicationHash request when disk already matches the last successful
|
|
@@ -428,13 +412,6 @@ export declare class SyncService extends TracedEventEmitter<EventMap> implements
|
|
|
428
412
|
*/
|
|
429
413
|
createDraftFile(filePath: string, draftContent: string | Buffer): Promise<void>;
|
|
430
414
|
applyDraftChanges(changes: DraftChange[]): Promise<void>;
|
|
431
|
-
private get nativeDraftJournal();
|
|
432
|
-
private assertNoNativeDraftSession;
|
|
433
|
-
withNativeDraftSession<T>(execute: (signal: AbortSignal) => Promise<T>): Promise<T>;
|
|
434
|
-
private runNativeDraftSession;
|
|
435
|
-
recoverNativeDraftSession(): Promise<boolean>;
|
|
436
|
-
private reconcileNativeDraftSession;
|
|
437
|
-
trackDraftMutation<T>(paths: string[], forward: () => Promise<T>, preflightPaths?: string[]): Promise<T>;
|
|
438
415
|
/**
|
|
439
416
|
* Creates the marker file only for a draft edit or addition.
|
|
440
417
|
* Compare to `createDraftFile`. This method does not actually write content to target file.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sync-service/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAGjD,OAAO,EACL,oBAAoB,EAErB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,2BAA2B,EAChC,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sync-service/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAGjD,OAAO,EACL,oBAAoB,EAErB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,2BAA2B,EAChC,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB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|
@@ -3,7 +3,7 @@ import * as fs from "node:fs/promises";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { normalizePath } from "vite";
|
|
5
5
|
import { SyncronizationStatus, } from "@superblocksteam/library-shared/types";
|
|
6
|
-
import { addTracingToMethods, TracedEventEmitter, BadRequestError,
|
|
6
|
+
import { addTracingToMethods, TracedEventEmitter, BadRequestError, unwrapResponseDto, } from "@superblocksteam/shared";
|
|
7
7
|
import { applyErrorHandling, } from "../errors/error-handler.js";
|
|
8
8
|
import { makeServerError } from "../errors/make-server-error.js";
|
|
9
9
|
import { POLICY_GATE_RUN_SYNC_BLOCKED_ERROR, policyGateRunRegistry, } from "../policy-gate-run-registry.js";
|
|
@@ -11,12 +11,10 @@ import { getErrorMeta, } from "../util/logger.js";
|
|
|
11
11
|
import { OperationQueue } from "../util/operation-queue.js";
|
|
12
12
|
import { withResolvers } from "../util/with-resolvers.js";
|
|
13
13
|
import { classifyCheckpointResult } from "./checkpoint-result.js";
|
|
14
|
-
import { downloadApplicationDirectory, DraftRestoreError,
|
|
14
|
+
import { downloadApplicationDirectory, DraftRestoreError, restoreDraftMarkersFromCheckpoint, } from "./download.js";
|
|
15
15
|
import { hasSwapFiles, discardAllDrafts, commitAllDrafts, getDraftInfo, createDraft, generateDraftDiff, createDraftMarkerOnly, createDraftDelete, cleanUpDraftsDirectory, } from "./draft-helpers.js";
|
|
16
|
-
import { DraftMutation } from "./draft-mutation.js";
|
|
17
16
|
import { recordDraftRestore, recordDraftStateReport, } from "./draft-state-report-metrics.js";
|
|
18
17
|
import { HashCache } from "./hash-cache.js";
|
|
19
|
-
import { NativeDraftJournal } from "./native-draft-session.js";
|
|
20
18
|
import { validatePageReferences } from "./page-reference-guard.js";
|
|
21
19
|
import { snapshotLocalDirectory, snapshotLocalDirectoryWithDrafts, snapshotPathHashes, } from "./snapshot/take-snapshot.js";
|
|
22
20
|
import { uploadDirectorySnapshot } from "./snapshot/upload-snapshot.js";
|
|
@@ -25,7 +23,6 @@ const SYNC_INTERVAL_MS = 10_000;
|
|
|
25
23
|
const SYNC_MAX_WAIT_MS = 30_000;
|
|
26
24
|
const AI_ACCEPT_UPLOAD_MAX_ATTEMPTS = 3;
|
|
27
25
|
const AI_ACCEPT_UPLOAD_RETRY_DELAY_MS = 500;
|
|
28
|
-
const SERVER_FRESHNESS_INTERVAL_MS = 10_000;
|
|
29
26
|
export var SyncServiceStatus;
|
|
30
27
|
(function (SyncServiceStatus) {
|
|
31
28
|
/** The sync service is not currently syncing or scheduled to sync */
|
|
@@ -137,11 +134,6 @@ export class SyncService extends TracedEventEmitter {
|
|
|
137
134
|
/** When true, `uploadDirectory()` short-circuits so the migration can
|
|
138
135
|
* run `flipTemplate()` without waiting behind autosave queue entries. */
|
|
139
136
|
_autoSyncPaused = false;
|
|
140
|
-
canReloadFromServer = async () => true;
|
|
141
|
-
nativeDraftSession;
|
|
142
|
-
nativeDraftSessionCompletion;
|
|
143
|
-
nativeDraftRecoveryFailed = false;
|
|
144
|
-
nativeDraftJournalDirectory;
|
|
145
137
|
lockService;
|
|
146
138
|
_status = SyncServiceStatus.IDLE;
|
|
147
139
|
_synchronizationStatus = SyncronizationStatus.SERVER_AHEAD;
|
|
@@ -154,7 +146,6 @@ export class SyncService extends TracedEventEmitter {
|
|
|
154
146
|
constructor(config) {
|
|
155
147
|
super(config.tracer);
|
|
156
148
|
this.fsOperationQueue = config.fsOperationQueue;
|
|
157
|
-
this.nativeDraftJournalDirectory = config.nativeDraftJournalDirectory;
|
|
158
149
|
// Normalize path to handle Windows drive letter case
|
|
159
150
|
this.appRootDirPath = normalizePath(config.appRootDirPath);
|
|
160
151
|
this.applicationId = config.applicationId;
|
|
@@ -170,7 +161,6 @@ export class SyncService extends TracedEventEmitter {
|
|
|
170
161
|
uploadDirectory: { operation: "syncing directory to server" },
|
|
171
162
|
syncCurrentDirectoryWithDraftsNow: {
|
|
172
163
|
operation: "syncing current directory to server",
|
|
173
|
-
rethrow: true,
|
|
174
164
|
},
|
|
175
165
|
hasLocalDraftChanges: { operation: "checking for local draft changes" },
|
|
176
166
|
commitLocalDraftChanges: {
|
|
@@ -191,12 +181,8 @@ export class SyncService extends TracedEventEmitter {
|
|
|
191
181
|
"createDraftFile",
|
|
192
182
|
"discardLocalDraftChanges",
|
|
193
183
|
"commitLocalDraftChanges",
|
|
194
|
-
"withNativeDraftSession",
|
|
195
|
-
"recoverNativeDraftSession",
|
|
196
184
|
];
|
|
197
185
|
addTracingToMethods(this, methods, this._tracer);
|
|
198
|
-
// unref: the tick must never keep the dev server process alive.
|
|
199
|
-
setInterval(() => void this.checkServerFreshness(), SERVER_FRESHNESS_INTERVAL_MS).unref();
|
|
200
186
|
}
|
|
201
187
|
getLogger() {
|
|
202
188
|
return this._logger;
|
|
@@ -214,7 +200,6 @@ export class SyncService extends TracedEventEmitter {
|
|
|
214
200
|
return this._branchName;
|
|
215
201
|
}
|
|
216
202
|
setBranchName(nextBranchName) {
|
|
217
|
-
this.assertNoNativeDraftSession();
|
|
218
203
|
if (this._branchName === nextBranchName) {
|
|
219
204
|
return;
|
|
220
205
|
}
|
|
@@ -278,66 +263,8 @@ export class SyncService extends TracedEventEmitter {
|
|
|
278
263
|
* Pulls the application down from the server.
|
|
279
264
|
*/
|
|
280
265
|
downloadDirectory() {
|
|
281
|
-
return this.downloadDirectoryOrThrow();
|
|
282
|
-
}
|
|
283
|
-
setReloadGuard(canReload) {
|
|
284
|
-
this.canReloadFromServer = canReload;
|
|
285
|
-
}
|
|
286
|
-
async reloadFromServer() {
|
|
287
|
-
// A publish builds from these files, so a pull must not replace them mid-run.
|
|
288
|
-
if (policyGateRunRegistry.isRunning(this.applicationId)) {
|
|
289
|
-
throw new Error(POLICY_GATE_RUN_SYNC_BLOCKED_ERROR);
|
|
290
|
-
}
|
|
291
|
-
if (this.pendingSyncUp) {
|
|
292
|
-
clearTimeout(this.pendingSyncUp.timeoutId);
|
|
293
|
-
this.pendingSyncUp = undefined;
|
|
294
|
-
}
|
|
295
|
-
await this.downloadDirectoryOrThrow();
|
|
296
|
-
await this.syncCurrentDirectoryWithDraftsNowIfChanged("requestedFilesSync");
|
|
297
|
-
}
|
|
298
|
-
/** Pulls a newer server tree into a user branch pod, so the pod stays fresh without a browser. */
|
|
299
|
-
async checkServerFreshness() {
|
|
300
|
-
const inFlight = this.status === SyncServiceStatus.UPLOADING ||
|
|
301
|
-
this.status === SyncServiceStatus.DOWNLOADING;
|
|
302
|
-
if (!isUserBranchName(this._branchName) ||
|
|
303
|
-
!this.lastSyncedDirectoryHash ||
|
|
304
|
-
inFlight ||
|
|
305
|
-
this._autoSyncPaused ||
|
|
306
|
-
policyGateRunRegistry.isRunning(this.applicationId)) {
|
|
307
|
-
return;
|
|
308
|
-
}
|
|
309
|
-
const serverIsNewer = async () => {
|
|
310
|
-
const { hash } = await this._rpcClient.call((rpcClient) => getDraftOrLiveDirectoryHash(rpcClient, this.applicationId, this._branchName));
|
|
311
|
-
return hash !== this.lastSyncedDirectoryHash;
|
|
312
|
-
};
|
|
313
|
-
try {
|
|
314
|
-
if (!(await serverIsNewer())) {
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
// Upload local edits first, so the server merges them and the download does not overwrite them.
|
|
318
|
-
await this.uploadDirectoryNowIfNeeded("requestedFilesSync");
|
|
319
|
-
if (!(await serverIsNewer())) {
|
|
320
|
-
return;
|
|
321
|
-
}
|
|
322
|
-
if (this.pendingSyncUp || !(await this.canReloadFromServer())) {
|
|
323
|
-
this.getLogger().debug("[sync-service] Server tree is newer, waiting for Clark, drafts, or pending edits before the download");
|
|
324
|
-
return;
|
|
325
|
-
}
|
|
326
|
-
await this.reloadFromServer();
|
|
327
|
-
}
|
|
328
|
-
catch (err) {
|
|
329
|
-
this.getLogger().warn("[sync-service] Server freshness check failed", getErrorMeta(err));
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
downloadDirectoryOrThrow() {
|
|
333
266
|
this.getLogger().info("[sync-service] Synchronizating application from the server");
|
|
334
267
|
return this.fsOperation(async () => {
|
|
335
|
-
if (this.nativeDraftSession)
|
|
336
|
-
throw new Error("Cannot download during native execution");
|
|
337
|
-
if (await this.reconcileNativeDraftSession(true)) {
|
|
338
|
-
this.setSynchronizationStatus(SyncronizationStatus.LOCAL_AHEAD);
|
|
339
|
-
return;
|
|
340
|
-
}
|
|
341
268
|
this.status = SyncServiceStatus.DOWNLOADING;
|
|
342
269
|
try {
|
|
343
270
|
const { directoryHash, latestNonDraftCommitId } = await this._rpcClient.call(async (rpcClient) => {
|
|
@@ -436,9 +363,7 @@ export class SyncService extends TracedEventEmitter {
|
|
|
436
363
|
}
|
|
437
364
|
/** Resolves after scheduling, not uploading. Await before filesystem changes. */
|
|
438
365
|
uploadDirectory(source) {
|
|
439
|
-
if (this._autoSyncPaused
|
|
440
|
-
this.nativeDraftSession ||
|
|
441
|
-
this.nativeDraftRecoveryFailed) {
|
|
366
|
+
if (this._autoSyncPaused) {
|
|
442
367
|
this.getLogger().info("[sync-service] Auto-sync paused (migration in progress), skipping upload");
|
|
443
368
|
return Promise.resolve();
|
|
444
369
|
}
|
|
@@ -555,12 +480,9 @@ export class SyncService extends TracedEventEmitter {
|
|
|
555
480
|
* `uploadDirectoryNowIfNeeded` is only an autosync drain; it can legally
|
|
556
481
|
* return the last synced hash when no autosync is pending.
|
|
557
482
|
*/
|
|
558
|
-
|
|
559
|
-
if (options?.waitForNativeSession)
|
|
560
|
-
await this.nativeDraftSessionCompletion;
|
|
483
|
+
syncCurrentDirectoryWithDraftsNow(source) {
|
|
561
484
|
this.getLogger().info(`[sync-service] Syncing current directory with drafts (source=${source})`);
|
|
562
485
|
return this.fsOperation(async () => {
|
|
563
|
-
await this.reconcileNativeDraftSession(!this.nativeDraftSession);
|
|
564
486
|
const directorySnapshot = await snapshotLocalDirectoryWithDrafts(this.appRootDirPath);
|
|
565
487
|
const completedPromise = this.scheduleUploadDirectory(directorySnapshot, true, this.generationNumberSequence?.currentValue, source);
|
|
566
488
|
const result = await completedPromise;
|
|
@@ -576,9 +498,7 @@ export class SyncService extends TracedEventEmitter {
|
|
|
576
498
|
* while a genuinely changed directory still attempts its final upload.
|
|
577
499
|
*/
|
|
578
500
|
syncCurrentDirectoryWithDraftsNowIfChanged(source) {
|
|
579
|
-
if (this._autoSyncPaused
|
|
580
|
-
this.nativeDraftSession ||
|
|
581
|
-
this.nativeDraftRecoveryFailed) {
|
|
501
|
+
if (this._autoSyncPaused) {
|
|
582
502
|
this.getLogger().info("[sync-service] Auto-sync paused (migration in progress), skipping final upload");
|
|
583
503
|
return Promise.resolve({
|
|
584
504
|
directoryHash: this.lastSyncedDirectoryHash || "",
|
|
@@ -758,9 +678,7 @@ export class SyncService extends TracedEventEmitter {
|
|
|
758
678
|
* slot on the way. That is what `lastEnqueuedSyncUp` answers.
|
|
759
679
|
*/
|
|
760
680
|
retentionFor(enqueued) {
|
|
761
|
-
if (this._autoSyncPaused
|
|
762
|
-
this.nativeDraftSession ||
|
|
763
|
-
this.nativeDraftRecoveryFailed) {
|
|
681
|
+
if (this._autoSyncPaused) {
|
|
764
682
|
// A migration paused autosync while this waited its turn; it wants the
|
|
765
683
|
// queues empty, and the pod restarts with a fresh service on success.
|
|
766
684
|
return { kind: "discarded" };
|
|
@@ -951,18 +869,18 @@ export class SyncService extends TracedEventEmitter {
|
|
|
951
869
|
// Now that the directory has been uploaded, we know that all of its hashes are in the server,
|
|
952
870
|
// so we can add them to the hash cache
|
|
953
871
|
this.hashCache.add_directory_recursive(directorySnapshot);
|
|
954
|
-
const { degradedMode, commitId, commitMessage, checkpointSkipped
|
|
872
|
+
const { degradedMode, commitId, commitMessage, checkpointSkipped } = await this._rpcClient.call(async (rpcClient) => {
|
|
955
873
|
const payload = {
|
|
956
874
|
applicationId: this.applicationId,
|
|
957
875
|
branchName: this._branchName,
|
|
958
876
|
hash: directorySnapshot.hash,
|
|
959
|
-
baseHash: this.lastSyncedDirectoryHash,
|
|
960
877
|
source: source,
|
|
961
878
|
};
|
|
962
879
|
if (source === "migrate:templateFlip" && targetTemplateName) {
|
|
963
880
|
payload.targetTemplateName = targetTemplateName;
|
|
964
881
|
}
|
|
965
|
-
if ((source === "migrate:backup" ||
|
|
882
|
+
if ((source === "migrate:backup" ||
|
|
883
|
+
source === "migrate:templateFlip") &&
|
|
966
884
|
migrationGeneration !== undefined) {
|
|
967
885
|
payload.migrationGeneration = migrationGeneration;
|
|
968
886
|
}
|
|
@@ -993,7 +911,6 @@ export class SyncService extends TracedEventEmitter {
|
|
|
993
911
|
this.getLogger().warn(`[sync-service] No commitId and no skip reason returned from server - checkpoint creation may have failed (source=${source})`);
|
|
994
912
|
}
|
|
995
913
|
this.emit("degradedModeChange", degradedMode);
|
|
996
|
-
await this.nativeDraftJournal.retireUploaded(directorySnapshot.hash);
|
|
997
914
|
this.lastSyncedGenerationNumber = generationNumber;
|
|
998
915
|
this.setSynchronizationStatus(SyncronizationStatus.IN_SYNC, source);
|
|
999
916
|
if (commitId) {
|
|
@@ -1003,13 +920,6 @@ export class SyncService extends TracedEventEmitter {
|
|
|
1003
920
|
if (commitId && !checkpointSkipped) {
|
|
1004
921
|
this.emit("checkpointCreated", { commitId, commitMessage });
|
|
1005
922
|
}
|
|
1006
|
-
if (conflicts?.length) {
|
|
1007
|
-
this.emit("serverMergeConflicts", conflicts);
|
|
1008
|
-
}
|
|
1009
|
-
// The server merged this upload with a newer tree. The timer runs after the caller records this upload.
|
|
1010
|
-
if (serverHash !== directorySnapshot.hash) {
|
|
1011
|
-
setTimeout(() => void this.checkServerFreshness(), 0);
|
|
1012
|
-
}
|
|
1013
923
|
return {
|
|
1014
924
|
checkpointSkipped,
|
|
1015
925
|
commitId,
|
|
@@ -1321,98 +1231,6 @@ export class SyncService extends TracedEventEmitter {
|
|
|
1321
1231
|
}
|
|
1322
1232
|
});
|
|
1323
1233
|
}
|
|
1324
|
-
get nativeDraftJournal() {
|
|
1325
|
-
return new NativeDraftJournal(this.appRootDirPath, `${this.applicationId}:${this._branchName ?? ""}`, this.nativeDraftJournalDirectory);
|
|
1326
|
-
}
|
|
1327
|
-
assertNoNativeDraftSession() {
|
|
1328
|
-
if (this.nativeDraftSession || this.nativeDraftRecoveryFailed)
|
|
1329
|
-
throw new Error("Cannot accept or discard drafts during native execution or pending recovery");
|
|
1330
|
-
}
|
|
1331
|
-
async withNativeDraftSession(execute) {
|
|
1332
|
-
if (this.nativeDraftSession)
|
|
1333
|
-
throw new Error("A native execution session is already active");
|
|
1334
|
-
const controller = new AbortController();
|
|
1335
|
-
this.nativeDraftSession = controller;
|
|
1336
|
-
const execution = this.runNativeDraftSession(execute, controller);
|
|
1337
|
-
this.nativeDraftSessionCompletion = execution.then(() => undefined);
|
|
1338
|
-
void this.nativeDraftSessionCompletion.catch(() => { });
|
|
1339
|
-
return execution;
|
|
1340
|
-
}
|
|
1341
|
-
async runNativeDraftSession(execute, controller) {
|
|
1342
|
-
this.cancelPendingSync();
|
|
1343
|
-
const abort = () => controller.abort(new Error("Native execution lost the application edit lock"));
|
|
1344
|
-
const checkLock = () => {
|
|
1345
|
-
if (!this.lockService.isLocked)
|
|
1346
|
-
abort();
|
|
1347
|
-
};
|
|
1348
|
-
let captured = false;
|
|
1349
|
-
try {
|
|
1350
|
-
if (!(await this.lockService.ensureLockForWrite({
|
|
1351
|
-
reclaimAfterHandback: true,
|
|
1352
|
-
})))
|
|
1353
|
-
throw new Error("Native execution requires the application edit lock");
|
|
1354
|
-
this.lockService.on("lockReleased", abort);
|
|
1355
|
-
this.lockService.on("closedByServer", abort);
|
|
1356
|
-
this.lockService.on("statusChange", checkLock);
|
|
1357
|
-
checkLock();
|
|
1358
|
-
controller.signal.throwIfAborted();
|
|
1359
|
-
await this.fsOperation(async () => {
|
|
1360
|
-
this.cancelPendingSync();
|
|
1361
|
-
await this.syncOperationQueue.enqueue(async () => undefined);
|
|
1362
|
-
await this.reconcileNativeDraftSession(true);
|
|
1363
|
-
await this.nativeDraftJournal.capture();
|
|
1364
|
-
captured = true;
|
|
1365
|
-
});
|
|
1366
|
-
controller.signal.throwIfAborted();
|
|
1367
|
-
return await execute(controller.signal);
|
|
1368
|
-
}
|
|
1369
|
-
finally {
|
|
1370
|
-
this.lockService.off("lockReleased", abort);
|
|
1371
|
-
this.lockService.off("closedByServer", abort);
|
|
1372
|
-
this.lockService.off("statusChange", checkLock);
|
|
1373
|
-
try {
|
|
1374
|
-
if (captured) {
|
|
1375
|
-
const changed = await this.fsOperation(() => this.reconcileNativeDraftSession(true));
|
|
1376
|
-
if (changed) {
|
|
1377
|
-
await this.syncCurrentDirectoryWithDraftsNow("ai:generate:post");
|
|
1378
|
-
this.emit("nativeDraftSessionSynced");
|
|
1379
|
-
}
|
|
1380
|
-
}
|
|
1381
|
-
}
|
|
1382
|
-
finally {
|
|
1383
|
-
this.nativeDraftSession = undefined;
|
|
1384
|
-
}
|
|
1385
|
-
}
|
|
1386
|
-
}
|
|
1387
|
-
async recoverNativeDraftSession() {
|
|
1388
|
-
if (this.nativeDraftSession)
|
|
1389
|
-
throw new Error("Cannot recover drafts during native execution");
|
|
1390
|
-
return this.fsOperation(() => this.reconcileNativeDraftSession(true));
|
|
1391
|
-
}
|
|
1392
|
-
async reconcileNativeDraftSession(finalize) {
|
|
1393
|
-
try {
|
|
1394
|
-
const result = await this.nativeDraftJournal.reconcile(finalize);
|
|
1395
|
-
this.nativeDraftRecoveryFailed = false;
|
|
1396
|
-
if (!result)
|
|
1397
|
-
return false;
|
|
1398
|
-
for (const relative of result.changedPaths)
|
|
1399
|
-
this._moduleInvalidationCallback?.(relative);
|
|
1400
|
-
if (result.changedPaths.length)
|
|
1401
|
-
this.notifyDraftStateChanged(await hasSwapFiles(this.appRootDirPath));
|
|
1402
|
-
return result.changedPaths.length > 0;
|
|
1403
|
-
}
|
|
1404
|
-
catch (error) {
|
|
1405
|
-
this.nativeDraftRecoveryFailed = true;
|
|
1406
|
-
throw error;
|
|
1407
|
-
}
|
|
1408
|
-
}
|
|
1409
|
-
async trackDraftMutation(paths, forward, preflightPaths = []) {
|
|
1410
|
-
return this.fsOperation(() => new DraftMutation(this.appRootDirPath).run(paths, forward, preflightPaths, async (changedPaths) => {
|
|
1411
|
-
for (const relative of changedPaths)
|
|
1412
|
-
this._moduleInvalidationCallback?.(relative);
|
|
1413
|
-
this.notifyDraftStateChanged(await hasSwapFiles(this.appRootDirPath));
|
|
1414
|
-
}));
|
|
1415
|
-
}
|
|
1416
1234
|
/**
|
|
1417
1235
|
* Creates the marker file only for a draft edit or addition.
|
|
1418
1236
|
* Compare to `createDraftFile`. This method does not actually write content to target file.
|
|
@@ -1442,12 +1260,9 @@ export class SyncService extends TracedEventEmitter {
|
|
|
1442
1260
|
* @returns A promise that resolves when all draft changes have been discarded.
|
|
1443
1261
|
*/
|
|
1444
1262
|
async discardLocalDraftChanges(source) {
|
|
1445
|
-
this.assertNoNativeDraftSession();
|
|
1446
1263
|
this.getLogger().info("[sync-service] Discarding local draft changes");
|
|
1447
1264
|
await this.fsOperation(async () => {
|
|
1448
|
-
this.assertNoNativeDraftSession();
|
|
1449
1265
|
await discardAllDrafts(this.appRootDirPath);
|
|
1450
|
-
await this.nativeDraftJournal.clear();
|
|
1451
1266
|
// Emit event so UI can refresh
|
|
1452
1267
|
this.getLogger().info("[sync-service] Local draft changes discarded");
|
|
1453
1268
|
});
|
|
@@ -1466,7 +1281,6 @@ export class SyncService extends TracedEventEmitter {
|
|
|
1466
1281
|
* @returns A promise that resolves when all drafts have been committed.
|
|
1467
1282
|
*/
|
|
1468
1283
|
async commitLocalDraftChanges(source) {
|
|
1469
|
-
this.assertNoNativeDraftSession();
|
|
1470
1284
|
const checkpointAttemptId = source === "ai:accept" ? randomUUID() : undefined;
|
|
1471
1285
|
if (checkpointAttemptId) {
|
|
1472
1286
|
this.getLogger().info(`[sync-service] Committing local draft changes (source=${source})`, { checkpointAttemptId });
|
|
@@ -1475,9 +1289,7 @@ export class SyncService extends TracedEventEmitter {
|
|
|
1475
1289
|
this.getLogger().info(`[sync-service] Committing local draft changes (source=${source})`);
|
|
1476
1290
|
}
|
|
1477
1291
|
await this.fsOperation(async () => {
|
|
1478
|
-
this.assertNoNativeDraftSession();
|
|
1479
1292
|
await commitAllDrafts(this.appRootDirPath);
|
|
1480
|
-
await this.nativeDraftJournal.clear();
|
|
1481
1293
|
this.getLogger().info("[sync-service] Local draft changes committed");
|
|
1482
1294
|
});
|
|
1483
1295
|
const uploadResult = await this.uploadCommittedDraftForSource(source, checkpointAttemptId);
|