@tidegap/core 0.19.0 → 0.20.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.
Files changed (167) hide show
  1. package/README.md +1 -1
  2. package/dist/agent-snippet.d.ts +30 -0
  3. package/dist/agent-snippet.js +120 -0
  4. package/dist/channels/commands.d.ts +137 -0
  5. package/dist/channels/commands.js +377 -0
  6. package/dist/channels/delivery-codes.d.ts +9 -0
  7. package/dist/channels/delivery-codes.js +53 -0
  8. package/dist/channels/digest.d.ts +102 -0
  9. package/dist/channels/digest.js +146 -0
  10. package/dist/channels/format.d.ts +127 -0
  11. package/dist/channels/format.js +407 -0
  12. package/dist/channels/index.d.ts +15 -0
  13. package/dist/channels/index.js +15 -0
  14. package/dist/channels/kinds/command.d.ts +13 -0
  15. package/dist/channels/kinds/command.js +65 -0
  16. package/dist/channels/kinds/discord.d.ts +16 -0
  17. package/dist/channels/kinds/discord.js +67 -0
  18. package/dist/channels/kinds/email.d.ts +20 -0
  19. package/dist/channels/kinds/email.js +162 -0
  20. package/dist/channels/kinds/index.d.ts +8 -0
  21. package/dist/channels/kinds/index.js +17 -0
  22. package/dist/channels/kinds/ntfy.d.ts +25 -0
  23. package/dist/channels/kinds/ntfy.js +163 -0
  24. package/dist/channels/kinds/pushover.d.ts +11 -0
  25. package/dist/channels/kinds/pushover.js +77 -0
  26. package/dist/channels/kinds/shared.d.ts +25 -0
  27. package/dist/channels/kinds/shared.js +39 -0
  28. package/dist/channels/kinds/shortcuts.d.ts +9 -0
  29. package/dist/channels/kinds/shortcuts.js +45 -0
  30. package/dist/channels/kinds/slack.d.ts +8 -0
  31. package/dist/channels/kinds/slack.js +57 -0
  32. package/dist/channels/kinds/telegram.d.ts +4 -0
  33. package/dist/channels/kinds/telegram.js +26 -0
  34. package/dist/channels/kinds/webhook.d.ts +30 -0
  35. package/dist/channels/kinds/webhook.js +177 -0
  36. package/dist/channels/payload.d.ts +36 -0
  37. package/dist/channels/payload.js +61 -0
  38. package/dist/channels/plan.d.ts +24 -0
  39. package/dist/channels/plan.js +66 -0
  40. package/dist/channels/registry.d.ts +191 -0
  41. package/dist/channels/registry.js +125 -0
  42. package/dist/channels/telegram.d.ts +110 -0
  43. package/dist/channels/telegram.js +168 -0
  44. package/dist/channels/types.d.ts +107 -0
  45. package/dist/channels/types.js +26 -0
  46. package/dist/claude-tools.d.ts +29 -0
  47. package/dist/claude-tools.js +49 -0
  48. package/dist/data/tables.generated.d.ts +6 -0
  49. package/dist/data/tables.generated.js +37 -0
  50. package/dist/energy.d.ts +77 -0
  51. package/dist/energy.js +131 -0
  52. package/dist/grid.d.ts +17 -2
  53. package/dist/grid.js +43 -4
  54. package/dist/handoff.d.ts +152 -0
  55. package/dist/handoff.js +430 -0
  56. package/dist/history.d.ts +2 -0
  57. package/dist/history.js +3 -1
  58. package/dist/index.d.ts +43 -13
  59. package/dist/index.js +32 -6
  60. package/dist/job-cadence.d.ts +76 -0
  61. package/dist/job-cadence.js +240 -0
  62. package/dist/jobs.d.ts +173 -0
  63. package/dist/jobs.js +794 -0
  64. package/dist/notify.d.ts +2 -0
  65. package/dist/notify.js +2 -1
  66. package/dist/postpone.d.ts +113 -0
  67. package/dist/postpone.js +185 -0
  68. package/dist/providers/anthropic.js +7 -3
  69. package/dist/providers/base.d.ts +113 -1
  70. package/dist/providers/base.js +15 -0
  71. package/dist/providers/budget.d.ts +25 -0
  72. package/dist/providers/budget.js +57 -0
  73. package/dist/providers/defaults.js +4 -0
  74. package/dist/providers/defer.d.ts +16 -0
  75. package/dist/providers/defer.js +31 -0
  76. package/dist/providers/gemini.d.ts +1 -0
  77. package/dist/providers/gemini.js +27 -20
  78. package/dist/providers/index.d.ts +2 -2
  79. package/dist/providers/index.js +1 -1
  80. package/dist/providers/ollama.d.ts +1 -0
  81. package/dist/providers/ollama.js +26 -22
  82. package/dist/providers/openai.js +5 -5
  83. package/dist/providers/timeout.d.ts +18 -0
  84. package/dist/providers/timeout.js +33 -0
  85. package/dist/quota.d.ts +7 -2
  86. package/dist/quota.js +12 -27
  87. package/dist/readiness.d.ts +169 -0
  88. package/dist/readiness.js +254 -0
  89. package/dist/redact.d.ts +42 -0
  90. package/dist/redact.js +110 -0
  91. package/dist/region-host.d.ts +30 -0
  92. package/dist/region-host.js +69 -0
  93. package/dist/region.d.ts +102 -20
  94. package/dist/region.js +175 -23
  95. package/dist/run-session.d.ts +36 -0
  96. package/dist/run-session.js +72 -0
  97. package/dist/schedule-job.d.ts +95 -0
  98. package/dist/schedule-job.js +195 -0
  99. package/dist/scheduler.d.ts +245 -14
  100. package/dist/scheduler.js +919 -109
  101. package/dist/sign.d.ts +8 -1
  102. package/dist/sign.js +49 -3
  103. package/dist/storage/sqlite.d.ts +157 -5
  104. package/dist/storage/sqlite.js +661 -20
  105. package/dist/task-events.d.ts +102 -0
  106. package/dist/task-events.js +308 -0
  107. package/dist/tool-surface.d.ts +31 -2
  108. package/dist/tool-surface.js +359 -65
  109. package/dist/types.d.ts +246 -3
  110. package/dist/types.js +8 -1
  111. package/dist/zone-time.d.ts +22 -0
  112. package/dist/zone-time.js +76 -0
  113. package/package.json +10 -5
  114. package/dist/aggregator.d.ts.map +0 -1
  115. package/dist/aggregator.js.map +0 -1
  116. package/dist/budget.d.ts.map +0 -1
  117. package/dist/budget.js.map +0 -1
  118. package/dist/data/tables.generated.d.ts.map +0 -1
  119. package/dist/data/tables.generated.js.map +0 -1
  120. package/dist/energy.d.ts.map +0 -1
  121. package/dist/energy.js.map +0 -1
  122. package/dist/grid.d.ts.map +0 -1
  123. package/dist/grid.js.map +0 -1
  124. package/dist/history.d.ts.map +0 -1
  125. package/dist/history.js.map +0 -1
  126. package/dist/index.d.ts.map +0 -1
  127. package/dist/index.js.map +0 -1
  128. package/dist/notify.d.ts.map +0 -1
  129. package/dist/notify.js.map +0 -1
  130. package/dist/paths.d.ts.map +0 -1
  131. package/dist/paths.js.map +0 -1
  132. package/dist/providers/anthropic.d.ts.map +0 -1
  133. package/dist/providers/anthropic.js.map +0 -1
  134. package/dist/providers/base.d.ts.map +0 -1
  135. package/dist/providers/base.js.map +0 -1
  136. package/dist/providers/defaults.d.ts.map +0 -1
  137. package/dist/providers/defaults.js.map +0 -1
  138. package/dist/providers/gemini.d.ts.map +0 -1
  139. package/dist/providers/gemini.js.map +0 -1
  140. package/dist/providers/index.d.ts.map +0 -1
  141. package/dist/providers/index.js.map +0 -1
  142. package/dist/providers/ollama.d.ts.map +0 -1
  143. package/dist/providers/ollama.js.map +0 -1
  144. package/dist/providers/openai.d.ts.map +0 -1
  145. package/dist/providers/openai.js.map +0 -1
  146. package/dist/quota.d.ts.map +0 -1
  147. package/dist/quota.js.map +0 -1
  148. package/dist/recommend.d.ts.map +0 -1
  149. package/dist/recommend.js.map +0 -1
  150. package/dist/redact.d.ts.map +0 -1
  151. package/dist/redact.js.map +0 -1
  152. package/dist/region.d.ts.map +0 -1
  153. package/dist/region.js.map +0 -1
  154. package/dist/routing.d.ts.map +0 -1
  155. package/dist/routing.js.map +0 -1
  156. package/dist/scheduler.d.ts.map +0 -1
  157. package/dist/scheduler.js.map +0 -1
  158. package/dist/select-window.d.ts.map +0 -1
  159. package/dist/select-window.js.map +0 -1
  160. package/dist/sign.d.ts.map +0 -1
  161. package/dist/sign.js.map +0 -1
  162. package/dist/storage/sqlite.d.ts.map +0 -1
  163. package/dist/storage/sqlite.js.map +0 -1
  164. package/dist/tool-surface.d.ts.map +0 -1
  165. package/dist/tool-surface.js.map +0 -1
  166. package/dist/types.d.ts.map +0 -1
  167. package/dist/types.js.map +0 -1
