@marcopeg/hal 1.0.25 → 1.0.26

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.
Files changed (36) hide show
  1. package/dist/bot/commands/model-callback.d.ts.map +1 -1
  2. package/dist/bot/commands/model-callback.js +2 -1
  3. package/dist/bot/commands/model-callback.js.map +1 -1
  4. package/dist/bot/commands/model.d.ts.map +1 -1
  5. package/dist/bot/commands/model.js +2 -1
  6. package/dist/bot/commands/model.js.map +1 -1
  7. package/dist/bot/commands/tasks.d.ts +5 -0
  8. package/dist/bot/commands/tasks.d.ts.map +1 -0
  9. package/dist/bot/commands/tasks.js +123 -0
  10. package/dist/bot/commands/tasks.js.map +1 -0
  11. package/dist/bot/handlers/index.d.ts +1 -0
  12. package/dist/bot/handlers/index.d.ts.map +1 -1
  13. package/dist/bot/handlers/index.js +1 -0
  14. package/dist/bot/handlers/index.js.map +1 -1
  15. package/dist/bot/handlers/mjs-callback.d.ts +15 -0
  16. package/dist/bot/handlers/mjs-callback.d.ts.map +1 -0
  17. package/dist/bot/handlers/mjs-callback.js +84 -0
  18. package/dist/bot/handlers/mjs-callback.js.map +1 -0
  19. package/dist/bot.d.ts.map +1 -1
  20. package/dist/bot.js +3 -1
  21. package/dist/bot.js.map +1 -1
  22. package/dist/cli.js +185 -57
  23. package/dist/cli.js.map +1 -1
  24. package/dist/config.d.ts.map +1 -1
  25. package/dist/config.js +14 -1
  26. package/dist/config.js.map +1 -1
  27. package/dist/engine/cli-available.d.ts +6 -0
  28. package/dist/engine/cli-available.d.ts.map +1 -0
  29. package/dist/engine/cli-available.js +19 -0
  30. package/dist/engine/cli-available.js.map +1 -0
  31. package/dist/engine/opencode-models.d.ts +30 -0
  32. package/dist/engine/opencode-models.d.ts.map +1 -0
  33. package/dist/engine/opencode-models.js +96 -0
  34. package/dist/engine/opencode-models.js.map +1 -0
  35. package/dist/init-template.yaml +32 -0
  36. package/package.json +2 -2
