@omercnet/paseo-context-mode 2.0.0 → 2.0.1-next.254.1

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 CHANGED
@@ -22,7 +22,7 @@ These previews were captured from an isolated Paseo test daemon with Context Mod
22
22
 
23
23
  - Bundles Context Mode as a runtime dependency; a separately installed global executable remains optional.
24
24
  - Resolves a configured absolute executable first, then the daemon's `PATH`, then the bundled runtime.
25
- - Shows Context Mode version, structured diagnostics, provider activation, storage roots, lifetime savings, activity, categories, and indexed sources. Savings lists the built-in harness storage plus the storage of every provider configured in Paseo (including ones derived with `extends`), the latter under its Paseo provider id and the root its own `env` resolves to. `ctx_stats` and the Setup tab report the daemon's storage only.
25
+ - Shows Context Mode version, structured diagnostics, provider activation, storage roots, lifetime savings, activity, categories, and indexed sources. Savings lists the built-in harness storage plus the storage of every provider configured in Paseo (including ones derived with `extends`), the latter under its Paseo provider id and the root its own `env` resolves to. `ctx_stats` and the Setup tab run against a plugin-owned probe store (`<PASEO_HOME>/plugin-data/context-mode/probe`) so they never write into a provider root; it starts empty.
26
26
  - Reads Context Mode 1.0.169 SQLite databases in query-only mode, honors active WAL state, isolates corrupt databases, and reports partial coverage instead of mutating schemas.
27
27
  - Injects the bundled stdio MCP server into new supported agents through Paseo's `agent.create` hook.
28
28
  - Injects provider identity and an existing provider-specific storage root on create, resume, refresh, and import.
@@ -20,14 +20,22 @@ export function parseScreenParams(params: Record<string, string>): ScreenParams
20
20
  };
21
21
  }
22
22
 
23
+ // Screen params survive the host switcher and shared links, so the id may belong to another host.
24
+ function notOnThisHost(kind: "agent" | "workspace"): KnowledgeScope {
25
+ return {
26
+ provider: null,
27
+ projectPath: "",
28
+ note: `The ${kind} this screen was opened from is not on this host. Select a provider and project.`,
29
+ };
30
+ }
31
+
23
32
  export async function resolveKnowledgeScope(
24
33
  paseo: PaseoApi,
25
34
  params: ScreenParams,
26
35
  ): Promise<KnowledgeScope> {
27
36
  if (params.agentId) {
28
37
  const result = await paseo.agents.ref(params.agentId).refresh();
29
- if (!result)
30
- throw new Error("Agent not found on this host. Select a provider and project explicitly.");
38
+ if (!result) return notOnThisHost("agent");
31
39
  if (params.workspaceId && result.agent.workspaceId !== params.workspaceId) {
32
40
  throw new Error(
33
41
  "Agent no longer belongs to this workspace. Select a provider and project explicitly.",
@@ -38,8 +46,7 @@ export async function resolveKnowledgeScope(
38
46
  const workspace = params.workspaceId
39
47
  ? await paseo.workspaces.ref(params.workspaceId).refresh()
40
48
  : null;
41
- if (!workspace)
42
- throw new Error("Workspace not found on this host. Select a provider and project explicitly.");
49
+ if (!workspace) return notOnThisHost("workspace");
43
50
  return {
44
51
  provider: null,
45
52
  projectPath: workspace.workspaceDirectory,
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@omercnet/paseo-context-mode",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@omercnet/paseo-context-mode",
9
- "version": "2.0.0",
9
+ "version": "2.0.1",
10
10
  "dependencies": {
11
11
  "context-mode": "1.0.169"
12
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omercnet/paseo-context-mode",
3
- "version": "2.0.0",
3
+ "version": "2.0.1-next.254.1",
4
4
  "type": "module",
5
5
  "description": "Provider-aware Context Mode health, savings, and MCP activation for Paseo.",
6
6
  "license": "MIT",
@@ -1,3 +1,5 @@
1
+ import { homedir } from "node:os";
2
+ import { join } from "node:path";
1
3
  import type { PluginSettings } from "@getpaseo/plugin/server";
2
4
  import type {
3
5
  BinaryStatus,
@@ -25,11 +27,29 @@ type SettingsHandle = PluginSettings<typeof contextModeSettings.schema>;
25
27
  type ToolName = "ctx_doctor" | "ctx_stats";
26
28
  type FailureReport = Extract<CommandReport, { state: "unavailable" }>;
27
29
 
30
+ interface ProbeOptions {
31
+ env: NodeJS.ProcessEnv;
32
+ }
33
+
34
+ /**
35
+ * Panel probes belong to no provider. Without an explicit storage root Context Mode falls back to
36
+ * whichever provider config directory exists, and writes its sidecar and content store there.
37
+ */
38
+ function contextModeProbeOptions(env: NodeJS.ProcessEnv = process.env): ProbeOptions {
39
+ const home = env.PASEO_HOME?.trim() || join(homedir(), ".paseo");
40
+ return { env: { CONTEXT_MODE_DIR: join(home, "plugin-data", "context-mode", "probe") } };
41
+ }
42
+
28
43
  export interface ContextModeHandlerDependencies {
29
44
  now?: () => Date;
30
45
  resolveBinary?: (settings: ContextModeSettings) => Promise<BinaryResolution>;
31
- inspect?: (launch: LaunchDescriptor) => Promise<McpInspection>;
32
- callTool?: (launch: LaunchDescriptor, name: ToolName) => Promise<string>;
46
+ inspect?: (launch: LaunchDescriptor, options: ProbeOptions) => Promise<McpInspection>;
47
+ callTool?: (
48
+ launch: LaunchDescriptor,
49
+ name: ToolName,
50
+ arguments_: Record<string, never>,
51
+ options: ProbeOptions,
52
+ ) => Promise<string>;
33
53
  createAudit?: (
34
54
  settings: ContextModeSettings,
35
55
  runtime: { path: string; version: string | null },
@@ -71,6 +91,7 @@ export function createContextModeHandlers(
71
91
  const callTool = dependencies.callTool ?? callContextModeTool;
72
92
  const buildAudit = dependencies.createAudit ?? createIntegrationAudit;
73
93
  const cache = new Map<string, CacheEntry<BinaryStatus | CommandReport>>();
94
+ const probe = contextModeProbeOptions();
74
95
 
75
96
  async function settingsAndBinary(): Promise<
76
97
  | {
@@ -145,7 +166,7 @@ export function createContextModeHandlers(
145
166
  return cached(cacheKey, 10_000, fresh, async () => {
146
167
  const checkedAt = now().toISOString();
147
168
  try {
148
- const inspection = await inspect(resolved.binary.launch);
169
+ const inspection = await inspect(resolved.binary.launch, probe);
149
170
  return {
150
171
  state: "ready",
151
172
  binaryPath: resolved.binary.path,
@@ -170,7 +191,7 @@ export function createContextModeHandlers(
170
191
  return {
171
192
  state: "ready",
172
193
  binaryPath: resolved.binary.path,
173
- output: await callTool(resolved.binary.launch, name),
194
+ output: await callTool(resolved.binary.launch, name, {}, probe),
174
195
  checkedAt,
175
196
  };
176
197
  } catch (error) {
@@ -193,7 +214,7 @@ export function createContextModeHandlers(
193
214
  checkedAt: resolved.report.checkedAt,
194
215
  };
195
216
  }
196
- const inspection = await inspect(resolved.binary.launch).catch(() => ({
217
+ const inspection = await inspect(resolved.binary.launch, probe).catch(() => ({
197
218
  version: null,
198
219
  tools: [],
199
220
  }));