@buda-ai/connector 0.1.34 → 0.1.36

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,19 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Sourced through BASH_ENV for Pi bash tool processes. Raising the score is
4
+ # permitted without CAP_SYS_RESOURCE and is inherited by every child process.
5
+ case "${BUDA_TOOL_OOM_SCORE_ADJ:-900}" in
6
+ '' | *[!0-9]*)
7
+ _buda_tool_oom_score=900
8
+ ;;
9
+ *)
10
+ _buda_tool_oom_score="${BUDA_TOOL_OOM_SCORE_ADJ:-900}"
11
+ ;;
12
+ esac
13
+
14
+ if [ "$_buda_tool_oom_score" -gt 1000 ]; then
15
+ _buda_tool_oom_score=1000
16
+ fi
17
+
18
+ printf '%s\n' "$_buda_tool_oom_score" >"/proc/$$/oom_score_adj" 2>/dev/null || true
19
+ unset _buda_tool_oom_score
@@ -64,19 +64,18 @@ If a user hits a plan limit (e.g., they ask for a cron schedule or an interval l
64
64
  1. Parse the user's request to determine:
65
65
  - **What** the task should do → becomes `taskTemplate.prompt` (the `name` is also used as `taskTemplate.title` automatically)
66
66
  - **When** it should run → becomes `scheduleType` + schedule config
67
- - **How to deliver result**:
68
- - Default to current automation session (`delivery.mode: "session"`)
69
- - Do **not** use `delivery.mode: "notify"` just because the task is scheduled, recurring, or uses cron
70
- - Use `delivery.mode: "notify"` only when the user explicitly asks to notify/push/send the result to a connected channel
71
- - Set `delivery.sessionId` to target the exact connected chat/group/DM whenever it is available
72
- - `delivery.channelId` is a legacy fallback only; do not prefer it over `delivery.sessionId`
67
+ - **Where the result belongs**:
68
+ - When created from a conversation, the tool pins execution to that exact current session.
69
+ - Without a current session, each run creates a new session.
70
+ - Return normal assistant text in the execution session; a bound external conversation receives that reply automatically.
71
+ - Do not configure `taskTemplate.delivery`, use a channel's most recent chat, or call `deliver_to_channel` for the automation's normal result.
72
+ - To change the execution conversation later, use the automation settings in the Buda UI to choose a fixed conversation or a new conversation per run.
73
73
  2. Choose the right schedule type (see [Schedule types](#schedule-types) below)
74
74
  3. Call the `create_automation` tool. Example for an interval schedule:
75
75
  - `name`: "Daily News Briefing"
76
76
  - `scheduleType`: "interval"
77
77
  - `intervalMinutes`: 1440
78
78
  - `taskTemplate.prompt`: "Search today's financial news and generate a summary"
79
- - `taskTemplate.delivery.mode`: "session"
80
79
 
81
80
  Example for a cron schedule:
82
81
  - `name`: "Morning News"
@@ -84,16 +83,6 @@ If a user hits a plan limit (e.g., they ask for a cron schedule or an interval l
84
83
  - `cronExpression`: "0 9 * * *"
85
84
  - `timezone`: "Asia/Shanghai"
86
85
  - `taskTemplate.prompt`: "Search today's financial news and generate a summary"
87
- - `taskTemplate.delivery.mode`: "session"
88
-
89
- Example only when the user explicitly asks to push results to a connected chat/group/DM:
90
- - `name`: "Morning News to Team Group"
91
- - `scheduleType`: "cron"
92
- - `cronExpression`: "0 9 * * *"
93
- - `timezone`: "Asia/Shanghai"
94
- - `taskTemplate.prompt`: "Search today's financial news and generate a summary"
95
- - `taskTemplate.delivery.mode`: "notify"
96
- - `taskTemplate.delivery.sessionId`: "tsk_xxxxxxxxxxxxxxxx"
97
86
 
98
87
  4. Report the result to the user, including the automation name and next run time.
99
88
 
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { readFileSync } = require("fs");
4
+ const path = require("path");
5
+
6
+ const PACKAGE_JSON_PATH = path.join(__dirname, "..", "package.json");
7
+ const NODE_DOWNLOAD_URL = "https://nodejs.org/en/download";
8
+
9
+ function parseVersion(value) {
10
+ const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(value);
11
+ if (!match) throw new Error(`Invalid Node.js version: ${value}`);
12
+ return match.slice(1).map(Number);
13
+ }
14
+
15
+ function parseMinimumVersion(requirement) {
16
+ const match = /^>=\s*(\d+\.\d+\.\d+)$/.exec(requirement);
17
+ if (!match) {
18
+ throw new Error(
19
+ `Unsupported package.json engines.node requirement: ${JSON.stringify(requirement)}`,
20
+ );
21
+ }
22
+ return match[1];
23
+ }
24
+
25
+ function isVersionAtLeast(detected, required) {
26
+ const detectedParts = parseVersion(detected);
27
+ const requiredParts = parseVersion(required);
28
+ for (let index = 0; index < requiredParts.length; index += 1) {
29
+ if (detectedParts[index] > requiredParts[index]) return true;
30
+ if (detectedParts[index] < requiredParts[index]) return false;
31
+ }
32
+ return true;
33
+ }
34
+
35
+ function readNodeRequirement(readPackageJson = readFileSync) {
36
+ const packageJson = JSON.parse(readPackageJson(PACKAGE_JSON_PATH, "utf8"));
37
+ if (
38
+ typeof packageJson !== "object" ||
39
+ packageJson === null ||
40
+ typeof packageJson.engines !== "object" ||
41
+ packageJson.engines === null ||
42
+ typeof packageJson.engines.node !== "string"
43
+ ) {
44
+ throw new Error("package.json engines.node must be configured");
45
+ }
46
+ return packageJson.engines.node;
47
+ }
48
+
49
+ function unsupportedNodeMessage(detected, requirement) {
50
+ return [
51
+ "Buda AI Connector requires a newer version of Node.js.",
52
+ "",
53
+ `Detected: Node.js v${detected}`,
54
+ `Required: Node.js ${requirement}`,
55
+ "Recommended: Node.js 24 LTS",
56
+ "",
57
+ `Upgrade Node.js: ${NODE_DOWNLOAD_URL}`,
58
+ "After upgrading, run your Buda Connector command again.",
59
+ "",
60
+ ].join("\n");
61
+ }
62
+
63
+ async function runBootstrap(options = {}) {
64
+ const detected = options.nodeVersion || process.versions.node;
65
+ const requirement = options.nodeRequirement || readNodeRequirement(options.readPackageJson);
66
+ const required = parseMinimumVersion(requirement);
67
+ if (!isVersionAtLeast(detected, required)) {
68
+ const writeError = options.writeError || ((message) => process.stderr.write(message));
69
+ writeError(unsupportedNodeMessage(detected, requirement));
70
+ return 1;
71
+ }
72
+
73
+ const loadCli = options.loadCli || (() => import("./cli.js"));
74
+ await loadCli();
75
+ return 0;
76
+ }
77
+
78
+ if (require.main === module) {
79
+ runBootstrap()
80
+ .then((exitCode) => {
81
+ process.exitCode = exitCode;
82
+ })
83
+ .catch((error) => {
84
+ console.error("[buda-connector] failed to start:", error);
85
+ process.exitCode = 1;
86
+ });
87
+ }
88
+
89
+ module.exports = {
90
+ isVersionAtLeast,
91
+ parseMinimumVersion,
92
+ parseVersion,
93
+ readNodeRequirement,
94
+ runBootstrap,
95
+ unsupportedNodeMessage,
96
+ };