podster 0.0.1-test.5 → 0.0.1-test.8

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.
package/README.md CHANGED
@@ -40,6 +40,7 @@ Then:
40
40
 
41
41
  ```bash
42
42
  npx --ignore-scripts podster@test status # what this Runner's record says, by IDs
43
+ npx --ignore-scripts podster@test why <tsk_…> # the newest failure recorded for a task on this machine
43
44
  npx --ignore-scripts podster@test stop # stop the Runner running from this home, and any run, at once
44
45
  npx --ignore-scripts podster@test forget # delete this Runner's keys and record; disconnect the agent in Podster yourself
45
46
  ```
@@ -48,6 +49,20 @@ Every command takes `--home <folder>`, Runner's own folder. The default is `~/.p
48
49
 
49
50
  Running tasks needs plain paths: letters, digits, `.`, `_`, `-` and `/` only. If your home folder's path has a space or any other character, Runner refuses to run tasks (`helper_unavailable`, or `path_unsafe` for its home), since both npm's cache, where `npx` puts Runner (`<cache>/_npx`), and `~/.podster-runner` sit under it. Then point npm's cache and Runner's home at plain folders only you can write, for example `npm_config_cache=/Users/Shared/podster-npm npx --ignore-scripts podster@test run --home /Users/Shared/podster-runner …`, and use the same two on every command.
50
51
 