@@ -23,7 +23,9 @@
23
23
  * the MCP renderer validates strictly (it `.parse()`s incoming arguments),
24
24
  * the OpenClaw renderer advertises the looser shapes it always has — so the
25
25
  * observable wire contract on each host is preserved while the surface
26
- * (names, parameter sets, requiredness, descriptions) is unified.
26
+ * (names, parameter sets, requiredness, descriptions) is unified. A tool
27
+ * whose handler differs per host carries a `descriptionPerHost` override;
28
+ * resolve the text with `descriptionForHost`.
27
29
  *
28
30
  * Host applicability is first-class: `set_delivery` is OpenClaw-only, and a
29
31
  * handful of parameters are host-scoped (MCP's `dry_run` / `dispatch` /
@@ -44,7 +46,7 @@ const deadlineParam = {
44
46
  name: "deadline",
45
47
  kind: "string",
46
48
  format: "date-time",
47
- description: "ISO-8601 timestamp (e.g. '2026-05-13T08:00:00-04:00') by which the task must have completed. Must be in the future. Required.",
49
+ description: "When the task must be finished: ISO-8601 with a UTC offset, in the future. Convert the user's words, e.g. \"by 8am tomorrow\" in New York becomes '2026-05-13T08:00:00-04:00'.",
48
50
  };
49
51
  const regionParam = (opts) => ({
50
52
  name: "region",
@@ -58,31 +60,44 @@ const carbonBudgetParam = {
58
60
  kind: "number",
59
61
  positive: true,
60
62
  optional: true,
61
- description: "Optional hard cap on estimated grams CO2-equivalent for this task. Windows above the cap are dropped before the cleanest is chosen; if none inside the deadline meets the cap the task fails rather than dispatching to a dirty window.",
62
- };
63
- const providerParam = {
64
- name: "provider",
65
- kind: "enum",
66
- values: ["anthropic", "openai", "gemini", "ollama"],
67
- optional: true,
68
- description: "Which provider to dispatch this task through: 'anthropic', 'openai', 'gemini', or 'ollama' (local). Defaults to 'anthropic'. 'anthropic' and 'openai' can auto-route through a 50%-cheaper Batch API when the deadline allows; 'gemini' and 'ollama' always dispatch synchronously.",
63
+ description: "Hard cap on the task's estimated grams CO2e, e.g. 5. Windows above it are skipped; if no window before the deadline fits, the task fails instead of running on a dirty grid. Omit for no cap.",
69
64
  };
65
+ // `claude-code` runs only in `tidegap tick` (the CLI host spawns the local
66
+ // Claude Code CLI), so it is offered on MCP and not on OpenClaw.
67
+ const providerParams = [
68
+ {
69
+ name: "provider",
70
+ kind: "enum",
71
+ hosts: ["mcp"],
72
+ values: ["anthropic", "openai", "gemini", "ollama", "claude-code"],
73
+ optional: true,
74
+ description: "Where the task runs. 'claude-code' uses the local Claude Code login on the next `tidegap tick`, with no API key (see tools); 'ollama' is a local model; the others need their API key. Defaults to 'claude-code' when queued from a Claude Code session (it then runs in a copy of that session, in its project directory), else 'anthropic'; an explicit 'anthropic' never resumes a session. 'anthropic' and 'openai' can use the 50%-cheaper Batch API when the deadline allows; the others always run synchronously.",
75
+ },
76
+ {
77
+ name: "provider",
78
+ kind: "enum",
79
+ hosts: ["openclaw"],
80
+ values: ["anthropic", "openai", "gemini", "ollama"],
81
+ optional: true,
82
+ description: "Where the task runs; 'ollama' is a local model, the others need their key in the plugin config. Defaults to the provider the model name implies ('gpt-…' is openai, 'gemini-…' is gemini, a configured Ollama model is ollama), else 'anthropic'. The gateway runs every task synchronously.",
83
+ },
84
+ ];
70
85
  const candidatesParam = {
71
86
  name: "candidates",
72
87
  kind: "array",
73
88
  itemKind: "string",
74
89
  optional: true,
75
- description: "Optional cross-provider routing candidates: 'provider:model' strings (e.g. ['anthropic:claude-haiku-4-5','openai:gpt-6-luna','ollama:llama-3-1-8b']) the caller EXPLICITLY allows. With >= 2 entries the scheduler scores them at the chosen dispatch window on a weighted blend of carbon, cost and latency and dispatches the winner (recording the full scored list on the signed receipt). No silent model swaps — routing only ever picks from this list. Absent or a single entry leaves the provider/model behavior unchanged. Every candidate model must exist in the price table or the task is rejected loudly.",
90
+ description: "'provider:model' pairs the user allows, e.g. ['anthropic:claude-haiku-4-5','ollama:llama-3-1-8b']. With 2 or more, the scheduler scores each at the chosen window on carbon, cost and latency (see route_weights), runs the winner and records the scores on the receipt; it never picks a model outside this list. Omit, or pass one entry, to keep provider and model as given. A model missing from the price table is rejected.",
76
91
  };
77
92
  const routeWeightsParam = {
78
93
  name: "route_weights",
79
94
  kind: "object",
80
95
  optional: true,
81
- description: "Optional routing weights {carbon, cost, latency}, non-negative and normalized internally. Default {carbon:0.6, cost:0.3, latency:0.1}. Only used when 'candidates' has >= 2 entries.",
96
+ description: "How to rank candidates, e.g. {\"carbon\": 1} for carbon only. Weights are relative and normalized; a key left out counts as 0. Omit for the default {carbon: 0.6, cost: 0.3, latency: 0.1}. Ignored unless candidates has 2 or more entries.",
82
97
  properties: [
83
- { name: "carbon", kind: "number", min: 0, optional: true, description: "Weight on estimated grams CO2e at the chosen window (non-negative)." },
84
- { name: "cost", kind: "number", min: 0, optional: true, description: "Weight on estimated USD list cost, batch discount applied when eligible (non-negative)." },
85
- { name: "latency", kind: "number", min: 0, optional: true, description: "Weight on the static latency tier: local < hosted-sync < hosted-batch (non-negative)." },
98
+ { name: "carbon", kind: "number", min: 0, optional: true, description: "Relative weight on the estimated grams CO2e at the chosen window. Omit to weight it 0 when route_weights is given." },
99
+ { name: "cost", kind: "number", min: 0, optional: true, description: "Relative weight on the estimated USD list cost, batch discount included when eligible. Omit to weight it 0 when route_weights is given." },
100
+ { name: "latency", kind: "number", min: 0, optional: true, description: "Relative weight on speed: local beats hosted sync, which beats hosted batch. Omit to weight it 0 when route_weights is given." },
86
101
  ],
87
102
  };
88
103
  const modelParam = (opts) => ({
@@ -92,12 +107,12 @@ const modelParam = (opts) => ({
92
107
  hosts: opts.hosts,
93
108
  description: opts.description,
94
109
  });
95
- const scheduleModelDescription = (anthropicOverride) => `Model to dispatch with (e.g. 'claude-sonnet-5' for Anthropic, 'gpt-6-sol' for OpenAI). Defaults per provider: anthropic '${DEFAULT_MODEL_BY_PROVIDER.anthropic}'${anthropicOverride}, openai '${DEFAULT_MODEL_BY_PROVIDER.openai}', gemini '${DEFAULT_MODEL_BY_PROVIDER.gemini}', ollama '${DEFAULT_MODEL_BY_PROVIDER.ollama}'. When >= 2 'candidates' are supplied, routing may overwrite this with the winning candidate.`;
110
+ const scheduleModelDescription = (anthropicOverride) => `Model id for the chosen provider, e.g. 'claude-sonnet-5' (anthropic) or 'gpt-6-sol' (openai). Omit for the provider default: anthropic '${DEFAULT_MODEL_BY_PROVIDER.anthropic}'${anthropicOverride}, openai '${DEFAULT_MODEL_BY_PROVIDER.openai}', gemini '${DEFAULT_MODEL_BY_PROVIDER.gemini}', ollama '${DEFAULT_MODEL_BY_PROVIDER.ollama}'. With 2 or more candidates, routing may pick another model from that list.`;
96
111
  const taskIdRequired = {
97
112
  name: "task_id",
98
113
  kind: "string",
99
114
  minLength: 1,
100
- description: "Task identifier returned by schedule_task.",
115
+ description: "The task's id, e.g. 't-3f2a…', from the schedule_task reply or the check_queue_status list.",
101
116
  };
102
117
  const deliverModes = ["chat", "telegram", "webhook", "file", "queue", "os"];
103
118
  const reportFormats = ["md", "html", "txt", "json", "pdf"];
@@ -108,21 +123,21 @@ const deliverParam = (optional) => ({
108
123
  values: deliverModes,
109
124
  optional,
110
125
  hosts: ["openclaw"],
111
- description: "How to deliver the result when the task completes — one or more of: chat (the user's active OpenClaw chat), telegram, webhook, file, queue, os (a native desktop notification on the gateway host). Default: chat.",
126
+ description: "Where the result goes when the task completes, one or more modes, e.g. ['chat','file']. chat is the user's active OpenClaw chat; os is a desktop notification on the gateway host; queue sends nothing. Default: chat. Ask the user first; set_delivery can change it later.",
112
127
  });
113
128
  const webhookUrlParam = {
114
129
  name: "webhook_url",
115
130
  kind: "string",
116
131
  optional: true,
117
132
  hosts: ["openclaw"],
118
- description: "Target URL when deliver includes 'webhook'.",
133
+ description: "URL that receives the full result as a POST, e.g. 'https://example.com/hooks/tidegap'. Needed when deliver includes 'webhook'; omit otherwise.",
119
134
  };
120
135
  const filePathParam = {
121
136
  name: "file_path",
122
137
  kind: "string",
123
138
  optional: true,
124
139
  hosts: ["openclaw"],
125
- description: "Output path when deliver includes 'file'.",
140
+ description: "Path on the gateway host to write the report to, e.g. '/var/reports/digest.md'. Needed when deliver includes 'file'; omit otherwise.",
126
141
  };
127
142
  const fileFormatParam = {
128
143
  name: "file_format",
@@ -130,20 +145,30 @@ const fileFormatParam = {
130
145
  values: reportFormats,
131
146
  optional: true,
132
147
  hosts: ["openclaw"],
133
- description: "Report format for 'file' delivery: md, html, txt, json, or pdf (pdf renders the HTML report via puppeteer if installed on the gateway). Default: md.",
148
+ description: "Report format for 'file' delivery, e.g. 'html'. Default: md. 'pdf' renders the HTML report and needs puppeteer on the gateway.",
134
149
  };
135
150
  // ── The canonical surface ───────────────────────────────────────────────────
136
151
  export const TOOL_SURFACE = [
137
152
  {
138
153
  name: "get_grid_forecast",
139
154
  hosts: ["mcp", "openclaw"],
140
- description: "Return the projected electricity-grid carbon intensity for a region, hour by hour. Use this when deciding whether to run an expensive AI task now or defer it — intensity is reported in grams CO2-equivalent per kWh with a categorical band (very_clean / clean / average / dirty / very_dirty). Read-only; does not touch the task queue.",
155
+ description: "Return the hour-by-hour grid carbon intensity forecast for one region, up to 72 hours ahead. Use when: the user asks how clean the grid is now or later, or wants the raw curve. Do not use to pick a run time for a task (use recommend_window) or to queue work (use schedule_task). Behavior: writes nothing; reads one grid feed, no login; GB is live without a key, other zones need a feed key or get synthetic data (Source: mock). Returns: region, source, generated time, one row per hour (gCO2/kWh and band), and the cleanest and dirtiest hour. Rejects an unknown zone and lists the closest zones.",
156
+ descriptionPerHost: {
157
+ openclaw: "Return the hour-by-hour grid carbon intensity forecast for one region, up to 72 hours ahead. Use when: the user asks how clean the grid is now or later, or wants the raw curve. Do not use to pick a run time for a task (use recommend_window) or to queue work (use schedule_task). Behavior: writes nothing; reads one grid feed; GB is live without a key, other zones need a feed key in the plugin config or get synthetic data (source: mock). Returns: region, source, generatedAt and entries (datetime, carbonIntensityGCo2PerKwh, band). Throws on an unknown zone, naming the closest ones.",
158
+ },
159
+ annotations: {
160
+ title: "Grid carbon forecast",
161
+ readOnlyHint: true,
162
+ destructiveHint: false,
163
+ idempotentHint: true,
164
+ openWorldHint: true,
165
+ },
141
166
  params: [
142
167
  regionParam({
143
168
  // Required on the MCP server; optional on OpenClaw, which defaults a
144
169
  // missing region from its config / the host timezone (else GB).
145
170
  optionalPerHost: { mcp: false, openclaw: true },
146
- description: "Electricity Maps grid zone code (e.g. 'US-CAL-CISO', 'US-TEX-ERCO', 'GB', 'FR', 'DE'). On hosts that allow omitting it, defaults to the configured region, else a host-timezone guess, else GB.",
171
+ description: "Grid zone code, e.g. 'US-CAL-CISO', 'GB' or 'DE'; take it from the user's location or the data center they name. `tidegap region list` prints the supported zones; any zone works with an Electricity Maps key. Defaults, where the host lets it be omitted, to the configured region, else the stored setting (`tidegap region set`), else a time-zone guess, else GB.",
147
172
  }),
148
173
  {
149
174
  name: "hours",
@@ -152,14 +177,24 @@ export const TOOL_SURFACE = [
152
177
  min: 1,
153
178
  max: 72,
154
179
  optional: true,
155
- description: "Forecast horizon in hours (1-72). Defaults to 24.",
180
+ description: "How many hours ahead to forecast, e.g. 12 to cover \"tonight\". Defaults to 24; 72 is the most.",
156
181
  },
157
182
  ],
158
183
  },
159
184
  {
160
185
  name: "recommend_window",
161
186
  hosts: ["mcp", "openclaw"],
162
- description: "Return the optimal carbon-aware execution window for a task WITHOUT scheduling it. Use this for non-committal planning — to see when the cleanest grid moment falls inside the deadline (and the savings vs running now) before deciding whether to commit via schedule_task. Returns the chosen window, top alternatives, a batch_eligible flag, the grid_source (which feed produced the forecast — 'mock' means synthetic data), and a one-line reasoning string. Read-only; does not touch the task queue.",
187
+ description: "Preview the cleanest run window before a task's deadline, without queuing it. Use when: the user asks when a task would run or what waiting saves. Do not use to queue the task (use schedule_task) or for the raw hourly curve (use get_grid_forecast). Behavior: writes nothing; reads the grid forecast; no login or key. Returns: scheduled_for, intensity, band, estimated_carbon_g_co2, estimated_savings_vs_now_pct, batch_eligible, grid_source (mock = synthetic), alternatives, reasoning; routing_preview with 2+ candidates. Rejects a past deadline, an unknown zone, or a carbon_budget_g no window meets.",
188
+ descriptionPerHost: {
189
+ openclaw: "Preview the cleanest run window before a task's deadline, without queuing it. Use when: the user asks when a task would run or what waiting saves. Do not use to queue the task (use schedule_task) or for the raw hourly curve (use get_grid_forecast). Behavior: writes nothing; reads the grid forecast; no key needed. Returns: scheduledFor, intensityGCo2PerKwh, band, estimatedCarbonGCo2, estimatedSavingsVsNowPct, batchEligible, gridSource (mock = synthetic), alternatives, reasoning, routingPreview with 2+ candidates. Throws on a past deadline, an unknown zone, or a carbon_budget_g no window meets.",
190
+ },
191
+ annotations: {
192
+ title: "Preview cleanest window",
193
+ readOnlyHint: true,
194
+ destructiveHint: false,
195
+ idempotentHint: true,
196
+ openWorldHint: true,
197
+ },
163
198
  params: [
164
199
  deadlineParam,
165
200
  regionParam({
@@ -167,14 +202,14 @@ export const TOOL_SURFACE = [
167
202
  // historically made it optional — kept as-is.
168
203
  optionalPerHost: { mcp: false, openclaw: true },
169
204
  minLength: 1,
170
- description: "Electricity Maps grid zone code (e.g. 'US-CAL-CISO', 'FR') the recommendation reasons over. On hosts that allow omitting it, defaults to the configured region, else a host-timezone guess, else GB.",
205
+ description: "Grid zone the task would run against, e.g. 'US-CAL-CISO' or 'FR'. `tidegap region list` prints the supported zones; any zone works with an Electricity Maps key. Defaults, where the host lets it be omitted, to the configured region, else the stored setting (`tidegap region set`), else a time-zone guess, else GB.",
171
206
  }),
172
207
  carbonBudgetParam,
173
208
  modelParam({
174
209
  // MCP-only: affects the reasoning string. OpenClaw's recommend_window
175
210
  // never exposed a model parameter.
176
211
  hosts: ["mcp"],
177
- description: "Optional vendor model name (e.g. 'claude-sonnet-5'). Affects the reasoning string only.",
212
+ description: "Model name to mention in the reasoning text, e.g. 'claude-sonnet-5'; it does not change the window. Omit to leave it out.",
178
213
  }),
179
214
  candidatesParam,
180
215
  routeWeightsParam,
@@ -183,13 +218,31 @@ export const TOOL_SURFACE = [
183
218
  {
184
219
  name: "schedule_task",
185
220
  hosts: ["mcp", "openclaw"],
186
- description: "Queue an AI task to run during off-peak hours inside the given deadline. Three parallel wins: (1) lighter on the electricity grid — deferring non-urgent tasks smooths projected AI compute demand; (2) 50% of sync list price (projected) — auto-routes through Anthropic/OpenAI Batch APIs when the deadline allows; (3) lower carbon — dispatch at the cleanest electricity-grid hour. Invoke this tool whenever the user phrases a request with deferral language: \"do this later\", \"by tomorrow\", \"tonight\", \"overnight\", \"by EOD\", \"sometime this week\", \"when you have a moment\", \"remind me to\", \"queue this up\", \"schedule this\", \"no rush\", \"not urgent\". Convert the user's wording to an ISO-8601 deadline and pass the task as the prompt. Returns a task_id you can later check with check_queue_status. Good fits: nightly digests, batch summaries, research sweeps, evaluator runs, multi-step report generation — anything the user is fine waiting on. Do NOT use for live chat, interactive code edits, or any task the user is actively waiting to see complete.",
221
+ description: "Queue an AI task or recurring job to run at the cleanest grid hour before its deadline; long deadlines may use the provider Batch API. Use when: the user defers work (\"tonight\", \"no rush\", \"before my limit resets\") or wants it repeated (\"every night\", \"daily\", a cron); map that to deadline or repeat. Do not use for work the user waits on (do it now), to preview only (use recommend_window or dry_run) or for limits (use tidegap_usage). Behavior: adds one task, one run of one runner (dry_run writes nothing), or with repeat a job of such tasks; `tidegap tick` runs it; reads the grid forecast; no login; the result stays in the queue (check_queue_status). Returns: task_id, status, scheduled_for, deadline, provider, model, runs_in, estimated_carbon_g_co2, a readiness line; a job adds job_id and its guarantee. Rejects a past deadline, an unknown zone, disallowed tools and shell commands.",
222
+ descriptionPerHost: {
223
+ openclaw: "Queue an AI task or recurring job to run at the cleanest grid hour before its deadline. Use when: the user defers work (\"tonight\", \"no rush\") or wants it repeated (\"every night\", \"daily\", a cron); map that to deadline or repeat. Do not use for work the user waits on (do it now) or to preview only (use recommend_window). Behavior: adds one task, one LLM call (never several agents), or with repeat a job of such tasks with chat delivery; the gateway runs it synchronously with a plugin provider key or the OpenClaw runtime; reads the grid forecast. Returns: task_id, status, scheduled_for, region, provider, model, estimated_carbon_g_co2, grid_source, dispatch, delivery_options, next_step (ask, then call set_delivery); a job returns job_id, guarantee, first_task_id. Throws on a past deadline, an unknown zone, a provider with no key, or shell commands.",
224
+ },
225
+ annotations: {
226
+ title: "Schedule task at cleanest hour",
227
+ readOnlyHint: false,
228
+ destructiveHint: false,
229
+ idempotentHint: false,
230
+ openWorldHint: true,
231
+ },
187
232
  params: [
188
233
  {
189
234
  name: "prompt",
190
235
  kind: "string",
191
236
  minLength: 1,
192
- description: "The prompt or task description to dispatch when the chosen window arrives.",
237
+ hosts: ["openclaw"],
238
+ description: "The full instruction the model receives when the window arrives, e.g. 'Summarize today's AI policy news in 5 bullets'. Include every fact the run needs.",
239
+ },
240
+ {
241
+ name: "prompt",
242
+ kind: "string",
243
+ minLength: 1,
244
+ hosts: ["mcp"],
245
+ description: "The full instruction the model receives when the window arrives, e.g. 'Summarize today's AI policy news in 5 bullets'. The run may start in a fresh session without this conversation (the reply's runs_in line says which), so name the files, decisions and constraints it needs.",
193
246
  },
194
247
  // OpenClaw keeps `deadline` required. On MCP it is optional because a
195
248
  // `deadline_kind: "quota_reset"` task has its deadline resolved by the
@@ -199,12 +252,12 @@ export const TOOL_SURFACE = [
199
252
  ...deadlineParam,
200
253
  hosts: ["mcp"],
201
254
  optional: true,
202
- description: "ISO-8601 timestamp (e.g. '2026-05-13T08:00:00-04:00') by which the task must have completed. Must be in the future. Required unless deadline_kind is 'quota_reset', in which case it is ignored.",
255
+ description: "When the task must be finished: ISO-8601 with a UTC offset, in the future. Convert the user's words, e.g. \"by 8am tomorrow\" in New York becomes '2026-05-13T08:00:00-04:00'. Omit with deadline_kind 'quota_reset', which sets it (a value is then ignored), or with a job repeat, whose first run then follows the cadence.",
203
256
  },
204
257
  regionParam({
205
258
  // Optional on BOTH hosts for schedule_task.
206
259
  optionalPerHost: { mcp: true, openclaw: true },
207
- description: "Grid-region override (Electricity Maps zone code such as 'US-CAL-CISO'). Defaults to the host's configured region, else a host-timezone guess, else GB.",
260
+ description: "Grid zone to plan against, e.g. 'US-CAL-CISO' or 'FR'; pass it only when the user names a place. `tidegap region list` prints the supported zones; any zone works with an Electricity Maps key. Defaults to the host's configured region (MCP: TIDEGAP_DEFAULT_REGION; OpenClaw: defaultRegion), else the stored setting (`tidegap region set`), else a time-zone guess, else GB. The reply's region_source names the rule that applied.",
208
261
  }),
209
262
  carbonBudgetParam,
210
263
  // The TIDEGAP_DEFAULT_MODEL override is read only by the MCP server, so the
@@ -217,30 +270,75 @@ export const TOOL_SURFACE = [
217
270
  hosts: ["openclaw"],
218
271
  description: scheduleModelDescription(""),
219
272
  }),
220
- providerParam,
273
+ ...providerParams,
221
274
  candidatesParam,
222
275
  routeWeightsParam,
223
276
  // ── MCP-only parameters ──
277
+ {
278
+ name: "tools",
279
+ kind: "array",
280
+ itemKind: "string",
281
+ optional: true,
282
+ hosts: ["mcp"],
283
+ description: "Claude Code tools for a 'claude-code' run, e.g. ['WebSearch','WebFetch'] for a research task; [] means none. Allowed: WebSearch, WebFetch, Read, Grep, Glob. Omit for the default: Read, Grep and Glob in the session's project directory for a task queued from a Claude Code session, else WebSearch and WebFetch (TIDEGAP_CLAUDE_TOOLS overrides that one). A web tool makes a task from a session run fresh, without its context. Rejected: any other name (Bash, Write, Edit, ...) and a set that mixes a file tool with a web tool, because web content is untrusted. A job keeps the whole group: any file tool means Read, Grep and Glob; any web tool means WebSearch and WebFetch. A job stores its tools when created and ignores TIDEGAP_CLAUDE_TOOLS.",
284
+ },
285
+ {
286
+ name: "runner",
287
+ kind: "enum",
288
+ values: ["anthropic", "openai", "gemini", "ollama", "claude-code"],
289
+ optional: true,
290
+ hosts: ["mcp"],
291
+ description: "Another name for provider, e.g. 'claude-code'; pass one of the two, or both with the same value. Omit it to follow provider and its default. 'command' is rejected: a shell command task is the user's call, queued with `tidegap queue add --runner command`.",
292
+ },
293
+ {
294
+ name: "cwd",
295
+ kind: "string",
296
+ optional: true,
297
+ hosts: ["mcp"],
298
+ description: "Absolute folder a 'claude-code' run works in, e.g. a worktree '/work/app/.worktrees/fix-login'. This session's project folder keeps the run in a copy of this session; another folder runs fresh there, told where the task came from. Rejected: '/', the home folder, a folder another user owns, home dot folders, ~/Library and .git folders. Omit to run in the session's project folder, or a temporary folder without a session.",
299
+ },
300
+ {
301
+ name: "permission_profile",
302
+ kind: "enum",
303
+ values: ["read", "web", "none"],
304
+ optional: true,
305
+ hosts: ["mcp"],
306
+ description: "Tool set of a 'claude-code' run: 'read' is Read, Grep and Glob in its folder; 'web' is WebSearch and WebFetch in a fresh temporary folder (no cwd); 'none' is no tools. Runs never get Bash, Write or Edit. Defaults to 'read' when cwd is given; omit both for tools or its default. Rejected when tools names another set.",
307
+ },
308
+ {
309
+ name: "result_path",
310
+ kind: "string",
311
+ optional: true,
312
+ hosts: ["mcp"],
313
+ description: "Absolute path of a new file, e.g. '/tmp/review.md'. When the task completes, Tidegap (never the run) writes the result text there with mode 0600, and the session's notice names it. It must be inside cwd, this session's project folder or the temp folder; rejected: an existing file, a name starting with '.', ~/.ssh, ~/.config, ~/Library and similar folders. Omit to keep the result in the queue only (check_queue_status).",
314
+ },
315
+ {
316
+ name: "wake_session",
317
+ kind: "boolean",
318
+ optional: true,
319
+ hosts: ["mcp"],
320
+ description: "true wakes this Claude Code session when the task finishes, if it sits idle, within 12 hours after its last turn ended: the session starts a turn by itself with the notice. A wake spends a model turn while nobody may be watching, so set it only when the user wants the result acted on at once. Rejected outside a Claude Code session. Omit (default false) to get the notice with the next prompt.",
321
+ },
224
322
  {
225
323
  name: "dry_run",
226
324
  kind: "boolean",
227
325
  optional: true,
228
326
  hosts: ["mcp"],
229
- description: "If true, return the planned dispatch (recommended window + carbon estimate) WITHOUT persisting anything. Useful for confirmation flows.",
327
+ description: "true previews the plan (window, carbon estimate, provider, model, runs_in) and queues nothing, e.g. to confirm with the user first. Defaults to false.",
230
328
  },
231
329
  {
232
330
  name: "dispatch",
233
331
  kind: "boolean",
234
332
  optional: true,
235
333
  hosts: ["mcp"],
236
- description: "If true (default), persist a provider_call task body that `tidegap tick` (CLI) or scheduler.tick (library) can dispatch. Set to false only to enqueue a placeholder prompt without a dispatchable body (legacy in-memory mode).",
334
+ description: "Defaults to true: store a task that `tidegap tick` runs. false queues an in-memory placeholder that never calls a model (tests only) and cannot combine with not_before or after_limit_reset. Omit it in normal use.",
237
335
  },
238
336
  {
239
337
  name: "output_path",
240
338
  kind: "string",
241
339
  optional: true,
242
340
  hosts: ["mcp"],
243
- description: "Optional absolute file path. When the task completes, Tidegap writes { taskId, result, receipt } as JSON to this path.",
341
+ description: "Absolute file path inside cwd, this session's project folder or the temp folder, e.g. '/tmp/digest.json'; when the task completes, { taskId, result, receipt } is written there as JSON, replacing a regular file you own. Its folder must exist; a name starting with '.', ~/.ssh, ~/.config, ~/Library and similar folders are rejected. Omit to keep the result only in the queue (check_queue_status).",
244
342
  },
245
343
  {
246
344
  name: "redact_in_receipt",
@@ -248,14 +346,14 @@ export const TOOL_SURFACE = [
248
346
  itemKind: "string",
249
347
  optional: true,
250
348
  hosts: ["mcp"],
251
- description: "Optional regex patterns to strip from the prompt before storing it on the receipt. Omit to use the default redaction of API-key-looking strings.",
349
+ description: "Regex patterns removed from the prompt before it is stored on the receipt, e.g. ['customer-[0-9]+'] for customer ids. Omit for the default, which strips API-key-looking strings.",
252
350
  },
253
351
  {
254
352
  name: "title",
255
353
  kind: "string",
256
354
  optional: true,
257
355
  hosts: ["mcp"],
258
- description: "Optional short title for the task (shown in queue lists). Defaults to the first line of the prompt, cut to 80 characters. API-key-looking strings are redacted.",
356
+ description: "Short label for queue lists, e.g. 'Weekly digest'. Defaults to the prompt's first line, cut to 80 characters; API-key-looking strings are redacted.",
259
357
  },
260
358
  {
261
359
  name: "deadline_kind",
@@ -263,29 +361,81 @@ export const TOOL_SURFACE = [
263
361
  values: ["absolute", "quota_reset"],
264
362
  optional: true,
265
363
  hosts: ["mcp"],
266
- description: "How the deadline is chosen. 'absolute' (default): use 'deadline'. 'quota_reset': run before the next weekly subscription-quota reset, minus a safety margin, as configured in ~/.tidegap/config (TIDEGAP_QUOTA_RESET_<LABEL>=<weekday> <HH:MM> [<IANA zone>], optional TIDEGAP_QUOTA_MARGIN_H_<LABEL>=<hours>, default 2). Use it when the user says 'before my weekly limit resets' or similar. A deadline more than 24 hours away can route the task through the provider Batch API.",
364
+ description: "Defaults to 'absolute': the deadline parameter sets the due time. 'quota_reset' sets it to the next weekly subscription-quota reset minus a margin, from ~/.tidegap/config (TIDEGAP_QUOTA_RESET_<LABEL>=<weekday> <HH:MM> [<IANA zone>]; margin TIDEGAP_QUOTA_MARGIN_H_<LABEL>, default 2 hours). Use it when the user says \"before my weekly limit resets\". A due time more than 24 hours away can use the provider Batch API.",
267
365
  },
268
366
  {
269
367
  name: "quota_provider",
270
368
  kind: "string",
271
369
  optional: true,
272
370
  hosts: ["mcp"],
273
- description: "Quota label for deadline_kind 'quota_reset' (e.g. 'claude', 'codex'). Optional when exactly one label is configured.",
371
+ description: "Which configured quota to follow with deadline_kind 'quota_reset', e.g. 'claude' or 'codex'. Omit when exactly one label is configured; rejected with any other deadline_kind.",
274
372
  },
275
373
  {
276
374
  name: "repeat",
277
375
  kind: "enum",
278
- values: ["none", "daily", "weekly", "quota_reset"],
376
+ values: ["none", "daily", "weekdays", "weekly", "every_n_hours", "quota_reset"],
279
377
  optional: true,
280
378
  hosts: ["mcp"],
281
- description: "Repeat rule. Defaults to 'none' (a one-off), also for deadline_kind 'quota_reset'; pass 'weekly' (or 'daily') to repeat. 'quota_reset' follows the weekly quota reset and needs deadline_kind 'quota_reset'. When an occurrence finishes (or is cancelled as a skip), the next one is queued automatically with the same prompt; each occurrence costs one provider call. Stop the series with cancel_task series=true.",
379
+ description: "Defaults to 'none', a one-off. 'daily', 'weekdays', 'weekly' and 'every_n_hours' create a job: each run is a new task with this prompt, started fresh (never a copy of this session) in this project at the cleanest hour of its period, e.g. \"every night\" is 'daily' with window '22:00-08:00'. A job rejects per-task options (region, carbon_budget_g, candidates, not_before, dry_run and the like). With deadline_kind 'quota_reset', 'daily', 'weekly' and 'quota_reset' start the older series instead, which follows the quota reset; 'weekdays' and 'every_n_hours' are rejected there. End a job or series with cancel_task series=true.",
380
+ },
381
+ {
382
+ name: "repeat",
383
+ kind: "enum",
384
+ values: ["none", "daily", "weekdays", "weekly", "every_n_hours"],
385
+ optional: true,
386
+ hosts: ["openclaw"],
387
+ description: "Defaults to 'none', a one-off. 'daily', 'weekdays', 'weekly' and 'every_n_hours' create a job: each run is a new task with this prompt at the cleanest hour of its period, e.g. \"every night\" is 'daily' with window '22:00-08:00'; deadline then bounds only the first run. A job rejects per-task options (region, carbon_budget_g, candidates, route_weights, deliver, webhook_url, file_path, file_format). End the job with cancel_task series=true.",
388
+ },
389
+ {
390
+ name: "every_hours",
391
+ kind: "number",
392
+ integer: true,
393
+ min: 2,
394
+ max: 168,
395
+ optional: true,
396
+ description: "Hours between runs for repeat 'every_n_hours', e.g. 6 for \"every 6 hours\". Each run comes at most this long after the previous start and not sooner than half of it. Required with 'every_n_hours'; omit for any other repeat.",
397
+ },
398
+ {
399
+ name: "days",
400
+ kind: "array",
401
+ itemKind: "enum",
402
+ values: ["mon", "tue", "wed", "thu", "fri", "sat", "sun"],
403
+ optional: true,
404
+ description: "Weekdays for repeat 'weekly', e.g. ['mon','thu'] for \"Mondays and Thursdays\". Defaults to today's weekday in time_zone; omit for any other repeat.",
405
+ },
406
+ {
407
+ name: "window",
408
+ kind: "string",
409
+ optional: true,
410
+ description: "Local hours a job may run in, 'HH:MM-HH:MM', e.g. '22:00-08:00' for \"at night\"; '22:00-06:00' crosses midnight. Each run then picks its cleanest hour inside that day's window. Only with repeat 'daily', 'weekdays' or 'weekly'; omit to allow any hour.",
411
+ },
412
+ {
413
+ name: "time_zone",
414
+ kind: "string",
415
+ optional: true,
416
+ description: "IANA zone that window and days are read in, e.g. 'Europe/Berlin'; take it from the user's location. Defaults to the host's system zone. Only with a job repeat.",
282
417
  },
283
418
  {
284
419
  name: "origin_session_id",
285
420
  kind: "string",
286
421
  optional: true,
287
422
  hosts: ["mcp"],
288
- description: "Claude Code session id of the conversation that queued the task, so the task detail can show `claude --resume <id>`. Pass it only when the host substitutes it (e.g. ${CLAUDE_SESSION_ID} in a slash command); values that are not 8-128 letters, digits, '-' or '_' are ignored.",
423
+ description: "Claude Code session id of the conversation that queued the task. Omit it: the server finds the current session itself when the Tidegap plugin is installed. Pass it only when the host substitutes it (e.g. ${CLAUDE_SESSION_ID} in a slash command); it then wins. Values that are not 8-128 letters, digits, '-' or '_' are ignored.",
424
+ },
425
+ {
426
+ name: "after_limit_reset",
427
+ kind: "boolean",
428
+ optional: true,
429
+ hosts: ["mcp"],
430
+ description: "true when the user says \"after my limit resets\": the task starts no earlier than the Claude subscription limit reset (the latest reset of an exhausted 5-hour or weekly window, else the fuller window's reset; see tidegap_usage), then runs at the cleanest hour after it. The deadline rises to at least two hours after the reset. Fails, queuing nothing, when no limit reading exists. Defaults to false; cannot combine with not_before.",
431
+ },
432
+ {
433
+ name: "not_before",
434
+ kind: "string",
435
+ format: "date-time",
436
+ optional: true,
437
+ hosts: ["mcp"],
438
+ description: "Earliest start, ISO-8601 with offset, e.g. '2026-05-12T18:00:00+02:00' for \"not before 6pm\" or \"after lunch\". The task then runs at the cleanest hour between it and the deadline; it must be in the future and not after the deadline. It is a bound, not a run time: with not_before 70 minutes away and a 3-hour deadline, the task can run near the end. Omit to allow any time up to the deadline; cannot combine with after_limit_reset.",
289
439
  },
290
440
  // ── OpenClaw-only parameters (result delivery) ──
291
441
  deliverParam(true),
@@ -297,81 +447,213 @@ export const TOOL_SURFACE = [
297
447
  {
298
448
  name: "check_queue_status",
299
449
  hosts: ["mcp", "openclaw"],
300
- description: "Report on the Tidegap task queue. With no arguments, returns a summary of all known tasks (including tasks persisted by previous sessions — the queue survives host restarts). With task_id, returns full detail for one task, including its title, prompt, result and any carbon receipt (estimated vs actual grams, grid_source, energy_source); viewing a completed or failed task marks it read. Never changes a task's status.",
450
+ description: "Show the local task queue and jobs: every task in brief or one in full. Use when: the user asks what is queued or repeats, whether a task finished, or for its result. Do not use to change a task (use cancel_task, postpone_task, update_deadline or retry_task) or for limits (use tidegap_usage). Behavior: no network or login; marks a shown completed or failed task read; never changes a status. Returns: without task_id, status counts, last_tick_at, a line per task and job (guarantee, next run and id, last result); with task_id, its prompt, result, receipt and events. Rejects an unknown task_id.",
451
+ descriptionPerHost: {
452
+ openclaw: "Show the local task queue and jobs: every task in brief, or one task in full. Use when: the user asks what is queued or repeats, whether a task finished, or for its result. Do not use to change a task (use cancel_task, update_deadline or retry_task) or to set delivery (use set_delivery). Behavior: no network or login; marks a completed or failed task read when shown; never changes a status. Returns: without task_id, total, last_tick_at, tasks (task_id, title, status, scheduled_for, job_id) and jobs (guarantee, next_run, last_outcome); with task_id, its record. Throws on an unknown task_id.",
453
+ },
454
+ annotations: {
455
+ title: "Show task queue",
456
+ readOnlyHint: false,
457
+ destructiveHint: false,
458
+ idempotentHint: true,
459
+ openWorldHint: false,
460
+ },
301
461
  params: [
302
462
  {
303
463
  name: "task_id",
304
464
  kind: "string",
305
465
  optional: true,
306
- description: "If present, return only this task. If omitted, return a queue summary.",
466
+ description: "One task's id, e.g. 't-3f2a…', from schedule_task or this tool's summary, to get its full record. Omit for the summary of all tasks.",
467
+ },
468
+ ],
469
+ },
470
+ {
471
+ name: "tidegap_usage",
472
+ hosts: ["mcp"],
473
+ description: "Report this machine's Claude Code limits: 5-hour and weekly percent used, reset times, and Codex limits if present. Use when: the user asks how much quota is left, or before heavy Claude Code work; at 90% or more, pass after_limit_reset to schedule_task. Do not use for task state (use check_queue_status). Behavior: reads the statusline reading, no API key; TIDEGAP_USAGE_OAUTH=1 calls the usage endpoint with the Claude Code login and caches it in ~/.tidegap/usage.json; never writes tasks or settings. Returns: a summary line and the usage/v1 JSON (windows, reading age, after_limit_reset wait).",
474
+ annotations: {
475
+ title: "Claude usage limits",
476
+ readOnlyHint: false,
477
+ destructiveHint: false,
478
+ idempotentHint: true,
479
+ openWorldHint: true,
480
+ },
481
+ params: [
482
+ {
483
+ name: "include_spend",
484
+ kind: "boolean",
485
+ optional: true,
486
+ description: "true adds claude_spend: tokens and an API list-price cost estimate for the current 5-hour window from the local Claude Code logs (total, by model, the five latest sessions), plus the tokens of recent Codex sessions. Use it when the user asks what their usage would cost; the scan takes a few seconds. Defaults to false.",
307
487
  },
308
488
  ],
309
489
  },
310
490
  {
311
491
  name: "cancel_task",
312
492
  hosts: ["mcp", "openclaw"],
313
- description: "Cancel a queued or scheduled task. Idempotent — if the task is already completed/failed/cancelled this returns the existing status without error. Throws only if task_id is unknown. Cancelling one occurrence of a repeating task skips it and queues the next one; pass series=true to end the series.",
493
+ description: "Cancel one queued or scheduled task by task_id; for all pending, use cancel_all. Use when: the user drops one task. Do not use to delay it (use postpone_task) or rerun a failed one (use retry_task). Behavior: marks it cancelled locally (no network) and redacts its prompt. Also cancels running and submitted tasks; a Batch call may still bill. A job or series skips this run; series=true ends it, even from a finished run. Else a finished task or repeat call changes nothing. Returns: \"Task <id> status: <status>\", terminated_at, and a job or series line when ended. Rejects an unknown task_id.",
494
+ descriptionPerHost: {
495
+ openclaw: "Cancel one queued or scheduled task by task_id; for all pending, use cancel_all. Use when: the user drops a task. Do not use to delay it (use update_deadline) or rerun a failed one (use retry_task). Behavior: marks it cancelled locally (no network) and redacts its prompt. Also cancels running and submitted tasks; a Batch call may still bill. A job or series skips this run; series=true ends it, even from a finished run. Else a finished task or repeat call changes nothing. Returns: task_id, status, completed_at, job_id and job_ended or series_id and series_ended. Throws on an unknown task_id.",
496
+ },
497
+ annotations: {
498
+ title: "Cancel one task",
499
+ readOnlyHint: false,
500
+ destructiveHint: true,
501
+ idempotentHint: true,
502
+ openWorldHint: false,
503
+ },
314
504
  params: [
315
- { ...taskIdRequired, description: "The id of the task to cancel." },
505
+ { ...taskIdRequired, description: "Id of the task to cancel, e.g. 't-3f2a…', from the schedule_task reply or the check_queue_status list." },
316
506
  {
317
507
  name: "series",
318
508
  kind: "boolean",
319
509
  optional: true,
320
- description: "If true and the task repeats, also end its series: no further occurrence is queued. Default false (skip only this occurrence).",
510
+ description: "true also ends the job or series this task is a run of, so no further run is queued; use it for \"stop this for good\". Defaults to false: skip only this run; a job then plans its next one. No effect on a one-off task.",
321
511
  },
322
512
  ],
323
513
  },
324
514
  {
325
515
  name: "expedite_task",
326
516
  hosts: ["mcp", "openclaw"],
327
- description: "Dispatch a queued or scheduled provider-call task immediately, bypassing the scheduler's chosen carbon window. The resulting receipt records intensitySource='expedited'. Only provider-call tasks still queued/scheduled can be expedited; running, submitted (awaiting Batch API results), or terminal (completed/failed/cancelled) tasks are rejected with an explanatory error.",
328
- params: [{ ...taskIdRequired, description: "The id of the task to dispatch now." }],
517
+ description: "Run one queued or scheduled task now, skipping its clean window. Use when: the user wants the result now. Do not use for a failed task (use retry_task), to pick a new deadline (use update_deadline), or for a claude-code task (run `tidegap queue run-now <id>`). Behavior: drops its earliest start and makes one provider call at the current grid intensity; needs the task provider's key in the server env (and ANTHROPIC_API_KEY or OPENAI_API_KEY); the receipt records intensitySource=expedited. Returns: status and error on failure. Rejects running, submitted, finished and unknown tasks.",
518
+ descriptionPerHost: {
519
+ openclaw: "Run one queued or scheduled task now, skipping its clean-grid window. Use when: the user wants the result now (\"do it now\", \"don't wait\"). Do not use for a failed task (use retry_task) or to pick a new deadline (use update_deadline). Behavior: drops its earliest start and makes one provider call at the current grid intensity, through the OpenClaw runtime or a provider key in the plugin config, then delivers the result; the receipt records intensitySource=expedited. Returns: status, error on failure, result, receipt and delivery. Throws on running, submitted, finished and unknown tasks.",
520
+ },
521
+ annotations: {
522
+ title: "Run task now",
523
+ readOnlyHint: false,
524
+ destructiveHint: false,
525
+ idempotentHint: false,
526
+ openWorldHint: true,
527
+ },
528
+ params: [{ ...taskIdRequired, description: "Id of the queued or scheduled task to run now, e.g. 't-3f2a…', from the schedule_task reply or the check_queue_status list." }],
329
529
  },
330
530
  {
331
531
  name: "update_deadline",
332
532
  hosts: ["mcp", "openclaw"],
333
- description: "Re-score and reschedule a queued or scheduled task against a new deadline; the scheduler re-picks the cleanest window inside it. Throws if the task is already running or terminal, or if the new deadline is invalid or in the past.",
533
+ description: "Change the deadline of one queued or scheduled task and re-pick its cleanest window inside it. Use when: the user moves the due time, earlier or later (\"by 6pm instead\"). Do not use to delay the start inside the same deadline (use postpone_task), to run now (use expedite_task) or to stop it (use cancel_task). Behavior: rewrites only this task in the local queue, clears its earliest start and quota rule, re-reads the grid forecast; no login. A repeat call only re-picks the hour. Returns: status, scheduled_for, new_deadline. Rejects running, finished or unknown tasks and a past deadline.",
534
+ descriptionPerHost: {
535
+ openclaw: "Change the deadline of one queued or scheduled task and re-pick its cleanest window inside it. Use when: the user moves the due time, earlier or later (\"by 6pm instead\"). Do not use to run now (use expedite_task) or to stop it (use cancel_task). Behavior: rewrites only this task in the local queue, clears its quota rule and re-reads the grid forecast; no login or key. A repeat call only re-picks the hour. Returns: task_id, status, scheduled_for, new_deadline. Throws on running, finished or unknown tasks and a past deadline.",
536
+ },
537
+ annotations: {
538
+ title: "Change task deadline",
539
+ readOnlyHint: false,
540
+ destructiveHint: false,
541
+ idempotentHint: true,
542
+ openWorldHint: true,
543
+ },
544
+ params: [
545
+ { ...taskIdRequired, description: "Id of the queued or scheduled task to move, e.g. 't-3f2a…', from the schedule_task reply or the check_queue_status list." },
546
+ { ...deadlineParam, description: "The new due time, ISO-8601 with offset, earlier or later than the current one and in the future, e.g. '2026-05-12T18:00:00+02:00' for \"by 6pm instead\"." },
547
+ ],
548
+ },
549
+ {
550
+ name: "postpone_task",
551
+ hosts: ["mcp"],
552
+ description: "Move one queued or scheduled task later; it never runs earlier than planned. Use when: the user says \"tonight\" or \"after my limit resets\"; pass exactly one of preset, until or delay_minutes. Do not use to set a new due time (use update_deadline) or to stop it (use cancel_task). Behavior: rewrites this task's earliest start in the local queue and re-picks the cleanest hour after it, but an until time is kept exactly; after_limit_reset reads the Claude limits. Returns: status, not_before, scheduled_for, deadline. Rejects a target at or before the planned start, finished and unknown tasks.",
553
+ annotations: {
554
+ title: "Postpone task",
555
+ readOnlyHint: false,
556
+ destructiveHint: false,
557
+ idempotentHint: false,
558
+ openWorldHint: true,
559
+ },
334
560
  params: [
335
- { ...taskIdRequired, description: "The id of the task to reschedule." },
336
- { ...deadlineParam, description: "New ISO-8601 deadline. Must be in the future." },
561
+ { ...taskIdRequired, description: "Id of the queued or scheduled task to move later, e.g. 't-3f2a…', from the schedule_task reply or the check_queue_status list." },
562
+ {
563
+ name: "preset",
564
+ kind: "enum",
565
+ values: ["1h", "tonight", "tomorrow_morning", "after_limit_reset"],
566
+ optional: true,
567
+ description: "A named later time, in this machine's local time: '1h' is one hour after the planned start; 'tonight' is 22:00 to 06:00 (after midnight: now to 06:00); 'tomorrow_morning' is 09:00 to 12:00 tomorrow; 'after_limit_reset' is 5 minutes after the Claude limit reset (needs reset_at, this machine's limit reading or a reset time given before). Omit when passing until or delay_minutes.",
568
+ },
569
+ {
570
+ name: "until",
571
+ kind: "string",
572
+ format: "date-time",
573
+ optional: true,
574
+ description: "The exact time the user picked, ISO-8601 with offset, after the planned start, e.g. '2026-05-12T21:30:00+02:00'. Omit when passing preset or delay_minutes.",
575
+ },
576
+ {
577
+ name: "delay_minutes",
578
+ kind: "number",
579
+ integer: true,
580
+ min: 1,
581
+ max: 10080,
582
+ optional: true,
583
+ description: "Minutes to add to the planned start, e.g. 90 for \"an hour and a half later\"; at most 10080 (7 days). Omit when passing preset or until.",
584
+ },
585
+ {
586
+ name: "reset_at",
587
+ kind: "string",
588
+ format: "date-time",
589
+ optional: true,
590
+ description: "When the Claude limit resets, ISO-8601 with offset, if the user says it (\"my limit resets at 15:00\"). Only with preset 'after_limit_reset'; must be in the future and is remembered for later tasks. Omit to use this machine's limit reading.",
591
+ },
337
592
  ],
338
593
  },
339
594
  {
340
595
  name: "reply_task",
341
596
  hosts: ["mcp", "openclaw"],
342
- description: "Continue a completed task's conversation: creates a NEW task that sends the earlier prompt, the model's reply and this text to the same provider and model, and runs at the next clean window before its deadline (default one hour). Costs one provider call. Only completed tasks accept a reply; failed or cancelled tasks are rejected. Returns the new task id and its scheduled time.",
597
+ description: "Send a follow-up message in a completed task's conversation, as a new queued task. Use when: the user follows up on a finished task's result. Do not use for a failed task (use retry_task) or for an unrelated new task (use schedule_task). Behavior: each call adds one task to the local queue with earlier turns as history, the same provider and model, and its own clean window; no login now; it runs later as one provider call with the original's credentials. Returns: task_id, parent_task_id, status, scheduled_for, deadline. Rejects non-completed and unknown tasks and text over 32000 characters.",
598
+ annotations: {
599
+ title: "Reply to a completed task",
600
+ readOnlyHint: false,
601
+ destructiveHint: false,
602
+ idempotentHint: false,
603
+ openWorldHint: true,
604
+ },
343
605
  params: [
344
- { ...taskIdRequired, description: "The id of the completed task to reply to." },
606
+ { ...taskIdRequired, description: "Id of the completed task to continue, e.g. 't-3f2a…', from the check_queue_status list (status completed)." },
345
607
  {
346
608
  name: "text",
347
609
  kind: "string",
348
610
  minLength: 1,
349
- description: "The follow-up message (1 to 32000 characters).",
611
+ description: "The user's follow-up, sent as the next turn after the task's earlier reply, e.g. 'Now cut it to 3 bullets'. Up to 32000 characters.",
350
612
  },
351
613
  {
352
614
  ...deadlineParam,
353
615
  optional: true,
354
- description: "Optional ISO-8601 deadline for the reply. Defaults to one hour from now.",
616
+ description: "When the reply must be finished, ISO-8601 with offset, e.g. '2026-05-12T20:00:00Z'. Defaults to one hour from now.",
355
617
  },
356
618
  ],
357
619
  },
358
620
  {
359
621
  name: "retry_task",
360
622
  hosts: ["mcp", "openclaw"],
361
- description: "Re-dispatch a failed provider-call task. Only valid when the task's current status is 'failed' — queued/scheduled/running/submitted/completed tasks are rejected with an explanatory error. The new run's receipt overwrites the old.",
362
- params: [{ ...taskIdRequired, description: "The id of the failed task to retry." }],
623
+ description: "Run a failed task again now, with the same prompt, provider and model. Use when: a task failed on a transient error (rate limit, 5xx). Do not use for a task that did not fail (use expedite_task to run it now, update_deadline to move it), or for a claude-code task (run `tidegap queue run-now <id>`). Behavior: one provider call now; needs the task provider's key in the server env (and ANTHROPIC_API_KEY or OPENAI_API_KEY); the new result and signed receipt replace the old ones. Returns: status (completed or failed) and error on failure. Rejects non-failed and unknown tasks.",
624
+ descriptionPerHost: {
625
+ openclaw: "Run a failed task again now, with the same prompt, provider and model. Use when: a task failed on a transient error (rate limit, 5xx) and the user wants it redone. Do not use for a task that did not fail (use expedite_task to run it now, update_deadline to move it). Behavior: one provider call now, through the OpenClaw runtime or a provider key in the plugin config; the new result and signed receipt replace the old ones, then the result is delivered. Returns: status, error on failure, result, receipt and delivery. Throws on tasks that are not failed and unknown task_ids.",
626
+ },
627
+ annotations: {
628
+ title: "Retry a failed task",
629
+ readOnlyHint: false,
630
+ destructiveHint: true,
631
+ idempotentHint: false,
632
+ openWorldHint: true,
633
+ },
634
+ params: [{ ...taskIdRequired, description: "Id of the failed task to run again, e.g. 't-3f2a…', from the check_queue_status list (status failed)." }],
363
635
  },
364
636
  {
365
637
  name: "cancel_all",
366
638
  hosts: ["mcp", "openclaw"],
367
- description: "Bulk-cancel every task in the queue that is still cancellable (status queued or scheduled). Running/completed/failed/cancelled tasks are left untouched. Optionally filter by status. Returns the number of tasks cancelled.",
639
+ description: "Cancel every queued and scheduled task in the local queue at once; for a single task use cancel_task. Use when: the user says \"cancel everything\" or \"clear the queue\". Do not use to drop one task or to end a repeating series (use cancel_task, with series=true for a series). Behavior: marks each pending task cancelled; running, submitted and finished tasks stay as they are; no network or login. A repeating task skips this occurrence and its next one is queued, so a second call cancels that one too. Returns: \"Cancelled N of M task(s).\" and one error line per task that could not be cancelled.",
640
+ descriptionPerHost: {
641
+ openclaw: "Cancel every queued and scheduled task in the local queue at once; for a single task use cancel_task. Use when: the user says \"cancel everything\" or \"clear the queue\". Do not use to drop one task or to end a repeating series (use cancel_task, with series=true for a series). Behavior: marks each pending task cancelled; running, submitted and finished tasks stay as they are; no network or login. A repeating task skips this occurrence and its next one is queued, so a second call cancels that one too. Returns: matched, cancelled, and errors (task_id and error per task that could not be cancelled).",
642
+ },
643
+ annotations: {
644
+ title: "Cancel all pending tasks",
645
+ readOnlyHint: false,
646
+ destructiveHint: true,
647
+ idempotentHint: false,
648
+ openWorldHint: false,
649
+ },
368
650
  params: [
369
651
  {
370
652
  name: "status",
371
653
  kind: "enum",
372
654
  values: ["queued", "scheduled"],
373
655
  optional: true,
374
- description: "Optional. If set, cancel only tasks in this status. Valid: 'queued', 'scheduled'. Defaults to both.",
656
+ description: "Cancel only tasks in one state: 'queued' (no window picked yet) or 'scheduled' (window picked). Omit to cancel both.",
375
657
  },
376
658
  ],
377
659
  },
@@ -379,10 +661,10 @@ export const TOOL_SURFACE = [
379
661
  // OpenClaw-only: the MCP server has no result-delivery subsystem.
380
662
  name: "set_delivery",
381
663
  hosts: ["openclaw"],
382
- description: "Set or change how a scheduled task's result is delivered when it completes. Call this right after schedule_task, once you have ASKED the user how they want the result. The user may pick several modes. Modes: chat (their active OpenClaw chat), telegram, webhook (needs webhook_url), file (needs file_path; format md/html/txt/json/pdf), queue (no push — retrievable via check_queue_status), os (a native desktop notification on the gateway host). PRIVACY BOUNDARY — queue is the only mode that transmits nothing (the result stays in the local ledger; read it back with check_queue_status). chat delivers through the gateway's configured chat channel, which on a Telegram-backed gateway is the SAME Telegram Bot API path as the telegram mode — do not describe chat to the user as staying inside OpenClaw. telegram sends the FULL result to a third-party service, webhook POSTs the FULL result to whatever URL is supplied (Tidegap does not restrict or inspect that destination), and file writes it to any path on the gateway host. Never pick telegram, webhook or file on the user's behalf: confirm the destination with them first, and for sensitive tasks prefer queue. Default if the user is unsure: chat.",
664
+ description: "Set how a scheduled task's result is delivered when it completes; several modes allowed. Use when: right after schedule_task, once the user has chosen. Do not use to read a result (use check_queue_status). Behavior: saves the setting locally, without checking the task exists; sends nothing now. queue transmits nothing; chat may route through Telegram; telegram, webhook and file send or write the FULL result, so confirm those destinations first. Default: chat. Returns: task_id and the saved delivery. Throws on a missing webhook_url or file_path.",
383
665
  params: [
384
- { ...taskIdRequired, description: "The id returned by schedule_task." },
385
- { ...deliverParam(false), description: "One or more delivery modes the user chose." },
666
+ { ...taskIdRequired, description: "Id of the task, e.g. 't-3f2a…', from the schedule_task reply or the check_queue_status list." },
667
+ { ...deliverParam(false), description: "The modes the user chose, e.g. ['telegram'] or ['chat','file']. webhook needs webhook_url; file needs file_path. Confirm telegram, webhook and file destinations with the user first." },
386
668
  webhookUrlParam,
387
669
  filePathParam,
388
670
  fileFormatParam,
@@ -402,10 +684,21 @@ export function getToolDefOrThrow(name) {
402
684
  throw new Error(`unknown Tidegap tool: ${name}`);
403
685
  return def;
404
686
  }
405
- /** The tools a given host registers, in canonical order. */
687
+ /** A tool's description as one host shows it (its override, else the base). */
688
+ export function descriptionForHost(def, host) {
689
+ return def.descriptionPerHost?.[host] ?? def.description;
690
+ }
691
+ /** The tools a given host registers, in canonical order, each carrying the
692
+ * description resolved for that host. */
406
693
  export function toolsForHost(host) {
407
- return TOOL_SURFACE.filter((t) => t.hosts.includes(host));
694
+ return TOOL_SURFACE.filter((t) => t.hosts.includes(host)).map((t) => ({
695
+ ...t,
696
+ description: descriptionForHost(t, host),
697
+ }));
408
698
  }
699
+ /** Tool counts per host; the site derives its "N tools" copy from these. */
700
+ export const MCP_TOOL_COUNT = toolsForHost("mcp").length;
701
+ export const OPENCLAW_TOOL_COUNT = toolsForHost("openclaw").length;
409
702
  /** Which hosts expose a given parameter (defaults to the tool's hosts). */
410
703
  export function paramHosts(param, def) {
411
704
  return param.hosts ?? def.hosts;
@@ -443,6 +736,7 @@ export function neutralSurfaceForHost(host) {
443
736
  return toolsForHost(host).map((def) => ({
444
737
  name: def.name,
445
738
  description: def.description,
739
+ ...(def.annotations ? { annotations: def.annotations } : {}),
446
740
  params: paramsForHost(def, host).map((p) => neutralParam(p, host)),
447
741
  }));
448
742
  }