@pellux/goodvibes-sdk 0.21.20 → 0.21.23
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/_internal/contracts/types.d.ts +2 -1
- package/dist/_internal/contracts/types.d.ts.map +1 -1
- package/dist/_internal/daemon/runtime-session-routes.d.ts +12 -1
- package/dist/_internal/daemon/runtime-session-routes.d.ts.map +1 -1
- package/dist/_internal/daemon/runtime-session-routes.js +23 -5
- package/dist/_internal/daemon/system-routes.js +1 -1
- package/dist/_internal/platform/companion/companion-chat-rate-limiter.d.ts +40 -2
- package/dist/_internal/platform/companion/companion-chat-rate-limiter.d.ts.map +1 -1
- package/dist/_internal/platform/companion/companion-chat-rate-limiter.js +34 -5
- package/dist/_internal/platform/companion/companion-chat-routes.d.ts +13 -0
- package/dist/_internal/platform/companion/companion-chat-routes.d.ts.map +1 -1
- package/dist/_internal/platform/companion/companion-chat-routes.js +29 -0
- package/dist/_internal/platform/config/schema-domain-runtime.d.ts +5 -0
- package/dist/_internal/platform/config/schema-domain-runtime.d.ts.map +1 -1
- package/dist/_internal/platform/config/schema-domain-runtime.js +13 -0
- package/dist/_internal/platform/config/schema-types.d.ts +8 -2
- package/dist/_internal/platform/config/schema-types.d.ts.map +1 -1
- package/dist/_internal/platform/config/schema.d.ts.map +1 -1
- package/dist/_internal/platform/config/schema.js +1 -0
- package/dist/_internal/platform/control-plane/operator-contract.d.ts.map +1 -1
- package/dist/_internal/platform/control-plane/operator-contract.js +45 -1
- package/dist/_internal/platform/control-plane/session-broker.d.ts +12 -0
- package/dist/_internal/platform/control-plane/session-broker.d.ts.map +1 -1
- package/dist/_internal/platform/control-plane/session-broker.js +22 -0
- package/dist/_internal/platform/daemon/cli.js +24 -5
- package/dist/_internal/platform/daemon/facade-composition.d.ts +5 -0
- package/dist/_internal/platform/daemon/facade-composition.d.ts.map +1 -1
- package/dist/_internal/platform/daemon/facade-composition.js +1 -0
- package/dist/_internal/platform/daemon/facade.d.ts.map +1 -1
- package/dist/_internal/platform/daemon/facade.js +1 -0
- package/dist/_internal/platform/daemon/http/router-route-contexts.d.ts.map +1 -1
- package/dist/_internal/platform/daemon/http/router-route-contexts.js +4 -0
- package/dist/_internal/platform/daemon/http/router.d.ts +5 -0
- package/dist/_internal/platform/daemon/http/router.d.ts.map +1 -1
- package/dist/_internal/platform/daemon/http/router.js +1 -1
- package/dist/_internal/platform/daemon/types.d.ts +7 -0
- package/dist/_internal/platform/daemon/types.d.ts.map +1 -1
- package/dist/_internal/platform/pairing/companion-token.js +2 -2
- package/dist/_internal/platform/runtime/events/index.d.ts +4 -1
- package/dist/_internal/platform/runtime/events/index.d.ts.map +1 -1
- package/dist/_internal/platform/runtime/events/index.js +0 -15
- package/dist/_internal/platform/runtime/events/workspace.d.ts +22 -0
- package/dist/_internal/platform/runtime/events/workspace.d.ts.map +1 -1
- package/dist/_internal/platform/runtime/health/effect-handlers.d.ts.map +1 -1
- package/dist/_internal/platform/runtime/health/effect-handlers.js +12 -1
- package/dist/_internal/platform/runtime/services.d.ts +19 -0
- package/dist/_internal/platform/runtime/services.d.ts.map +1 -1
- package/dist/_internal/platform/runtime/services.js +31 -0
- package/dist/_internal/platform/state/memory-store.d.ts +11 -0
- package/dist/_internal/platform/state/memory-store.d.ts.map +1 -1
- package/dist/_internal/platform/state/memory-store.js +22 -0
- package/dist/_internal/platform/state/project-index.d.ts +13 -3
- package/dist/_internal/platform/state/project-index.d.ts.map +1 -1
- package/dist/_internal/platform/state/project-index.js +31 -0
- package/dist/_internal/platform/tools/state/index.d.ts +23 -0
- package/dist/_internal/platform/tools/state/index.d.ts.map +1 -1
- package/dist/_internal/platform/tools/state/index.js +49 -5
- package/dist/_internal/platform/version.js +1 -1
- package/dist/_internal/platform/workspace/daemon-home.d.ts +13 -1
- package/dist/_internal/platform/workspace/daemon-home.d.ts.map +1 -1
- package/dist/_internal/platform/workspace/daemon-home.js +101 -14
- package/dist/_internal/platform/workspace/workspace-swap-manager.d.ts +2 -0
- package/dist/_internal/platform/workspace/workspace-swap-manager.d.ts.map +1 -1
- package/dist/_internal/platform/workspace/workspace-swap-manager.js +25 -25
- package/package.json +1 -1
|
@@ -157,6 +157,25 @@ export interface RuntimeServices {
|
|
|
157
157
|
readonly modeManager: ModeManager;
|
|
158
158
|
readonly fileUndoManager: FileUndoManager;
|
|
159
159
|
readonly integrationHelpers: IntegrationHelperService;
|
|
160
|
+
/**
|
|
161
|
+
* Re-root all path-bound services to a new working directory.
|
|
162
|
+
*
|
|
163
|
+
* Called by WorkspaceSwapManager.requestSwap() after the new directory has
|
|
164
|
+
* been verified and its subdirectories created.
|
|
165
|
+
*
|
|
166
|
+
* Stores that are re-rooted in-process:
|
|
167
|
+
* - MemoryStore (memory.sqlite + vector index): closed and reopened at new path.
|
|
168
|
+
* - ProjectIndex: flushed to old location then reset to new directory.
|
|
169
|
+
*
|
|
170
|
+
* Stores that require a process restart to fully re-root emit a warn-level log
|
|
171
|
+
* naming the subsystem. They continue serving the old path until the daemon is
|
|
172
|
+
* restarted with --working-dir=<newDir> (or the persisted daemon-settings.json
|
|
173
|
+
* value is picked up at startup).
|
|
174
|
+
*
|
|
175
|
+
* @throws if MemoryStore or ProjectIndex reroot fails. Propagated as INVALID_PATH
|
|
176
|
+
* by WorkspaceSwapManager.
|
|
177
|
+
*/
|
|
178
|
+
rerootStores(newWorkingDir: string): Promise<void>;
|
|
160
179
|
}
|
|
161
180
|
export declare function createRuntimeServices(options: RuntimeServicesOptions): RuntimeServices;
|
|
162
181
|
//# sourceMappingURL=services.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../../../src/_internal/platform/runtime/services.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../../../src/_internal/platform/runtime/services.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,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C,QAAQ,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;IAChD,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;IAC1C,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;IAC1C,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAC9C,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IACxC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IACxC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;IAC1C,QAAQ,CAAC,kBAAkB,EAAE,wBAAwB,CAAC;IACtD;;;;;;;;;;;;;;;;;OAiBG;IACH,YAAY,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpD;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,GAAG,eAAe,CA2ZtF"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
|
+
import { logger } from '../utils/logger.js';
|
|
2
3
|
import { ConfigManager } from '../config/manager.js';
|
|
3
4
|
import { SecretsManager } from '../config/secrets.js';
|
|
4
5
|
import { ServiceRegistry } from '../config/service-registry.js';
|
|
@@ -438,5 +439,35 @@ export function createRuntimeServices(options) {
|
|
|
438
439
|
modeManager,
|
|
439
440
|
fileUndoManager,
|
|
440
441
|
integrationHelpers,
|
|
442
|
+
async rerootStores(newWorkingDir) {
|
|
443
|
+
// Step 1: Re-root MemoryStore — close existing SQLite/vector handles, reopen at new path.
|
|
444
|
+
const newMemoryDbPath = join(newWorkingDir, '.goodvibes', surfaceRoot, 'memory.sqlite');
|
|
445
|
+
await memoryStore.reroot(newMemoryDbPath);
|
|
446
|
+
// Step 2: Re-root ProjectIndex — flush old location, reset, load from new directory.
|
|
447
|
+
await projectIndex.reroot(newWorkingDir);
|
|
448
|
+
// Step 3: Subsystems that cannot be live-rerooted emit a warn log.
|
|
449
|
+
// They continue operating at the old root path until the next process restart,
|
|
450
|
+
// at which point --working-dir / daemon-settings.json points to the new path.
|
|
451
|
+
// This is acceptable because: (a) the swap endpoint is daemon-token-gated,
|
|
452
|
+
// (b) these services primarily write user-scoped state (auth, bookmarks, profiles)
|
|
453
|
+
// that is not workspace-scoped, and (c) knowledge/artifact stores resolve paths
|
|
454
|
+
// through configManager which does not hot-reload during a running session.
|
|
455
|
+
const cannotReroot = [
|
|
456
|
+
'knowledgeStore (SQLite at configManager-resolved path — restart required)',
|
|
457
|
+
'sessionManager (initialised with fixed workingDirectory)',
|
|
458
|
+
'sessionOrchestration (task-graph.json path fixed at init)',
|
|
459
|
+
'artifactStore (resolves rootDir via configManager.getControlPlaneConfigDir)',
|
|
460
|
+
'hookDispatcher (projectRoot fixed at init)',
|
|
461
|
+
'sandboxSessionRegistry (workingDirectory fixed at init)',
|
|
462
|
+
'agentOrchestrator (workingDirectory fixed at init)',
|
|
463
|
+
'wrfcController (projectRoot fixed at init)',
|
|
464
|
+
'overflowHandler (baseDir fixed at init)',
|
|
465
|
+
'replayEngine (workingDirectory fixed at init)',
|
|
466
|
+
'planManager (workingDirectory fixed at init)',
|
|
467
|
+
];
|
|
468
|
+
for (const name of cannotReroot) {
|
|
469
|
+
logger.warn('[rerootStores] subsystem requires restart to reroot', { subsystem: name, newWorkingDir });
|
|
470
|
+
}
|
|
471
|
+
},
|
|
441
472
|
};
|
|
442
473
|
}
|
|
@@ -171,6 +171,17 @@ export declare class MemoryStore {
|
|
|
171
171
|
doctor(): Promise<MemoryDoctorReport>;
|
|
172
172
|
save(): Promise<boolean>;
|
|
173
173
|
close(): void;
|
|
174
|
+
/**
|
|
175
|
+
* Re-root the store to a new SQLite database path.
|
|
176
|
+
*
|
|
177
|
+
* Closes the existing SQLite handle and vector index, then re-opens both at
|
|
178
|
+
* the new path. The caller is responsible for ensuring no writes are in-flight
|
|
179
|
+
* when this is called (WorkspaceSwapManager enforces this via the busy-session
|
|
180
|
+
* guard).
|
|
181
|
+
*
|
|
182
|
+
* @throws if the new SQLite store or vector index cannot be opened.
|
|
183
|
+
*/
|
|
184
|
+
reroot(newDbPath: string): Promise<void>;
|
|
174
185
|
private persist;
|
|
175
186
|
}
|
|
176
187
|
//# sourceMappingURL=memory-store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-store.d.ts","sourceRoot":"","sources":["../../../../src/_internal/platform/state/memory-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAEL,KAAK,iBAAiB,EAEvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAEL,+BAA+B,EAC/B,KAAK,2BAA2B,EACjC,MAAM,wBAAwB,CAAC;AAmBhC,MAAM,MAAM,WAAW,GACnB,UAAU,GACV,YAAY,GACZ,UAAU,GACV,SAAS,GACT,MAAM,GACN,MAAM,GACN,SAAS,GACT,cAAc,GACd,WAAW,CAAC;AAEhB,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;AAEzD,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,UAAU,GAAG,OAAO,GAAG,cAAc,CAAC;AAEhF,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAEhF,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,kBAAkB,CAAC;IACzB,4FAA4F;IAC5F,GAAG,EAAE,MAAM,CAAC;IACZ,qCAAqC;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,8CAA8C;IAC9C,EAAE,EAAE,MAAM,CAAC;IACX,+DAA+D;IAC/D,KAAK,EAAE,WAAW,CAAC;IACnB,sEAAsE;IACtE,GAAG,EAAE,WAAW,CAAC;IACjB,oCAAoC;IACpC,OAAO,EAAE,MAAM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C;IAQrC,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;IAI9B,KAAK,IAAI,IAAI;IAMb;;;;;;;;;OASG;IACG,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAmB9C,OAAO,CAAC,OAAO;CAKhB"}
|
|
@@ -465,6 +465,28 @@ export class MemoryStore {
|
|
|
465
465
|
this.vectorIndex?.close();
|
|
466
466
|
this.ready = false;
|
|
467
467
|
}
|
|
468
|
+
/**
|
|
469
|
+
* Re-root the store to a new SQLite database path.
|
|
470
|
+
*
|
|
471
|
+
* Closes the existing SQLite handle and vector index, then re-opens both at
|
|
472
|
+
* the new path. The caller is responsible for ensuring no writes are in-flight
|
|
473
|
+
* when this is called (WorkspaceSwapManager enforces this via the busy-session
|
|
474
|
+
* guard).
|
|
475
|
+
*
|
|
476
|
+
* @throws if the new SQLite store or vector index cannot be opened.
|
|
477
|
+
*/
|
|
478
|
+
async reroot(newDbPath) {
|
|
479
|
+
// Step 1: close existing handles
|
|
480
|
+
this.sqlite.close();
|
|
481
|
+
this.vectorIndex?.close();
|
|
482
|
+
this.ready = false;
|
|
483
|
+
this.rebuildVectorIndexPromise = null;
|
|
484
|
+
// Step 2: open at new path
|
|
485
|
+
this.sqlite = new SQLiteStore(newDbPath);
|
|
486
|
+
this.vectorIndex = new SqliteVecMemoryIndex(resolveMemoryVectorDbPath(newDbPath), undefined, this.embeddingRegistry);
|
|
487
|
+
// Step 3: initialise
|
|
488
|
+
await this.init();
|
|
489
|
+
}
|
|
468
490
|
// ── Private helpers ──────────────────────────────────────────────────────────
|
|
469
491
|
persist() {
|
|
470
492
|
void this.save().catch((err) => {
|
|
@@ -16,9 +16,9 @@ export interface FileEntry {
|
|
|
16
16
|
* Disk format: v4 tree (see DiskFormat above).
|
|
17
17
|
*/
|
|
18
18
|
export declare class ProjectIndex {
|
|
19
|
-
private
|
|
20
|
-
private
|
|
21
|
-
|
|
19
|
+
private indexPath;
|
|
20
|
+
private projectRoot;
|
|
21
|
+
baseDir: string;
|
|
22
22
|
private files;
|
|
23
23
|
private flushTimer;
|
|
24
24
|
private createdAt;
|
|
@@ -52,6 +52,16 @@ export declare class ProjectIndex {
|
|
|
52
52
|
removeFile(path: string): void;
|
|
53
53
|
private normalizePath;
|
|
54
54
|
dispose(): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Re-root the project index to a new base directory.
|
|
57
|
+
*
|
|
58
|
+
* Flushes any pending writes to the old location, then resets all in-memory
|
|
59
|
+
* state and re-points the index path to the new directory. A fresh load is
|
|
60
|
+
* performed to pick up any existing index at the new location.
|
|
61
|
+
*
|
|
62
|
+
* @param newBaseDir - Absolute path to the new project root.
|
|
63
|
+
*/
|
|
64
|
+
reroot(newBaseDir: string): Promise<void>;
|
|
55
65
|
private scheduleFlush;
|
|
56
66
|
private flush;
|
|
57
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-index.d.ts","sourceRoot":"","sources":["../../../../src/_internal/platform/state/project-index.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,4DAA4D;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,iCAAiC;IACjC,MAAM,EAAE,MAAM,CAAC;CAChB;AAyBD;;;;;;;GAOG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"project-index.d.ts","sourceRoot":"","sources":["../../../../src/_internal/platform/state/project-index.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,4DAA4D;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,iCAAiC;IACjC,MAAM,EAAE,MAAM,CAAC;CAChB;AAyBD;;;;;;;GAOG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,KAAK,CAAkC;IAC/C,OAAO,CAAC,UAAU,CAA8C;IAChE,OAAO,CAAC,SAAS,CAAoC;IACrD,OAAO,CAAC,MAAM,CAAS;gBAEX,OAAO,EAAE,MAAM;IAU3B;;;OAGG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAoB3B;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAYjC,QAAQ,IAAI,SAAS,EAAE;IAIvB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAOvC,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE;IAW7C,qEAAqE;IACrE,aAAa,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAUvC,cAAc,IAAI,MAAM;IAUxB;;;OAGG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IAO/C;;;OAGG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAc7B,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAW9B,OAAO,CAAC,aAAa;IAWf,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ9B;;;;;;;;OAQG;IACG,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAsB/C,OAAO,CAAC,aAAa;YAUP,KAAK;CAiCpB"}
|
|
@@ -157,6 +157,37 @@ export class ProjectIndex {
|
|
|
157
157
|
}
|
|
158
158
|
await this.forceFlush();
|
|
159
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* Re-root the project index to a new base directory.
|
|
162
|
+
*
|
|
163
|
+
* Flushes any pending writes to the old location, then resets all in-memory
|
|
164
|
+
* state and re-points the index path to the new directory. A fresh load is
|
|
165
|
+
* performed to pick up any existing index at the new location.
|
|
166
|
+
*
|
|
167
|
+
* @param newBaseDir - Absolute path to the new project root.
|
|
168
|
+
*/
|
|
169
|
+
async reroot(newBaseDir) {
|
|
170
|
+
// Step 1: flush pending writes to the old location (best-effort)
|
|
171
|
+
if (this.flushTimer !== null) {
|
|
172
|
+
clearTimeout(this.flushTimer);
|
|
173
|
+
this.flushTimer = null;
|
|
174
|
+
}
|
|
175
|
+
try {
|
|
176
|
+
await this.forceFlush();
|
|
177
|
+
}
|
|
178
|
+
catch {
|
|
179
|
+
// Non-fatal — old location may be inaccessible after swap
|
|
180
|
+
}
|
|
181
|
+
// Step 2: reset state and re-point to new directory
|
|
182
|
+
this.projectRoot = newBaseDir;
|
|
183
|
+
this.baseDir = newBaseDir;
|
|
184
|
+
this.indexPath = join(newBaseDir, '.goodvibes', 'project-index.json');
|
|
185
|
+
this.files = new Map();
|
|
186
|
+
this.loaded = false;
|
|
187
|
+
this.createdAt = new Date().toISOString();
|
|
188
|
+
// Step 3: load existing index at new location (no-op if not present)
|
|
189
|
+
await this.load();
|
|
190
|
+
}
|
|
160
191
|
scheduleFlush() {
|
|
161
192
|
if (this.flushTimer !== null)
|
|
162
193
|
clearTimeout(this.flushTimer);
|
|
@@ -9,6 +9,29 @@ export interface StateToolOptions {
|
|
|
9
9
|
readonly hookDispatcher?: HookDispatcher;
|
|
10
10
|
readonly modeManager?: ModeManager;
|
|
11
11
|
readonly telemetryDB?: TelemetryDB;
|
|
12
|
+
/**
|
|
13
|
+
* Current working directory at session start. Exposed as the well-known
|
|
14
|
+
* read-only key `runtime.workingDir` via `mode=get`.
|
|
15
|
+
* Updated dynamically via WorkspaceSwapManager on workspace swap.
|
|
16
|
+
*/
|
|
17
|
+
readonly workingDir?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Daemon home directory (immutable after startup). Exposed as the well-known
|
|
20
|
+
* read-only key `daemon.homeDir` via `mode=get`.
|
|
21
|
+
*/
|
|
22
|
+
readonly daemonHomeDir?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Workspace swap manager. When provided, `set({values: {'runtime.workingDir': '/new/path'}})`
|
|
25
|
+
* will trigger a real workspace swap via `requestSwap()` instead of returning an error.
|
|
26
|
+
* Swap failures are surfaced as `success: false` with the error reason.
|
|
27
|
+
*/
|
|
28
|
+
readonly swapManager?: {
|
|
29
|
+
requestSwap(newDir: string): Promise<{
|
|
30
|
+
ok: boolean;
|
|
31
|
+
reason?: string;
|
|
32
|
+
code?: string;
|
|
33
|
+
}>;
|
|
34
|
+
};
|
|
12
35
|
}
|
|
13
36
|
/**
|
|
14
37
|
* Create the `state` tool bound to the given KVState and ProjectIndex.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/tools/state/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,KAAK,EAAE,IAAI,EAAkB,MAAM,sBAAsB,CAAC;AAiCjE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC;IACzC,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC;IACnC,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/tools/state/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,KAAK,EAAE,IAAI,EAAkB,MAAM,sBAAsB,CAAC;AAiCjE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC;IACzC,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC;IACnC,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC;IACnC;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE;QAAE,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;YAAE,EAAE,EAAE,OAAO,CAAC;YAAC,MAAM,CAAC,EAAE,MAAM,CAAC;YAAC,IAAI,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC;CAClH;AAMD;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,gBAAgB,GACxB,IAAI,CAsFN"}
|
|
@@ -51,6 +51,9 @@ export function createStateTool(kvState, projectIndex, options) {
|
|
|
51
51
|
const hookDispatcher = options.hookDispatcher;
|
|
52
52
|
const modeManager = options.modeManager;
|
|
53
53
|
const telemetryDB = options.telemetryDB;
|
|
54
|
+
const workingDir = options.workingDir;
|
|
55
|
+
const daemonHomeDir = options.daemonHomeDir;
|
|
56
|
+
const swapManager = options.swapManager;
|
|
54
57
|
// Session start time and telemetry are scoped per-instance so multiple
|
|
55
58
|
// createStateTool() calls don't share state.
|
|
56
59
|
const SESSION_START_MS = Date.now();
|
|
@@ -82,8 +85,8 @@ export function createStateTool(kvState, projectIndex, options) {
|
|
|
82
85
|
const input = args;
|
|
83
86
|
const { mode } = input;
|
|
84
87
|
switch (mode) {
|
|
85
|
-
case 'get': return runGet(input, kvState);
|
|
86
|
-
case 'set': return runSet(input, kvState);
|
|
88
|
+
case 'get': return runGet(input, kvState, workingDir, daemonHomeDir);
|
|
89
|
+
case 'set': return runSet(input, kvState, workingDir, daemonHomeDir, swapManager);
|
|
87
90
|
case 'list': return runList(input, kvState);
|
|
88
91
|
case 'clear': return runClear(input, kvState);
|
|
89
92
|
case 'budget': return runBudget(kvState, projectIndex);
|
|
@@ -404,19 +407,60 @@ function runMode(input, manager) {
|
|
|
404
407
|
}
|
|
405
408
|
return { success: false, error: `Unknown mode action: ${String(action)}` };
|
|
406
409
|
}
|
|
407
|
-
|
|
410
|
+
/**
|
|
411
|
+
* Well-known read-only keys surfaced directly by the state tool.
|
|
412
|
+
* These keys are injected into the `get` response alongside KVState values
|
|
413
|
+
* and rejected with an error in `set` to prevent mutation.
|
|
414
|
+
*/
|
|
415
|
+
const WELL_KNOWN_READONLY_KEYS = new Set(['runtime.workingDir', 'daemon.homeDir']);
|
|
416
|
+
async function runGet(input, kvState, workingDir, daemonHomeDir) {
|
|
408
417
|
const keys = input.keys ?? [];
|
|
409
418
|
if (keys.length === 0) {
|
|
410
419
|
return { success: false, error: 'mode "get" requires a non-empty "keys" array' };
|
|
411
420
|
}
|
|
412
|
-
|
|
421
|
+
// Separate well-known keys from regular KV keys
|
|
422
|
+
const kvKeys = keys.filter((k) => !WELL_KNOWN_READONLY_KEYS.has(k));
|
|
423
|
+
const values = kvKeys.length > 0 ? await kvState.get(kvKeys) : {};
|
|
424
|
+
// Inject well-known read-only keys
|
|
425
|
+
if (keys.includes('runtime.workingDir')) {
|
|
426
|
+
values['runtime.workingDir'] = workingDir ?? null;
|
|
427
|
+
}
|
|
428
|
+
if (keys.includes('daemon.homeDir')) {
|
|
429
|
+
values['daemon.homeDir'] = daemonHomeDir ?? null;
|
|
430
|
+
}
|
|
413
431
|
return { success: true, output: JSON.stringify({ mode: 'get', values }) };
|
|
414
432
|
}
|
|
415
|
-
async function runSet(input, kvState) {
|
|
433
|
+
async function runSet(input, kvState, _workingDir, _daemonHomeDir, swapManager) {
|
|
416
434
|
const values = input.values;
|
|
417
435
|
if (!values || typeof values !== 'object') {
|
|
418
436
|
return { success: false, error: 'mode "set" requires a "values" object' };
|
|
419
437
|
}
|
|
438
|
+
// Handle runtime.workingDir specially — delegate to swap manager if available.
|
|
439
|
+
if ('runtime.workingDir' in values) {
|
|
440
|
+
const newDir = values['runtime.workingDir'];
|
|
441
|
+
if (typeof newDir !== 'string' || !newDir.trim()) {
|
|
442
|
+
return { success: false, error: 'runtime.workingDir must be a non-empty string.' };
|
|
443
|
+
}
|
|
444
|
+
if (!swapManager) {
|
|
445
|
+
return {
|
|
446
|
+
success: false,
|
|
447
|
+
error: 'Cannot write to runtime.workingDir: no swap manager available. Use POST /config to change runtime.workingDir.',
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
const result = await swapManager.requestSwap(newDir);
|
|
451
|
+
if (!result.ok) {
|
|
452
|
+
return { success: false, error: `Workspace swap failed (${result.code ?? 'UNKNOWN'}): ${result.reason ?? 'unknown error'}` };
|
|
453
|
+
}
|
|
454
|
+
return { success: true, output: JSON.stringify({ mode: 'set', swapped: true, newWorkingDir: newDir }) };
|
|
455
|
+
}
|
|
456
|
+
// Reject writes to other read-only well-known keys
|
|
457
|
+
const readonlyAttempts = Object.keys(values).filter((k) => WELL_KNOWN_READONLY_KEYS.has(k));
|
|
458
|
+
if (readonlyAttempts.length > 0) {
|
|
459
|
+
return {
|
|
460
|
+
success: false,
|
|
461
|
+
error: `Cannot write to read-only well-known key(s): ${readonlyAttempts.join(', ')}. These keys are immutable at runtime.`,
|
|
462
|
+
};
|
|
463
|
+
}
|
|
420
464
|
await kvState.set(values);
|
|
421
465
|
// Only report keys that KVState actually persists (exclude reserved keys).
|
|
422
466
|
const written = Object.keys(values).filter((k) => !RESERVED_KEYS.has(k));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
-
let version = '0.21.
|
|
3
|
+
let version = '0.21.23';
|
|
4
4
|
try {
|
|
5
5
|
const pkg = JSON.parse(readFileSync(join(import.meta.dir, '..', '..', 'package.json'), 'utf-8'));
|
|
6
6
|
version = pkg.version ?? version;
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* - <cwd>/.goodvibes/operator-tokens.json → ~/.goodvibes/daemon/operator-tokens.json (F3 revision)
|
|
22
22
|
* - Old paths are left intact (never deleted) to avoid breaking older binaries.
|
|
23
23
|
*/
|
|
24
|
+
import type { RuntimeEventBus } from '../runtime/events/index.js';
|
|
24
25
|
export interface DaemonHomeDirs {
|
|
25
26
|
/** Absolute path to the daemon home directory (immutable identity state). */
|
|
26
27
|
readonly daemonHomeDir: string;
|
|
@@ -35,6 +36,14 @@ export interface DaemonHomeOptions {
|
|
|
35
36
|
/** Override process.env for testing. */
|
|
36
37
|
readonly env?: NodeJS.ProcessEnv;
|
|
37
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Optional dependencies for migration event emission.
|
|
41
|
+
* When provided, migration outcomes are broadcast on the runtime event bus
|
|
42
|
+
* under the 'workspace' domain.
|
|
43
|
+
*/
|
|
44
|
+
export interface DaemonHomeMigrationDeps {
|
|
45
|
+
readonly runtimeBus?: RuntimeEventBus;
|
|
46
|
+
}
|
|
38
47
|
/**
|
|
39
48
|
* Resolve the daemon home directory from CLI flag, environment variable, or default.
|
|
40
49
|
*/
|
|
@@ -46,13 +55,16 @@ export declare function resolveDaemonHomeDir(options?: DaemonHomeOptions): strin
|
|
|
46
55
|
*
|
|
47
56
|
* Returns `freshInstall: true` when migration ran, `false` when the dir already existed.
|
|
48
57
|
*/
|
|
49
|
-
export declare function runDaemonHomeMigration(daemonHomeDir: string, options?: DaemonHomeOptions): DaemonHomeDirs;
|
|
58
|
+
export declare function runDaemonHomeMigration(daemonHomeDir: string, options?: DaemonHomeOptions, deps?: DaemonHomeMigrationDeps): DaemonHomeDirs;
|
|
50
59
|
/**
|
|
51
60
|
* Read a single key from daemon-settings.json, or return undefined if missing.
|
|
52
61
|
*/
|
|
53
62
|
export declare function readDaemonSetting(daemonHomeDir: string, key: string): string | undefined;
|
|
54
63
|
/**
|
|
55
64
|
* Write a single key into daemon-settings.json (merge, not replace).
|
|
65
|
+
*
|
|
66
|
+
* Uses a write-to-tmp-then-rename pattern for atomicity:
|
|
67
|
+
* a crash between write and rename leaves a .tmp file, never a corrupt target.
|
|
56
68
|
*/
|
|
57
69
|
export declare function writeDaemonSetting(daemonHomeDir: string, key: string, value: string): void;
|
|
58
70
|
//# sourceMappingURL=daemon-home.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daemon-home.d.ts","sourceRoot":"","sources":["../../../../src/_internal/platform/workspace/daemon-home.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;
|
|
1
|
+
{"version":3,"file":"daemon-home.d.ts","sourceRoot":"","sources":["../../../../src/_internal/platform/workspace/daemon-home.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAOH,OAAO,KAAK,EAAE,eAAe,EAAwB,MAAM,4BAA4B,CAAC;AAOxF,MAAM,WAAW,cAAc;IAC7B,6EAA6E;IAC7E,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,iFAAiF;IACjF,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,WAAW,iBAAiB;IAChC,oDAAoD;IACpD,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5C,6EAA6E;IAC7E,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,wCAAwC;IACxC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CAClC;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,UAAU,CAAC,EAAE,eAAe,CAAC;CACvC;AAMD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,iBAAsB,GAAG,MAAM,CAiB5E;AAMD;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE,iBAAsB,EAC/B,IAAI,GAAE,uBAA4B,GACjC,cAAc,CAoFhB;AAMD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAWxF;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAc1F"}
|
|
@@ -21,9 +21,11 @@
|
|
|
21
21
|
* - <cwd>/.goodvibes/operator-tokens.json → ~/.goodvibes/daemon/operator-tokens.json (F3 revision)
|
|
22
22
|
* - Old paths are left intact (never deleted) to avoid breaking older binaries.
|
|
23
23
|
*/
|
|
24
|
-
import { existsSync, mkdirSync, copyFileSync, readFileSync, writeFileSync } from 'node:fs';
|
|
25
|
-
import { join, isAbsolute, resolve } from 'node:path';
|
|
24
|
+
import { existsSync, mkdirSync, copyFileSync, readFileSync, writeFileSync, renameSync, readdirSync } from 'node:fs';
|
|
25
|
+
import { join, isAbsolute, resolve, dirname } from 'node:path';
|
|
26
26
|
import { homedir } from 'node:os';
|
|
27
|
+
import { logger } from '../utils/logger.js';
|
|
28
|
+
import { createEventEnvelope } from '../runtime/events/index.js';
|
|
27
29
|
// ---------------------------------------------------------------------------
|
|
28
30
|
// Resolution
|
|
29
31
|
// ---------------------------------------------------------------------------
|
|
@@ -56,13 +58,13 @@ export function resolveDaemonHomeDir(options = {}) {
|
|
|
56
58
|
*
|
|
57
59
|
* Returns `freshInstall: true` when migration ran, `false` when the dir already existed.
|
|
58
60
|
*/
|
|
59
|
-
export function runDaemonHomeMigration(daemonHomeDir, options = {}) {
|
|
61
|
+
export function runDaemonHomeMigration(daemonHomeDir, options = {}, deps = {}) {
|
|
60
62
|
const alreadyExists = existsSync(daemonHomeDir);
|
|
61
63
|
if (alreadyExists) {
|
|
62
64
|
return { daemonHomeDir, freshInstall: false };
|
|
63
65
|
}
|
|
64
66
|
// Create the daemon home directory tree
|
|
65
|
-
mkdirSync(
|
|
67
|
+
mkdirSync(daemonHomeDir, { recursive: true });
|
|
66
68
|
const userGoodVibesRoot = join(homedir(), '.goodvibes');
|
|
67
69
|
const cwd = options.cwd ?? process.cwd();
|
|
68
70
|
// Migrate auth-users.json from tui surface path
|
|
@@ -75,12 +77,63 @@ export function runDaemonHomeMigration(daemonHomeDir, options = {}) {
|
|
|
75
77
|
if (existsSync(legacyBootstrap)) {
|
|
76
78
|
safeCopy(legacyBootstrap, join(daemonHomeDir, 'auth-bootstrap.txt'));
|
|
77
79
|
}
|
|
78
|
-
// Migrate operator-tokens.json
|
|
79
|
-
// 0.21.17
|
|
80
|
-
// 0.21.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
// Migrate operator-tokens.json — search multiple legacy paths (F3 revision).
|
|
81
|
+
// 0.21.17 used <cwd>/.goodvibes/operator-tokens.json (workspace-scoped).
|
|
82
|
+
// 0.21.16 and earlier used surface-scoped ~/.goodvibes/<surface>/companion-token.json.
|
|
83
|
+
// 0.21.19+ canonical path is <daemonHomeDir>/operator-tokens.json.
|
|
84
|
+
const destTokenPath = join(daemonHomeDir, 'operator-tokens.json');
|
|
85
|
+
if (!existsSync(destTokenPath)) {
|
|
86
|
+
// Priority 1: workspace-scoped path from 0.21.17
|
|
87
|
+
const legacyWorkspaceTokens = join(cwd, '.goodvibes', 'operator-tokens.json');
|
|
88
|
+
// Priority 2: surface-scoped legacy tokens from 0.21.16 and earlier
|
|
89
|
+
const legacySurfaceToken = join(userGoodVibesRoot, 'tui', 'companion-token.json');
|
|
90
|
+
// Priority 3: XDG data home if set
|
|
91
|
+
const xdgDataHome = options.env?.['XDG_DATA_HOME'];
|
|
92
|
+
const xdgToken = xdgDataHome ? join(xdgDataHome, 'goodvibes', 'operator-tokens.json') : null;
|
|
93
|
+
// Scan for any surface-scoped companion-token.json files under ~/.goodvibes/
|
|
94
|
+
const surfaceScopedTokens = [];
|
|
95
|
+
try {
|
|
96
|
+
const entries = readdirSync(userGoodVibesRoot, { withFileTypes: true });
|
|
97
|
+
for (const entry of entries) {
|
|
98
|
+
if (entry.isDirectory()) {
|
|
99
|
+
const candidate = join(userGoodVibesRoot, entry.name, 'companion-token.json');
|
|
100
|
+
if (existsSync(candidate))
|
|
101
|
+
surfaceScopedTokens.push(candidate);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
// Best-effort scan
|
|
107
|
+
}
|
|
108
|
+
const tokenSources = [
|
|
109
|
+
legacyWorkspaceTokens,
|
|
110
|
+
...(xdgToken ? [xdgToken] : []),
|
|
111
|
+
legacySurfaceToken,
|
|
112
|
+
...surfaceScopedTokens,
|
|
113
|
+
];
|
|
114
|
+
for (const src of tokenSources) {
|
|
115
|
+
if (!existsSync(src))
|
|
116
|
+
continue;
|
|
117
|
+
// Validate JSON before copying — corrupt JSON must not be migrated.
|
|
118
|
+
try {
|
|
119
|
+
JSON.parse(readFileSync(src, 'utf-8'));
|
|
120
|
+
}
|
|
121
|
+
catch (parseErr) {
|
|
122
|
+
const reason = parseErr instanceof Error ? parseErr.message : String(parseErr);
|
|
123
|
+
logger.warn('daemon-home: skipping corrupt token file during migration', {
|
|
124
|
+
sourcePath: src,
|
|
125
|
+
reason,
|
|
126
|
+
});
|
|
127
|
+
_emitMigrationEvent(deps.runtimeBus, { type: 'WORKSPACE_IDENTITY_MIGRATION_FAILED', sourcePath: src, reason });
|
|
128
|
+
safeCopy(src, destTokenPath, { skipIfInvalid: true });
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
if (safeCopy(src, destTokenPath)) {
|
|
132
|
+
logger.info('daemon-home: migrated operator token', { from: src, to: destTokenPath });
|
|
133
|
+
_emitMigrationEvent(deps.runtimeBus, { type: 'WORKSPACE_IDENTITY_MIGRATED', from: src, to: destTokenPath });
|
|
134
|
+
}
|
|
135
|
+
break; // First valid source wins
|
|
136
|
+
}
|
|
84
137
|
}
|
|
85
138
|
return { daemonHomeDir, freshInstall: true };
|
|
86
139
|
}
|
|
@@ -106,10 +159,14 @@ export function readDaemonSetting(daemonHomeDir, key) {
|
|
|
106
159
|
}
|
|
107
160
|
/**
|
|
108
161
|
* Write a single key into daemon-settings.json (merge, not replace).
|
|
162
|
+
*
|
|
163
|
+
* Uses a write-to-tmp-then-rename pattern for atomicity:
|
|
164
|
+
* a crash between write and rename leaves a .tmp file, never a corrupt target.
|
|
109
165
|
*/
|
|
110
166
|
export function writeDaemonSetting(daemonHomeDir, key, value) {
|
|
111
167
|
mkdirSync(daemonHomeDir, { recursive: true });
|
|
112
168
|
const settingsPath = join(daemonHomeDir, 'daemon-settings.json');
|
|
169
|
+
const tmpPath = settingsPath + '.tmp';
|
|
113
170
|
let existing = {};
|
|
114
171
|
if (existsSync(settingsPath)) {
|
|
115
172
|
try {
|
|
@@ -119,16 +176,46 @@ export function writeDaemonSetting(daemonHomeDir, key, value) {
|
|
|
119
176
|
// Overwrite corrupt file
|
|
120
177
|
}
|
|
121
178
|
}
|
|
122
|
-
writeFileSync(
|
|
179
|
+
writeFileSync(tmpPath, JSON.stringify({ ...existing, [key]: value }, null, 2), 'utf-8');
|
|
180
|
+
renameSync(tmpPath, settingsPath);
|
|
123
181
|
}
|
|
124
182
|
// ---------------------------------------------------------------------------
|
|
125
183
|
// Helpers
|
|
126
184
|
// ---------------------------------------------------------------------------
|
|
127
|
-
|
|
185
|
+
/**
|
|
186
|
+
* Emit a workspace migration event on the runtime bus.
|
|
187
|
+
* Never throws — bus emission must not interrupt migration.
|
|
188
|
+
*/
|
|
189
|
+
function _emitMigrationEvent(bus, payload) {
|
|
190
|
+
if (!bus)
|
|
191
|
+
return;
|
|
128
192
|
try {
|
|
129
|
-
|
|
193
|
+
const envelope = createEventEnvelope(payload.type, payload, { sessionId: '', source: 'daemon-home-migration' });
|
|
194
|
+
bus.emit('workspace',
|
|
195
|
+
// WorkspaceEvent discriminated-union member; single widening cast is safe.
|
|
196
|
+
envelope);
|
|
130
197
|
}
|
|
131
198
|
catch {
|
|
132
|
-
//
|
|
199
|
+
// Swallow — never let event emission break migration
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Copy src to dest. Returns true on success, false on failure.
|
|
204
|
+
* Failures are logged at warn level. Never throws.
|
|
205
|
+
*/
|
|
206
|
+
function safeCopy(src, dest, opts) {
|
|
207
|
+
if (opts?.skipIfInvalid)
|
|
208
|
+
return false;
|
|
209
|
+
try {
|
|
210
|
+
copyFileSync(src, dest);
|
|
211
|
+
return true;
|
|
212
|
+
}
|
|
213
|
+
catch (err) {
|
|
214
|
+
logger.warn('daemon-home: safeCopy failed', {
|
|
215
|
+
src,
|
|
216
|
+
dest,
|
|
217
|
+
error: err instanceof Error ? err.message : String(err),
|
|
218
|
+
});
|
|
219
|
+
return false;
|
|
133
220
|
}
|
|
134
221
|
}
|
|
@@ -50,9 +50,11 @@ export type WorkspaceSwapResult = {
|
|
|
50
50
|
export declare class WorkspaceSwapManager {
|
|
51
51
|
private readonly deps;
|
|
52
52
|
private currentWorkingDir;
|
|
53
|
+
private swapInProgress;
|
|
53
54
|
constructor(initialWorkingDir: string, deps: WorkspaceSwapDeps);
|
|
54
55
|
getCurrentWorkingDir(): string;
|
|
55
56
|
requestSwap(newWorkingDir: string): Promise<WorkspaceSwapResult>;
|
|
57
|
+
private _requestSwapInner;
|
|
56
58
|
private _emit;
|
|
57
59
|
}
|
|
58
60
|
//# sourceMappingURL=workspace-swap-manager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace-swap-manager.d.ts","sourceRoot":"","sources":["../../../../src/_internal/platform/workspace/workspace-swap-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;
|
|
1
|
+
{"version":3,"file":"workspace-swap-manager.d.ts","sourceRoot":"","sources":["../../../../src/_internal/platform/workspace/workspace-swap-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAMH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAOlE,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,UAAU,EAAE,eAAe,GAAG,IAAI,CAAC;IAC5C,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B;;;OAGG;IACH,QAAQ,CAAC,mBAAmB,EAAE,MAAM,MAAM,CAAC;IAC3C;;;;OAIG;IACH,QAAQ,CAAC,YAAY,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACjE;AAMD,MAAM,MAAM,mBAAmB,GAC3B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAC/C;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GACzE;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,cAAc,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAMxD,qBAAa,oBAAoB;IAM7B,OAAO,CAAC,QAAQ,CAAC,IAAI;IALvB,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,cAAc,CAA6C;gBAGjE,iBAAiB,EAAE,MAAM,EACR,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