52
+ ## When something fails
53
+
54
+ Runner's log is one JSON line per event, with IDs and a code, on standard error. Under each failure, refusal or stop it adds a line in plain English: what happened, what to do, the code, and where the details are. For example:
55
+
56
+ ```text
57
+ why: The room's policy lists network hosts, which Runner can't enforce yet. Set rooms[].network to [] in policy.json, then start Runner again. (code network_allowlist_unsupported; details: ~/.podster-runner/logs/errors.jsonl)
58
+ ```
59
+
60
+ The details are in `logs/errors.jsonl` in Runner's home: one line per failure, with the time, the run's IDs, the code, and the raw error's message and stack. For a Docker command it also has Docker's exit code and the end of its error output. Each field is cut to 4 KiB. Before anything is written, the exact tokens Runner holds for a run (its broker token and the task's GitHub token) are written as `[redacted]`, and so is anything else that looks like a key or token. If Docker cut its own output, the last word of that output is redacted too. The folder is readable only by you (mode 700, owned by you, not a link). The file is mode 600, owned by you, with one link. The file is kept to 1 MiB and moves to `errors.jsonl.1` and `.2` as it fills, so at most three files are kept. It stays on this machine: Runner never sends it to Podster or anywhere else. `podster why <tsk_…>` prints a task's newest entry.
61
+
62
+ The room sees only fixed words. When the agent answers `blocked`, Runner posts its reason on the task's thread, under the room's output policy. When a run can't start, Runner posts a fixed note with one generic code, `runner_could_not_start`. The specific cause stays in your terminal and the details file, never in the room.
63
+
64
+ When the agent's structured result breaks one of Runner's rules, Runner tells the agent which rule, in fixed words, so it can fix it and give the result again. Examples: a summary that's too long, a file outside the task's folder, an unknown field. The log's code names the rule, such as `result_file_outside_folder`.
65
+
51
66
  ## Your provider key
52
67
 
53
68
  Without `--provider-key-file`, `run` records offers and accepts none.
@@ -118,7 +133,7 @@ A complete, valid example, for one workroom. Replace the `org_…` and `ws_…`
118
133
  | `rooms[].mode` | `"ask"` shows each run at your terminal for you to approve. `"unattended"` runs without asking. Unattended runs are off by default: leave `mode` out or set `"ask"` until you choose otherwise. |
119
134
  | `rooms[].outputs` | `"hold"` keeps a finished run's result on your machine until you approve publishing it. `"share"` publishes it. Leaving it out means `"hold"`. |
120
135
  | `rooms[].tools` | Runner's own tools for a task. `read`, `search`, `write` and `edit` are the default. `shell` is never on unless you list it. |
121
- | `rooms[].network` | Host names a task may reach, such as `"registry.npmjs.org"`. An empty list, the default, means no network. |
136
+ | `rooms[].network` | Must be `[]` (the default): no network. Runner can't allow hosts yet, since a task's container has no egress proxy, so a room listing any host is refused when Runner starts, with `network_allowlist_unsupported`. Host names will be allowed once the proxy exists. |
122
137
  | `rooms[].repository` | `null` for a task that starts in an empty folder, or `{ "full_name": "owner/name", "provider_repo_id": 123456 }` for one GitHub repository. |
123
138
  | `rooms[].allowed_orgs` | Other organizations whose tasks you'll run in this room. Do not list `owner_org`: your own organization is always allowed, and Runner refuses a policy that lists it. An empty list is fine. |
124
139
  | `rooms[].acknowledged` | Both flags are required. Until `trust_statement` is `true`, Runner asks you at your terminal each time. Until `public_room_warning` is `true`, it also asks for a public room. |
@@ -113,3 +113,16 @@ export function meaningOf(error) {
113
113
  return "authority";
114
114
  return "refused";
115
115
  }
116
+ /**
117
+ * An error whose message is a fixed code, with the facts a person needs to see why (the owner's request of 2026-11-20):
118
+ * a command's exit code and the tail of its error output. The detail goes only to the local diagnostics file, redacted
119
+ * there, never to a log line, Podster or the network.
120
+ */
121
+ export class DetailedError extends Error {
122
+ /** `cut`: the error output was cut at its head cap, so its last word may be part of a secret. */
123
+ detail;
124
+ constructor(code, detail = {}) {
125
+ super(code);
126
+ this.detail = detail;
127
+ }
128
+ }
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Plain-English explanations of Runner's failure codes (the owner's request of 2026-11-20: "I need to know why certain
3
+ * actions failed, the detail, instead of just the code"). A fixed table keyed by code: each says what happened and what
4
+ * to do. Nothing is interpolated but the code itself, which is a fixed shape, so no task text, error message or secret
5
+ * can reach the terminal through it. A code with no entry says so and points to the local diagnostics file.
6
+ *
7
+ * None of this reaches the room: a start failure reaches it as one generic code, `runner_could_not_start`, in Runner's
8
+ * fixed note (`composeBlockedNote`), and the specific code and its explanation stay on the owner's machine.
9
+ */
10
+ const CODE = /^[a-z][a-z0-9_]{0,63}$/;
11
+ const group = (codes, what, todo) => codes.map((c) => [c, { what, todo }]);
12
+ const SEND = "send the code and the matching entry in the diagnostics file to whoever supports your Runner.";
13
+ const SUPPORT = `If it happens again, ${SEND}`;
14
+ const RESTART = `Restart Runner with \`run\`; if it happens again, ${SEND}`;
15
+ const TABLE = new Map([
16
+ // The run policy and the network.
17
+ ...group(["network_allowlist_unsupported"], "The room's policy lists network hosts, which Runner can't enforce yet.", "Set rooms[].network to [] in policy.json, then start Runner again."),
18
+ ...group(["config_invalid", "budget_invalid"], "Runner's run policy can't be read or used.", "Fix policy.json; `run` names the field it refused when it starts."),
19
+ ...group(["clock_invalid"], "This machine's clock went back past the day Runner last counted spend.", "Set the clock right; the task waits until then."),
20
+ ...group(["authority_stale"], "Runner hasn't heard from Podster recently enough to trust this agent's access.", "Check the network connection; the task waits and is tried again."),
21
+ ...group(["room_not_configured"], "This room isn't in Runner's run policy.", "Add the room to rooms[] in policy.json if Runner should work in it."),
22
+ ...group(["requester_out_of_scope", "author_out_of_scope"], "Someone who wrote this task isn't in an organization the room's policy allows.", "Add their organization to rooms[].allowed_orgs if Runner should take their tasks."),
23
+ ...group(["day_budget_exhausted"], "Today's spend cap is used up.", "The task waits for tomorrow, or raise day_caps.spend_micro_usd in policy.json."),
24
+ ...group(["attempts_exhausted"], "This task was tried too many times today.", "It's tried again tomorrow."),
25
+ ...group(["owner_declined"], "You declined the task at the terminal.", "Nothing to do."),
26
+ ...group(["prompt_unavailable", "provenance_invalid", "prompt_mismatch", "task_invalid"], "The task's inputs couldn't be read exactly as Podster listed them, so no prompt was built.", `Ask the room to check the task; if it happens again, ${SEND}`),
27
+ ...group(["prompt_too_large", "prompt_invalid"], "The task's words are too large, or not text Runner can hand to the agent.", "Ask the room to shorten the task."),
28
+ ...group(["blocked_same_inputs"], "The agent already answered blocked on these exact inputs, so Runner won't pay for the same answer again.", "Change the task, request changes, post a message on the task, or change the room's policy (such as adding shell), and it runs again."),
29
+ ...group(["run_blocked"], "The agent reported it is blocked and couldn't finish.", "Read its reason on the task's thread. If it needs a shell, add \"shell\" to rooms[].tools in policy.json; network access can't be allowed yet (rooms[].network must stay [])."),
30
+ ...group(["note_scan_unknown", "note_scan_exhausted"], "Runner couldn't read the task's thread to check whether its note landed before a restart.", "It tries again with a growing wait; after six tries it posts its fixed note once."),
31
+ ...group(["runner_could_not_start"], "Runner couldn't start a run for this task.", "The log line before it has the cause code, and the details file has the raw error."),
32
+ // A run that never started.
33
+ ...group(["docker_unavailable"], "Runner couldn't run Docker.", "Start Docker (Docker Desktop on a Mac), then the next offer runs."),
34
+ ...group(["container_failed", "container_invalid", "strays_remain"], "The task's container couldn't be started or prepared.", "Check that Docker is running and the task image is built; the details file has Docker's exit code and output."),
35
+ ...group(["workspace_on_windows_drive"], "The task's folder is on a Windows drive, where Runner can't protect its files.", "Move workspace_root in policy.json into the Linux file system."),
36
+ ...group(["adapter_unavailable", "transport_unavailable"], "Runner has no agent SDK or provider for this room's policy.", "Start Runner with a provider key file, and check policy.json's adapter."),
37
+ ...group(["broker_invalid", "run_ref_invalid", "halted", "start_failed"], "Runner couldn't set the run up.", RESTART),
38
+ ...group(["relay_check_failed", "relay_check_unix_only", "relay_port", "relay_socket_path", "relay_socket_path_too_long", "listener_not_loopback", "listener_socket_host", "listener_socket_path", "listener_socket_unsafe"], "Runner's link between Claude Code's container and its model broker couldn't be set up.", "Start Runner with a shorter --home (the default ~/.podster-runner) and check Docker; the details file has more."),
39
+ ...group(["upstream_not_allowed", "headers_not_allowed"], "A model request didn't match the one provider address Runner allows.", SUPPORT),
40
+ // A run that ended without a result to submit.
41
+ ...group(["run_failed", "driver_failed", "sdk_error", "exec_exited", "plugins_unexpected"], "The agent's run failed before it gave a result.", "The details file has the driver's code; the task is released, and offered again by the room."),
42
+ ...group(["run_timed_out", "run_time"], "The run used its whole time cap.", "Raise caps.run_time_ms in policy.json, or ask for a smaller task."),
43
+ ...group(["run_budget_stopped", "spend_cap", "turns_exhausted", "output_tokens_exhausted", "max_turns"], "The run reached one of its caps on spend, turns or output.", "Raise the matching cap in policy.json's caps, or ask for a smaller task."),
44
+ ...group(["refusal_ignored", "tool_refused_unchecked"], "The agent's SDK ran a tool call Runner had refused, so Runner stopped the run.", SUPPORT),
45
+ ...group(["disk_bound"], "The run wrote more to disk than Runner allows.", "Ask for a smaller task."),
46
+ ...group(["stopped", "stopped_locally"], "The run was stopped on this machine.", "Nothing to do; it's released once its stop is confirmed."),
47
+ ...group(["runner_restarted", "run_interrupted"], "Runner stopped while a run was going.", "Nothing to do; the task is released once the old run is confirmed stopped."),
48
+ ...group(["offline_grace", "revoked", "canceled", "not_readable", "inputs_changed", "policy_changed"], "The run was stopped because the task, its inputs, its access or the policy changed while it ran.", "Nothing to do; the task is read again."),
49
+ ...group(["result_missing"], "The agent ended without giving its structured result.", `The task is released; if it keeps happening, ${SEND}`),
50
+ ...group(["result_invalid"], "The agent's structured result broke one of Runner's rules.", "The details file names the rule."),
51
+ ...group(["result_not_object", "result_missing_field", "result_unknown_field", "result_status_invalid"], "The agent's result wasn't shaped as Runner's result: status, summary and files.", "The agent was told and may resubmit; nothing to do unless it keeps happening."),
52
+ ...group(["result_summary_empty", "result_summary_too_long", "result_summary_control_char"], "The agent's result summary was empty, too long, or held a control character.", "The agent was told and may resubmit; nothing to do unless it keeps happening."),
53
+ ...group(["result_files_not_list", "result_too_many_files", "result_file_outside_folder", "result_file_not_allowed", "result_file_duplicate"], "The agent's result named files Runner can't accept.", "The agent was told and may resubmit; nothing to do unless it keeps happening."),
54
+ // Tool calls and model requests Runner refused.
55
+ ...group(["call_invalid", "input_invalid", "tool_not_allowed", "shell_not_allowed", "path_outside_folder", "path_not_allowed", "run_stopped"], "Runner refused one of the agent's tool calls.", "Nothing to do unless the agent needs that tool: shell needs rooms[].tools to list shell."),
56
+ ...group(["method_not_allowed", "query_not_allowed", "body_too_large", "body_invalid", "body_not_allowed", "model_not_allowed", "model_unpriced", "upstream_failed"], "Runner refused or couldn't send one of the agent's model requests.", SUPPORT),
57
+ // The repository path.
58
+ ...group(["repository_unavailable", "helper_unavailable", "git_unavailable"], "Runner can't work with this room's repository on this machine.", "Check that Git is installed and the room's repository is set in policy.json."),
59
+ ...group(["repository_out_of_scope", "clone_url_unexpected", "repository_id_mismatch", "repository_renamed", "repository_archived", "repository_unprotected", "repository_unreadable"], "The room's repository isn't the one Runner's policy allows, or can't be used as it is.", "Check rooms[].repository in policy.json against the room's repository on GitHub."),
60
+ ...group(["path_unsafe", "unsafe", "work_tree_git", "work_tree_link", "work_tree_special", "work_tree_too_large"], "The task's folder held something Runner won't commit or push.", "The details file names the check; the task is released."),
61
+ ...group(["access_authority_invalid", "access_expired", "access_fields", "access_invalid", "access_not_object", "access_permissions", "access_token_format", "token_revoked"], "Podster's repository access for this task wasn't usable.", "Try again later; if it keeps happening, check the room's repository settings in Podster."),
62
+ ...group(["github_unavailable", "github_unreachable", "github_refused", "github_answer_too_large"], "GitHub couldn't be reached or refused a request.", "Check the network; Runner tries again later."),
63
+ ...group(["checkout_failed", "checkout_moved", "checkout_unverified", "fetch_invalid", "git_init_failed", "default_branch_invalid", "ref_unreadable", "base_moved", "task_branch_moved"], "Runner couldn't prepare a clean checkout of the repository.", "Runner tries again later; the details file has more."),
64
+ ...group(["commit_failed", "commit_unexpected", "push_invalid", "push_rejected", "push_unconfirmed", "repo_publish_failed", "publish_failed"], "Runner couldn't commit or push the run's work.", "Runner retries for an hour, then releases the task; check the task branch's protection on GitHub."),
65
+ ...group(["pull_request_commit_changed", "pull_request_not_found", "pull_request_not_open", "pull_request_refused", "pull_request_unreadable", "pull_request_wrong_base", "pull_request_wrong_head", "pull_request_wrong_repository", "pull_request_unread"], "The task's pull request wasn't as Runner pushed it.", "Check the pull request on GitHub; the task is released if it can't be submitted."),
66
+ ...group(["run_no_changes"], "The run changed nothing, so there was nothing to submit.", "The task is released."),
67
+ ...group(["record_invalid", "repo_record_invalid", "result_record_invalid"], "Runner's own record of this run was incomplete.", SUPPORT),
68
+ // Podster's answers.
69
+ ...group(["version_conflict", "invalid_transition", "commit_changed", "not_allowed", "not_found", "task_not_found", "idempotency_mismatch"], "Podster refused the call: the task had changed, or wasn't this agent's to act on.", "Nothing to do; the task is read again."),
70
+ ...group(["accept_unexpected", "unknown", "unexpected", "network", "too_large", "not_data", "bad_answer", "unreadable", "request_invalid"], "Runner got an answer it didn't expect.", SUPPORT),
71
+ // Runner's own state.
72
+ ...group(["accept_without_decision", "start_without_decision", "reservation_invalid", "docker_rm_lingers", "docker_network_lingers", "docker_exec_ls_cut", "docker_ps_cut", "docker_ps_output", "diagnostics_folder_unsafe", "diagnostics_file_unsafe"], "Runner's own bookkeeping or cleanup didn't go as expected.", RESTART),
73
+ ]);
74
+ /** Codes with a fixed prefix and a varying part: a Docker command's step and exit code, or a Podster refusal's code. */
75
+ const PREFIXES = [
76
+ [/^docker_[a-z]+_(?:\d+|x|cut|output)$/, { what: "A Docker command failed.", todo: "Check that Docker is running; the details file has its exit code and output." }],
77
+ [/^(?:submit|accept|give_up|consume|pin|issue)_/, { what: "Podster or Runner's policy refused a step for this task.", todo: "The rest of the code says which; the task is read again or released." }],
78
+ [/^repo_/, { what: "A step on the room's repository failed.", todo: "The details file has the cause." }],
79
+ [/^task_[a-z_]+$/, { what: "The task's state changed, so Runner left it.", todo: "Nothing to do." }],
80
+ [/^policy_/, { what: "The run policy changed while the run went.", todo: "Nothing to do; the task is evaluated again." }],
81
+ ];
82
+ /** The explanation for a code, and whether the table knows it. A `repo_` code is explained by the code under it. */
83
+ export function explain(code) {
84
+ const exact = TABLE.get(code) ?? (code.startsWith("repo_") ? TABLE.get(code.slice(5)) : undefined);
85
+ if (exact)
86
+ return { ...exact, known: true };
87
+ const prefixed = CODE.test(code) ? PREFIXES.find(([pattern]) => pattern.test(code)) : undefined;
88
+ if (prefixed)
89
+ return { ...prefixed[1], known: true };
90
+ return { what: "Runner has no explanation for this code.", todo: "The diagnostics file has the details.", known: false };
91
+ }
92
+ /** Every code the table names exactly. */
93
+ export const EXPLAINED_CODES = [...TABLE.keys()];
94
+ /** Outcomes of a log line that are a failure, a refusal or a stop: the terminal explains their code. */
95
+ export const FAILURE_OUTCOMES = new Set([
96
+ "start_failed",
97
+ "run_failed",
98
+ "run_timed_out",
99
+ "run_budget_stopped",
100
+ "result_missing",
101
+ "result_invalid",
102
+ "run_blocked",
103
+ "released",
104
+ "declined",
105
+ "refused",
106
+ "refuse",
107
+ "pin_refused",
108
+ "unavailable",
109
+ "not_submitted",
110
+ "nothing_to_submit",
111
+ "reason_not_posted",
112
+ "given_up",
113
+ "halted",
114
+ "held",
115
+ "waiting",
116
+ ]);
117
+ /** The terminal's line under a failure: what happened and what to do, the code, and where the details are. */
118
+ export function explainLine(code, diagnosticsFile) {
119
+ const e = explain(CODE.test(code) ? code : "unknown");
120
+ return ` why: ${e.what} ${e.todo} (code ${CODE.test(code) ? code : "unknown"}; details: ${diagnosticsFile})`;
121
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * The exact secret values Runner holds right now (review of #489): a run's broker token and a task's GitHub token. The
3
+ * local diagnostics file redacts each by exact match before it writes, beside the pattern redaction, which a bare 64-hex
4
+ * token wouldn't match. Values live in memory only, from when they're made or received until they're dropped.
5
+ */
6
+ const held = new Map();
7
+ const MIN_LENGTH = 16;
8
+ /** Holds `value` until the returned release is called. Short values are ignored: they'd redact ordinary words. */
9
+ export function holdSecret(value) {
10
+ if (typeof value !== "string" || value.length < MIN_LENGTH)
11
+ return () => undefined;
12
+ held.set(value, (held.get(value) ?? 0) + 1);
13
+ let released = false;
14
+ return () => {
15
+ if (released)
16
+ return;
17
+ released = true;
18
+ const n = (held.get(value) ?? 1) - 1;
19
+ if (n <= 0)
20
+ held.delete(value);
21
+ else
22
+ held.set(value, n);
23
+ };
24
+ }
25
+ /** The text with every held secret value replaced by `[redacted]`, and how many were. */
26
+ export function redactKnown(text) {
27
+ let out = text;
28
+ let count = 0;
29
+ // Longest first, so a value that contains another is taken whole.
30
+ for (const value of [...held.keys()].sort((a, b) => b.length - a.length)) {
31
+ const parts = out.split(value);
32
+ count += parts.length - 1;
33
+ out = parts.join("[redacted]");
34
+ }
35
+ return { text: out, count };
36
+ }
37
+ /** How many values are held, for tests. */
38
+ export const heldSecretCount = () => held.size;