@raindrop-ai/wizard 0.0.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/LICENSE +47 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +117 -0
- package/dist/bin.js.map +1 -0
- package/dist/src/docs/browser.md +105 -0
- package/dist/src/docs/python.md +618 -0
- package/dist/src/docs/typescript.md +584 -0
- package/dist/src/docs/vercel-ai-sdk.md +304 -0
- package/dist/src/lib/agent-interface.d.ts +46 -0
- package/dist/src/lib/agent-interface.js +292 -0
- package/dist/src/lib/agent-interface.js.map +1 -0
- package/dist/src/lib/agent-prompts.d.ts +10 -0
- package/dist/src/lib/agent-prompts.js +49 -0
- package/dist/src/lib/agent-prompts.js.map +1 -0
- package/dist/src/lib/config.d.ts +39 -0
- package/dist/src/lib/config.js +549 -0
- package/dist/src/lib/config.js.map +1 -0
- package/dist/src/lib/constants.d.ts +27 -0
- package/dist/src/lib/constants.js +165 -0
- package/dist/src/lib/constants.js.map +1 -0
- package/dist/src/lib/handlers.d.ts +68 -0
- package/dist/src/lib/handlers.js +420 -0
- package/dist/src/lib/handlers.js.map +1 -0
- package/dist/src/lib/integration-testing.d.ts +44 -0
- package/dist/src/lib/integration-testing.js +123 -0
- package/dist/src/lib/integration-testing.js.map +1 -0
- package/dist/src/lib/mcp.d.ts +14 -0
- package/dist/src/lib/mcp.js +134 -0
- package/dist/src/lib/mcp.js.map +1 -0
- package/dist/src/lib/sdk-messages.d.ts +17 -0
- package/dist/src/lib/sdk-messages.js +278 -0
- package/dist/src/lib/sdk-messages.js.map +1 -0
- package/dist/src/lib/wizard.d.ts +6 -0
- package/dist/src/lib/wizard.js +131 -0
- package/dist/src/lib/wizard.js.map +1 -0
- package/dist/src/run.d.ts +8 -0
- package/dist/src/run.js +53 -0
- package/dist/src/run.js.map +1 -0
- package/dist/src/ui/App.d.ts +15 -0
- package/dist/src/ui/App.js +27 -0
- package/dist/src/ui/App.js.map +1 -0
- package/dist/src/ui/cancellation.d.ts +14 -0
- package/dist/src/ui/cancellation.js +17 -0
- package/dist/src/ui/cancellation.js.map +1 -0
- package/dist/src/ui/components/ClarifyingQuestionsPrompt.d.ts +17 -0
- package/dist/src/ui/components/ClarifyingQuestionsPrompt.js +359 -0
- package/dist/src/ui/components/ClarifyingQuestionsPrompt.js.map +1 -0
- package/dist/src/ui/components/ContinuePrompt.d.ts +14 -0
- package/dist/src/ui/components/ContinuePrompt.js +23 -0
- package/dist/src/ui/components/ContinuePrompt.js.map +1 -0
- package/dist/src/ui/components/DiffDisplay.d.ts +18 -0
- package/dist/src/ui/components/DiffDisplay.js +110 -0
- package/dist/src/ui/components/DiffDisplay.js.map +1 -0
- package/dist/src/ui/components/FeedbackSelectPrompt.d.ts +20 -0
- package/dist/src/ui/components/FeedbackSelectPrompt.js +132 -0
- package/dist/src/ui/components/FeedbackSelectPrompt.js.map +1 -0
- package/dist/src/ui/components/HistoryItemDisplay.d.ts +14 -0
- package/dist/src/ui/components/HistoryItemDisplay.js +140 -0
- package/dist/src/ui/components/HistoryItemDisplay.js.map +1 -0
- package/dist/src/ui/components/Logo.d.ts +10 -0
- package/dist/src/ui/components/Logo.js +47 -0
- package/dist/src/ui/components/Logo.js.map +1 -0
- package/dist/src/ui/components/OrgInfoBox.d.ts +11 -0
- package/dist/src/ui/components/OrgInfoBox.js +16 -0
- package/dist/src/ui/components/OrgInfoBox.js.map +1 -0
- package/dist/src/ui/components/PendingPrompt.d.ts +18 -0
- package/dist/src/ui/components/PendingPrompt.js +57 -0
- package/dist/src/ui/components/PendingPrompt.js.map +1 -0
- package/dist/src/ui/components/PersistentTextInput.d.ts +21 -0
- package/dist/src/ui/components/PersistentTextInput.js +117 -0
- package/dist/src/ui/components/PersistentTextInput.js.map +1 -0
- package/dist/src/ui/components/PlanApprovalPrompt.d.ts +19 -0
- package/dist/src/ui/components/PlanApprovalPrompt.js +62 -0
- package/dist/src/ui/components/PlanApprovalPrompt.js.map +1 -0
- package/dist/src/ui/components/PromptContainer.d.ts +14 -0
- package/dist/src/ui/components/PromptContainer.js +18 -0
- package/dist/src/ui/components/PromptContainer.js.map +1 -0
- package/dist/src/ui/components/SelectPrompt.d.ts +14 -0
- package/dist/src/ui/components/SelectPrompt.js +62 -0
- package/dist/src/ui/components/SelectPrompt.js.map +1 -0
- package/dist/src/ui/components/SpinnerDisplay.d.ts +13 -0
- package/dist/src/ui/components/SpinnerDisplay.js +11 -0
- package/dist/src/ui/components/SpinnerDisplay.js.map +1 -0
- package/dist/src/ui/components/ToolApprovalPrompt.d.ts +14 -0
- package/dist/src/ui/components/ToolApprovalPrompt.js +142 -0
- package/dist/src/ui/components/ToolApprovalPrompt.js.map +1 -0
- package/dist/src/ui/components/ToolCallDisplay.d.ts +14 -0
- package/dist/src/ui/components/ToolCallDisplay.js +83 -0
- package/dist/src/ui/components/ToolCallDisplay.js.map +1 -0
- package/dist/src/ui/components/WriteKeyDisplay.d.ts +15 -0
- package/dist/src/ui/components/WriteKeyDisplay.js +13 -0
- package/dist/src/ui/components/WriteKeyDisplay.js.map +1 -0
- package/dist/src/ui/contexts/WizardContext.d.ts +210 -0
- package/dist/src/ui/contexts/WizardContext.js +362 -0
- package/dist/src/ui/contexts/WizardContext.js.map +1 -0
- package/dist/src/ui/hooks/useCancellation.d.ts +15 -0
- package/dist/src/ui/hooks/useCancellation.js +25 -0
- package/dist/src/ui/hooks/useCancellation.js.map +1 -0
- package/dist/src/ui/render.d.ts +34 -0
- package/dist/src/ui/render.js +94 -0
- package/dist/src/ui/render.js.map +1 -0
- package/dist/src/ui/types.d.ts +184 -0
- package/dist/src/ui/types.js +6 -0
- package/dist/src/ui/types.js.map +1 -0
- package/dist/src/utils/clack-utils.d.ts +13 -0
- package/dist/src/utils/clack-utils.js +131 -0
- package/dist/src/utils/clack-utils.js.map +1 -0
- package/dist/src/utils/debug.d.ts +13 -0
- package/dist/src/utils/debug.js +47 -0
- package/dist/src/utils/debug.js.map +1 -0
- package/dist/src/utils/environment.d.ts +5 -0
- package/dist/src/utils/environment.js +131 -0
- package/dist/src/utils/environment.js.map +1 -0
- package/dist/src/utils/logging.d.ts +9 -0
- package/dist/src/utils/logging.js +38 -0
- package/dist/src/utils/logging.js.map +1 -0
- package/dist/src/utils/oauth.d.ts +12 -0
- package/dist/src/utils/oauth.js +497 -0
- package/dist/src/utils/oauth.js.map +1 -0
- package/dist/src/utils/package-json-types.d.ts +44 -0
- package/dist/src/utils/package-json-types.js +6 -0
- package/dist/src/utils/package-json-types.js.map +1 -0
- package/dist/src/utils/package-json.d.ts +19 -0
- package/dist/src/utils/package-json.js +22 -0
- package/dist/src/utils/package-json.js.map +1 -0
- package/dist/src/utils/session.d.ts +2 -0
- package/dist/src/utils/session.js +87 -0
- package/dist/src/utils/session.js.map +1 -0
- package/dist/src/utils/types.d.ts +61 -0
- package/dist/src/utils/types.js +2 -0
- package/dist/src/utils/types.js.map +1 -0
- package/dist/src/utils/ui.d.ts +120 -0
- package/dist/src/utils/ui.js +164 -0
- package/dist/src/utils/ui.js.map +1 -0
- package/package.json +140 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 PostHog
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
--------------------------------------------------------------------------------
|
|
24
|
+
|
|
25
|
+
Portions of this software are derived from Sentry’s codebase located at https://github.com/getsentry/sentry-wizard and are used under the terms of the MIT License provided below:
|
|
26
|
+
|
|
27
|
+
The MIT License (MIT)
|
|
28
|
+
|
|
29
|
+
Copyright (c) 2017 Sentry
|
|
30
|
+
|
|
31
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
32
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
33
|
+
in the Software without restriction, including without limitation the rights
|
|
34
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
35
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
36
|
+
furnished to do so, subject to the following conditions:
|
|
37
|
+
|
|
38
|
+
The above copyright notice and this permission notice shall be included in all
|
|
39
|
+
copies or substantial portions of the Software.
|
|
40
|
+
|
|
41
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
42
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
43
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
44
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
45
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
46
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
47
|
+
SOFTWARE.
|
package/dist/bin.d.ts
ADDED
package/dist/bin.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { satisfies } from 'semver';
|
|
3
|
+
import { red } from './src/utils/logging.js';
|
|
4
|
+
import yargs from 'yargs';
|
|
5
|
+
import { hideBin } from 'yargs/helpers';
|
|
6
|
+
const NODE_VERSION_RANGE = '>=18.17.0';
|
|
7
|
+
// Node version check - must use console.log before Ink is initialized
|
|
8
|
+
if (!satisfies(process.version, NODE_VERSION_RANGE)) {
|
|
9
|
+
red(`Raindrop wizard requires Node.js ${NODE_VERSION_RANGE}. You are using Node.js ${process.version}. Please upgrade your Node.js version.`);
|
|
10
|
+
process.exit(1);
|
|
11
|
+
}
|
|
12
|
+
import { runWizard } from './src/run.js';
|
|
13
|
+
import { isNonInteractiveEnvironment } from './src/utils/environment.js';
|
|
14
|
+
import ui, { initWizardUI } from './src/utils/ui.js';
|
|
15
|
+
// Prevent unhandled rejection errors from showing during graceful shutdown
|
|
16
|
+
process.on('unhandledRejection', (reason) => {
|
|
17
|
+
// Ignore ProcessTransport errors during shutdown
|
|
18
|
+
if (reason?.message?.includes('ProcessTransport is not ready') ||
|
|
19
|
+
reason?.message?.includes('Stream can only be iterated once')) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
// Log other unhandled rejections
|
|
23
|
+
console.error('Unhandled rejection:', reason);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
});
|
|
26
|
+
// Prevent uncaught exceptions from showing during graceful shutdown
|
|
27
|
+
process.on('uncaughtException', (error) => {
|
|
28
|
+
// Ignore ProcessTransport errors during shutdown
|
|
29
|
+
if (error.message?.includes('ProcessTransport is not ready') ||
|
|
30
|
+
error.message?.includes('Stream can only be iterated once')) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
// Log other uncaught exceptions
|
|
34
|
+
console.error('Uncaught exception:', error);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
});
|
|
37
|
+
yargs(hideBin(process.argv))
|
|
38
|
+
.env('RAINDROP')
|
|
39
|
+
// global options
|
|
40
|
+
.options({
|
|
41
|
+
debug: {
|
|
42
|
+
default: false,
|
|
43
|
+
describe: 'Enable verbose logging\nenv: RAINDROP_DEBUG',
|
|
44
|
+
type: 'boolean',
|
|
45
|
+
},
|
|
46
|
+
default: {
|
|
47
|
+
default: false,
|
|
48
|
+
describe: 'Use default options for all prompts\nenv: RAINDROP_DEFAULT',
|
|
49
|
+
type: 'boolean',
|
|
50
|
+
},
|
|
51
|
+
})
|
|
52
|
+
.command(['$0'], 'Run the Raindrop setup wizard', (yargs) => {
|
|
53
|
+
return yargs.options({
|
|
54
|
+
'force-install': {
|
|
55
|
+
default: false,
|
|
56
|
+
describe: 'Force install packages even if peer dependency checks fail\nenv: RAINDROP_FORCE_INSTALL',
|
|
57
|
+
type: 'boolean',
|
|
58
|
+
},
|
|
59
|
+
'install-dir': {
|
|
60
|
+
describe: 'Directory to install Raindrop in\nenv: RAINDROP_INSTALL_DIR',
|
|
61
|
+
type: 'string',
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
}, (argv) => {
|
|
65
|
+
const options = { ...argv };
|
|
66
|
+
// TTY check - must use console before Ink is initialized
|
|
67
|
+
if (isNonInteractiveEnvironment()) {
|
|
68
|
+
red('Raindrop wizard requires an interactive terminal (TTY) to run.\n' +
|
|
69
|
+
'It appears you are running in a non-interactive environment.\n' +
|
|
70
|
+
'Please run the Raindrop wizard in an interactive terminal.');
|
|
71
|
+
process.exit(1);
|
|
72
|
+
}
|
|
73
|
+
// Run the async wizard logic
|
|
74
|
+
void (async () => {
|
|
75
|
+
// Initialize the unified Ink app (single render call)
|
|
76
|
+
const wizardUI = await initWizardUI();
|
|
77
|
+
// Handle Ctrl+C gracefully - exit without showing SDK cleanup errors
|
|
78
|
+
let sigintCount = 0;
|
|
79
|
+
const handleSIGINT = () => {
|
|
80
|
+
sigintCount++;
|
|
81
|
+
if (sigintCount === 1) {
|
|
82
|
+
// First Ctrl+C - let the agent handle it gracefully
|
|
83
|
+
// The agent-interface.ts will handle the interrupt
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
// Second Ctrl+C - force exit immediately
|
|
87
|
+
wizardUI.unmount();
|
|
88
|
+
process.exit(130); // Standard exit code for SIGINT
|
|
89
|
+
};
|
|
90
|
+
process.on('SIGINT', handleSIGINT);
|
|
91
|
+
// Display logo through Ink
|
|
92
|
+
ui.addItem({ type: 'logo', text: '' });
|
|
93
|
+
try {
|
|
94
|
+
await runWizard(options);
|
|
95
|
+
wizardUI.unmount();
|
|
96
|
+
process.removeListener('SIGINT', handleSIGINT);
|
|
97
|
+
process.exit(0);
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
ui.addItem({
|
|
101
|
+
type: 'error',
|
|
102
|
+
text: `Error: ${error instanceof Error ? error.message : String(error)}`,
|
|
103
|
+
});
|
|
104
|
+
wizardUI.unmount();
|
|
105
|
+
process.exit(1);
|
|
106
|
+
}
|
|
107
|
+
// The wizard completes - unmount the UI
|
|
108
|
+
// (cleanup is handled in the try/catch above)
|
|
109
|
+
})();
|
|
110
|
+
})
|
|
111
|
+
.help()
|
|
112
|
+
.alias('help', 'h')
|
|
113
|
+
.version()
|
|
114
|
+
.alias('version', 'v')
|
|
115
|
+
.wrap(null) // null = use terminal width automatically
|
|
116
|
+
.parse();
|
|
117
|
+
//# sourceMappingURL=bin.js.map
|
package/dist/bin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,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satisfies } from 'semver';\nimport { red } from './src/utils/logging.js';\n\nimport yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\n\nconst NODE_VERSION_RANGE = '>=18.17.0';\n\n// Node version check - must use console.log before Ink is initialized\nif (!satisfies(process.version, NODE_VERSION_RANGE)) {\n red(\n `Raindrop wizard requires Node.js ${NODE_VERSION_RANGE}. You are using Node.js ${process.version}. Please upgrade your Node.js version.`,\n );\n process.exit(1);\n}\n\nimport type { WizardOptions } from './src/utils/types.js';\nimport { runWizard } from './src/run.js';\nimport { isNonInteractiveEnvironment } from './src/utils/environment.js';\nimport ui, { initWizardUI } from './src/utils/ui.js';\n\n// Prevent unhandled rejection errors from showing during graceful shutdown\nprocess.on('unhandledRejection', (reason: any) => {\n // Ignore ProcessTransport errors during shutdown\n if (\n reason?.message?.includes('ProcessTransport is not ready') ||\n reason?.message?.includes('Stream can only be iterated once')\n ) {\n return;\n }\n // Log other unhandled rejections\n console.error('Unhandled rejection:', reason);\n process.exit(1);\n});\n\n// Prevent uncaught exceptions from showing during graceful shutdown\nprocess.on('uncaughtException', (error: Error) => {\n // Ignore ProcessTransport errors during shutdown\n if (\n error.message?.includes('ProcessTransport is not ready') ||\n error.message?.includes('Stream can only be iterated once')\n ) {\n return;\n }\n // Log other uncaught exceptions\n console.error('Uncaught exception:', error);\n process.exit(1);\n});\n\nyargs(hideBin(process.argv))\n .env('RAINDROP')\n // global options\n .options({\n debug: {\n default: false,\n describe: 'Enable verbose logging\\nenv: RAINDROP_DEBUG',\n type: 'boolean',\n },\n default: {\n default: false,\n describe: 'Use default options for all prompts\\nenv: RAINDROP_DEFAULT',\n type: 'boolean',\n },\n })\n .command(\n ['$0'],\n 'Run the Raindrop setup wizard',\n (yargs) => {\n return yargs.options({\n 'force-install': {\n default: false,\n describe:\n 'Force install packages even if peer dependency checks fail\\nenv: RAINDROP_FORCE_INSTALL',\n type: 'boolean',\n },\n 'install-dir': {\n describe:\n 'Directory to install Raindrop in\\nenv: RAINDROP_INSTALL_DIR',\n type: 'string',\n },\n });\n },\n (argv) => {\n const options = { ...argv };\n\n // TTY check - must use console before Ink is initialized\n if (isNonInteractiveEnvironment()) {\n red(\n 'Raindrop wizard requires an interactive terminal (TTY) to run.\\n' +\n 'It appears you are running in a non-interactive environment.\\n' +\n 'Please run the Raindrop wizard in an interactive terminal.',\n );\n process.exit(1);\n }\n\n // Run the async wizard logic\n void (async () => {\n // Initialize the unified Ink app (single render call)\n const wizardUI = await initWizardUI();\n\n // Handle Ctrl+C gracefully - exit without showing SDK cleanup errors\n let sigintCount = 0;\n const handleSIGINT = () => {\n sigintCount++;\n if (sigintCount === 1) {\n // First Ctrl+C - let the agent handle it gracefully\n // The agent-interface.ts will handle the interrupt\n return;\n }\n // Second Ctrl+C - force exit immediately\n wizardUI.unmount();\n process.exit(130); // Standard exit code for SIGINT\n };\n process.on('SIGINT', handleSIGINT);\n\n // Display logo through Ink\n ui.addItem({ type: 'logo', text: '' });\n\n try {\n await runWizard(options as unknown as WizardOptions);\n wizardUI.unmount();\n process.removeListener('SIGINT', handleSIGINT);\n process.exit(0);\n } catch (error) {\n ui.addItem({\n type: 'error',\n text: `Error: ${\n error instanceof Error ? error.message : String(error)\n }`,\n });\n wizardUI.unmount();\n process.exit(1);\n }\n\n // The wizard completes - unmount the UI\n // (cleanup is handled in the try/catch above)\n })();\n },\n )\n .help()\n .alias('help', 'h')\n .version()\n .alias('version', 'v')\n .wrap(null) // null = use terminal width automatically\n .parse();\n"]}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 'Browser (JavaScript)'
|
|
3
|
+
description:
|
|
4
|
+
'Minimal browser-safe SDK for tracking AI events via /v1/events from web apps.'
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
### **Installation**
|
|
8
|
+
|
|
9
|
+
Install the browser SDK package:
|
|
10
|
+
|
|
11
|
+
<CodeGroup>
|
|
12
|
+
|
|
13
|
+
```bash npm
|
|
14
|
+
npm install @raindrop-ai/browser-sdk
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```bash yarn
|
|
18
|
+
yarn add @raindrop-ai/browser-sdk
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```bash bun
|
|
22
|
+
bun add @raindrop-ai/browser-sdk
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
</CodeGroup>
|
|
26
|
+
|
|
27
|
+
### **Quickstart**
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { Raindrop } from '@raindrop-ai/browser-sdk';
|
|
31
|
+
|
|
32
|
+
const rd = new Raindrop({ apiKey: RAINDROP_WRITE_KEY, // Your project's Raindrop write key
|
|
33
|
+
wizardSession: '__WIZARD_SESSION_UUID__' // REQUIRED
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// 1) Single-shot AI event (camelCase fields)
|
|
37
|
+
// Note: `input` and `output` should be the actual prompt sent to and response
|
|
38
|
+
// received from your AI model - not literal placeholder strings.
|
|
39
|
+
const { eventIds } = await rd.trackAi({
|
|
40
|
+
event: 'chat_message',
|
|
41
|
+
userId: userId, // Required: unique user ID string (e.g. user ID, email, auth sub; or generate one if not available)
|
|
42
|
+
model: modelName,
|
|
43
|
+
input: userPrompt, // The actual prompt sent to the model
|
|
44
|
+
output: modelResponse, // The actual response from the model
|
|
45
|
+
convoId: convId, // Conversation ID—set to how your app tracks/chat threads
|
|
46
|
+
properties: { exampleKey: 'exampleValue' },
|
|
47
|
+
});
|
|
48
|
+
console.log('trackAi eventIds:', eventIds);
|
|
49
|
+
|
|
50
|
+
// 2) Partial AI event flow (for streaming responses)
|
|
51
|
+
// Pass each chunk as it arrives, then call finish() with the complete response.
|
|
52
|
+
const eid = uuidv4(); // import { v4 as uuidv4 } from 'uuid' — avoid Node 'crypto' module in browser/bundler environments
|
|
53
|
+
const partial = await rd.trackAiPartial({
|
|
54
|
+
eventId: eid,
|
|
55
|
+
event: 'chat_message',
|
|
56
|
+
userId: userId, // Required: unique user ID string (e.g. user ID, email, auth sub; or generate one if not available)
|
|
57
|
+
model: modelName,
|
|
58
|
+
convoId: convId, // Conversation ID—set to how your app tracks/chat threads
|
|
59
|
+
output: chunk, // First streamed chunk from the model
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
await rd.trackAiPartial({ eventId: eid, output: nextChunk });
|
|
63
|
+
const done = await partial.finish({ output: fullResponse }); // Complete response
|
|
64
|
+
console.log('partial finished:', done);
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### **Identify users**
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
// Associate traits with the current user — use actual user data from your app
|
|
71
|
+
await rd.identify({
|
|
72
|
+
userId: userId, // The authenticated user's unique identifier
|
|
73
|
+
traits: {
|
|
74
|
+
name: userName, // User's display name from your app
|
|
75
|
+
email: userEmail, // User's email from your app
|
|
76
|
+
plan: userPlan, // e.g. 'free', 'pro', 'enterprise'
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// batch — replace with actual user data from your system
|
|
81
|
+
await rd.identify([
|
|
82
|
+
{ userId: userIdA, traits: { plan: planA } },
|
|
83
|
+
{ userId: userIdB, traits: { plan: planB } },
|
|
84
|
+
]);
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### **Signals**
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
// thumbs down with a comment
|
|
91
|
+
await rd.trackSignal({
|
|
92
|
+
eventId: eid,
|
|
93
|
+
name: 'thumbs_down',
|
|
94
|
+
type: 'feedback',
|
|
95
|
+
comment: 'Answer was off-topic',
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// edit signal capturing the corrected content
|
|
99
|
+
await rd.trackSignal({
|
|
100
|
+
eventId: eid,
|
|
101
|
+
name: 'edit',
|
|
102
|
+
type: 'edit',
|
|
103
|
+
after: 'the corrected final text',
|
|
104
|
+
});
|
|
105
|
+
```
|