@sumicom/quicksave 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +110 -0
- package/dist/ai/cardBuilder.d.ts.map +1 -1
- package/dist/ai/cardBuilder.js +14 -2
- package/dist/ai/cardBuilder.js.map +1 -1
- package/dist/ai/claudeCliProvider.d.ts.map +1 -1
- package/dist/ai/claudeCliProvider.js +8 -11
- package/dist/ai/claudeCliProvider.js.map +1 -1
- package/dist/ai/claudeSdkProvider.d.ts.map +1 -1
- package/dist/ai/claudeSdkProvider.js +9 -14
- package/dist/ai/claudeSdkProvider.js.map +1 -1
- package/dist/ai/enrichEntry.d.ts +11 -0
- package/dist/ai/enrichEntry.d.ts.map +1 -0
- package/dist/ai/enrichEntry.js +27 -0
- package/dist/ai/enrichEntry.js.map +1 -0
- package/dist/ai/provider.d.ts +6 -0
- package/dist/ai/provider.d.ts.map +1 -1
- package/dist/ai/sandboxMcp.d.ts +41 -3
- package/dist/ai/sandboxMcp.d.ts.map +1 -1
- package/dist/ai/sandboxMcp.js +44 -3
- package/dist/ai/sandboxMcp.js.map +1 -1
- package/dist/ai/sandboxMcpStdio.js +103 -9
- package/dist/ai/sandboxMcpStdio.js.map +1 -1
- package/dist/ai/sessionManager.d.ts +23 -5
- package/dist/ai/sessionManager.d.ts.map +1 -1
- package/dist/ai/sessionManager.js +160 -22
- package/dist/ai/sessionManager.js.map +1 -1
- package/dist/ai/sessionRegistry.d.ts +57 -6
- package/dist/ai/sessionRegistry.d.ts.map +1 -1
- package/dist/ai/sessionRegistry.js +237 -31
- package/dist/ai/sessionRegistry.js.map +1 -1
- package/dist/config.d.ts +41 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +86 -0
- package/dist/config.js.map +1 -1
- package/dist/connection/connection.d.ts +61 -0
- package/dist/connection/connection.d.ts.map +1 -1
- package/dist/connection/connection.js +274 -1
- package/dist/connection/connection.js.map +1 -1
- package/dist/connection/relay.d.ts +20 -0
- package/dist/connection/relay.d.ts.map +1 -1
- package/dist/connection/relay.js +62 -1
- package/dist/connection/relay.js.map +1 -1
- package/dist/handlers/messageHandler.d.ts +10 -6
- package/dist/handlers/messageHandler.d.ts.map +1 -1
- package/dist/handlers/messageHandler.js +59 -62
- package/dist/handlers/messageHandler.js.map +1 -1
- package/dist/index.js +74 -5
- package/dist/index.js.map +1 -1
- package/dist/service/ipcClient.js +1 -1
- package/dist/service/ipcServer.d.ts.map +1 -1
- package/dist/service/ipcServer.js +10 -4
- package/dist/service/ipcServer.js.map +1 -1
- package/dist/service/run.d.ts.map +1 -1
- package/dist/service/run.js +69 -27
- package/dist/service/run.js.map +1 -1
- package/dist/service/types.d.ts +15 -0
- package/dist/service/types.d.ts.map +1 -1
- package/dist/service/types.js +6 -2
- package/dist/service/types.js.map +1 -1
- package/dist/tombstoneCheck.d.ts +43 -0
- package/dist/tombstoneCheck.d.ts.map +1 -0
- package/dist/tombstoneCheck.js +96 -0
- package/dist/tombstoneCheck.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { getEventStore } from '../storage/eventStore.js';
|
|
2
|
+
/**
|
|
3
|
+
* Join runtime event-store stats onto a registry entry for broadcast on
|
|
4
|
+
* `/sessions/history` (and on-demand fetches like `session:list-archived`).
|
|
5
|
+
* Cache / context fields live only in SQLite; we enrich here so inactive
|
|
6
|
+
* sessions render the same info that `/sessions/active` delivers for live
|
|
7
|
+
* ones. Safe for sessions with zero events — every added field is optional
|
|
8
|
+
* and simply stays undefined.
|
|
9
|
+
*/
|
|
10
|
+
export function enrichEntry(entry) {
|
|
11
|
+
const eventStore = getEventStore();
|
|
12
|
+
const stats = eventStore.getSessionStats(entry.sessionId);
|
|
13
|
+
const lastTurn = eventStore.getLastTurn(entry.sessionId);
|
|
14
|
+
return {
|
|
15
|
+
...entry,
|
|
16
|
+
lastPromptAt: stats.lastPromptAt ?? undefined,
|
|
17
|
+
lastTurnEndedAt: stats.lastTurnEndedAt ?? undefined,
|
|
18
|
+
turnCount: stats.turnCount || undefined,
|
|
19
|
+
totalInputTokens: stats.totalInputTokens || undefined,
|
|
20
|
+
totalOutputTokens: stats.totalOutputTokens || undefined,
|
|
21
|
+
lastTurnInputTokens: lastTurn?.inputTokens,
|
|
22
|
+
lastTurnCacheCreationTokens: lastTurn?.cacheCreationTokens,
|
|
23
|
+
lastTurnCacheReadTokens: lastTurn?.cacheReadTokens,
|
|
24
|
+
lastTurnContextUsage: lastTurn?.contextUsage,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=enrichEntry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enrichEntry.js","sourceRoot":"","sources":["../../src/ai/enrichEntry.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CAAC,KAA2B;IACrD,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;IACnC,MAAM,KAAK,GAAG,UAAU,CAAC,eAAe,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAC1D,MAAM,QAAQ,GAAG,UAAU,CAAC,WAAW,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACzD,OAAO;QACL,GAAG,KAAK;QACR,YAAY,EAAE,KAAK,CAAC,YAAY,IAAI,SAAS;QAC7C,eAAe,EAAE,KAAK,CAAC,eAAe,IAAI,SAAS;QACnD,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,SAAS;QACvC,gBAAgB,EAAE,KAAK,CAAC,gBAAgB,IAAI,SAAS;QACrD,iBAAiB,EAAE,KAAK,CAAC,iBAAiB,IAAI,SAAS;QACvD,mBAAmB,EAAE,QAAQ,EAAE,WAAW;QAC1C,2BAA2B,EAAE,QAAQ,EAAE,mBAAmB;QAC1D,uBAAuB,EAAE,QAAQ,EAAE,eAAe;QAClD,oBAAoB,EAAE,QAAQ,EAAE,YAAiD;KAClF,CAAC;AACJ,CAAC"}
|
package/dist/ai/provider.d.ts
CHANGED
|
@@ -26,6 +26,12 @@ export interface ProviderCallbacks {
|
|
|
26
26
|
response?: string;
|
|
27
27
|
updatedInput?: Record<string, unknown>;
|
|
28
28
|
}>;
|
|
29
|
+
/** Fired when a tool_use block is observed on the assistant stream. Runs for
|
|
30
|
+
* EVERY tool invocation regardless of whether the permission callback fires.
|
|
31
|
+
* CLI auto-mode silently pre-approves MCP tools without sending can_use_tool,
|
|
32
|
+
* so daemon-side side effects (e.g. UpdateSessionStatus persistence) must be
|
|
33
|
+
* driven from this hook, not handlePermissionRequest. */
|
|
34
|
+
onToolUse?(sessionId: string, toolName: string, toolInput: Record<string, unknown>): void;
|
|
29
35
|
onModelDetected(model: string): void;
|
|
30
36
|
/** Fired when the underlying provider process has fully exited. SessionManager
|
|
31
37
|
* uses this to remove the session from its in-memory map and emit
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/ai/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAC1G,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG,aAAa,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAChG,MAAM,MAAM,mBAAmB,GAAG,cAAc,GAAG,QAAQ,CAAC;AAE5D,6CAA6C;AAC7C,MAAM,WAAW,eAAe;IAC9B,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,SAAS,IAAI,IAAI,CAAC;IAClB,IAAI,IAAI,IAAI,CAAC;IACb,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB;;4EAEwE;IACxE,eAAe,CAAC,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AK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,eAAe,CAAC;IACjC,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,WAAW,EAAE,mBAAmB,CAAC;IAE1C,YAAY,CACV,IAAI,EAAE,gBAAgB,EACtB,WAAW,EAAE,iBAAiB,EAC9B,SAAS,EAAE,iBAAiB,GAC3B,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,eAAe,CAAA;KAAE,CAAC,CAAC;IAE5D,aAAa,CACX,IAAI,EAAE,iBAAiB,EACvB,WAAW,EAAE,iBAAiB,EAC9B,SAAS,EAAE,iBAAiB,GAC3B,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,eAAe,CAAA;KAAE,CAAC,CAAC;CAC7D"}
|
package/dist/ai/sandboxMcp.d.ts
CHANGED
|
@@ -1,12 +1,50 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Sandbox MCP constants.
|
|
2
|
+
* Sandbox MCP constants and spawn-config helper.
|
|
3
3
|
*
|
|
4
4
|
* The actual MCP server is in `sandboxMcpStdio.ts`.
|
|
5
|
-
* These constants are used by `claudeCliProvider.ts` for tool-name matching.
|
|
6
5
|
*/
|
|
7
6
|
/** MCP server name — tool names appear as `mcp__quicksave-sandbox__<tool>` in canUseTool. */
|
|
8
7
|
export declare const SANDBOX_MCP_NAME = "quicksave-sandbox";
|
|
9
8
|
export declare const SANDBOX_MCP_PREFIX = "mcp__quicksave-sandbox__";
|
|
10
9
|
export declare const SANDBOX_BASH_TOOL = "mcp__quicksave-sandbox__SandboxBash";
|
|
11
|
-
export declare const
|
|
10
|
+
export declare const UPDATE_SESSION_STATUS_TOOL = "mcp__quicksave-sandbox__UpdateSessionStatus";
|
|
11
|
+
export interface SandboxMcpServerConfig {
|
|
12
|
+
type: 'stdio';
|
|
13
|
+
command: string;
|
|
14
|
+
args: string[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Build the stdio MCP server spawn config for the Claude CLI / SDK.
|
|
18
|
+
*
|
|
19
|
+
* ⚠️ DO NOT "simplify" this to `command: 'npx', args: ['tsx', ...]` — that
|
|
20
|
+
* shape looks cleaner but silently fails in our setup. Two reasons:
|
|
21
|
+
*
|
|
22
|
+
* 1. Claude CLI spawns MCP stdio servers with cwd = the user's project dir.
|
|
23
|
+
* In a pnpm monorepo, `tsx` is installed under `apps/agent/node_modules/
|
|
24
|
+
* .bin/tsx` (not hoisted to the workspace root). `npx tsx` only searches
|
|
25
|
+
* upward from cwd for `.bin/tsx`, so from the project root it falls
|
|
26
|
+
* through to fetching from the npm registry — which in practice exits
|
|
27
|
+
* with `sh: 1: tsx: not found`, and Claude CLI marks the server
|
|
28
|
+
* `mcp_servers[quicksave-sandbox].status = "failed"`. The MCP tools then
|
|
29
|
+
* never reach the model's tool surface and neither `SandboxBash` nor
|
|
30
|
+
* `UpdateSessionStatus` are callable.
|
|
31
|
+
*
|
|
32
|
+
* 2. Even if tsx were resolvable, running through `npx` pulls npm's warning
|
|
33
|
+
* output (e.g. the `.npmrc` "Unknown project config" warning) onto stdout.
|
|
34
|
+
* The MCP protocol uses JSON-RPC over stdio; any non-JSON line before the
|
|
35
|
+
* handshake reply corrupts the stream and the CLI tears the server down.
|
|
36
|
+
*
|
|
37
|
+
* So: resolve `tsx` by absolute path relative to the agent package. Behavior
|
|
38
|
+
* is pinned by `sandboxMcp.test.ts`; break it and tests fail.
|
|
39
|
+
*/
|
|
40
|
+
export declare function buildSandboxMcpServerConfig(opts: {
|
|
41
|
+
/** The provider's own dir — `dirname(fileURLToPath(import.meta.url))`.
|
|
42
|
+
* Expected to be `apps/agent/src/ai` (dev, tsx) or `apps/agent/dist/ai` (prod, node).
|
|
43
|
+
* Used to locate `sandboxMcpStdio.{ts,js}` and the agent package's node_modules. */
|
|
44
|
+
ownDir: string;
|
|
45
|
+
/** Project directory the MCP server operates in — becomes `--cwd`. */
|
|
46
|
+
cwd: string;
|
|
47
|
+
/** When resuming, lets the server's UpdateSessionStatus dry-run read the registry file. */
|
|
48
|
+
sessionId?: string;
|
|
49
|
+
}): SandboxMcpServerConfig;
|
|
12
50
|
//# sourceMappingURL=sandboxMcp.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandboxMcp.d.ts","sourceRoot":"","sources":["../../src/ai/sandboxMcp.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"sandboxMcp.d.ts","sourceRoot":"","sources":["../../src/ai/sandboxMcp.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,6FAA6F;AAC7F,eAAO,MAAM,gBAAgB,sBAAsB,CAAC;AACpD,eAAO,MAAM,kBAAkB,6BAA+B,CAAC;AAC/D,eAAO,MAAM,iBAAiB,wCAAqC,CAAC;AACpE,eAAO,MAAM,0BAA0B,gDAA6C,CAAC;AAErF,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE;IAChD;;wFAEoF;IACpF,MAAM,EAAE,MAAM,CAAC;IACf,sEAAsE;IACtE,GAAG,EAAE,MAAM,CAAC;IACZ,2FAA2F;IAC3F,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,sBAAsB,CAiBzB"}
|
package/dist/ai/sandboxMcp.js
CHANGED
|
@@ -1,12 +1,53 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Sandbox MCP constants.
|
|
2
|
+
* Sandbox MCP constants and spawn-config helper.
|
|
3
3
|
*
|
|
4
4
|
* The actual MCP server is in `sandboxMcpStdio.ts`.
|
|
5
|
-
* These constants are used by `claudeCliProvider.ts` for tool-name matching.
|
|
6
5
|
*/
|
|
6
|
+
import { existsSync } from 'fs';
|
|
7
|
+
import { join } from 'path';
|
|
7
8
|
/** MCP server name — tool names appear as `mcp__quicksave-sandbox__<tool>` in canUseTool. */
|
|
8
9
|
export const SANDBOX_MCP_NAME = 'quicksave-sandbox';
|
|
9
10
|
export const SANDBOX_MCP_PREFIX = `mcp__${SANDBOX_MCP_NAME}__`;
|
|
10
11
|
export const SANDBOX_BASH_TOOL = `${SANDBOX_MCP_PREFIX}SandboxBash`;
|
|
11
|
-
export const
|
|
12
|
+
export const UPDATE_SESSION_STATUS_TOOL = `${SANDBOX_MCP_PREFIX}UpdateSessionStatus`;
|
|
13
|
+
/**
|
|
14
|
+
* Build the stdio MCP server spawn config for the Claude CLI / SDK.
|
|
15
|
+
*
|
|
16
|
+
* ⚠️ DO NOT "simplify" this to `command: 'npx', args: ['tsx', ...]` — that
|
|
17
|
+
* shape looks cleaner but silently fails in our setup. Two reasons:
|
|
18
|
+
*
|
|
19
|
+
* 1. Claude CLI spawns MCP stdio servers with cwd = the user's project dir.
|
|
20
|
+
* In a pnpm monorepo, `tsx` is installed under `apps/agent/node_modules/
|
|
21
|
+
* .bin/tsx` (not hoisted to the workspace root). `npx tsx` only searches
|
|
22
|
+
* upward from cwd for `.bin/tsx`, so from the project root it falls
|
|
23
|
+
* through to fetching from the npm registry — which in practice exits
|
|
24
|
+
* with `sh: 1: tsx: not found`, and Claude CLI marks the server
|
|
25
|
+
* `mcp_servers[quicksave-sandbox].status = "failed"`. The MCP tools then
|
|
26
|
+
* never reach the model's tool surface and neither `SandboxBash` nor
|
|
27
|
+
* `UpdateSessionStatus` are callable.
|
|
28
|
+
*
|
|
29
|
+
* 2. Even if tsx were resolvable, running through `npx` pulls npm's warning
|
|
30
|
+
* output (e.g. the `.npmrc` "Unknown project config" warning) onto stdout.
|
|
31
|
+
* The MCP protocol uses JSON-RPC over stdio; any non-JSON line before the
|
|
32
|
+
* handshake reply corrupts the stream and the CLI tears the server down.
|
|
33
|
+
*
|
|
34
|
+
* So: resolve `tsx` by absolute path relative to the agent package. Behavior
|
|
35
|
+
* is pinned by `sandboxMcp.test.ts`; break it and tests fail.
|
|
36
|
+
*/
|
|
37
|
+
export function buildSandboxMcpServerConfig(opts) {
|
|
38
|
+
const tsPath = join(opts.ownDir, 'sandboxMcpStdio.ts');
|
|
39
|
+
const jsPath = join(opts.ownDir, 'sandboxMcpStdio.js');
|
|
40
|
+
const hasTs = existsSync(tsPath);
|
|
41
|
+
// Dev: invoke tsx directly by absolute path. See header comment for why
|
|
42
|
+
// `npx tsx` is forbidden here.
|
|
43
|
+
// Prod: the TS source isn't shipped — run the bundled .js with plain `node`.
|
|
44
|
+
const scriptPath = hasTs ? tsPath : jsPath;
|
|
45
|
+
const command = hasTs
|
|
46
|
+
? join(opts.ownDir, '..', '..', 'node_modules', '.bin', 'tsx')
|
|
47
|
+
: 'node';
|
|
48
|
+
const args = [scriptPath, '--cwd', opts.cwd];
|
|
49
|
+
if (opts.sessionId)
|
|
50
|
+
args.push('--session-id', opts.sessionId);
|
|
51
|
+
return { type: 'stdio', command, args };
|
|
52
|
+
}
|
|
12
53
|
//# sourceMappingURL=sandboxMcp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandboxMcp.js","sourceRoot":"","sources":["../../src/ai/sandboxMcp.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"sandboxMcp.js","sourceRoot":"","sources":["../../src/ai/sandboxMcp.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,6FAA6F;AAC7F,MAAM,CAAC,MAAM,gBAAgB,GAAG,mBAAmB,CAAC;AACpD,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAQ,gBAAgB,IAAI,CAAC;AAC/D,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,kBAAkB,aAAa,CAAC;AACpE,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,kBAAkB,qBAAqB,CAAC;AAQrF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,2BAA2B,CAAC,IAS3C;IACC,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IACvD,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IACvD,MAAM,KAAK,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;IAEjC,wEAAwE;IACxE,+BAA+B;IAC/B,6EAA6E;IAC7E,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;IAC3C,MAAM,OAAO,GAAG,KAAK;QACnB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,KAAK,CAAC;QAC9D,CAAC,CAAC,MAAM,CAAC;IAEX,MAAM,IAAI,GAAG,CAAC,UAAU,EAAE,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IAC7C,IAAI,IAAI,CAAC,SAAS;QAAE,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAE9D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC1C,CAAC"}
|
|
@@ -15,16 +15,25 @@
|
|
|
15
15
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
16
16
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
17
17
|
import { execFileSync } from 'child_process';
|
|
18
|
-
import { realpathSync, existsSync } from 'fs';
|
|
18
|
+
import { realpathSync, existsSync, readFileSync } from 'fs';
|
|
19
19
|
import { join, dirname } from 'path';
|
|
20
|
+
import { homedir, platform } from 'os';
|
|
20
21
|
import { fileURLToPath } from 'url';
|
|
21
22
|
import { z } from 'zod';
|
|
22
|
-
import { platform } from 'os';
|
|
23
23
|
const __ownDir = dirname(fileURLToPath(import.meta.url));
|
|
24
|
-
|
|
25
|
-
const
|
|
24
|
+
function readArg(flag) {
|
|
25
|
+
const idx = process.argv.indexOf(flag);
|
|
26
|
+
return idx !== -1 ? process.argv[idx + 1] : undefined;
|
|
27
|
+
}
|
|
28
|
+
const cwd = readArg('--cwd') ?? process.cwd();
|
|
29
|
+
/** Known only on resume; undefined when the CLI spawns this MCP for a fresh session. */
|
|
30
|
+
const sessionIdHint = readArg('--session-id');
|
|
26
31
|
const realCwd = realpathSync(cwd);
|
|
27
32
|
const realHome = realpathSync(process.env.HOME ?? '/');
|
|
33
|
+
const quicksaveHome = process.env.QUICKSAVE_HOME || join(homedir(), '.quicksave');
|
|
34
|
+
const sessionRegistryDir = join(quicksaveHome, 'state', 'session-registry');
|
|
35
|
+
/** Same encoding as `apps/agent/src/ai/sessionRegistry.ts:encodeProjectPath`. */
|
|
36
|
+
const encodedCwd = cwd.replace(/\//g, '-');
|
|
28
37
|
const PROFILE_PATH = join(__ownDir, 'profiles', 'project-sandbox.sb');
|
|
29
38
|
function detectBackend() {
|
|
30
39
|
const os = platform();
|
|
@@ -111,12 +120,97 @@ server.tool('SandboxBash', 'Execute a shell command WITHOUT requiring user permi
|
|
|
111
120
|
};
|
|
112
121
|
}
|
|
113
122
|
});
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
123
|
+
function readStoredStatus() {
|
|
124
|
+
const empty = {
|
|
125
|
+
subject: null, stage: null, blocked: null, note: null, recentNotes: [], source: 'unknown',
|
|
126
|
+
};
|
|
127
|
+
if (!sessionIdHint)
|
|
128
|
+
return empty;
|
|
129
|
+
const path = join(sessionRegistryDir, encodedCwd, `${sessionIdHint}.json`);
|
|
130
|
+
if (!existsSync(path))
|
|
131
|
+
return empty;
|
|
132
|
+
try {
|
|
133
|
+
const entry = JSON.parse(readFileSync(path, 'utf-8'));
|
|
134
|
+
const history = Array.isArray(entry.noteHistory) ? entry.noteHistory : [];
|
|
135
|
+
return {
|
|
136
|
+
subject: typeof entry.title === 'string' ? entry.title : null,
|
|
137
|
+
stage: entry.stage ?? null,
|
|
138
|
+
blocked: typeof entry.blocked === 'boolean' ? entry.blocked : null,
|
|
139
|
+
note: typeof entry.note === 'string' ? entry.note : null,
|
|
140
|
+
recentNotes: history.slice(-5),
|
|
141
|
+
source: 'stored',
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
return empty;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
server.tool('UpdateSessionStatus', 'Update the ticket-style status for the current session, shown to the user on the home screen.\n' +
|
|
149
|
+
'\n' +
|
|
150
|
+
'Call at the START of every session (first response), and again whenever stage changes, ' +
|
|
151
|
+
'work gets blocked/unblocked, or progress is worth surfacing.\n' +
|
|
152
|
+
'\n' +
|
|
153
|
+
'Call with NO fields to read the current stored status without mutating ' +
|
|
154
|
+
'(dry-run). Useful on resume to check whether subject/stage already match the work.\n' +
|
|
155
|
+
'\n' +
|
|
156
|
+
'Fields:\n' +
|
|
157
|
+
' subject — What this session is solving, from the user\'s perspective.\n' +
|
|
158
|
+
' Good: "Fix auth token expiring early" Bad: "Debugging jwt.ts"\n' +
|
|
159
|
+
' stage — Ticket lifecycle stage:\n' +
|
|
160
|
+
' investigating reading code, finding root cause, understanding problem, designing\n' +
|
|
161
|
+
' working actively writing or changing code\n' +
|
|
162
|
+
' verifying running tests, confirming the fix, waiting on CI\n' +
|
|
163
|
+
' done user-visible deliverable is complete\n' +
|
|
164
|
+
' blocked — Orthogonal flag. Set true when stuck (waiting on user decision, ' +
|
|
165
|
+
'permission request, external service). Set false when unblocked. Do not change stage.\n' +
|
|
166
|
+
' note — One progress/finding entry, max ~12 words. APPENDED to the session\'s event log ' +
|
|
167
|
+
'(not overwritten). Emit one on meaningful state changes: ruling out a hypothesis, ' +
|
|
168
|
+
'completing a sub-goal, hitting a blocker, starting verification, etc. ' +
|
|
169
|
+
'Examples: "handler done, writing tests" / "permission pending on git push" / ' +
|
|
170
|
+
'"ruled out jwt.ts — secret looks right".\n' +
|
|
171
|
+
'\n' +
|
|
172
|
+
'Typical flows:\n' +
|
|
173
|
+
' Bug / debug: investigating → working → verifying → (loop or done)\n' +
|
|
174
|
+
' Feature: investigating → working → verifying → done\n' +
|
|
175
|
+
' Question: investigating → done\n' +
|
|
176
|
+
' Chore: working → verifying → done\n' +
|
|
177
|
+
'\n' +
|
|
178
|
+
'Rules:\n' +
|
|
179
|
+
'- Always call on the first response of a new session to set `subject` and `stage`.\n' +
|
|
180
|
+
'- On resume, if you cannot see a prior UpdateSessionStatus tool call in conversation ' +
|
|
181
|
+
'history, do a no-args dry-run first; then set/correct subject or stage if blank or ' +
|
|
182
|
+
'drifted from the current work.\n' +
|
|
183
|
+
'- For long-running tasks (research, large refactors), emit a `note` every time you ' +
|
|
184
|
+
'cross a sub-goal or learn something — the user opens the session to skim recent notes ' +
|
|
185
|
+
'as progress signal.\n' +
|
|
186
|
+
'- Do not skip `verifying` if you ran tests / build / repro.\n' +
|
|
187
|
+
'- Do not declare `done` until the user\'s problem is fully resolved.\n' +
|
|
188
|
+
'- For long refactors, prefer proposing to split into per-phase sub-sessions ' +
|
|
189
|
+
'over keeping one session in `investigating` for a long time.', {
|
|
190
|
+
subject: z.string().optional().describe('Subject line — what this session is solving'),
|
|
191
|
+
stage: z.enum(['investigating', 'working', 'verifying', 'done']).optional()
|
|
192
|
+
.describe('Current lifecycle stage'),
|
|
193
|
+
blocked: z.boolean().optional().describe('True when stuck, false when unblocked'),
|
|
194
|
+
note: z.string().optional()
|
|
195
|
+
.describe('One progress/finding entry (~12 words). Appended to the session event log; emit on each meaningful state change.'),
|
|
118
196
|
}, async (args) => {
|
|
119
|
-
|
|
197
|
+
const isDryRun = args.subject === undefined &&
|
|
198
|
+
args.stage === undefined &&
|
|
199
|
+
args.blocked === undefined &&
|
|
200
|
+
args.note === undefined;
|
|
201
|
+
// Daemon-side `shouldAutoApprove` has already persisted any updates by the
|
|
202
|
+
// time this handler runs, so re-reading the registry file yields the final
|
|
203
|
+
// merged state for both dry-run and write paths.
|
|
204
|
+
const snapshot = readStoredStatus();
|
|
205
|
+
const header = isDryRun
|
|
206
|
+
? (snapshot.source === 'stored' ? 'Current session status (dry-run read):' : 'No stored status for this session yet.')
|
|
207
|
+
: 'Session status updated. Current status:';
|
|
208
|
+
return {
|
|
209
|
+
content: [{
|
|
210
|
+
type: 'text',
|
|
211
|
+
text: `${header}\n${JSON.stringify(snapshot, null, 2)}`,
|
|
212
|
+
}],
|
|
213
|
+
};
|
|
120
214
|
});
|
|
121
215
|
/** Quote a string for safe use inside a bash -c argument. */
|
|
122
216
|
function shellQuote(s) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandboxMcpStdio.js","sourceRoot":"","sources":["../../src/ai/sandboxMcpStdio.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"sandboxMcpStdio.js","sourceRoot":"","sources":["../../src/ai/sandboxMcpStdio.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,YAAY,EAA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CAAC,OAAO,KAAK,SAAS;QAC1B,IAAI,CAAC,KAAK,KAAK,SAAS;QACxB,IAAI,CAAC,OAAO,KAAK,SAAS;QAC1B,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC;IAE1B,2EAA2E;IAC3E,2EAA2E;IAC3E,iDAAiD;IACjD,MAAM,QAAQ,GAAG,gBAAgB,EAAE,CAAC;IAEpC,MAAM,MAAM,GAAG,QAAQ;QACrB,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,wCAAwC,CAAC,CAAC,CAAC,wCAAwC,CAAC;QACtH,CAAC,CAAC,yCAAyC,CAAC;IAE9C,OAAO;QACL,OAAO,EAAE,CAAC;gBACR,IAAI,EAAE,MAAe;gBACrB,IAAI,EAAE,GAAG,MAAM,KAAK,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE;aACxD,CAAC;KACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,6DAA6D;AAC7D,SAAS,UAAU,CAAC,CAAS;IAC3B,OAAO,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,GAAG,CAAC;AAC9C,CAAC;AAED,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;AAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC"}
|
|
@@ -61,6 +61,10 @@ export declare class SessionManager extends EventEmitter {
|
|
|
61
61
|
/** Send a raw control_request to the active provider session (CLI only). */
|
|
62
62
|
sendControlRequest(sessionId: string, subtype: string, params?: Record<string, unknown>): Promise<unknown>;
|
|
63
63
|
closeSession(sessionId: string): boolean;
|
|
64
|
+
/** Resolve and remove every pending user-input request for a session that
|
|
65
|
+
* is going away. Used by closeSession and onSessionExited so the map
|
|
66
|
+
* doesn't leak and any awaiter unblocks with a deny. */
|
|
67
|
+
private cancelPendingInputsForSession;
|
|
64
68
|
setPermissionLevel(sessionId: string, level: PermissionLevel): Promise<boolean>;
|
|
65
69
|
getPermissionLevel(sessionId: string): PermissionLevel;
|
|
66
70
|
resolveUserInput(response: ClaudeUserInputResponsePayload): boolean;
|
|
@@ -110,8 +114,16 @@ export declare class SessionManager extends EventEmitter {
|
|
|
110
114
|
makeCallbacks(agentId: AgentId): ProviderCallbacks;
|
|
111
115
|
private handlePermissionRequest;
|
|
112
116
|
private shouldAutoApprove;
|
|
113
|
-
/**
|
|
114
|
-
|
|
117
|
+
/**
|
|
118
|
+
* Update session ticket-model status (triggered by the UpdateSessionStatus MCP tool).
|
|
119
|
+
* Partial update: only fields present in `input` are written. Unknown-typed inputs
|
|
120
|
+
* are validated here before being applied to session config / registry.
|
|
121
|
+
*
|
|
122
|
+
* `note`, when supplied, is appended to the session's `noteHistory` log in the
|
|
123
|
+
* registry (capped at SESSION_NOTE_HISTORY_CAP, oldest-first). The latest note
|
|
124
|
+
* text is also mirrored to session config / registry `note` for quick access.
|
|
125
|
+
*/
|
|
126
|
+
private updateSessionStatus;
|
|
115
127
|
/** Move per-session state from oldId to newId after the CLI forks on
|
|
116
128
|
* --resume. `sessionAgents[newId]` is already set by the caller; this
|
|
117
129
|
* helper moves the remaining side maps and clears the old key. */
|
|
@@ -123,9 +135,15 @@ export declare class SessionManager extends EventEmitter {
|
|
|
123
135
|
* a specific peer (e.g. PWA reconnect) instead of triggering a broadcast.
|
|
124
136
|
*/
|
|
125
137
|
buildSessionUpdatePayload(sessionId: string): SessionUpdatePayload;
|
|
126
|
-
/** Snapshot of every
|
|
127
|
-
*
|
|
128
|
-
*
|
|
138
|
+
/** Snapshot of every in-memory session's state (both streaming and idle —
|
|
139
|
+
* "idle" here meaning alive-between-turns / awaiting user input, i.e. the
|
|
140
|
+
* hot-resumable substate). Delivered via the bus `/sessions/active` snap
|
|
141
|
+
* frame on subscribe; subsequent incremental updates are published per
|
|
142
|
+
* session via the same path.
|
|
143
|
+
*
|
|
144
|
+
* Note: registry-only sessions (closed, never-opened this process) are
|
|
145
|
+
* intentionally NOT included here — the PWA learns about those via
|
|
146
|
+
* `/sessions/history` or the `claude:list-sessions` command instead. */
|
|
129
147
|
snapshotActiveSessions(): SessionUpdatePayload[];
|
|
130
148
|
private persistRegistryField;
|
|
131
149
|
private persistAllowPattern;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessionManager.d.ts","sourceRoot":"","sources":["../../src/ai/sessionManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAGtC,OAAO,KAAK,EACV,OAAO,EACP,oBAAoB,EACpB,6BAA6B,EAC7B,8BAA8B,EAC9B,iBAAiB,EACjB,WAAW,EAEX,mBAAmB,
|
|
1
|
+
{"version":3,"file":"sessionManager.d.ts","sourceRoot":"","sources":["../../src/ai/sessionManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAGtC,OAAO,KAAK,EACV,OAAO,EACP,oBAAoB,EACpB,6BAA6B,EAC7B,8BAA8B,EAC9B,iBAAiB,EACjB,WAAW,EAEX,mBAAmB,EAKnB,oBAAoB,EACrB,MAAM,2BAA2B,CAAC;AAOnC,OAAO,EAAE,iBAAiB,EAA6C,MAAM,kBAAkB,CAAC;AAIhG,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,eAAe,CAAC;AA6DvB,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,EAAE,eAAe,GAAG,IAAI,CAAC;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,OAAO,CAAC;IACnB,eAAe,EAAE,eAAe,CAAC;IACjC,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACtC,yGAAyG;IACzG,YAAY,CAAC,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