@raindrop-ai/wizard 0.0.12 → 0.0.13

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.
@@ -0,0 +1,75 @@
1
+ ---
2
+ title: OpenCode (Beta)
3
+ description: >-
4
+ Reference for integrating Raindrop with OpenCode.
5
+ ---
6
+
7
+ The `@raindrop-ai/opencode-plugin` plugin instruments
8
+ [OpenCode](https://opencode.ai) coding sessions. Every session, message, tool
9
+ call, and LLM response is automatically captured in Raindrop — no per-call
10
+ instrumentation needed.
11
+
12
+ <Note>
13
+ User tracking is not currently supported in beta. This integration assumes one
14
+ user per session.
15
+ </Note>
16
+
17
+ ## Installation
18
+
19
+ Add the plugin to your OpenCode configuration (`opencode.json` or
20
+ `~/.config/opencode/opencode.json`).
21
+
22
+ ```json
23
+ {
24
+ "plugin": ["@raindrop-ai/opencode-plugin"]
25
+ }
26
+ ```
27
+
28
+ If your project dynamically generates an `opencode.json` (for example, using
29
+ `createOpencodeDotJson` or a similar method) because each user receives their
30
+ own sandbox, make sure to include `@raindrop-ai/opencode-plugin` in the `plugin`
31
+ array of the generated configuration. This ensures the Raindrop plugin is
32
+ enabled for every sandbox.
33
+
34
+ ## Quick Start
35
+
36
+ 1. Add the plugin to your OpenCode config (above).
37
+ 2. Set your write key:
38
+
39
+ ```bash
40
+ export RAINDROP_WRITE_KEY="your-write-key"
41
+ ```
42
+
43
+ 3. Start OpenCode — sessions are now automatically traced to Raindrop.
44
+
45
+ Every session you start will appear in your Raindrop dashboard with turn-by-turn
46
+ input/output, tool spans, and LLM metadata.
47
+
48
+ ---
49
+
50
+ ## Configuration
51
+
52
+ ### Environment Variables
53
+
54
+ Export your Raindrop write key:
55
+
56
+ ```bash
57
+ export RAINDROP_WRITE_KEY="your-write-key"
58
+ ```
59
+
60
+ ---
61
+
62
+ ## Troubleshooting
63
+
64
+ ### Sessions not appearing in dashboard
65
+
66
+ 1. **Check your write key** — Ensure `RAINDROP_WRITE_KEY` is set in the
67
+ environment where OpenCode runs
68
+ 2. **Confirm the plugin loaded** — Check OpenCode's logs for
69
+ `Raindrop tracing enabled` or a `RAINDROP_WRITE_KEY not set` warning
70
+ 3. **Enable debug logging** — Run with `RAINDROP_DEBUG=true` to see what's being
71
+ shipped
72
+
73
+ ---
74
+
75
+ Use the Raindrop dashboard to verify events and traces after your first session.
@@ -17,22 +17,24 @@ const DOCS_FILE_BY_INTEGRATION_TYPE = {
17
17
  'vercel-ai-sdk': 'vercel-ai-sdk.mdx',
18
18
  browser: 'browser.mdx',
19
19
  'claude-agent-sdk': 'claude-agent-sdk.mdx',
20
- 'opencode-sdk': 'opencode-sdk.mdx',
20
+ 'opencode-plugin': 'opencode.mdx',
21
21
  };
22
22
  const INTEGRATION_TYPE_ALIASES = {
23
23
  'typescript sdk': 'typescript',
24
- 'typescript_sdk': 'typescript',
24
+ typescript_sdk: 'typescript',
25
25
  'browser sdk': 'browser',
26
- 'browser_sdk': 'browser',
26
+ browser_sdk: 'browser',
27
27
  'edge runtime': 'browser',
28
28
  'edge-runtime': 'browser',
29
29
  'vercel ai sdk': 'vercel-ai-sdk',
30
- 'vercel_ai_sdk': 'vercel-ai-sdk',
30
+ vercel_ai_sdk: 'vercel-ai-sdk',
31
31
  'claude agent sdk': 'claude-agent-sdk',
32
- 'claude_agent_sdk': 'claude-agent-sdk',
33
- 'opencode sdk': 'opencode-sdk',
34
- 'opencode ai sdk': 'opencode-sdk',
35
- 'opencode_ai_sdk': 'opencode-sdk',
32
+ claude_agent_sdk: 'claude-agent-sdk',
33
+ 'opencode sdk': 'opencode-plugin',
34
+ 'opencode ai sdk': 'opencode-plugin',
35
+ opencode_ai_sdk: 'opencode-plugin',
36
+ opencode_plugin: 'opencode-plugin',
37
+ 'opencode-sdk': 'opencode-plugin',
36
38
  };
37
39
  const SUPPORTED_INTEGRATION_TYPES = Object.keys(DOCS_FILE_BY_INTEGRATION_TYPE);
38
40
  function normalizeIntegrationType(integrationType) {
@@ -64,7 +66,7 @@ export function createMcpServer(hasCompletedWorkRef, sessionContext) {
64
66
  integrationType: z
65
67
  .string()
66
68
  .optional()
67
- .describe('The integration type to load docs for: python, typescript, vercel-ai-sdk, browser, claude-agent-sdk, or opencode-sdk'),
69
+ .describe('The integration type to load docs for: python, typescript, vercel-ai-sdk, browser, claude-agent-sdk, or opencode-plugin'),
68
70
  interactionType: z
69
71
  .string()
70
72
  .optional()
@@ -104,7 +106,7 @@ export function createMcpServer(hasCompletedWorkRef, sessionContext) {
104
106
  integrationType: z
105
107
  .string()
106
108
  .optional()
107
- .describe('The detected integration type: python, typescript, vercel-ai-sdk, browser, claude-agent-sdk, or opencode-sdk'),
109
+ .describe('The detected integration type: python, typescript, vercel-ai-sdk, browser, claude-agent-sdk, or opencode-plugin'),
108
110
  interactionType: z
109
111
  .string()
110
112
  .optional()
@@ -125,7 +127,7 @@ export function createMcpServer(hasCompletedWorkRef, sessionContext) {
125
127
  normalizedIntegrationType === 'vercel-ai-sdk' ||
126
128
  normalizedIntegrationType === 'browser' ||
127
129
  normalizedIntegrationType === 'claude-agent-sdk' ||
128
- normalizedIntegrationType === 'opencode-sdk') {
130
+ normalizedIntegrationType === 'opencode-plugin') {
129
131
  details = await collectTypeScriptSetupDetails(sessionContext.installDir);
130
132
  }
131
133
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../../src/lib/mcp.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MA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FAAkF;qBACzF;iBACF;aACF,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;IAEF,OAAO,kBAAkB,CAAC;QACxB,IAAI,EAAE,iBAAiB;QACvB,OAAO,EAAE,OAAO;QAChB,KAAK,EAAE,CAAC,cAAc,EAAE,qBAAqB,EAAE,qBAAqB,CAAC;KACtE,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * MCP server utilities for the Claude agent\n */\n\nimport { createSdkMcpServer, tool } from '@anthropic-ai/claude-agent-sdk';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { fileURLToPath } from 'url';\nimport { z } from 'zod';\nimport { logToFile } from '../utils/debug.js';\nimport { sendSessionInit } from '../utils/session.js';\nimport {\n collectPythonSetupDetails,\n collectTypeScriptSetupDetails,\n type SetupDetail,\n} from './config.js';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nconst DOCS_FILE_BY_INTEGRATION_TYPE = {\n python: 'python.mdx',\n typescript: 'typescript.mdx',\n 'vercel-ai-sdk': 'vercel-ai-sdk.mdx',\n browser: 'browser.mdx',\n 'claude-agent-sdk': 'claude-agent-sdk.mdx',\n 'opencode-sdk': 'opencode-sdk.mdx',\n} as const;\n\ntype SupportedIntegrationType = keyof typeof DOCS_FILE_BY_INTEGRATION_TYPE;\n\nconst INTEGRATION_TYPE_ALIASES: Record<string, SupportedIntegrationType> = {\n 'typescript sdk': 'typescript',\n 'typescript_sdk': 'typescript',\n 'browser sdk': 'browser',\n 'browser_sdk': 'browser',\n 'edge runtime': 'browser',\n 'edge-runtime': 'browser',\n 'vercel ai sdk': 'vercel-ai-sdk',\n 'vercel_ai_sdk': 'vercel-ai-sdk',\n 'claude agent sdk': 'claude-agent-sdk',\n 'claude_agent_sdk': 'claude-agent-sdk',\n 'opencode sdk': 'opencode-sdk',\n 'opencode ai sdk': 'opencode-sdk',\n 'opencode_ai_sdk': 'opencode-sdk',\n};\n\nconst SUPPORTED_INTEGRATION_TYPES = Object.keys(\n DOCS_FILE_BY_INTEGRATION_TYPE,\n) as SupportedIntegrationType[];\n\nfunction normalizeIntegrationType(\n integrationType: string,\n): SupportedIntegrationType | null {\n const normalized = integrationType.trim().toLowerCase();\n if (normalized in DOCS_FILE_BY_INTEGRATION_TYPE) {\n return normalized as SupportedIntegrationType;\n }\n return INTEGRATION_TYPE_ALIASES[normalized] ?? null;\n}\n\n/**\n * Create an in-process MCP server with the CompleteIntegration tool\n */\nexport function createMcpServer(\n hasCompletedWorkRef: {\n value: boolean;\n },\n sessionContext: {\n sessionId: string;\n accessToken: string;\n orgId: string;\n installDir: string;\n },\n): any {\n const completionTool = tool(\n 'CompleteIntegration',\n 'Signals that the Raindrop integration is complete. Call this tool ONLY after you have confirmed that: 1) the Raindrop package is successfully installed, 2) Raindrop is integrated into user-facing AI features, and 3) Verified the project builds/runs without errors.',\n {}, // No input parameters\n (_args: Record<string, never>, _extra: unknown): any => {\n logToFile(\n 'Agent called CompleteIntegration tool - integration is complete',\n );\n\n // Set the completion flag\n hasCompletedWorkRef.value = true;\n\n return {\n content: [\n {\n type: 'text',\n text: 'Integration completion acknowledged. Transitioning to testing phase...',\n },\n ],\n };\n },\n );\n\n const loadDocumentationTool = tool(\n 'LoadDocumentation',\n 'Load Raindrop documentation for a specific integration type',\n {\n integrationType: z\n .string()\n .optional()\n .describe(\n 'The integration type to load docs for: python, typescript, vercel-ai-sdk, browser, claude-agent-sdk, or opencode-sdk',\n ),\n interactionType: z\n .string()\n .optional()\n .describe('Alias for integrationType for backward compatibility'),\n },\n async (\n args: { integrationType?: string; interactionType?: string },\n _extra: unknown,\n ): Promise<any> => {\n const requestedIntegrationType =\n args.integrationType || args.interactionType;\n if (!requestedIntegrationType) {\n return {\n content: [\n {\n type: 'text',\n text: `Missing integration type. Supported values: ${SUPPORTED_INTEGRATION_TYPES.join(\n ', ',\n )}`,\n },\n ],\n };\n }\n\n const normalizedIntegrationType = normalizeIntegrationType(\n requestedIntegrationType,\n );\n if (!normalizedIntegrationType) {\n return {\n content: [\n {\n type: 'text',\n text: `Unsupported integration type: ${requestedIntegrationType}. Supported values: ${SUPPORTED_INTEGRATION_TYPES.join(\n ', ',\n )}`,\n },\n ],\n };\n }\n\n const docsPath = path.resolve(\n __dirname,\n '../../src/docs',\n DOCS_FILE_BY_INTEGRATION_TYPE[normalizedIntegrationType],\n );\n logToFile(`Loading ${normalizedIntegrationType} docs from: ${docsPath}`);\n const docs = await fs.promises.readFile(docsPath, 'utf-8');\n const processedDocs = docs.replace(\n /__WIZARD_SESSION_UUID__/g,\n sessionContext.sessionId,\n );\n return {\n content: [{ type: 'text', text: processedDocs }],\n };\n },\n );\n\n const initializeSessionTool = tool(\n 'InitializeSession',\n 'Initialize session context for the integration. Call this immediately after confirming the integration type with the user and BEFORE loading documentation.',\n {\n integrationType: z\n .string()\n .optional()\n .describe(\n 'The detected integration type: python, typescript, vercel-ai-sdk, browser, claude-agent-sdk, or opencode-sdk',\n ),\n interactionType: z\n .string()\n .optional()\n .describe('Alias for integrationType for backward compatibility'),\n },\n async (\n args: { integrationType?: string; interactionType?: string },\n _extra: unknown,\n ): Promise<any> => {\n const requestedIntegrationType =\n args.integrationType || args.interactionType;\n logToFile(\n `InitializeSession called with integrationType: ${requestedIntegrationType}`,\n );\n\n try {\n // Collect setup details based on integration type\n let details: SetupDetail[] = [];\n const normalizedIntegrationType = requestedIntegrationType\n ? normalizeIntegrationType(requestedIntegrationType)\n : null;\n\n if (normalizedIntegrationType === 'python') {\n details = await collectPythonSetupDetails(sessionContext.installDir);\n } else if (\n normalizedIntegrationType === 'typescript' ||\n normalizedIntegrationType === 'vercel-ai-sdk' ||\n normalizedIntegrationType === 'browser' ||\n normalizedIntegrationType === 'claude-agent-sdk' ||\n normalizedIntegrationType === 'opencode-sdk'\n ) {\n details = await collectTypeScriptSetupDetails(\n sessionContext.installDir,\n );\n } else {\n logToFile(\n `Unknown or missing integration type: ${requestedIntegrationType}, defaulting to TypeScript setup details`,\n );\n details = await collectTypeScriptSetupDetails(\n sessionContext.installDir,\n );\n }\n\n // Format setup details into the expected string format\n const compiledSetup = details\n .map((d) => `=== ${d.filename} ===\\n${d.content}`)\n .join('\\n\\n');\n\n logToFile(\n `Collected ${details.length} setup details, total length: ${compiledSetup.length}`,\n );\n\n // Send session init with the setup details\n sendSessionInit(\n sessionContext.sessionId,\n compiledSetup,\n sessionContext.accessToken,\n sessionContext.orgId,\n );\n\n logToFile('InitializeSession completed successfully');\n\n return {\n content: [\n {\n type: 'text',\n text: 'Session initialized successfully. You may now proceed to load documentation.',\n },\n ],\n };\n } catch (error) {\n // Log error but still return success to allow wizard to continue\n logToFile('Error in InitializeSession:', error);\n\n // Still send session init with minimal details\n sendSessionInit(\n sessionContext.sessionId,\n '',\n sessionContext.accessToken,\n sessionContext.orgId,\n );\n\n return {\n content: [\n {\n type: 'text',\n text: 'Session initialized with partial details. You may proceed to load documentation.',\n },\n ],\n };\n }\n },\n );\n\n return createSdkMcpServer({\n name: 'raindrop-wizard',\n version: '1.0.0',\n tools: [completionTool, loadDocumentationTool, initializeSessionTool],\n });\n}\n"]}
1
+ {"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../../src/lib/mcp.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EACL,yBAAyB,EACzB,6BAA6B,GAE9B,MAAM,aAAa,CAAC;AAErB,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAA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AAO,kBAAkB,CAAC;QACxB,IAAI,EAAE,iBAAiB;QACvB,OAAO,EAAE,OAAO;QAChB,KAAK,EAAE,CAAC,cAAc,EAAE,qBAAqB,EAAE,qBAAqB,CAAC;KACtE,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * MCP server utilities for the Claude agent\n */\n\nimport { createSdkMcpServer, tool } from '@anthropic-ai/claude-agent-sdk';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { fileURLToPath } from 'url';\nimport { z } from 'zod';\nimport { logToFile } from '../utils/debug.js';\nimport { sendSessionInit } from '../utils/session.js';\nimport {\n collectPythonSetupDetails,\n collectTypeScriptSetupDetails,\n type SetupDetail,\n} from './config.js';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nconst DOCS_FILE_BY_INTEGRATION_TYPE = {\n python: 'python.mdx',\n typescript: 'typescript.mdx',\n 'vercel-ai-sdk': 'vercel-ai-sdk.mdx',\n browser: 'browser.mdx',\n 'claude-agent-sdk': 'claude-agent-sdk.mdx',\n 'opencode-plugin': 'opencode.mdx',\n} as const;\n\ntype SupportedIntegrationType = keyof typeof DOCS_FILE_BY_INTEGRATION_TYPE;\n\nconst INTEGRATION_TYPE_ALIASES: Record<string, SupportedIntegrationType> = {\n 'typescript sdk': 'typescript',\n typescript_sdk: 'typescript',\n 'browser sdk': 'browser',\n browser_sdk: 'browser',\n 'edge runtime': 'browser',\n 'edge-runtime': 'browser',\n 'vercel ai sdk': 'vercel-ai-sdk',\n vercel_ai_sdk: 'vercel-ai-sdk',\n 'claude agent sdk': 'claude-agent-sdk',\n claude_agent_sdk: 'claude-agent-sdk',\n 'opencode sdk': 'opencode-plugin',\n 'opencode ai sdk': 'opencode-plugin',\n opencode_ai_sdk: 'opencode-plugin',\n opencode_plugin: 'opencode-plugin',\n 'opencode-sdk': 'opencode-plugin',\n};\n\nconst SUPPORTED_INTEGRATION_TYPES = Object.keys(\n DOCS_FILE_BY_INTEGRATION_TYPE,\n) as SupportedIntegrationType[];\n\nfunction normalizeIntegrationType(\n integrationType: string,\n): SupportedIntegrationType | null {\n const normalized = integrationType.trim().toLowerCase();\n if (normalized in DOCS_FILE_BY_INTEGRATION_TYPE) {\n return normalized as SupportedIntegrationType;\n }\n return INTEGRATION_TYPE_ALIASES[normalized] ?? null;\n}\n\n/**\n * Create an in-process MCP server with the CompleteIntegration tool\n */\nexport function createMcpServer(\n hasCompletedWorkRef: {\n value: boolean;\n },\n sessionContext: {\n sessionId: string;\n accessToken: string;\n orgId: string;\n installDir: string;\n },\n): any {\n const completionTool = tool(\n 'CompleteIntegration',\n 'Signals that the Raindrop integration is complete. Call this tool ONLY after you have confirmed that: 1) the Raindrop package is successfully installed, 2) Raindrop is integrated into user-facing AI features, and 3) Verified the project builds/runs without errors.',\n {}, // No input parameters\n (_args: Record<string, never>, _extra: unknown): any => {\n logToFile(\n 'Agent called CompleteIntegration tool - integration is complete',\n );\n\n // Set the completion flag\n hasCompletedWorkRef.value = true;\n\n return {\n content: [\n {\n type: 'text',\n text: 'Integration completion acknowledged. Transitioning to testing phase...',\n },\n ],\n };\n },\n );\n\n const loadDocumentationTool = tool(\n 'LoadDocumentation',\n 'Load Raindrop documentation for a specific integration type',\n {\n integrationType: z\n .string()\n .optional()\n .describe(\n 'The integration type to load docs for: python, typescript, vercel-ai-sdk, browser, claude-agent-sdk, or opencode-plugin',\n ),\n interactionType: z\n .string()\n .optional()\n .describe('Alias for integrationType for backward compatibility'),\n },\n async (\n args: { integrationType?: string; interactionType?: string },\n _extra: unknown,\n ): Promise<any> => {\n const requestedIntegrationType =\n args.integrationType || args.interactionType;\n if (!requestedIntegrationType) {\n return {\n content: [\n {\n type: 'text',\n text: `Missing integration type. Supported values: ${SUPPORTED_INTEGRATION_TYPES.join(\n ', ',\n )}`,\n },\n ],\n };\n }\n\n const normalizedIntegrationType = normalizeIntegrationType(\n requestedIntegrationType,\n );\n if (!normalizedIntegrationType) {\n return {\n content: [\n {\n type: 'text',\n text: `Unsupported integration type: ${requestedIntegrationType}. Supported values: ${SUPPORTED_INTEGRATION_TYPES.join(\n ', ',\n )}`,\n },\n ],\n };\n }\n\n const docsPath = path.resolve(\n __dirname,\n '../../src/docs',\n DOCS_FILE_BY_INTEGRATION_TYPE[normalizedIntegrationType],\n );\n logToFile(`Loading ${normalizedIntegrationType} docs from: ${docsPath}`);\n const docs = await fs.promises.readFile(docsPath, 'utf-8');\n const processedDocs = docs.replace(\n /__WIZARD_SESSION_UUID__/g,\n sessionContext.sessionId,\n );\n return {\n content: [{ type: 'text', text: processedDocs }],\n };\n },\n );\n\n const initializeSessionTool = tool(\n 'InitializeSession',\n 'Initialize session context for the integration. Call this immediately after confirming the integration type with the user and BEFORE loading documentation.',\n {\n integrationType: z\n .string()\n .optional()\n .describe(\n 'The detected integration type: python, typescript, vercel-ai-sdk, browser, claude-agent-sdk, or opencode-plugin',\n ),\n interactionType: z\n .string()\n .optional()\n .describe('Alias for integrationType for backward compatibility'),\n },\n async (\n args: { integrationType?: string; interactionType?: string },\n _extra: unknown,\n ): Promise<any> => {\n const requestedIntegrationType =\n args.integrationType || args.interactionType;\n logToFile(\n `InitializeSession called with integrationType: ${requestedIntegrationType}`,\n );\n\n try {\n // Collect setup details based on integration type\n let details: SetupDetail[] = [];\n const normalizedIntegrationType = requestedIntegrationType\n ? normalizeIntegrationType(requestedIntegrationType)\n : null;\n\n if (normalizedIntegrationType === 'python') {\n details = await collectPythonSetupDetails(sessionContext.installDir);\n } else if (\n normalizedIntegrationType === 'typescript' ||\n normalizedIntegrationType === 'vercel-ai-sdk' ||\n normalizedIntegrationType === 'browser' ||\n normalizedIntegrationType === 'claude-agent-sdk' ||\n normalizedIntegrationType === 'opencode-plugin'\n ) {\n details = await collectTypeScriptSetupDetails(\n sessionContext.installDir,\n );\n } else {\n logToFile(\n `Unknown or missing integration type: ${requestedIntegrationType}, defaulting to TypeScript setup details`,\n );\n details = await collectTypeScriptSetupDetails(\n sessionContext.installDir,\n );\n }\n\n // Format setup details into the expected string format\n const compiledSetup = details\n .map((d) => `=== ${d.filename} ===\\n${d.content}`)\n .join('\\n\\n');\n\n logToFile(\n `Collected ${details.length} setup details, total length: ${compiledSetup.length}`,\n );\n\n // Send session init with the setup details\n sendSessionInit(\n sessionContext.sessionId,\n compiledSetup,\n sessionContext.accessToken,\n sessionContext.orgId,\n );\n\n logToFile('InitializeSession completed successfully');\n\n return {\n content: [\n {\n type: 'text',\n text: 'Session initialized successfully. You may now proceed to load documentation.',\n },\n ],\n };\n } catch (error) {\n // Log error but still return success to allow wizard to continue\n logToFile('Error in InitializeSession:', error);\n\n // Still send session init with minimal details\n sendSessionInit(\n sessionContext.sessionId,\n '',\n sessionContext.accessToken,\n sessionContext.orgId,\n );\n\n return {\n content: [\n {\n type: 'text',\n text: 'Session initialized with partial details. You may proceed to load documentation.',\n },\n ],\n };\n }\n },\n );\n\n return createSdkMcpServer({\n name: 'raindrop-wizard',\n version: '1.0.0',\n tools: [completionTool, loadDocumentationTool, initializeSessionTool],\n });\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raindrop-ai/wizard",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "type": "module",
5
5
  "homepage": "https://github.com/raindrop/wizard",
6
6
  "repository": "https://github.com/raindrop/wizard",