@raindrop-ai/claude-code 0.0.2 → 0.0.4
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/cli.js +96 -21
- package/dist/index.cjs +32 -12
- package/dist/index.d.cts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +32 -12
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -653,7 +653,7 @@ globalThis.RAINDROP_ASYNC_LOCAL_STORAGE = AsyncLocalStorage;
|
|
|
653
653
|
|
|
654
654
|
// src/package-info.ts
|
|
655
655
|
var PACKAGE_NAME = "@raindrop-ai/claude-code";
|
|
656
|
-
var PACKAGE_VERSION = "0.0.
|
|
656
|
+
var PACKAGE_VERSION = "0.0.4";
|
|
657
657
|
|
|
658
658
|
// src/shipper.ts
|
|
659
659
|
var EventShipper2 = class extends EventShipper {
|
|
@@ -796,6 +796,7 @@ async function mapHookToRaindrop(payload, config, eventShipper, traceShipper) {
|
|
|
796
796
|
var _a;
|
|
797
797
|
const convoId = payload.session_id;
|
|
798
798
|
const baseProperties = {
|
|
799
|
+
...config.customProperties,
|
|
799
800
|
cwd: payload.cwd,
|
|
800
801
|
permission_mode: payload.permission_mode,
|
|
801
802
|
plugin_version: PACKAGE_VERSION,
|
|
@@ -870,7 +871,7 @@ async function handleUserPromptSubmit(payload, convoId, config, properties, even
|
|
|
870
871
|
isPending: true,
|
|
871
872
|
userId: config.userId,
|
|
872
873
|
convoId,
|
|
873
|
-
eventName:
|
|
874
|
+
eventName: config.eventName,
|
|
874
875
|
input: payload.prompt,
|
|
875
876
|
model,
|
|
876
877
|
properties
|
|
@@ -990,7 +991,7 @@ async function handlePostCompact(payload, eventId, config, properties, eventShip
|
|
|
990
991
|
isPending: true,
|
|
991
992
|
userId: config.userId,
|
|
992
993
|
convoId: payload.session_id,
|
|
993
|
-
eventName:
|
|
994
|
+
eventName: config.eventName,
|
|
994
995
|
properties: {
|
|
995
996
|
...properties,
|
|
996
997
|
compaction_trigger: payload.trigger,
|
|
@@ -999,15 +1000,19 @@ async function handlePostCompact(payload, eventId, config, properties, eventShip
|
|
|
999
1000
|
});
|
|
1000
1001
|
}
|
|
1001
1002
|
async function handleStop(payload, eventId, config, properties, eventShipper) {
|
|
1002
|
-
await eventShipper.
|
|
1003
|
+
await eventShipper.patch(eventId, {
|
|
1004
|
+
isPending: false,
|
|
1003
1005
|
userId: config.userId,
|
|
1006
|
+
eventName: config.eventName,
|
|
1004
1007
|
output: payload.last_assistant_message,
|
|
1005
1008
|
properties
|
|
1006
1009
|
});
|
|
1007
1010
|
}
|
|
1008
1011
|
async function handleStopFailure(payload, eventId, config, properties, eventShipper) {
|
|
1009
|
-
await eventShipper.
|
|
1012
|
+
await eventShipper.patch(eventId, {
|
|
1013
|
+
isPending: false,
|
|
1010
1014
|
userId: config.userId,
|
|
1015
|
+
eventName: config.eventName,
|
|
1011
1016
|
output: payload.last_assistant_message,
|
|
1012
1017
|
properties: {
|
|
1013
1018
|
...properties,
|
|
@@ -1017,8 +1022,10 @@ async function handleStopFailure(payload, eventId, config, properties, eventShip
|
|
|
1017
1022
|
});
|
|
1018
1023
|
}
|
|
1019
1024
|
async function handleSessionEnd(payload, eventId, config, properties, eventShipper) {
|
|
1020
|
-
await eventShipper.
|
|
1025
|
+
await eventShipper.patch(eventId, {
|
|
1026
|
+
isPending: false,
|
|
1021
1027
|
userId: config.userId,
|
|
1028
|
+
eventName: config.eventName,
|
|
1022
1029
|
properties: {
|
|
1023
1030
|
...properties,
|
|
1024
1031
|
session_end_reason: payload.reason
|
|
@@ -1032,7 +1039,7 @@ import { homedir, userInfo } from "os";
|
|
|
1032
1039
|
import { dirname, join as join2 } from "path";
|
|
1033
1040
|
var CONFIG_PATH = join2(homedir(), ".config", "raindrop", "config.json");
|
|
1034
1041
|
function loadConfig() {
|
|
1035
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1042
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
1036
1043
|
let file = {};
|
|
1037
1044
|
try {
|
|
1038
1045
|
if (existsSync2(CONFIG_PATH)) {
|
|
@@ -1047,12 +1054,25 @@ function loadConfig() {
|
|
|
1047
1054
|
return "unknown";
|
|
1048
1055
|
}
|
|
1049
1056
|
})();
|
|
1057
|
+
let customProperties = (_a = file.custom_properties) != null ? _a : {};
|
|
1058
|
+
const envProps = process.env["RAINDROP_PROPERTIES"];
|
|
1059
|
+
if (envProps) {
|
|
1060
|
+
try {
|
|
1061
|
+
const parsed = JSON.parse(envProps);
|
|
1062
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
1063
|
+
customProperties = { ...customProperties, ...parsed };
|
|
1064
|
+
}
|
|
1065
|
+
} catch (e) {
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1050
1068
|
return {
|
|
1051
|
-
writeKey: (
|
|
1052
|
-
endpoint: (
|
|
1053
|
-
userId: (
|
|
1054
|
-
debug: process.env["RAINDROP_DEBUG"] === "true" ? true : (
|
|
1055
|
-
enabled: (
|
|
1069
|
+
writeKey: (_c = (_b = process.env["RAINDROP_WRITE_KEY"]) != null ? _b : file.write_key) != null ? _c : "",
|
|
1070
|
+
endpoint: (_e = (_d = process.env["RAINDROP_API_URL"]) != null ? _d : file.api_url) != null ? _e : "https://api.raindrop.ai/v1",
|
|
1071
|
+
userId: (_g = (_f = process.env["RAINDROP_USER_ID"]) != null ? _f : file.user_id) != null ? _g : systemUser,
|
|
1072
|
+
debug: process.env["RAINDROP_DEBUG"] === "true" ? true : (_h = file.debug) != null ? _h : false,
|
|
1073
|
+
enabled: (_i = file.enabled) != null ? _i : true,
|
|
1074
|
+
eventName: (_k = (_j = process.env["RAINDROP_EVENT_NAME"]) != null ? _j : file.event_name) != null ? _k : "claude_code_session",
|
|
1075
|
+
customProperties
|
|
1056
1076
|
};
|
|
1057
1077
|
}
|
|
1058
1078
|
function getConfigPath() {
|
|
@@ -1223,7 +1243,9 @@ async function handleHook() {
|
|
|
1223
1243
|
}
|
|
1224
1244
|
const mapperConfig = {
|
|
1225
1245
|
userId: config.userId,
|
|
1226
|
-
debug: config.debug
|
|
1246
|
+
debug: config.debug,
|
|
1247
|
+
eventName: config.eventName,
|
|
1248
|
+
customProperties: config.customProperties
|
|
1227
1249
|
};
|
|
1228
1250
|
const eventShipper = new EventShipper2({
|
|
1229
1251
|
writeKey: config.writeKey,
|
|
@@ -1284,13 +1306,14 @@ import { existsSync as existsSync5, mkdirSync as mkdirSync4, readFileSync as rea
|
|
|
1284
1306
|
import { homedir as homedir2, userInfo as userInfo2 } from "os";
|
|
1285
1307
|
import { dirname as dirname2, join as join5, resolve } from "path";
|
|
1286
1308
|
import { createInterface } from "readline";
|
|
1309
|
+
import { execSync } from "child_process";
|
|
1287
1310
|
function getClaudeSettingsPath(scope, cwd) {
|
|
1288
1311
|
if (scope === "project") {
|
|
1289
1312
|
return resolve(cwd, ".claude", "settings.json");
|
|
1290
1313
|
}
|
|
1291
1314
|
return join5(homedir2(), ".claude", "settings.json");
|
|
1292
1315
|
}
|
|
1293
|
-
var
|
|
1316
|
+
var CORE_HOOK_EVENTS = [
|
|
1294
1317
|
"SessionStart",
|
|
1295
1318
|
"UserPromptSubmit",
|
|
1296
1319
|
"PreToolUse",
|
|
@@ -1298,15 +1321,58 @@ var HOOK_EVENTS = [
|
|
|
1298
1321
|
"PostToolUseFailure",
|
|
1299
1322
|
"SubagentStart",
|
|
1300
1323
|
"SubagentStop",
|
|
1301
|
-
"PermissionDenied",
|
|
1302
|
-
"PostCompact",
|
|
1303
1324
|
"Stop",
|
|
1304
|
-
"StopFailure",
|
|
1305
1325
|
"SessionEnd"
|
|
1306
1326
|
];
|
|
1307
|
-
|
|
1327
|
+
var VERSIONED_HOOK_EVENTS = [
|
|
1328
|
+
{ minVersion: "2.1.78", events: ["StopFailure"] },
|
|
1329
|
+
{ minVersion: "2.1.76", events: ["PostCompact"] },
|
|
1330
|
+
{ minVersion: "2.1.89", events: ["PermissionDenied"] }
|
|
1331
|
+
];
|
|
1332
|
+
function parseVersion(version) {
|
|
1333
|
+
const match = version.match(/(\d+)\.(\d+)\.(\d+)/);
|
|
1334
|
+
if (!match) return void 0;
|
|
1335
|
+
return [parseInt(match[1], 10), parseInt(match[2], 10), parseInt(match[3], 10)];
|
|
1336
|
+
}
|
|
1337
|
+
function isVersionAtLeast(current, required) {
|
|
1338
|
+
const req = parseVersion(required);
|
|
1339
|
+
if (!req) return false;
|
|
1340
|
+
for (let i = 0; i < 3; i++) {
|
|
1341
|
+
if (current[i] > req[i]) return true;
|
|
1342
|
+
if (current[i] < req[i]) return false;
|
|
1343
|
+
}
|
|
1344
|
+
return true;
|
|
1345
|
+
}
|
|
1346
|
+
function detectClaudeCodeVersion() {
|
|
1347
|
+
try {
|
|
1348
|
+
const output = execSync("claude --version", {
|
|
1349
|
+
encoding: "utf-8",
|
|
1350
|
+
timeout: 5e3,
|
|
1351
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
1352
|
+
}).trim();
|
|
1353
|
+
const match = output.match(/(\d+\.\d+\.\d+)/);
|
|
1354
|
+
return match ? match[1] : void 0;
|
|
1355
|
+
} catch (e) {
|
|
1356
|
+
return void 0;
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
function getHookEventsForVersion(version) {
|
|
1360
|
+
const events = [...CORE_HOOK_EVENTS];
|
|
1361
|
+
if (!version) {
|
|
1362
|
+
return events;
|
|
1363
|
+
}
|
|
1364
|
+
const parsed = parseVersion(version);
|
|
1365
|
+
if (!parsed) return events;
|
|
1366
|
+
for (const { minVersion, events: versionedEvents } of VERSIONED_HOOK_EVENTS) {
|
|
1367
|
+
if (isVersionAtLeast(parsed, minVersion)) {
|
|
1368
|
+
events.push(...versionedEvents);
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
return events;
|
|
1372
|
+
}
|
|
1373
|
+
function makeHookConfig(hookEvents) {
|
|
1308
1374
|
const hooks = {};
|
|
1309
|
-
for (const event of
|
|
1375
|
+
for (const event of hookEvents) {
|
|
1310
1376
|
hooks[event] = [
|
|
1311
1377
|
{
|
|
1312
1378
|
hooks: [
|
|
@@ -1371,6 +1437,14 @@ async function runSetup(args2) {
|
|
|
1371
1437
|
writeFileSync4(configPath, JSON.stringify(raindropConfig, null, 2) + "\n", "utf-8");
|
|
1372
1438
|
console.log(` Saved Raindrop config to ${configPath}`);
|
|
1373
1439
|
}
|
|
1440
|
+
const ccVersion = detectClaudeCodeVersion();
|
|
1441
|
+
const hookEvents = getHookEventsForVersion(ccVersion);
|
|
1442
|
+
if (ccVersion) {
|
|
1443
|
+
console.log(` Detected Claude Code v${ccVersion}`);
|
|
1444
|
+
} else {
|
|
1445
|
+
console.log(` Could not detect Claude Code version \u2014 registering core hooks only.`);
|
|
1446
|
+
console.log(` Run setup again after installing Claude Code to enable all hooks.`);
|
|
1447
|
+
}
|
|
1374
1448
|
const settingsPath = getClaudeSettingsPath(scope, process.cwd());
|
|
1375
1449
|
const settingsDir = dirname2(settingsPath);
|
|
1376
1450
|
mkdirSync4(settingsDir, { recursive: true });
|
|
@@ -1384,7 +1458,7 @@ async function runSetup(args2) {
|
|
|
1384
1458
|
}
|
|
1385
1459
|
}
|
|
1386
1460
|
const existingHooks = (_e = settings["hooks"]) != null ? _e : {};
|
|
1387
|
-
const newHooks = makeHookConfig();
|
|
1461
|
+
const newHooks = makeHookConfig(hookEvents);
|
|
1388
1462
|
for (const [event, hookGroups] of Object.entries(newHooks)) {
|
|
1389
1463
|
const existing = existingHooks[event];
|
|
1390
1464
|
if (!existing || !Array.isArray(existing)) {
|
|
@@ -1405,7 +1479,6 @@ async function runSetup(args2) {
|
|
|
1405
1479
|
settings["hooks"] = existingHooks;
|
|
1406
1480
|
writeFileSync4(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf-8");
|
|
1407
1481
|
console.log(` Updated Claude Code hooks in ${settingsPath} (${scopeLabel})`);
|
|
1408
|
-
const { execSync } = await import("child_process");
|
|
1409
1482
|
const whichCmd = process.platform === "win32" ? "where" : "which";
|
|
1410
1483
|
try {
|
|
1411
1484
|
execSync(`${whichCmd} raindrop-claude-code`, { stdio: "ignore" });
|
|
@@ -1518,6 +1591,8 @@ async function main() {
|
|
|
1518
1591
|
Environment:
|
|
1519
1592
|
RAINDROP_WRITE_KEY API write key (alternative to --write-key or config file)
|
|
1520
1593
|
RAINDROP_USER_ID User ID override
|
|
1594
|
+
RAINDROP_EVENT_NAME Custom event name (default: "claude_code_session")
|
|
1595
|
+
RAINDROP_PROPERTIES JSON object merged into every event's properties
|
|
1521
1596
|
RAINDROP_API_URL Custom API endpoint
|
|
1522
1597
|
RAINDROP_LOCAL_DEBUGGER Local debugger URL (auto-detected if running on :5899)
|
|
1523
1598
|
RAINDROP_DEBUG Set to "true" for verbose logging
|
package/dist/index.cjs
CHANGED
|
@@ -680,7 +680,7 @@ globalThis.RAINDROP_ASYNC_LOCAL_STORAGE = import_async_hooks.AsyncLocalStorage;
|
|
|
680
680
|
|
|
681
681
|
// src/package-info.ts
|
|
682
682
|
var PACKAGE_NAME = "@raindrop-ai/claude-code";
|
|
683
|
-
var PACKAGE_VERSION = "0.0.
|
|
683
|
+
var PACKAGE_VERSION = "0.0.4";
|
|
684
684
|
|
|
685
685
|
// src/shipper.ts
|
|
686
686
|
var EventShipper2 = class extends EventShipper {
|
|
@@ -723,7 +723,7 @@ var import_node_os = require("os");
|
|
|
723
723
|
var import_node_path = require("path");
|
|
724
724
|
var CONFIG_PATH = (0, import_node_path.join)((0, import_node_os.homedir)(), ".config", "raindrop", "config.json");
|
|
725
725
|
function loadConfig() {
|
|
726
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
726
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
727
727
|
let file = {};
|
|
728
728
|
try {
|
|
729
729
|
if ((0, import_node_fs.existsSync)(CONFIG_PATH)) {
|
|
@@ -738,12 +738,25 @@ function loadConfig() {
|
|
|
738
738
|
return "unknown";
|
|
739
739
|
}
|
|
740
740
|
})();
|
|
741
|
+
let customProperties = (_a = file.custom_properties) != null ? _a : {};
|
|
742
|
+
const envProps = process.env["RAINDROP_PROPERTIES"];
|
|
743
|
+
if (envProps) {
|
|
744
|
+
try {
|
|
745
|
+
const parsed = JSON.parse(envProps);
|
|
746
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
747
|
+
customProperties = { ...customProperties, ...parsed };
|
|
748
|
+
}
|
|
749
|
+
} catch (e) {
|
|
750
|
+
}
|
|
751
|
+
}
|
|
741
752
|
return {
|
|
742
|
-
writeKey: (
|
|
743
|
-
endpoint: (
|
|
744
|
-
userId: (
|
|
745
|
-
debug: process.env["RAINDROP_DEBUG"] === "true" ? true : (
|
|
746
|
-
enabled: (
|
|
753
|
+
writeKey: (_c = (_b = process.env["RAINDROP_WRITE_KEY"]) != null ? _b : file.write_key) != null ? _c : "",
|
|
754
|
+
endpoint: (_e = (_d = process.env["RAINDROP_API_URL"]) != null ? _d : file.api_url) != null ? _e : "https://api.raindrop.ai/v1",
|
|
755
|
+
userId: (_g = (_f = process.env["RAINDROP_USER_ID"]) != null ? _f : file.user_id) != null ? _g : systemUser,
|
|
756
|
+
debug: process.env["RAINDROP_DEBUG"] === "true" ? true : (_h = file.debug) != null ? _h : false,
|
|
757
|
+
enabled: (_i = file.enabled) != null ? _i : true,
|
|
758
|
+
eventName: (_k = (_j = process.env["RAINDROP_EVENT_NAME"]) != null ? _j : file.event_name) != null ? _k : "claude_code_session",
|
|
759
|
+
customProperties
|
|
747
760
|
};
|
|
748
761
|
}
|
|
749
762
|
function getConfigPath() {
|
|
@@ -872,6 +885,7 @@ async function mapHookToRaindrop(payload, config, eventShipper, traceShipper) {
|
|
|
872
885
|
var _a;
|
|
873
886
|
const convoId = payload.session_id;
|
|
874
887
|
const baseProperties = {
|
|
888
|
+
...config.customProperties,
|
|
875
889
|
cwd: payload.cwd,
|
|
876
890
|
permission_mode: payload.permission_mode,
|
|
877
891
|
plugin_version: PACKAGE_VERSION,
|
|
@@ -946,7 +960,7 @@ async function handleUserPromptSubmit(payload, convoId, config, properties, even
|
|
|
946
960
|
isPending: true,
|
|
947
961
|
userId: config.userId,
|
|
948
962
|
convoId,
|
|
949
|
-
eventName:
|
|
963
|
+
eventName: config.eventName,
|
|
950
964
|
input: payload.prompt,
|
|
951
965
|
model,
|
|
952
966
|
properties
|
|
@@ -1066,7 +1080,7 @@ async function handlePostCompact(payload, eventId, config, properties, eventShip
|
|
|
1066
1080
|
isPending: true,
|
|
1067
1081
|
userId: config.userId,
|
|
1068
1082
|
convoId: payload.session_id,
|
|
1069
|
-
eventName:
|
|
1083
|
+
eventName: config.eventName,
|
|
1070
1084
|
properties: {
|
|
1071
1085
|
...properties,
|
|
1072
1086
|
compaction_trigger: payload.trigger,
|
|
@@ -1075,15 +1089,19 @@ async function handlePostCompact(payload, eventId, config, properties, eventShip
|
|
|
1075
1089
|
});
|
|
1076
1090
|
}
|
|
1077
1091
|
async function handleStop(payload, eventId, config, properties, eventShipper) {
|
|
1078
|
-
await eventShipper.
|
|
1092
|
+
await eventShipper.patch(eventId, {
|
|
1093
|
+
isPending: false,
|
|
1079
1094
|
userId: config.userId,
|
|
1095
|
+
eventName: config.eventName,
|
|
1080
1096
|
output: payload.last_assistant_message,
|
|
1081
1097
|
properties
|
|
1082
1098
|
});
|
|
1083
1099
|
}
|
|
1084
1100
|
async function handleStopFailure(payload, eventId, config, properties, eventShipper) {
|
|
1085
|
-
await eventShipper.
|
|
1101
|
+
await eventShipper.patch(eventId, {
|
|
1102
|
+
isPending: false,
|
|
1086
1103
|
userId: config.userId,
|
|
1104
|
+
eventName: config.eventName,
|
|
1087
1105
|
output: payload.last_assistant_message,
|
|
1088
1106
|
properties: {
|
|
1089
1107
|
...properties,
|
|
@@ -1093,8 +1111,10 @@ async function handleStopFailure(payload, eventId, config, properties, eventShip
|
|
|
1093
1111
|
});
|
|
1094
1112
|
}
|
|
1095
1113
|
async function handleSessionEnd(payload, eventId, config, properties, eventShipper) {
|
|
1096
|
-
await eventShipper.
|
|
1114
|
+
await eventShipper.patch(eventId, {
|
|
1115
|
+
isPending: false,
|
|
1097
1116
|
userId: config.userId,
|
|
1117
|
+
eventName: config.eventName,
|
|
1098
1118
|
properties: {
|
|
1099
1119
|
...properties,
|
|
1100
1120
|
session_end_reason: payload.reason
|
package/dist/index.d.cts
CHANGED
|
@@ -227,6 +227,8 @@ interface ConfigFile {
|
|
|
227
227
|
user_id?: string;
|
|
228
228
|
debug?: boolean;
|
|
229
229
|
enabled?: boolean;
|
|
230
|
+
event_name?: string;
|
|
231
|
+
custom_properties?: Record<string, unknown>;
|
|
230
232
|
}
|
|
231
233
|
interface RaindropConfig {
|
|
232
234
|
writeKey: string;
|
|
@@ -234,6 +236,8 @@ interface RaindropConfig {
|
|
|
234
236
|
userId: string;
|
|
235
237
|
debug: boolean;
|
|
236
238
|
enabled: boolean;
|
|
239
|
+
eventName: string;
|
|
240
|
+
customProperties: Record<string, unknown>;
|
|
237
241
|
}
|
|
238
242
|
/**
|
|
239
243
|
* Load config with precedence (low -> high):
|
|
@@ -275,11 +279,13 @@ interface HookPayload {
|
|
|
275
279
|
interface MapperConfig {
|
|
276
280
|
userId: string;
|
|
277
281
|
debug: boolean;
|
|
282
|
+
eventName: string;
|
|
283
|
+
customProperties: Record<string, unknown>;
|
|
278
284
|
}
|
|
279
285
|
declare function mapHookToRaindrop(payload: HookPayload, config: MapperConfig, eventShipper: EventShipper, traceShipper: TraceShipper): Promise<void>;
|
|
280
286
|
|
|
281
287
|
declare const PACKAGE_NAME = "@raindrop-ai/claude-code";
|
|
282
|
-
declare const PACKAGE_VERSION = "0.0.
|
|
288
|
+
declare const PACKAGE_VERSION = "0.0.4";
|
|
283
289
|
|
|
284
290
|
interface LocalDebuggerResult {
|
|
285
291
|
/** The resolved base URL (e.g. "http://localhost:5899/v1/"), or null if not detected. */
|
package/dist/index.d.ts
CHANGED
|
@@ -227,6 +227,8 @@ interface ConfigFile {
|
|
|
227
227
|
user_id?: string;
|
|
228
228
|
debug?: boolean;
|
|
229
229
|
enabled?: boolean;
|
|
230
|
+
event_name?: string;
|
|
231
|
+
custom_properties?: Record<string, unknown>;
|
|
230
232
|
}
|
|
231
233
|
interface RaindropConfig {
|
|
232
234
|
writeKey: string;
|
|
@@ -234,6 +236,8 @@ interface RaindropConfig {
|
|
|
234
236
|
userId: string;
|
|
235
237
|
debug: boolean;
|
|
236
238
|
enabled: boolean;
|
|
239
|
+
eventName: string;
|
|
240
|
+
customProperties: Record<string, unknown>;
|
|
237
241
|
}
|
|
238
242
|
/**
|
|
239
243
|
* Load config with precedence (low -> high):
|
|
@@ -275,11 +279,13 @@ interface HookPayload {
|
|
|
275
279
|
interface MapperConfig {
|
|
276
280
|
userId: string;
|
|
277
281
|
debug: boolean;
|
|
282
|
+
eventName: string;
|
|
283
|
+
customProperties: Record<string, unknown>;
|
|
278
284
|
}
|
|
279
285
|
declare function mapHookToRaindrop(payload: HookPayload, config: MapperConfig, eventShipper: EventShipper, traceShipper: TraceShipper): Promise<void>;
|
|
280
286
|
|
|
281
287
|
declare const PACKAGE_NAME = "@raindrop-ai/claude-code";
|
|
282
|
-
declare const PACKAGE_VERSION = "0.0.
|
|
288
|
+
declare const PACKAGE_VERSION = "0.0.4";
|
|
283
289
|
|
|
284
290
|
interface LocalDebuggerResult {
|
|
285
291
|
/** The resolved base URL (e.g. "http://localhost:5899/v1/"), or null if not detected. */
|
package/dist/index.js
CHANGED
|
@@ -645,7 +645,7 @@ globalThis.RAINDROP_ASYNC_LOCAL_STORAGE = AsyncLocalStorage;
|
|
|
645
645
|
|
|
646
646
|
// src/package-info.ts
|
|
647
647
|
var PACKAGE_NAME = "@raindrop-ai/claude-code";
|
|
648
|
-
var PACKAGE_VERSION = "0.0.
|
|
648
|
+
var PACKAGE_VERSION = "0.0.4";
|
|
649
649
|
|
|
650
650
|
// src/shipper.ts
|
|
651
651
|
var EventShipper2 = class extends EventShipper {
|
|
@@ -688,7 +688,7 @@ import { homedir, userInfo } from "os";
|
|
|
688
688
|
import { dirname, join } from "path";
|
|
689
689
|
var CONFIG_PATH = join(homedir(), ".config", "raindrop", "config.json");
|
|
690
690
|
function loadConfig() {
|
|
691
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
691
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
692
692
|
let file = {};
|
|
693
693
|
try {
|
|
694
694
|
if (existsSync(CONFIG_PATH)) {
|
|
@@ -703,12 +703,25 @@ function loadConfig() {
|
|
|
703
703
|
return "unknown";
|
|
704
704
|
}
|
|
705
705
|
})();
|
|
706
|
+
let customProperties = (_a = file.custom_properties) != null ? _a : {};
|
|
707
|
+
const envProps = process.env["RAINDROP_PROPERTIES"];
|
|
708
|
+
if (envProps) {
|
|
709
|
+
try {
|
|
710
|
+
const parsed = JSON.parse(envProps);
|
|
711
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
712
|
+
customProperties = { ...customProperties, ...parsed };
|
|
713
|
+
}
|
|
714
|
+
} catch (e) {
|
|
715
|
+
}
|
|
716
|
+
}
|
|
706
717
|
return {
|
|
707
|
-
writeKey: (
|
|
708
|
-
endpoint: (
|
|
709
|
-
userId: (
|
|
710
|
-
debug: process.env["RAINDROP_DEBUG"] === "true" ? true : (
|
|
711
|
-
enabled: (
|
|
718
|
+
writeKey: (_c = (_b = process.env["RAINDROP_WRITE_KEY"]) != null ? _b : file.write_key) != null ? _c : "",
|
|
719
|
+
endpoint: (_e = (_d = process.env["RAINDROP_API_URL"]) != null ? _d : file.api_url) != null ? _e : "https://api.raindrop.ai/v1",
|
|
720
|
+
userId: (_g = (_f = process.env["RAINDROP_USER_ID"]) != null ? _f : file.user_id) != null ? _g : systemUser,
|
|
721
|
+
debug: process.env["RAINDROP_DEBUG"] === "true" ? true : (_h = file.debug) != null ? _h : false,
|
|
722
|
+
enabled: (_i = file.enabled) != null ? _i : true,
|
|
723
|
+
eventName: (_k = (_j = process.env["RAINDROP_EVENT_NAME"]) != null ? _j : file.event_name) != null ? _k : "claude_code_session",
|
|
724
|
+
customProperties
|
|
712
725
|
};
|
|
713
726
|
}
|
|
714
727
|
function getConfigPath() {
|
|
@@ -837,6 +850,7 @@ async function mapHookToRaindrop(payload, config, eventShipper, traceShipper) {
|
|
|
837
850
|
var _a;
|
|
838
851
|
const convoId = payload.session_id;
|
|
839
852
|
const baseProperties = {
|
|
853
|
+
...config.customProperties,
|
|
840
854
|
cwd: payload.cwd,
|
|
841
855
|
permission_mode: payload.permission_mode,
|
|
842
856
|
plugin_version: PACKAGE_VERSION,
|
|
@@ -911,7 +925,7 @@ async function handleUserPromptSubmit(payload, convoId, config, properties, even
|
|
|
911
925
|
isPending: true,
|
|
912
926
|
userId: config.userId,
|
|
913
927
|
convoId,
|
|
914
|
-
eventName:
|
|
928
|
+
eventName: config.eventName,
|
|
915
929
|
input: payload.prompt,
|
|
916
930
|
model,
|
|
917
931
|
properties
|
|
@@ -1031,7 +1045,7 @@ async function handlePostCompact(payload, eventId, config, properties, eventShip
|
|
|
1031
1045
|
isPending: true,
|
|
1032
1046
|
userId: config.userId,
|
|
1033
1047
|
convoId: payload.session_id,
|
|
1034
|
-
eventName:
|
|
1048
|
+
eventName: config.eventName,
|
|
1035
1049
|
properties: {
|
|
1036
1050
|
...properties,
|
|
1037
1051
|
compaction_trigger: payload.trigger,
|
|
@@ -1040,15 +1054,19 @@ async function handlePostCompact(payload, eventId, config, properties, eventShip
|
|
|
1040
1054
|
});
|
|
1041
1055
|
}
|
|
1042
1056
|
async function handleStop(payload, eventId, config, properties, eventShipper) {
|
|
1043
|
-
await eventShipper.
|
|
1057
|
+
await eventShipper.patch(eventId, {
|
|
1058
|
+
isPending: false,
|
|
1044
1059
|
userId: config.userId,
|
|
1060
|
+
eventName: config.eventName,
|
|
1045
1061
|
output: payload.last_assistant_message,
|
|
1046
1062
|
properties
|
|
1047
1063
|
});
|
|
1048
1064
|
}
|
|
1049
1065
|
async function handleStopFailure(payload, eventId, config, properties, eventShipper) {
|
|
1050
|
-
await eventShipper.
|
|
1066
|
+
await eventShipper.patch(eventId, {
|
|
1067
|
+
isPending: false,
|
|
1051
1068
|
userId: config.userId,
|
|
1069
|
+
eventName: config.eventName,
|
|
1052
1070
|
output: payload.last_assistant_message,
|
|
1053
1071
|
properties: {
|
|
1054
1072
|
...properties,
|
|
@@ -1058,8 +1076,10 @@ async function handleStopFailure(payload, eventId, config, properties, eventShip
|
|
|
1058
1076
|
});
|
|
1059
1077
|
}
|
|
1060
1078
|
async function handleSessionEnd(payload, eventId, config, properties, eventShipper) {
|
|
1061
|
-
await eventShipper.
|
|
1079
|
+
await eventShipper.patch(eventId, {
|
|
1080
|
+
isPending: false,
|
|
1062
1081
|
userId: config.userId,
|
|
1082
|
+
eventName: config.eventName,
|
|
1063
1083
|
properties: {
|
|
1064
1084
|
...properties,
|
|
1065
1085
|
session_end_reason: payload.reason
|
package/package.json
CHANGED