@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
|
@@ -27,6 +27,7 @@ import { createEventEnvelope } from '../runtime/events/index.js';
|
|
|
27
27
|
export class WorkspaceSwapManager {
|
|
28
28
|
deps;
|
|
29
29
|
currentWorkingDir;
|
|
30
|
+
swapInProgress = null;
|
|
30
31
|
constructor(initialWorkingDir, deps) {
|
|
31
32
|
this.deps = deps;
|
|
32
33
|
this.currentWorkingDir = initialWorkingDir;
|
|
@@ -35,6 +36,18 @@ export class WorkspaceSwapManager {
|
|
|
35
36
|
return this.currentWorkingDir;
|
|
36
37
|
}
|
|
37
38
|
async requestSwap(newWorkingDir) {
|
|
39
|
+
if (this.swapInProgress) {
|
|
40
|
+
return { ok: false, code: 'WORKSPACE_BUSY', reason: 'Another workspace swap is already in progress.', retryAfter: 1 };
|
|
41
|
+
}
|
|
42
|
+
this.swapInProgress = this._requestSwapInner(newWorkingDir);
|
|
43
|
+
try {
|
|
44
|
+
return await this.swapInProgress;
|
|
45
|
+
}
|
|
46
|
+
finally {
|
|
47
|
+
this.swapInProgress = null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async _requestSwapInner(newWorkingDir) {
|
|
38
51
|
const raw = newWorkingDir.trim();
|
|
39
52
|
if (!raw) {
|
|
40
53
|
return { ok: false, code: 'INVALID_PATH', reason: 'Working directory path must not be empty.' };
|
|
@@ -42,21 +55,15 @@ export class WorkspaceSwapManager {
|
|
|
42
55
|
const resolved = isAbsolute(raw) ? resolve(raw) : resolve(this.currentWorkingDir, raw);
|
|
43
56
|
const from = this.currentWorkingDir;
|
|
44
57
|
const to = resolved;
|
|
45
|
-
//
|
|
46
|
-
this._emit('WORKSPACE_SWAP_STARTED', { type: 'WORKSPACE_SWAP_STARTED', from, to });
|
|
47
|
-
// Check busy sessions
|
|
58
|
+
// Check busy sessions BEFORE emitting STARTED — don't emit STARTED if we'll immediately refuse.
|
|
48
59
|
const busyCount = this.deps.getBusySessionCount();
|
|
49
60
|
if (busyCount > 0) {
|
|
50
61
|
const reason = `${busyCount} session(s) have pending input. Retry after active inputs complete.`;
|
|
51
|
-
this._emit('WORKSPACE_SWAP_REFUSED',
|
|
52
|
-
type: 'WORKSPACE_SWAP_REFUSED',
|
|
53
|
-
from,
|
|
54
|
-
to,
|
|
55
|
-
reason,
|
|
56
|
-
retryAfter: 5,
|
|
57
|
-
});
|
|
62
|
+
this._emit({ type: 'WORKSPACE_SWAP_REFUSED', from, to, reason, retryAfter: 5 });
|
|
58
63
|
return { ok: false, code: 'WORKSPACE_BUSY', reason, retryAfter: 5 };
|
|
59
64
|
}
|
|
65
|
+
// Swap is proceeding — emit STARTED now that busy check passed.
|
|
66
|
+
this._emit({ type: 'WORKSPACE_SWAP_STARTED', from, to });
|
|
60
67
|
// Validate and create directory
|
|
61
68
|
try {
|
|
62
69
|
mkdirSync(join(resolved, '.goodvibes', 'sessions'), { recursive: true });
|
|
@@ -86,29 +93,22 @@ export class WorkspaceSwapManager {
|
|
|
86
93
|
catch {
|
|
87
94
|
// Non-fatal — swap succeeded but persistence failed
|
|
88
95
|
}
|
|
89
|
-
this._emit('WORKSPACE_SWAP_COMPLETED',
|
|
90
|
-
type: 'WORKSPACE_SWAP_COMPLETED',
|
|
91
|
-
from,
|
|
92
|
-
to: resolved,
|
|
93
|
-
persistedInDaemonSettings,
|
|
94
|
-
});
|
|
96
|
+
this._emit({ type: 'WORKSPACE_SWAP_COMPLETED', from, to: resolved, persistedInDaemonSettings });
|
|
95
97
|
return { ok: true, previous: from, current: resolved };
|
|
96
98
|
}
|
|
97
99
|
// ---------------------------------------------------------------------------
|
|
98
100
|
// Internal helpers
|
|
99
101
|
// ---------------------------------------------------------------------------
|
|
100
|
-
_emit(
|
|
102
|
+
_emit(payload) {
|
|
101
103
|
if (!this.deps.runtimeBus)
|
|
102
104
|
return;
|
|
103
105
|
try {
|
|
104
|
-
const envelope = createEventEnvelope(type, payload, {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
//
|
|
109
|
-
|
|
110
|
-
// runtime/health/effect-handlers.ts for CASCADE_APPLIED.
|
|
111
|
-
this.deps.runtimeBus.emit('workspace', envelope);
|
|
106
|
+
const envelope = createEventEnvelope(payload.type, payload, { sessionId: '', source: 'workspace-swap-manager' });
|
|
107
|
+
this.deps.runtimeBus.emit('workspace',
|
|
108
|
+
// WorkspaceEvent is the DomainEventMap['workspace'] union; createEventEnvelope
|
|
109
|
+
// infers the payload type as the concrete member rather than the full union.
|
|
110
|
+
// A single widening cast (not through unknown) is safe here.
|
|
111
|
+
envelope);
|
|
112
112
|
}
|
|
113
113
|
catch {
|
|
114
114
|
// Never throw from event emission
|