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 can only read.
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 Mod API type file of the 2.1.312 program (schemas/claude-code.d.ts).
"Run time" appears in a "Where it can be used" cell. It 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: An official docs page names this item. | Resolves the milliseconds since the epoch, now. | () => Promise<number>. | Run time. |
$. | Documented: An official docs page names this item. | Resolves after ms milliseconds. Rejects at once when signal aborts. | (ms, options?) => Promise<void>. The hook's budget continues during the wait. Pass signal: to end the wait with the dispatch. | Run time. |
$. | Documented: An official docs page names this item. | Calls fn once after ms milliseconds. cancel() before then stops it. | (ms, fn) => Timer. fn runs when the clock. dispatch resolves. It never runs when a hook refuses the dispatch. | Run time. |
$. | Documented: An official docs page names this item. | 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: An official docs page names this item. | Fetches url through the host, never the plugin's own network. Resolves { status, ok, headers, text } once the host reads the body. | (url, init?) => Promise<Http. Fetches an http or https URL. The organization's web-fetch policy can refuse it. init. takes a handle from $.. The engine uses it only on https to api.. | Run time. |
$. | Documented: An official docs page names this item. | 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. The call cuts output at 4,194,304 bytes. | CLI only. |
$. | Documented: An official docs page names this item. | 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: An official docs page names this item. | 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: An official docs page names this item. | 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: An official docs page names this item. | Resolves the settings merged over every source, one source's settings as loaded ({ source }), or the value of one top-level key ({ key }, with an optional source), undefined when the settings hold none. | (args?:. Returns a snapshot of plain data. A read of one key is the read of the merged object, projected, and raises no event of its own. With no hook, the merge takes a scalar from the last source that has it, joins lists, and merges objects. 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: An official docs page names this item. | $. | Input No. Value number. |
clock. | Documented: An official docs page names this item. | $.. The signal does not cross. It aborts the dispatch. | Input Clock. Value void. |
clock. | Documented: An official docs page names this item. | $.. fn stays in the plugin's environment. | Input Clock. Value void. |
clock. | Documented: An official docs page names this item. | $.. One dispatch for each period. | Input Clock. Value void. |
http. | Documented: An official docs page names this item. | $. | Input { url:. Value Http. |
process. | Documented: An official docs page names this item. | $. | Input { argv:. Value Process. |
process. | Documented: An official docs page names this item. | $.. It streams. { deny } kills a running child. | Input Process. Value Process. |
settings. | Documented: An official docs page names this item. | $., $. | 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. Each layer is { source, settings }, lowest precedence first. source is a settings source or plugin. A source with no settings, or one the engine bars from the read, is left out. |
env. | Documented: An official docs page names this item. | $.. The type pins name. | Input { name:. Value string | undefined. |
env. | Documented: An official docs page names this item. | $.. The type pins name. 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)