Clock, HTTP, Process, Env, and Settings
These five nouns reach the machine: $.clock for time and timers, $.http for web requests, $.process for commands, $.env for environment variables, and $.settings for the merged settings.
$.process works in the CLI only.
$.settings is read only.
A policy can refuse a call. For example, the organization's web-fetch policy can refuse $.http.fetch.
Official pages: Use the Mods API, Mods Reference. Source: the program (types-2.1.304.d.ts).
In a "Where it can be used" cell, "Run time" means in a hook, in a closure that a hook drew, or in a timer callback. It does not mean inside register.
Example
on('session.start', async ($, e, next) => {
const { exitCode, stdout } = await $.process.run(['git', 'status', '--short'])
if (exitCode === 0) $.ui.log(stdout)
$.clock.every(1000, () => $.ui.status('polling'))
return next(e)
})
Members
| Item | Status | What it does | How it works | Where it can be used |
|---|---|---|---|---|
$. | Documented | Resolves the milliseconds since the epoch, now. | () => Promise<number>. | Run time. |
$. | Documented | Resolves after ms milliseconds. Rejects at once when signal aborts. | (ms, options?) => Promise<void>. The hook's budget runs on during the wait. Pass signal: to end the wait with the dispatch. | Run time. |
$. | Documented | Calls fn once after ms milliseconds. cancel() before then stops it. | (ms, fn) => Timer. fn runs when the clock. dispatch resolves, and never when a hook refuses it. | Run time. |
$. | Documented | Calls fn every ms milliseconds (at least 1) until cancel(). | (ms, fn) => Timer. Runs fn once for each period. A refused period ends the interval. | Run time. |
$. | Documented | Fetches url through the host, never the plugin's own network. Resolves { status, ok, headers, text } once the body is read. | (url, init?) => Promise<Http. Fetches an http or https URL. The organization's web-fetch policy can refuse it. init. takes a handle from $. and is used only on https to api.. | Run time. |
$. | Documented | Runs a command on the host by its argument list (no shell). Resolves { exit once it exits, with any exit code. | (argv, init?) => Promise<Process. Timeout 30 seconds by default, 10 minutes at most. Output is cut at 4,194,304 bytes. | CLI only. |
$. | Documented | Starts a command on the host by its argument list (no shell) and streams what it writes, then how it ended. | (request) => Hook. Leaving the loop, next., or an unload kills the child. | CLI only. |
$. | Documented | Resolves the value of a variable, or undefined when unset. | (name) => Promise<string | undefined>. name must be a string literal. claude plugin validate lists the names your module reads. | The name must be a literal in the module source. |
$. | Documented | Sets the variable for this process and everything it starts later, or unsets it when value is undefined. | (name, value) => Promise<Env. name must be a string literal. Resolves {} or { deny }. | The name must be a literal in the module source. |
$. | Documented | Resolves the settings merged over every source, or one source's settings as loaded ({ source }). | (args?) => Promise<Settings>. Returns a snapshot of plain data. The merge takes a key from the last source that has it. A settings. hook gets each settings layer (layers) and rewrites the merged settings (new in 2.1.304). | Run time. |
Events Raised by These Calls
For each call, a hook above the caller returns next(e), { deny: reason }, or { value }.
| Item | Status | The argument | Input and value |
|---|---|---|---|
clock. | Documented | $. | Input No. Value number. |
clock. | Documented | $.. The signal does not cross. It aborts the dispatch. | Input Clock. Value void. |
clock. | Documented | $.. fn stays in the plugin's environment. | Input Clock. Value void. |
clock. | Documented | $.. Dispatched once for each period. | Input Clock. Value void. |
http. | Documented | $. | Input { url:. Value Http. |
process. | Documented | $. | Input { argv:. Value Process. |
process. | Documented | $.. It streams. { deny } kills a running child. | Input Process. Value Process. |
settings. | Documented | $. | Input Settings. Value Settings. Since 2.1.304 the hook also gets each settings layer (layers) and rewrites the merged settings. A managed mod can use this to make an organization's setting a ceiling, including cleanup, which the retention sweep uses. The program reads each layer's settings; no other shape is documented. |
env. | Documented | $.. name is pinned. | Input { name:. Value string | undefined. |
env. | Documented | $.. name is pinned. No value unsets. | Input { name:. Value Env. |
Related Pages
- Mod API Overview
- Files, Store, and State
- Files, State, Clock, HTTP, Process, and Settings Types (shapes of
HttpInit,ProcessRunInit,Settings, and more)