oneie 4.0.3 → 4.2.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.
package/dist/src/auth.js CHANGED
@@ -1,9 +1,8 @@
1
1
  import { Command } from 'commander';
2
+ import { CONFIG_DIR } from './lib/paths.js';
2
3
  import { writeFileSync, readFileSync, existsSync, mkdirSync, chmodSync, unlinkSync, renameSync, } from 'node:fs';
3
4
  import { resolve, join } from 'node:path';
4
- import { homedir } from 'node:os';
5
5
  import { requestDeviceCode, openBrowser, pollForToken } from './device-flow.js';
6
- const CONFIG_DIR = resolve(homedir(), '.config', 'oneie');
7
6
  const KEY_FILE = resolve(CONFIG_DIR, 'key');
8
7
  const DEFAULT_API = process.env.ONEIE_BASE_URL ?? 'https://one.ie';
9
8
  const CLI_CLIENT_ID = 'oneie-cli';
@@ -12,7 +11,7 @@ const CLI_SCOPE = 'read write';
12
11
  * Command shape, same action, registered under two parents (contract #11). */
13
12
  export function buildLoginCommand() {
14
13
  const cmd = new Command('login')
15
- .description('Sign in via browser and persist token to ~/.config/oneie/key')
14
+ .description('Sign in via browser and persist token to ~/.config/one/key')
16
15
  .option('--key <key>', 'Skip browser flow — store API key directly (or set ONEIE_API_KEY)')
17
16
  .option('--api <url>', 'API base URL', DEFAULT_API)
18
17
  .action(async (opts) => {
@@ -39,7 +38,7 @@ export function buildLoginCommand() {
39
38
  // (c) Poll until token or expiry
40
39
  process.stderr.write(`Waiting for sign-in (expires in ${dc.expires_in}s)…\n`);
41
40
  const token = await pollForToken(base, CLI_CLIENT_ID, dc.device_code, dc.interval, dc.expires_in);
42
- // (d) Write token to ~/.config/oneie/key mode 0600
41
+ // (d) Write token to ~/.config/one/key mode 0600
43
42
  writeKey(token.access_token);
44
43
  // (e) Print success — emit userId if server returned it
45
44
  const userId = token.userId ?? 'unknown';
@@ -255,9 +255,14 @@ export async function compileNode(dir, agencySlug, opts) {
255
255
  // human bits {id,label,tags,description,[[stages]]}; the rest is derived deterministically:
256
256
  // stage.slot numeric order (the wall loads ORDER BY slot) → the stage index
257
257
  // stage.tag full namespaced tag lifecycle:<id>:<stageId> (LifecycleStage.tag)
258
- // stage.subSteps / enter_when empty / null (no sub-steps or auto-enter rule by default —
259
- // the compiler cannot express an auto-enter rule from static TOML; patch
260
- // lifecycle_stages.enter_when directly after push if you need one)
258
+ // stage.subSteps always empty — TOML has no sub-step authoring surface
259
+ // stage.enter_when optional TOML field, straight through (null when absent) — the
260
+ // C7 rule engine grammar (an exact event name or a conversion-stage
261
+ // category, e.g. "purchase"/"intent"); the compiler does not validate
262
+ // it against event-vocabulary.ts (that package isn't a CLI dependency),
263
+ // so an author who wants the stage to self-populate from real traffic
264
+ // must use a value the web app's isValidEnterWhen() accepts — a bad
265
+ // value just leaves the stage manual-only (evaluate() never matches it).
261
266
  // stage.goal / principle / band plain string fields, straight through if present
262
267
  // stage.levers parseToml has no nested array-of-tables, so a lever is one string per
263
268
  // entry in a bracket list: levers = ["page:/pricing", "agent:one"] —
@@ -280,7 +285,7 @@ export async function compileNode(dir, agencySlug, opts) {
280
285
  tag: `lifecycle:${id}:${stageId}`,
281
286
  slot: i,
282
287
  subSteps: [],
283
- enter_when: null,
288
+ enter_when: s.enter_when ? String(s.enter_when) : null,
284
289
  ...(s.goal ? { goal: String(s.goal) } : {}),
285
290
  ...(s.principle ? { principle: String(s.principle) } : {}),
286
291
  ...(s.band ? { band: String(s.band) } : {}),
@@ -1,11 +1,10 @@
1
1
  import { Command } from 'commander';
2
2
  import { existsSync, readFileSync } from 'node:fs';
3
- import { homedir } from 'node:os';
4
- import { resolve } from 'node:path';
5
3
  import { mergeEnv } from './env.js';
6
4
  import { resolveBase, resolveKey, authHeaders } from './lib/client.js';
5
+ import { readKeyFolder, keyFolderStatus } from './lib/keyfile.js';
6
+ import { KEY_FILE } from './lib/paths.js';
7
7
  import { askPath } from './lib/api-path.js';
8
- const KEY_FILE = resolve(homedir(), '.config', 'oneie', 'key');
9
8
  /** api.one.ie (the gateway) answers `GET /health`; one.ie/web has no /health
10
9
  * route, so a HEAD / 200 is the reachability signal there — same host split
11
10
  * askPath() already makes for /ask. */
@@ -34,14 +33,70 @@ export async function runDoctor(dir, opts = {}) {
34
33
  const keyFile = opts.keyFile ?? KEY_FILE;
35
34
  const env = mergeEnv(dir);
36
35
  const checks = [];
37
- const hasConfig = existsSync(keyFile) || Boolean(env.ONE_API_KEY) || Boolean(env.ONEIE_API_KEY);
36
+ // A folder key outranks the machine key, the same order resolveKey uses — so
37
+ // doctor reports the credential the commands will actually send.
38
+ const folder = readKeyFolder(dir);
39
+ // A REFUSED folder key must be explained, not silently skipped. `foreign` means
40
+ // a .oneie/agent.key exists here but was minted for another directory — the
41
+ // credential-confusion guard. Silence would leave the operator staring at a key
42
+ // on disk that nothing uses, with no way to tell that from a bug.
43
+ const folderState = keyFolderStatus(dir);
44
+ if (folderState === 'foreign' || folderState === 'unsafe' || folderState === 'unreadable') {
45
+ checks.push({
46
+ name: 'folder-key',
47
+ ok: false,
48
+ detail: folderState === 'foreign'
49
+ ? 'a .oneie/agent.key here was minted for a DIFFERENT directory or machine — ignored. Run `one init --dir .` to mint one for this project.'
50
+ : folderState === 'unsafe'
51
+ ? 'a .oneie/agent.key here is a symlink, group/world-readable, or owned by another user — ignored. Delete it and re-mint.'
52
+ : 'a .oneie/agent.key here is empty or unreadable — ignored.',
53
+ });
54
+ }
55
+ const hasConfig = Boolean(folder) || existsSync(keyFile) || Boolean(env.ONE_API_KEY) || Boolean(env.ONEIE_API_KEY);
38
56
  checks.push({
39
57
  name: 'config',
40
58
  ok: hasConfig,
41
- detail: hasConfig ? `${keyFile} (0600)` : `${keyFile} missing — run \`one setup\` or \`one login\``,
59
+ detail: folder
60
+ ? `${dir}/.oneie/agent.key (0600, project)`
61
+ : hasConfig
62
+ ? `${keyFile} (0600)`
63
+ : `${keyFile} missing — run \`one setup\` or \`one login\``,
42
64
  });
43
- const key = env.ONE_API_KEY || env.ONEIE_API_KEY || (existsSync(keyFile) ? readFileSync(keyFile, 'utf8').trim() : '');
65
+ const key = env.ONE_API_KEY ||
66
+ env.ONEIE_API_KEY ||
67
+ folder?.apiKey ||
68
+ (existsSync(keyFile) ? readFileSync(keyFile, 'utf8').trim() : '');
44
69
  checks.push({ name: 'key', ok: Boolean(key), detail: key ? `${key.slice(0, 4)}***…` : 'no key found' });
70
+ // EXPIRY. Keys minted by the anonymous provision door carry a 90-day
71
+ // valid_to, and verifyWorldKey enforces it in SQL — so an unwatched folder
72
+ // key stops working one day with a bare 401, which `packages/cli/CLAUDE.md`
73
+ // documents as indistinguishable from a WRONG key. The metadata already
74
+ // records the date; reading it is what turns a scheduled outage into a
75
+ // warning. An absent expiresAt means a permanent key, not an unknown one, so
76
+ // it reports ok and says so rather than inventing a doubt.
77
+ const expiresAt = folder?.meta.expiresAt;
78
+ if (typeof expiresAt === 'string') {
79
+ const ms = Date.parse(expiresAt);
80
+ if (Number.isNaN(ms)) {
81
+ checks.push({ name: 'key-expiry', ok: false, detail: `unreadable expiresAt: ${expiresAt}` });
82
+ }
83
+ else {
84
+ const days = Math.floor((ms - Date.now()) / 86_400_000);
85
+ checks.push({
86
+ name: 'key-expiry',
87
+ // Expired is a failure; expiring is not, or doctor cries wolf for 83 days.
88
+ ok: days > 0,
89
+ detail: days > 14
90
+ ? `expires in ${days} days`
91
+ : days > 0
92
+ ? `expires in ${days} days — renew with \`one init --dir .\``
93
+ : `EXPIRED ${-days} days ago — renew with \`one init --dir .\``,
94
+ });
95
+ }
96
+ }
97
+ else if (folder) {
98
+ checks.push({ name: 'key-expiry', ok: true, detail: 'no expiry recorded (permanent key)' });
99
+ }
45
100
  const base = resolveBase({ api: opts.api });
46
101
  const reach = await checkReachability(base);
47
102
  checks.push({ name: 'substrate', ok: reach.ok, detail: `${base} ${reach.ms}ms` });
package/dist/src/eval.js CHANGED
@@ -18,6 +18,7 @@ export function evalCmd() {
18
18
  channelsUrl: opts.channels.replace(/\/$/, ''),
19
19
  eventsUrl: opts.events.replace(/\/$/, ''),
20
20
  groqApiKey: process.env.GROQ_API_KEY,
21
+ typesafeApiKey: process.env.TYPESAFE_API_KEY,
21
22
  });
22
23
  const failed = results.filter((r) => r.failed > 0).length;
23
24
  out({ ok: failed === 0, total: results.length, passed: results.length - failed, results });
package/dist/src/fn.js CHANGED
@@ -1,12 +1,9 @@
1
1
  import { Command } from 'commander';
2
2
  import { FN_MAP, FN_MAP_VERSION } from '@oneie/sdk/generated/fn-map';
3
+ // The allowlist is ONE source (`@oneie/sdk/fn-allowlist`) shared by web, MCP, CLI
4
+ // and channels — never a literal copied per surface.
5
+ import { FN_ALLOWLIST, isAllowedFn } from '@oneie/sdk/fn-allowlist';
3
6
  const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
4
- const ALLOWLIST = new Set([
5
- 'actionable_hypotheses', 'active_frontiers', 'active_objectives',
6
- 'actor_classification', 'actors_by_kind', 'actors_by_tag', 'actors_for',
7
- 'attractive_tasks', 'blocked_tasks', 'cheapest_provider', 'exploratory_tasks',
8
- 'highways', 'optimal_route', 'promising_frontiers', 'suggest_route', 'total_contribution',
9
- ]);
10
7
  function apiKey() {
11
8
  return process.env.ONEIE_API_KEY ?? process.env.ONE_API_KEY ?? '';
12
9
  }
@@ -32,7 +29,7 @@ export function fnCmd() {
32
29
  .command('list')
33
30
  .description('List all allowlisted functions')
34
31
  .action(() => {
35
- const rows = Array.from(ALLOWLIST).map((name) => {
32
+ const rows = FN_ALLOWLIST.map((name) => {
36
33
  const entry = FN_MAP[name];
37
34
  const params = entry?.params.map((p) => p.name).join(', ') ?? '';
38
35
  return ` ${name.padEnd(28)}${params ? `(${params})` : '()'} → ${entry?.returnKind ?? '?'}`;
@@ -46,7 +43,7 @@ export function fnCmd() {
46
43
  .option('--workspace <slug>', 'Workspace slug')
47
44
  .option('--api <url>', 'API base URL', DEFAULT_API)
48
45
  .action(async (name, opts) => {
49
- if (!ALLOWLIST.has(name)) {
46
+ if (!isAllowedFn(name)) {
50
47
  process.stderr.write(`error: '${name}' is not in the allowlist. Run 'one fn list' to see available functions.\n`);
51
48
  process.exit(1);
52
49
  }
package/dist/src/index.js CHANGED
@@ -33,6 +33,8 @@ import { initCmd } from './init.js';
33
33
  import { onboardCmd } from './onboard.js';
34
34
  import { pluginCmd } from './plugin.js';
35
35
  import { workflowCmd } from './workflow.js';
36
+ import { tasksCmd } from './tasks.js';
37
+ import { mediaCmd } from './media.js';
36
38
  import { readFileSync } from 'node:fs';
37
39
  import { fileURLToPath } from 'node:url';
38
40
  import { resolve, dirname } from 'node:path';
@@ -78,6 +80,8 @@ program.addCommand(initCmd());
78
80
  program.addCommand(onboardCmd());
79
81
  program.addCommand(pluginCmd());
80
82
  program.addCommand(workflowCmd());
83
+ program.addCommand(tasksCmd());
84
+ program.addCommand(mediaCmd());
81
85
  // Bare `oneie` (no args, no --help/--version): route the audience to its
82
86
  // journey instead of commander's default help dump. Never an interactive
83
87
  // prompt — agent env and human TTY both get a printed block (contract #10).
package/dist/src/init.js CHANGED
@@ -14,6 +14,7 @@ import { homedir } from 'node:os';
14
14
  import { renameSync, chmodSync } from 'node:fs';
15
15
  import { join } from 'node:path';
16
16
  import { mergeEnv, writeEnvLocal } from './env.js';
17
+ import { writeKeyFolder } from './lib/keyfile.js';
17
18
  const DEFAULT_API = process.env.ONEIE_BASE_URL ?? 'https://one.ie';
18
19
  const CONFIG_DIR = resolve(homedir(), '.config', 'oneie');
19
20
  const KEY_FILE = resolve(CONFIG_DIR, 'key');
@@ -66,6 +67,8 @@ export function initCmd() {
66
67
  .option('--no-content', 'Skip generating a starter agent.md')
67
68
  .option('--api <url>', 'API base URL', DEFAULT_API)
68
69
  .option('--write-env', 'Also write ONE_API_KEY to .env.local in the current directory')
70
+ .option('--dir <path>', 'Write the key into THIS project folder (.oneie/agent.key, 0600, gitignored) instead of the machine-wide ~/.config/oneie/key')
71
+ .option('--ttl-days <n>', 'Key lifetime in days (default 90, max 365)')
69
72
  .action(async (opts) => {
70
73
  const dir = process.cwd();
71
74
  if (opts.writeEnv) {
@@ -85,6 +88,8 @@ export function initCmd() {
85
88
  body.skills = skills;
86
89
  if (opts.email)
87
90
  body.invite = { email: opts.email, role: 'owner' };
91
+ if (opts.ttlDays)
92
+ body.ttlDays = Number(opts.ttlDays);
88
93
  let res;
89
94
  try {
90
95
  res = await fetch(`${opts.api.replace(/\/$/, '')}/api/provision/agent`, {
@@ -102,8 +107,32 @@ export function initCmd() {
102
107
  out(cmd, { ok: false, ...json });
103
108
  return;
104
109
  }
105
- const { workspace, apiKey, inviteUrl } = json;
106
- writeKey(apiKey);
110
+ const { workspace, apiKey, regKey, uid, expiresAt, inviteUrl } = json;
111
+ // --dir writes the credential INTO the project, which is narrower than the
112
+ // machine-wide default: one project's key, revocable alone, gone when the
113
+ // folder is. The ceremony writes the ignore entry BEFORE the key and
114
+ // refuses to write a key at all if it cannot — see lib/keyfile.ts.
115
+ let keyLocation;
116
+ if (opts.dir) {
117
+ const res = writeKeyFolder({
118
+ dir: opts.dir,
119
+ apiKey,
120
+ regKey,
121
+ workspace,
122
+ uid,
123
+ api: opts.api,
124
+ expiresAt,
125
+ });
126
+ if (!res.ok) {
127
+ out(cmd, { ok: false, error: res.error ?? 'could not write key folder' });
128
+ return;
129
+ }
130
+ keyLocation = `${res.keyPath} (0600, ignored via ${res.ignorePath})`;
131
+ }
132
+ else {
133
+ writeKey(apiKey);
134
+ keyLocation = `${KEY_FILE} (0600)`;
135
+ }
107
136
  if (opts.writeEnv) {
108
137
  writeEnvLocal(dir, { ONE_API_KEY: apiKey, ONE_API_URL: opts.api });
109
138
  }
@@ -111,7 +140,8 @@ export function initCmd() {
111
140
  ok: true,
112
141
  workspace,
113
142
  url: `${opts.api.replace(/\/$/, '')}/u/${workspace}`,
114
- key: `${KEY_FILE} (0600)`,
143
+ key: keyLocation,
144
+ ...(expiresAt ? { expires: new Date(expiresAt * 1000).toISOString() } : {}),
115
145
  ...(opts.writeEnv ? { env: `${dir}/.env.local`, mcp: 'export ONE_API_KEY before launching Claude Code — MCP reads the shell env, not .env.local directly' } : {}),
116
146
  ...(inviteUrl ? { invite: inviteUrl } : {}),
117
147
  ...(skills.length ? { skills: skills.join(', ') } : {}),
@@ -7,6 +7,13 @@ const AGENT_ENV_MARKERS = {
7
7
  CURSOR_TRACE_ID: 'cursor',
8
8
  WINDSURF: 'windsurf',
9
9
  GITHUB_COPILOT_CLI: 'copilot',
10
+ // Codex sets CODEX_SANDBOX (to "seatbelt" on macOS) for the child processes of
11
+ // its sandboxed tool calls. UNDOCUMENTED, and absent when sandboxing is off —
12
+ // so this NAMES a Codex shell when it can and never gates on it. The gate is
13
+ // still the TTY check below, which already answered true for every Codex shell;
14
+ // what was missing was `agentType()` being able to say WHICH agent, which is
15
+ // what the front door routes on.
16
+ CODEX_SANDBOX: 'codex',
10
17
  };
11
18
  /** The specific coding agent driving this shell, if env vars name one. */
12
19
  export function agentType(env = process.env) {
@@ -1,10 +1,9 @@
1
- import { existsSync, readFileSync } from 'node:fs';
2
- import { homedir } from 'node:os';
3
- import { resolve } from 'node:path';
1
+ import { readKeyFolder } from './keyfile.js';
2
+ import { readMachineKey } from './paths.js';
4
3
  // Every command resolves base URL, key, and --json the same way — this module
5
4
  // is the one place that knows the env contract. Composes askPath() from
6
5
  // ./api-path.js for the gateway-vs-web path split; does not replace it.
7
- const KEY_FILE = resolve(homedir(), '.config', 'oneie', 'key');
6
+ // Path canon lives in lib/paths.ts — six modules used to each carry their own.
8
7
  /** --api flag > ONE_API_URL (canonical) > ONEIE_BASE_URL (legacy) > fallback. ONE_BASE_URL is retired. */
9
8
  export function resolveBase(opts = {}, fallback = 'https://one.ie') {
10
9
  const base = opts.api ?? process.env.ONE_API_URL ?? process.env.ONEIE_BASE_URL ?? fallback;
@@ -18,9 +17,19 @@ export function resolveKey(opts = {}) {
18
17
  return process.env.ONE_API_KEY;
19
18
  if (process.env.ONEIE_API_KEY)
20
19
  return process.env.ONEIE_API_KEY;
21
- if (existsSync(KEY_FILE))
22
- return readFileSync(KEY_FILE, 'utf8').trim();
23
- return '';
20
+ // The PROJECT's key outranks the machine's. A folder that carries its own
21
+ // credential is saying "use mine", and `one init --dir .` wrote it there to
22
+ // narrow the blast radius — falling through to ~/.config/oneie/key would hand
23
+ // the command the machine-wide key instead and quietly undo that.
24
+ //
25
+ // Below the env vars on purpose: an explicit ONE_API_KEY in the shell is a
26
+ // deliberate override, and CI sets it that way.
27
+ const folder = readKeyFolder(process.cwd());
28
+ if (folder)
29
+ return folder.apiKey;
30
+ // readMachineKey tries ~/.config/one/key then the pre-rename ~/.config/oneie/key,
31
+ // so an upgrade does not silently log anyone out.
32
+ return readMachineKey();
24
33
  }
25
34
  export function authHeaders(opts = {}) {
26
35
  const h = { 'Content-Type': 'application/json' };
@@ -0,0 +1,130 @@
1
+ /** The per-project directory holding the key, the vault and their metadata. */
2
+ export declare const KEY_DIR_NAME = ".one";
3
+ /**
4
+ * The pre-rename project directory. READ-ONLY — a folder minted before the
5
+ * rename keeps working; nothing is ever written here again. Same fallback shape
6
+ * as `paths.ts` uses for ~/.config, and for the same reason: a rename must not
7
+ * present as "my key stopped working".
8
+ */
9
+ export declare const LEGACY_KEY_DIR_NAME = ".oneie";
10
+ /** `*.key` is already covered by the scaffold's root .gitignore. */
11
+ export declare const KEY_FILE_NAME = "agent.key";
12
+ export declare const META_FILE_NAME = "agent.json";
13
+ export interface KeyFolderInput {
14
+ /** Project root. The key lands at <dir>/.oneie/agent.key */
15
+ dir: string;
16
+ /** The workspace-scoped key — authenticates as the workspace actor. */
17
+ apiKey: string;
18
+ /** The uid-bound registration key. Distinct from apiKey; see the note below. */
19
+ regKey?: string;
20
+ workspace: string;
21
+ uid?: string;
22
+ api: string;
23
+ /** Unix seconds at which the key stops verifying, when the server set one. */
24
+ expiresAt?: number;
25
+ /** The spend ceiling the server reports for this actor, in USD. */
26
+ spendLimitUsd?: number;
27
+ }
28
+ export interface KeyFolderResult {
29
+ ok: boolean;
30
+ keyPath?: string;
31
+ metaPath?: string;
32
+ ignorePath?: string;
33
+ /** Set when the ceremony refused — the key was NOT written. */
34
+ error?: string;
35
+ }
36
+ /**
37
+ * True when `.gitignore` already ignores the key directory.
38
+ *
39
+ * Deliberately a literal scan, not a `git check-ignore` shell-out: the folder
40
+ * may not be a git repo yet (that is the common case — `npx oneie` runs before
41
+ * `git init`), and a check that silently passes on "not a repo" would be the
42
+ * false green this whole module exists to avoid.
43
+ */
44
+ export declare function ignoresKeyDir(ignoreText: string): boolean;
45
+ /**
46
+ * Ensure `<dir>/.gitignore` ignores the key directory. Returns the path on
47
+ * success, or null when it could not be written — in which case the caller must
48
+ * NOT write a key.
49
+ */
50
+ export declare function ensureIgnored(dir: string): string | null;
51
+ /**
52
+ * Canonical absolute path — symlinks resolved.
53
+ *
54
+ * `resolve()` alone is NOT enough for the path binding. On macOS `/tmp` is a
55
+ * symlink to `/private/tmp` and `/var` to `/private/var`, so a key minted at the
56
+ * path the user typed and read back after a `chdir` compares unequal and a
57
+ * legitimate credential is refused. Home directories and network mounts are
58
+ * symlinked on plenty of real machines too. Compare the REAL path on both sides
59
+ * or the check fails open on attackers and closed on users — the worst pairing.
60
+ *
61
+ * Falls back to `resolve()` when the path does not exist yet (realpath throws).
62
+ */
63
+ export declare function canonicalDir(p: string): string;
64
+ /**
65
+ * A stable, secret-ish id for THIS machine.
66
+ *
67
+ * The path binding alone is not enough where the path is predictable. A repo
68
+ * that ships `.oneie/agent.json` recording `dir:
69
+ * "/home/runner/work/<repo>/<repo>"` matches that path on EVERY GitHub Actions
70
+ * checkout of it — so the clone attack the binding closes for a laptop reopens
71
+ * for CI, which is exactly where nobody is watching. The machine id is a value
72
+ * the attacker cannot guess and cannot read from the victim's repo, so a key
73
+ * must be BOTH at the right path AND on the right machine.
74
+ *
75
+ * Stored 0600 beside the machine-wide key. Not a secret in the cryptographic
76
+ * sense — it authorises nothing on its own — so a read-only or unwritable home
77
+ * degrades to path-only binding rather than refusing all work.
78
+ */
79
+ export declare function machineId(): string | null;
80
+ /**
81
+ * Write `data` to `path` at 0600, refusing to follow a symlink.
82
+ *
83
+ * `writeFileSync` FOLLOWS symlinks. An attacker who can pre-plant
84
+ * `.oneie/agent.key.tmp` as a link to a file they control gets our chmod(0600)
85
+ * and our credential written to their target — the classic pre-plant, and the
86
+ * 0700 directory does not help because the link is created before we ever run.
87
+ * `O_NOFOLLOW` makes the kernel refuse, and `O_EXCL` means we never write onto
88
+ * an existing file at all.
89
+ */
90
+ export declare function writeSecret(path: string, data: string): void;
91
+ /**
92
+ * Write the key folder: ignore entry FIRST, then 0700 dir, then 0600 key via
93
+ * tmp+rename so a reader never observes a partial or world-readable file.
94
+ *
95
+ * Refuses (and writes nothing) when the ignore entry cannot be established.
96
+ */
97
+ export declare function writeKeyFolder(input: KeyFolderInput): KeyFolderResult;
98
+ /**
99
+ * Read a folder key back, or null when the folder has none — or when the key
100
+ * found there was minted for a DIFFERENT directory.
101
+ *
102
+ * THE PATH BINDING IS A SECURITY CONTROL, not bookkeeping. `resolveKey` consults
103
+ * the current working directory, so without this check any directory you `cd`
104
+ * into can supply your credentials: clone a repo that ships a `.oneie/agent.key`,
105
+ * run one `one` command inside it, and you are authenticated as WHOEVER MINTED
106
+ * THAT KEY. The damage is not that your key leaks — it is that your next
107
+ * `one push` writes your agents and skills into THEIR workspace, and your next
108
+ * `one trade` spends against their ledger. That is a credential-confusion
109
+ * exfiltration, and the folder-key rung introduced it.
110
+ *
111
+ * `agent.json` records the absolute path the key was minted for, so a key that
112
+ * travelled — by clone, copy, or archive — refuses rather than authenticates.
113
+ * This is the same shape as git's `safe.directory`, decided per key instead of
114
+ * per user.
115
+ *
116
+ * A key with NO recorded `dir` is pre-binding and also refused: the whole point
117
+ * is that an unbound credential is the untrustworthy case, and treating a
118
+ * missing field as permission is how the check gets bypassed by simply deleting
119
+ * a line.
120
+ */
121
+ export declare function readKeyFolder(dir: string): {
122
+ apiKey: string;
123
+ meta: Record<string, unknown>;
124
+ } | null;
125
+ /**
126
+ * Why a folder key present on disk was not used. Separate from `readKeyFolder`
127
+ * so a refusal can be EXPLAINED without the reader having to hold a credential:
128
+ * a silent null is right for `resolveKey` and useless for `doctor`.
129
+ */
130
+ export declare function keyFolderStatus(dir: string): 'none' | 'ok' | 'foreign' | 'unsafe' | 'unreadable';