@craftsamo/telegram-tools 0.1.0 → 0.3.0

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "telegram-tools",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "Unofficial Telegram tools for coding agents: chats, messages, received files and sends.",
5
5
  "author": {
6
6
  "name": "craftsamo",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "telegram-tools",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "Unofficial Telegram tools for coding agents: chats, messages, received files and sends.",
5
5
  "author": {
6
6
  "name": "craftsamo",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "telegram-tools",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "Unofficial Telegram tools for coding agents: chats, messages, received files and sends.",
5
5
  "author": {
6
6
  "name": "craftsamo",
@@ -15,6 +15,7 @@
15
15
  "command": "node",
16
16
  "args": ["dist/mcp.js"],
17
17
  "cwd": ".",
18
+ "default_tools_approval_mode": "writes",
18
19
  "env_vars": [
19
20
  "TELEGRAM_TOOLS_TOOLSETS",
20
21
  "TELEGRAM_TOOLS_READ_ONLY",
package/README.md CHANGED
@@ -79,7 +79,15 @@ codex plugin add telegram-tools@craft-agent
79
79
 
80
80
  Codex turns `-` into `_` in server names, so it shows the tools as
81
81
  `mcp__telegram_tools__telegram_*`. It starts the MCP server in the plugin's
82
- install directory, which is never the caller's working tree.
82
+ install directory and passes no roots, so the server takes each call's directory
83
+ from what Codex sends with the call: its sandbox state, which the server asks
84
+ for, else the one workspace it names.
85
+
86
+ The plugin declares `default_tools_approval_mode = "writes"`: Codex asks before
87
+ every tool not marked read-only. A user's
88
+ `[plugins."<plugin>".mcp_servers.<server>]` setting can only tighten it. Setting
89
+ `auto` there yields `prompt` (reads asked too), since Codex treats `auto` and
90
+ `writes` as incomparable.
83
91
 
84
92
  ### Grok Build
85
93
 
@@ -272,8 +280,10 @@ in Hermes.
272
280
  the entry points do. A tool that runs a program is tested against a fake of
273
281
  that program on `PATH`; no test reaches a real service.
274
282
  3. List it in `src/tools.ts`. A new toolset goes into `toolsets` in
275
- `src/project.ts` (and `defaultToolsets` when it is on by default), and a
276
- variable the tool reads besides the settings into `toolVariables`.
283
+ `src/project.ts` (and `defaultToolsets` when it is on by default), a
284
+ setting of the package's own into `options` (and `OPTIONS` in `project.py`
285
+ with `config_schema` in `plugin.yaml`), and a variable the tool reads
286
+ besides the settings into `toolVariables`.
277
287
  4. Add or update the toolset's skill, `skills/<prefix>-<toolset>/SKILL.md`,
278
288
  whose frontmatter names the toolset under `metadata`.
279
289
  5. Run `pnpm run build && pnpm run manifests` to list the tool in
@@ -282,6 +292,26 @@ in Hermes.
282
292
 
283
293
  [`docs/conventions.md`](docs/conventions.md) has the rules each step follows.
284
294
 
295
+ A package declares each option as `text`, `boolean`, `number`, `list`, `path`
296
+ or `paths`, or as an object with `type` and optional bounds. For example, in
297
+ `src/project.ts`:
298
+
299
+ ```ts
300
+ options: {
301
+ notes_dir: "path",
302
+ note_limit: { type: "number", integer: true, min: 1, max: 50 },
303
+ }
304
+ ```
305
+
306
+ `integer: true` requires a whole number; `min` and `max` bound a number or
307
+ count a `list` or `paths` value's items. An object with only `type` means the
308
+ same as the type alone. Hermes's `OPTIONS` mirrors the declarations on one
309
+ line, with double quotes and Python's `True` for `integer`:
310
+
311
+ ```python
312
+ OPTIONS: dict[str, str | dict[str, object]] = {"notes_dir": "path", "note_limit": {"type": "number", "integer": True, "min": 1, "max": 50}}
313
+ ```
314
+
285
315
  ## Reads and writes
286
316
 
287
317
  Every read tool is named `<prefix>_<domain>_read`. Reads can run unasked;
@@ -300,8 +330,11 @@ Where a write is asked about, and where it is not:
300
330
 
301
331
  - **OpenCode** grants any action no rule names, so a write runs unasked unless
302
332
  a rule asks for it: add the `telegram_*` rule shown under [OpenCode](#opencode).
303
- - **Codex** under `codex exec`, and **Grok Build** under `grok -p`, refuse a
304
- write they cannot ask about, unless it is allowed beforehand.
333
+ - **Codex** asks before every write because of the plugin's approval mode.
334
+ Under `codex exec` it refuses with "MCP tool call requires approval, but
335
+ approval policy is never".
336
+ - **Grok Build** under `grok -p` refuses a write it cannot ask about, unless it
337
+ is allowed beforehand.
305
338
  - **Grok Build** calls the plugin's tools through its `use_tool` tool, and the
306
339
  agent often names a tool without its server first. Grok checks the rules
307
340
  against the name as given, so the server-qualified rule alone does not match
@@ -318,22 +351,36 @@ Where a write is asked about, and where it is not:
318
351
  Every entry point takes the same settings. A flag wins over its environment
319
352
  variable, and an option or setting wins over the variable too.
320
353
 
321
- | Setting | Flag | Variable | Meaning |
322
- | ------------------- | ----------------------- | ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
323
- | `toolsets` | `--toolsets` | `TELEGRAM_TOOLS_TOOLSETS` | the toolsets that are on, or `all`; default those `src/project.ts` names |
324
- | `read_only` | `--read-only` | `TELEGRAM_TOOLS_READ_ONLY` | registers no tool that writes; wins over every other setting |
325
- | `tools` | `--tools` | `TELEGRAM_TOOLS_TOOLS` | single tools to add by ID, whatever their toolset |
326
- | `exclude_tools` | `--exclude-tools` | `TELEGRAM_TOOLS_EXCLUDE_TOOLS` | single tools to remove by ID; wins over `tools` and `toolsets` |
327
- | `confirm` | `--confirm` | `TELEGRAM_TOOLS_CONFIRM` | MCP server only: `harness` (default) or `elicitation`, as the conventions say |
328
- | `language` | `--language` | `TELEGRAM_TOOLS_LANGUAGE` | native plugins only: the approval prompt's language, such as `ja` |
329
- | `state_dir` | `--state-dir` | `TELEGRAM_TOOLS_STATE_DIR` | where every label's state lives; default `$XDG_STATE_HOME/telegram-tools` |
330
- | `download_dir` | `--download-dir` | `TELEGRAM_TOOLS_DOWNLOAD_DIR` | where `telegram_file_save` saves received files, a folder per message; default `~/Downloads/telegram-tools`; read by the tools, no service restart needed |
331
- | `download_max_mb` | `--download-max-mb <n>` | `TELEGRAM_TOOLS_DOWNLOAD_MAX_MB` | the largest file a download takes, in MB; integer 1..2000, default 100; read by the tools, no service restart needed |
332
- | `send_dirs` | `--send-dirs` | `TELEGRAM_TOOLS_SEND_DIRS` | the directories files may be sent from, besides the working directory; absolute paths, default none; read by the tools, no service restart needed |
333
- | `keep_disappearing` | `--keep-disappearing` | `TELEGRAM_TOOLS_KEEP_DISAPPEARING` | keep disappearing and view-once messages for the user; off by default; read by `sync` and `service install`, run `service install` again after changing it |
334
- | `channels` | `--channels` | `TELEGRAM_TOOLS_CHANNELS` | list, read, mirror and send to channels; off by default, see below; read by `sync` and `service install`, run `service install` again after changing it |
335
-
336
- Lists are comma-separated in a flag or a variable. Where each harness reads them:
354
+ | Setting | Flag | Variable | Meaning |
355
+ | ------------------- | ----------------------- | ---------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
356
+ | `toolsets` | `--toolsets` | `TELEGRAM_TOOLS_TOOLSETS` | the toolsets that are on, or `all`; default those `src/project.ts` names |
357
+ | `read_only` | `--read-only` | `TELEGRAM_TOOLS_READ_ONLY` | registers no tool that writes; wins over every other setting |
358
+ | `tools` | `--tools` | `TELEGRAM_TOOLS_TOOLS` | single tools to add by ID, whatever their toolset |
359
+ | `exclude_tools` | `--exclude-tools` | `TELEGRAM_TOOLS_EXCLUDE_TOOLS` | single tools to remove by ID; wins over `tools` and `toolsets` |
360
+ | `confirm` | `--confirm` | `TELEGRAM_TOOLS_CONFIRM` | MCP server only: `harness` (default) or `elicitation`, as the conventions say |
361
+ | `language` | `--language` | `TELEGRAM_TOOLS_LANGUAGE` | native plugins only: the approval prompt's language, such as `ja` |
362
+ | `emoji` | — | — | Hermes only: the emoji shown beside each toolset, by toolset name (`""` for none) |
363
+ | `state_dir` | `--state-dir` | `TELEGRAM_TOOLS_STATE_DIR` | `path`: where every label's state lives; default `$XDG_STATE_HOME/telegram-tools` |
364
+ | `download_dir` | `--download-dir` | `TELEGRAM_TOOLS_DOWNLOAD_DIR` | `path`: where `telegram_file_save` saves received files, a folder per message; default `~/Downloads/telegram-tools`; read by the tools, no service restart needed |
365
+ | `download_max_mb` | `--download-max-mb <n>` | `TELEGRAM_TOOLS_DOWNLOAD_MAX_MB` | `number`: the largest file a download takes, in MB; whole number 1..2000, default 100; read by the tools, no service restart needed |
366
+ | `send_dirs` | `--send-dirs` | `TELEGRAM_TOOLS_SEND_DIRS` | `paths`: the directories files may be sent from, besides the working directory; default none; read by the tools, no service restart needed |
367
+ | `keep_disappearing` | `--keep-disappearing` | `TELEGRAM_TOOLS_KEEP_DISAPPEARING` | `boolean`: keep disappearing and view-once messages for the user; off by default; read by `sync` and `service install`, run `service install` again after changing it |
368
+ | `channels` | `--channels` | `TELEGRAM_TOOLS_CHANNELS` | `boolean`: list, read, mirror and send to channels; off by default, see below; read by `sync` and `service install`, run `service install` again after changing it |
369
+
370
+ Lists are comma-separated in a flag or a variable. These are this package's own
371
+ settings listed in `options` in `src/project.ts`: `state_dir`, `download_dir`,
372
+ `download_max_mb`, `send_dirs`, `keep_disappearing` and `channels`. They are
373
+ read the same way. A `path` is trimmed; `~` and `~/…` (also with the platform
374
+ separator) stand for the home directory (`HOME` when it is absolute, else the
375
+ account's). It must then be absolute and reaches the tool normalized, without
376
+ a filesystem check. `paths` is a list of such paths, comma-separated in a flag or variable
377
+ and an array of strings in a plugin option. A blank path counts as unset, so
378
+ the default applies. Blank list items are dropped; a list with none left also
379
+ counts as unset.
380
+ Bounds check only a given value, not an unset option. Refused values are
381
+ `invalid_argument`, naming the flag, variable or option and what it must be.
382
+ Hermes passes paths and lists to the command line, which checks the paths and
383
+ bounds. Where each harness reads them:
337
384
 
338
385
  - **OpenCode** takes the plugin `options` shown above, with lists as arrays,
339
386
  `read_only` as a boolean, `state_dir` and `download_dir` as paths, and
@@ -507,7 +554,7 @@ device name the service logs in as identify it as unofficial (§2.2, §2.3).
507
554
  ## Layout
508
555
 
509
556
  - `src/project.ts` — the package's name, tool ID prefix, setting prefix,
510
- toolsets and the other variables its tools read.
557
+ toolsets, tool options and the other variables its tools read.
511
558
  - `src/core/` — the tool contract and the tools, free of any harness and of
512
559
  the project's names.
513
560
  - `src/tools.ts` — the list of every tool, which each entry point registers.