@@ -0,0 +1,30 @@
1
+ import type { ProviderModel } from "../config.js";
2
+ /** Minimal config shape needed to resolve effective provider models for /model UI. */
3
+ export interface EffectiveModelsConfig {
4
+ engine: string;
5
+ providerModels: ProviderModel[];
6
+ cwd: string;
7
+ engineCommand?: string;
8
+ }
9
+ /**
10
+ * Returns the model list to show in /model: from config, or from the engine CLI
11
+ * when the engine supports self-discovery (opencode, cursor) and providers.* is not set.
12
+ */
13
+ export declare function getEffectiveProviderModels(config: EffectiveModelsConfig): ProviderModel[];
14
+ /**
15
+ * Runs `opencode models` (or `${command} models`) in the given cwd and parses
16
+ * stdout into a list of ProviderModel. Used when providers.opencode is not
17
+ * set so the /model UI shows only models actually supported by the OpenCode CLI.
18
+ *
19
+ * Returns [] on any failure (command missing, non-zero exit, or unparseable output).
20
+ */
21
+ export declare function getOpencodeModelsFromCli(cwd: string, command?: string): ProviderModel[];
22
+ /**
23
+ * Runs `agent models` (or `${command} models`) in the given cwd and parses
24
+ * stdout into a list of ProviderModel. Used when providers.cursor is not set
25
+ * so the /model UI shows only models actually supported by the Cursor Agent CLI.
26
+ *
27
+ * Returns [] on any failure (command missing, non-zero exit, or unparseable output).
28
+ */
29
+ export declare function getCursorModelsFromCli(cwd: string, command?: string): ProviderModel[];
30
+ //# sourceMappingURL=opencode-models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opencode-models.d.ts","sourceRoot":"","sources":["../../src/engine/opencode-models.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,sFAAsF;AACtF,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,aAAa,EAAE,CAAC;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,qBAAqB,GAC5B,aAAa,EAAE,CAYjB;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,MAAmB,GAC3B,aAAa,EAAE,CAqCjB;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,MAAgB,GACxB,aAAa,EAAE,CAoCjB"}
@@ -0,0 +1,96 @@
1
+ import { execSync } from "node:child_process";
2
+ /**
3
+ * Returns the model list to show in /model: from config, or from the engine CLI
4
+ * when the engine supports self-discovery (opencode, cursor) and providers.* is not set.
5
+ */
6
+ export function getEffectiveProviderModels(config) {
7
+ if (config.providerModels.length > 0)
8
+ return config.providerModels;
9
+ if (config.engine === "opencode") {
10
+ return getOpencodeModelsFromCli(config.cwd, config.engineCommand ?? "opencode");
11
+ }
12
+ if (config.engine === "cursor") {
13
+ return getCursorModelsFromCli(config.cwd, config.engineCommand ?? "agent");
14
+ }
15
+ return config.providerModels;
16
+ }
17
+ /**
18
+ * Runs `opencode models` (or `${command} models`) in the given cwd and parses
19
+ * stdout into a list of ProviderModel. Used when providers.opencode is not
20
+ * set so the /model UI shows only models actually supported by the OpenCode CLI.
21
+ *
22
+ * Returns [] on any failure (command missing, non-zero exit, or unparseable output).
23
+ */
24
+ export function getOpencodeModelsFromCli(cwd, command = "opencode") {
25
+ try {
26
+ const stdout = execSync(`${command} models`, {
27
+ cwd,
28
+ encoding: "utf-8",
29
+ timeout: 15_000,
30
+ stdio: ["ignore", "pipe", "pipe"],
31
+ });
32
+ const lines = stdout
33
+ .split(/\r?\n/)
34
+ .map((l) => l.trim())
35
+ .filter(Boolean);
36
+ const models = [];
37
+ for (const line of lines) {
38
+ // Skip header-like lines (all caps, "Available", "Model", "---", etc.)
39
+ const lower = line.toLowerCase();
40
+ if (lower.startsWith("available") ||
41
+ lower === "models" ||
42
+ /^[-=]+$/.test(line) ||
43
+ /^model\s/i.test(line)) {
44
+ continue;
45
+ }
46
+ // Accept lines that look like provider/model (e.g. opencode/gpt-5-nano) or plain model ids
47
+ if (/^[\w.-]+\/[\w.-]+$/.test(line) || /^[\w.-]+$/.test(line)) {
48
+ models.push({ name: line, description: undefined, default: false });
49
+ }
50
+ }
51
+ return models;
52
+ }
53
+ catch {
54
+ return [];
55
+ }
56
+ }
57
+ /**
58
+ * Runs `agent models` (or `${command} models`) in the given cwd and parses
59
+ * stdout into a list of ProviderModel. Used when providers.cursor is not set
60
+ * so the /model UI shows only models actually supported by the Cursor Agent CLI.
61
+ *
62
+ * Returns [] on any failure (command missing, non-zero exit, or unparseable output).
63
+ */
64
+ export function getCursorModelsFromCli(cwd, command = "agent") {
65
+ try {
66
+ const stdout = execSync(`${command} models`, {
67
+ cwd,
68
+ encoding: "utf-8",
69
+ timeout: 15_000,
70
+ stdio: ["ignore", "pipe", "pipe"],
71
+ });
72
+ const lines = stdout
73
+ .split(/\r?\n/)
74
+ .map((l) => l.trim())
75
+ .filter(Boolean);
76
+ const models = [];
77
+ for (const line of lines) {
78
+ const lower = line.toLowerCase();
79
+ if (lower.startsWith("available") ||
80
+ lower === "models" ||
81
+ /^[-=]+$/.test(line) ||
82
+ /^model\s/i.test(line)) {
83
+ continue;
84
+ }
85
+ // Cursor model ids: sonnet-4.6, opus-4.6, composer-1.5, auto, etc.
86
+ if (/^[\w.-]+$/.test(line) && line.length > 0) {
87
+ models.push({ name: line, description: undefined, default: false });
88
+ }
89
+ }
90
+ return models;
91
+ }
92
+ catch {
93
+ return [];
94
+ }
95
+ }
96
+ //# sourceMappingURL=opencode-models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opencode-models.js","sourceRoot":"","sources":["../../src/engine/opencode-models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAW9C;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CACxC,MAA6B;IAE7B,IAAI,MAAM,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,MAAM,CAAC,cAAc,CAAC;IACnE,IA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CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;YACtE,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
@@ -0,0 +1,32 @@
1
+ # HAL configuration
2
+ # Full config docs:
3
+ # {{HAL_DOCS_CONFIG}}
4
+
5
+ globals:
6
+ engine:
7
+ name: {{ENGINE_NAME}}
8
+ model: {{ENGINE_MODEL}}
9
+
10
+ # Who can use the bot
11
+ #
12
+ # How do I find my Telegram userID?
13
+ # {{HAL_DOCS_TELEGRAM}}
14
+ access:
15
+ allowedUserIds: ["${YOUR_TELEGRAM_USER_ID}"]
16
+
17
+ projects:
18
+ prj1:
19
+ active: true
20
+ cwd: {{PROJECT_CWD}}
21
+ engine:
22
+ name: {{ENGINE_NAME}}
23
+
24
+ # Link this project to a Telegram bot
25
+ #
26
+ # How do I create a Telegram bot?
27
+ # {{HAL_DOCS_TELEGRAM_CREATE_BOT}}
28
+ #
29
+ # How do I safely set the bot's api key via .env file?
30
+ # {{HAL_DOCS_TELEGRAM}}
31
+ telegram:
32
+ botToken: "${TELEGRAM_BOT_TOKEN}"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marcopeg/hal",
3
- "version": "1.0.25",
3
+ "version": "1.0.26",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -13,7 +13,7 @@
13
13
  "packageManager": "pnpm@10.13.1",
14
14
  "scripts": {
15
15
  "start": "tsx watch src/cli.ts start --cwd examples",
16
- "build": "tsc && chmod +x dist/cli.js",
16
+ "build": "tsc && cp src/init-template.yaml dist/ && chmod +x dist/cli.js",
17
17
  "typecheck": "tsc --noEmit",
18
18
  "lint": "biome check src",
19
19
  "lint:fix": "biome check --write src",