@oneie/cli 4.0.7 → 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/README.md CHANGED
@@ -63,6 +63,23 @@ one connect telegram --token T # connect a channel by pasting its credential
63
63
  one trail <tag,tag> # ranked next-best tasks for a tag combination
64
64
  ```
65
65
 
66
+ ## Tasks — see, sequence, act
67
+
68
+ ```bash
69
+ one tasks brief --workspace one --tree # one screen: counts, ready, blocked-by, stale DONE, next five moves
70
+ one tasks board --workspace one --tree --all # every row; --kind work|approval|all (default work)
71
+ one tasks plan <goal-tid|tag> --tree # waves + critical path in hops; cycles, outside waits, ownerless
72
+ one tasks plan <goal> --emit dispatch --out w.json # hand-off: tid/assignee/model/effort/touches/accept per wave
73
+ one tasks sequence <tid> <tid> <tid> --apply # chain in order (one tasks:bulk call); preview without --apply
74
+ one tasks depend <tid> <blockedBy> # one edge; undepend removes it
75
+ one tasks set --where-tag t --set-status done # filter-driven edit; preview unless --apply
76
+ one tasks bulk --file plan.json # creates/edits from a file, chunked at 25
77
+ ```
78
+
79
+ Rows tagged `approval` are parked workflow runs: excluded by default, counted, and never closed by
80
+ status (`set --apply` refuses them unless `--kind all`). Every read states `total`, `truncated` and
81
+ `asOf`; a partial read says it is partial.
82
+
66
83
  ## Auth
67
84
 
68
85
  ```bash
@@ -115,6 +132,30 @@ one coordinate recall [about] | reputation [uid] # cross-session memory an
115
132
  one group bulk-create --csv # idempotent batch client provisioning
116
133
  ```
117
134
 
135
+ ## Media — the library an agent can reach
136
+
137
+ ```bash
138
+ one media list [--workspace S] [--kind image|video] [--prefix media|chat|ads|products|pages|brand|courses]
139
+ one media list --all # follow nextCursor to the end (ceiling 20 pages)
140
+ one media upload <path> [--workspace S] [--filename N] # a local file, sized against the 5 MiB cap before it is sent
141
+ ```
142
+
143
+ Two verbs, because only two earn a wrapper over `one ask`. `list` renders
144
+ `media:list`'s honest fields — `--limit` is R2 objects **scanned** per page, not
145
+ rows returned, and a `total` printed beside a truncation notice is a floor, so
146
+ the renderer says "at least N" rather than reading as complete. `upload` exists
147
+ because you cannot put a local file in a JSON body by hand; it reads, sizes and
148
+ encodes it, and the printed `key` names the workspace prefix the bytes actually
149
+ reached — `media:upload` refuses a workspace you may not write instead of
150
+ silently downgrading to your own.
151
+
152
+ Generation is deliberately **not** a subcommand — it is a prompt string in a
153
+ JSON body, so the raw door is no worse than a wrapper:
154
+
155
+ ```bash
156
+ one ask media:generate --data '{"prompt":"a red bicycle"}'
157
+ ```
158
+
118
159
  ## Chat — fan in · fan out
119
160
 
120
161
  Send to a space, broadcast to all, or stream incoming messages:
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneie/cli",
3
- "version": "4.0.7",
3
+ "version": "4.2.0",
4
4
  "description": "ONE agent CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -15,12 +15,12 @@
15
15
  "build": "tsc && cp package.json dist/ && chmod +x dist/src/index.js",
16
16
  "dev": "tsx src/index.ts",
17
17
  "typecheck": "tsc --noEmit",
18
- "test": "vitest run",
18
+ "test": "bash ../../.claude/scripts/gate-run.sh test-cli -- vitest run",
19
19
  "prepublishOnly": "bun run build"
20
20
  },
21
21
  "dependencies": {
22
22
  "commander": "^12.0.0",
23
- "@oneie/sdk": "^0.14.12"
23
+ "@oneie/sdk": "^0.16.0"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@oneie/evals": "^0.1.1",
@@ -1,5 +1,53 @@
1
1
  import { Command } from 'commander';
2
2
  export declare function agentCmd(): Command;
3
+ /**
4
+ * Structural validation — mirrors the rules enforced by the web's Zod schema
5
+ * (web/src/lib/agent-schema.ts) without pulling Zod or js-yaml into the CLI
6
+ * dependency graph. Catches the contract violations partners hit most often:
7
+ * missing frontmatter, name shape, journey/section anchor mismatches, chip
8
+ * id collisions, kebab-case ids. Anything outside these rules falls through
9
+ * to the live server-side validation when the agent is published.
10
+ */
11
+ /** Required: a reader REFUSES or silently SUBSTITUTES identity without it.
12
+ * name → publish refuses (world-receivers.ts:1407). kind → one-agents.mjs:191
13
+ * skips the file. (The non-empty body is checked separately.) */
14
+ export declare const AGENT_REQUIRED: readonly ["name", "kind"];
15
+ /** Recommended: every reader falls back without it, but the fallback is a
16
+ * different agent on the page (title → dir, description → 'Generic helpful
17
+ * assistant', tier/domain → inferred from the id). Warned when absent. */
18
+ export declare const AGENT_RECOMMENDED: readonly ["title", "tier", "domain", "subscribes"];
19
+ /** The closed enums the web schema owns (agent-schema.ts) — role-types.ts INFERS
20
+ * a value from the id when the declared one is off-enum, so an off-enum value
21
+ * is a silent re-placement on the org chart, not a load failure. */
22
+ export declare const AGENT_ENUMS: Record<string, readonly string[]>;
23
+ /** Keys the channels parser (channels/src/lib/agent-md.ts) can only read as a
24
+ * BLOCK list. An inline `[a, b]` is stored as the string "[a, b]", so
25
+ * `Array.isArray` fails in resolvePersona and the field is dropped at runtime. */
26
+ export declare const AGENT_BLOCK_LIST_KEYS: readonly ["tools", "subscribes", "emits", "skills", "tags"];
27
+ /** Every top-level key at least one reader consumes — the union of AgentMeta
28
+ * (agent-md.ts:435), agentFrontmatterSchema (agent-schema.ts:229), Persona
29
+ * (channels/src/context.ts:590), compile.ts:319, one-agents.mjs:130,
30
+ * role-types.ts and the publish path. A key outside this set is read by
31
+ * nothing; the validator names it rather than refusing it. `direction` is NOT here on
32
+ * purpose: C20 deleted it from 118 corpus files (0 readers; 93/95 `bidirectional`
33
+ * merely restated subscribes+emits, the rest contradicted them) — keeping it out
34
+ * is what makes `--strict` refuse a resurrection. */
35
+ export declare const AGENT_KNOWN_KEYS: ReadonlySet<string>;
36
+ export interface ValidateResult {
37
+ /** Fail the verdict — a required field is absent or the file is not an agent. */
38
+ errors: string[];
39
+ /** Measured hazards that do not fail by default; `--strict` promotes them. */
40
+ warnings: string[];
41
+ /** Top-level keys no reader consumes, by name. */
42
+ unknownKeys: string[];
43
+ }
44
+ export interface ValidateOpts {
45
+ /** Warnings become errors. */
46
+ strict?: boolean;
47
+ /** `publish` keeps the door's pre-spec gate: frontmatter + name + anchors. */
48
+ door?: 'validate' | 'publish';
49
+ }
50
+ export declare function validate(path: string, opts?: ValidateOpts): ValidateResult;
3
51
  /**
4
52
  * Targets the CLI can actually emit. `a2a` and `erc8004` were advertised in
5
53
  * --target help and in the docs but had no branch — they fell through to
@@ -8,4 +56,20 @@ export declare function agentCmd(): Command;
8
56
  * delegate to, and inventing one here would be worse than an honest error.
9
57
  */
10
58
  export declare const CLI_TARGETS: readonly ["mcp", "uagents", "skillmd", "web"];
59
+ export interface AgentverseReadiness {
60
+ ready: boolean;
61
+ /** Required and absent. Refuses the upload. */
62
+ missing: string[];
63
+ /** Optional and absent — named so an operator can choose, never a refusal. */
64
+ recommended: string[];
65
+ }
66
+ /**
67
+ * Is this agent.md ready to be a HOSTED Agentverse agent?
68
+ *
69
+ * `seed` is the only REQUIRED field, and it is required for one reason: it is the
70
+ * deterministic identity. Without it every deploy of the same file is a different
71
+ * agent as far as the network is concerned — a fresh address, so every peer that
72
+ * learned the old one is now talking to nobody.
73
+ */
74
+ export declare function agentverseReadiness(agentMd: string): AgentverseReadiness;
11
75
  export declare function compileTarget(content: string, target: string, skills?: Record<string, string>): string;
package/dist/src/agent.js CHANGED
@@ -38,10 +38,11 @@ export function agentCmd() {
38
38
  out(cmd, { ok: true, path: outPath, lines: body.split('\n').length });
39
39
  });
40
40
  cmd.command('validate <path>')
41
- .description('Validate agent.md frontmatter against spec')
42
- .action((path) => {
43
- const { errors } = validate(path);
44
- out(cmd, { ok: errors.length === 0, errors, checked: 1 });
41
+ .description('Validate agent.md frontmatter against the ONE agent spec (text/agents-spec.md)')
42
+ .option('--strict', 'Warnings are errors: unknown keys, off-enum values, list shapes the runtime cannot read')
43
+ .action((path, opts) => {
44
+ const { errors, warnings, unknownKeys } = validate(path, { strict: !!opts.strict });
45
+ out(cmd, { ok: errors.length === 0, errors, warnings, unknownKeys, checked: 1 });
45
46
  });
46
47
  cmd.command('lint <path>')
47
48
  .description('Lint agent.md style and spec rules')
@@ -102,12 +103,21 @@ export function agentCmd() {
102
103
  .option('--agentverse-key <key>', 'Agentverse API key (or set AGENTVERSE_API_KEY)')
103
104
  .option('--skills <dir>', 'Directory holding the skill markdown declared in the agent frontmatter (agentverse target)')
104
105
  .option('--live', 'Set lifecycle: active before publishing (skip the draft step)')
106
+ // The override for the Agentverse readiness refusal below. It is a flag, not a
107
+ // prompt, so the decision to deploy a non-deterministic identity is explicit and
108
+ // lands in the shell history of whoever made it.
109
+ .option('--force', 'Deploy to Agentverse even when the agent is not Agentverse-ready (no seed: — a new address every deploy)')
105
110
  .action(async (path, opts) => {
106
111
  if (!existsSync(path)) {
107
112
  out(cmd, { ok: false, error: `not found: ${path}` });
108
113
  return;
109
114
  }
110
- const { errors } = validate(path);
115
+ // The PUBLISH door keeps the gate it always had — the receiver itself
116
+ // refuses on `name:` alone (world-receivers.ts:1407) and this mirrors it.
117
+ // The spec's required set (kind, body) changes `validate`'s verdict, not
118
+ // whether a file may be uploaded; a stricter door here would be a reader
119
+ // changing behaviour, which text/agents-spec.md forbids.
120
+ const { errors } = validate(path, { door: 'publish' });
111
121
  if (errors.length) {
112
122
  out(cmd, { ok: false, errors });
113
123
  return;
@@ -129,6 +139,39 @@ export function agentCmd() {
129
139
  // deployed agent is a shell that cannot answer a message.
130
140
  const found = resolveSkillMds(path, content, opts.skills);
131
141
  warnSkillGap(found, 'uagents');
142
+ // ── The readiness gate — BEFORE the compile, and long before the network ──
143
+ //
144
+ // Placed next to warnSkillGap because it is the same kind of honesty: both
145
+ // name a capability the deployed agent will not have. It differs in what it
146
+ // does about it, and that difference is the whole cycle. A skill gap produces
147
+ // an agent that cannot answer; a seed gap produces an agent at a DIFFERENT
148
+ // ADDRESS each deploy — and the network cannot tell it is the same agent, so
149
+ // the damage is done the moment the upload succeeds, silently, to a caller
150
+ // who was told nothing. Warning and uploading anyway is the `--skip-tests`
151
+ // shape: a notice where a gate belongs. So the default REFUSES.
152
+ //
153
+ // `--force` keeps the plan's letter — it warns, then it uploads — while
154
+ // making the choice explicit and attributable.
155
+ //
156
+ // The refusal is STRUCTURED as well as spoken: `missing` rides the out()
157
+ // envelope so a --json caller branches on the field instead of scraping
158
+ // stderr. Naming which gate bit is the point.
159
+ const readiness = agentverseReadiness(content);
160
+ if (!readiness.ready) {
161
+ warnAgentverseGap(readiness);
162
+ if (!opts.force) {
163
+ out(cmd, {
164
+ ok: false,
165
+ error: `not Agentverse-ready — missing: ${readiness.missing.join(', ')}. Add the field, or pass --force to deploy a non-deterministic identity anyway.`,
166
+ ready: false,
167
+ missing: readiness.missing,
168
+ recommended: readiness.recommended,
169
+ force: '--force',
170
+ });
171
+ return;
172
+ }
173
+ console.error(' --force given — deploying anyway. This address will not be stable.');
174
+ }
132
175
  let python;
133
176
  try {
134
177
  python = compileAgent(content, { target: 'uagents', skills: found.skills });
@@ -767,21 +810,101 @@ function out(cmd, data) {
767
810
  * id collisions, kebab-case ids. Anything outside these rules falls through
768
811
  * to the live server-side validation when the agent is published.
769
812
  */
770
- function validate(path) {
771
- if (!existsSync(path))
772
- return { errors: [`not found: ${path}`] };
773
- const text = readFileSync(path, 'utf8');
813
+ // ── The ONE agent spec — text/agents-spec.md ─────────────────────────────────
814
+ //
815
+ // Six programs read a `kind: agent` file and each reads a different key set. The
816
+ // spec is derived from what they do; these constants are its machine half. Keep
817
+ // them in step with the spec's field table — the test asserts the shape.
818
+ /** Required: a reader REFUSES or silently SUBSTITUTES identity without it.
819
+ * name → publish refuses (world-receivers.ts:1407). kind → one-agents.mjs:191
820
+ * skips the file. (The non-empty body is checked separately.) */
821
+ export const AGENT_REQUIRED = ['name', 'kind'];
822
+ /** Recommended: every reader falls back without it, but the fallback is a
823
+ * different agent on the page (title → dir, description → 'Generic helpful
824
+ * assistant', tier/domain → inferred from the id). Warned when absent. */
825
+ export const AGENT_RECOMMENDED = ['title', 'tier', 'domain', 'subscribes'];
826
+ /** The closed enums the web schema owns (agent-schema.ts) — role-types.ts INFERS
827
+ * a value from the id when the declared one is off-enum, so an off-enum value
828
+ * is a silent re-placement on the org chart, not a load failure. */
829
+ export const AGENT_ENUMS = {
830
+ kind: ['agent', 'skill', 'pack', 'seed'],
831
+ tier: ['chairman', 'ceo', 'director', 'specialist'],
832
+ domain: ['marketing', 'sales', 'service', 'education', 'engineering', 'finance', 'community', 'governance'],
833
+ tone: ['primary', 'secondary', 'tertiary', 'neutral'],
834
+ };
835
+ /** Keys the channels parser (channels/src/lib/agent-md.ts) can only read as a
836
+ * BLOCK list. An inline `[a, b]` is stored as the string "[a, b]", so
837
+ * `Array.isArray` fails in resolvePersona and the field is dropped at runtime. */
838
+ export const AGENT_BLOCK_LIST_KEYS = ['tools', 'subscribes', 'emits', 'skills', 'tags'];
839
+ /** Every top-level key at least one reader consumes — the union of AgentMeta
840
+ * (agent-md.ts:435), agentFrontmatterSchema (agent-schema.ts:229), Persona
841
+ * (channels/src/context.ts:590), compile.ts:319, one-agents.mjs:130,
842
+ * role-types.ts and the publish path. A key outside this set is read by
843
+ * nothing; the validator names it rather than refusing it. `direction` is NOT here on
844
+ * purpose: C20 deleted it from 118 corpus files (0 readers; 93/95 `bidirectional`
845
+ * merely restated subscribes+emits, the rest contradicted them) — keeping it out
846
+ * is what makes `--strict` refuse a resurrection. */
847
+ export const AGENT_KNOWN_KEYS = new Set([
848
+ // identity + chart
849
+ 'agentmd', 'name', 'kind', 'title', 'tier', 'reports_to', 'reportsTo', 'tone', 'icon', 'iconName', 'uid',
850
+ 'tagline', 'domain', 'kpis', 'description', 'version', 'model', 'group', 'tags', 'channels', 'lifecycle',
851
+ 'sensitivity', 'starters', 'skills', 'tools', 'features', 'subscribes', 'emits', 'url',
852
+ // runtime (Persona)
853
+ 'intents', 'maxSteps', 'integrations', 'hooks', 'remote', 'subAgents',
854
+ // uAgents compile
855
+ 'seed', 'port', 'agentverse', 'mailbox', 'startup', 'shutdown', 'intervals', 'endpoints', 'bureau',
856
+ 'when_to_use', 'inputSchema', 'outputSchema', 'summary', 'evals',
857
+ // payments
858
+ 'wallet', 'accepts', 'price', 'currency',
859
+ // A/B + web-only blocks
860
+ 'variants', 'goals', 'journey', 'sections', 'branding', 'theme', 'ui', 'funnel', 'analytics', 'i18n', 'triggers',
861
+ ]);
862
+ /** Top-level frontmatter keys — a column-0 `key:` line. The same extraction the
863
+ * corpus histogram in text/agents-spec.md used, so validator and measurement
864
+ * agree by construction. */
865
+ function topLevelKeys(fm) {
866
+ const keys = [];
867
+ const re = /^([A-Za-z_][A-Za-z0-9_-]*):/gm;
868
+ let m;
869
+ while ((m = re.exec(fm)))
870
+ keys.push(m[1]);
871
+ return keys;
872
+ }
873
+ /** The scalar value of a top-level `key:` line, unquoted, trailing `# comment` stripped. */
874
+ function scalarOf(fm, key) {
875
+ const m = new RegExp(`^${key}:[ \\t]*(.*)$`, 'm').exec(fm);
876
+ if (!m)
877
+ return undefined;
878
+ return m[1].replace(/\s+#.*$/, '').trim().replace(/^["']|["']$/g, '');
879
+ }
880
+ export function validate(path, opts = {}) {
774
881
  const errors = [];
882
+ const warnings = [];
883
+ const unknownKeys = [];
884
+ const door = opts.door ?? 'validate';
885
+ const done = () => {
886
+ if (opts.strict && door === 'validate') {
887
+ errors.push(...warnings);
888
+ warnings.length = 0;
889
+ }
890
+ return { errors, warnings, unknownKeys };
891
+ };
892
+ if (!existsSync(path)) {
893
+ errors.push(`not found: ${path}`);
894
+ return done();
895
+ }
896
+ const text = readFileSync(path, 'utf8');
775
897
  if (!text.startsWith('---')) {
776
898
  errors.push('missing frontmatter — agent.md must start with `---`');
777
- return { errors };
899
+ return done();
778
900
  }
779
901
  const fmMatch = text.match(/^---\n([\s\S]*?)\n---/);
780
902
  if (!fmMatch) {
781
903
  errors.push('frontmatter not terminated — missing closing `---`');
782
- return { errors };
904
+ return done();
783
905
  }
784
906
  const fm = fmMatch[1];
907
+ const body = text.slice(fmMatch[0].length).trim();
785
908
  const nameMatch = /^name:\s*(\S+)/m.exec(fm);
786
909
  if (!nameMatch) {
787
910
  errors.push('missing required field: name');
@@ -811,7 +934,61 @@ function validate(path) {
811
934
  }
812
935
  }
813
936
  }
814
- return { errors };
937
+ // The publish door stops here — its gate is the receiver's own (name), and
938
+ // the spec forbids a door changing behaviour under a stricter validator.
939
+ if (door === 'publish')
940
+ return done();
941
+ // ── The spec's required set (text/agents-spec.md § required) ──────────────
942
+ const keys = topLevelKeys(fm);
943
+ const present = new Set(keys);
944
+ const kind = scalarOf(fm, 'kind');
945
+ if (!present.has('kind') || !kind) {
946
+ errors.push('missing required field: kind — `kind: agent` is what one-agents.mjs:191 and the spec key on; without it the file is the other genus (text/template-agent.md)');
947
+ }
948
+ else if (kind !== 'agent') {
949
+ errors.push(`kind: ${kind} — \`agent validate\` checks the kind: agent spec; a ${kind} file goes through \`oneie skill validate\``);
950
+ }
951
+ if (!body) {
952
+ errors.push('empty body — the markdown after the closing `---` IS the system prompt; empty, channels substitutes personas.one.systemPrompt (context.ts:593) and the agent silently becomes a different agent');
953
+ }
954
+ // ── Recommended: absent → a fallback that is a different agent on the page ──
955
+ for (const k of AGENT_RECOMMENDED) {
956
+ if (!present.has(k))
957
+ warnings.push(`missing recommended field: ${k}`);
958
+ }
959
+ if (!present.has('description') && !present.has('tagline')) {
960
+ warnings.push('missing recommended field: description (or tagline) — Persona falls back to "Generic helpful assistant" (personas.ts:60)');
961
+ }
962
+ else if (!present.has('description') && present.has('tagline')) {
963
+ warnings.push('tagline without description — the chart reads tagline (role-types.ts:396); the runtime reads only description (context.ts:591) and will answer as "Generic helpful assistant"');
964
+ }
965
+ // ── Off-enum values: the chart INFERS a placement instead of using yours ───
966
+ for (const [k, allowed] of Object.entries(AGENT_ENUMS)) {
967
+ if (k === 'kind')
968
+ continue;
969
+ const v = scalarOf(fm, k);
970
+ if (v !== undefined && v !== '' && !allowed.includes(v)) {
971
+ warnings.push(`${k}: ${v} is not one of ${allowed.join('|')} — the web schema reports it and role-types.ts infers ${k} from the id instead`);
972
+ }
973
+ }
974
+ // ── Shapes the runtime cannot read ─────────────────────────────────────────
975
+ for (const k of AGENT_BLOCK_LIST_KEYS) {
976
+ if (new RegExp(`^${k}:[ \\t]*\\[`, 'm').test(fm)) {
977
+ warnings.push(`${k}: is an inline [a, b] list — channels/src/lib/agent-md.ts stores it as a string and resolvePersona drops it; write a block list`);
978
+ }
979
+ }
980
+ if (/^\s+-\s+(signal|tag):\s/m.test(fm)) {
981
+ warnings.push('a `- signal: <tag>` list item — web keeps bare strings only, channels keeps the value, one-agents.mjs strips the prefix; write the bare tag');
982
+ }
983
+ // ── Keys read by nothing — named, never silently accepted ─────────────────
984
+ for (const k of keys) {
985
+ if (!AGENT_KNOWN_KEYS.has(k) && !unknownKeys.includes(k))
986
+ unknownKeys.push(k);
987
+ }
988
+ if (unknownKeys.length) {
989
+ warnings.push(`unknown keys (read by no reader): ${unknownKeys.join(', ')}`);
990
+ }
991
+ return done();
815
992
  }
816
993
  function lint(path) {
817
994
  if (!existsSync(path))
@@ -940,6 +1117,57 @@ function warnSkillGap(found, target) {
940
1117
  }
941
1118
  }
942
1119
  }
1120
+ /** Why each recommended field is worth declaring. Absent ⇒ a capability the hosted agent simply does not have. */
1121
+ const AGENTVERSE_RECOMMENDED = [
1122
+ ['agentverse', 'no Agentverse registration URL — the agent is hosted but not discoverable by name'],
1123
+ ['mailbox', 'mailbox is off — the agent can only be reached while it is running, never asynchronously'],
1124
+ ['endpoints', 'no endpoints — nothing outside the uAgents protocol can call it'],
1125
+ ['bureau', 'no bureau — it runs alone rather than beside its siblings'],
1126
+ ['port', 'no port — the compiler leaves the uAgents default (8000)'],
1127
+ ['when_to_use', 'no when_to_use — a discovering agent has nothing to route on'],
1128
+ ['version', 'no version — two deploys are indistinguishable in the registry'],
1129
+ // The three that emit BEHAVIOUR rather than configuration. Listed for the same
1130
+ // reason as the rest — the cycle enumerated eleven fields and a list silently
1131
+ // covering seven of them reads as an oversight — but they are the ones an operator
1132
+ // should most often decline: each buys a real model call on a schedule.
1133
+ ['intervals', 'no intervals — the agent only ever speaks when spoken to'],
1134
+ ['startup', 'no startup — it announces nothing when it boots'],
1135
+ ['shutdown', 'no shutdown — it announces nothing when it stops'],
1136
+ ];
1137
+ /**
1138
+ * Is this agent.md ready to be a HOSTED Agentverse agent?
1139
+ *
1140
+ * `seed` is the only REQUIRED field, and it is required for one reason: it is the
1141
+ * deterministic identity. Without it every deploy of the same file is a different
1142
+ * agent as far as the network is concerned — a fresh address, so every peer that
1143
+ * learned the old one is now talking to nobody.
1144
+ */
1145
+ export function agentverseReadiness(agentMd) {
1146
+ const { meta } = parseAgentMd(agentMd);
1147
+ const missing = [];
1148
+ // The emitter's own predicate (compile.ts:512), deliberately — not `in`.
1149
+ if (!meta.seed)
1150
+ missing.push('seed');
1151
+ const recommended = AGENTVERSE_RECOMMENDED
1152
+ .filter(([k]) => !meta[k])
1153
+ .map(([k, why]) => `${k}: ${why}`);
1154
+ return { ready: missing.length === 0, missing, recommended };
1155
+ }
1156
+ /**
1157
+ * Say what is missing, in `warnSkillGap`'s register and on the same stream — stderr,
1158
+ * so a `--json` stdout stays one machine-readable line. The caller decides whether to
1159
+ * refuse; this function only speaks.
1160
+ */
1161
+ function warnAgentverseGap(r) {
1162
+ if (r.missing.includes('seed')) {
1163
+ console.error('warning: this agent declares no seed: — its Agentverse identity is NOT deterministic.');
1164
+ console.error(' The compiled Python emits `Agent(name=...)` with no `seed=`, so uAgents derives a');
1165
+ console.error(' fresh key: a NEW agent address on every deploy, and every peer holding the old');
1166
+ console.error(' address is talking to nobody. Add `seed: <a secret phrase>` to the frontmatter.');
1167
+ }
1168
+ for (const line of r.recommended)
1169
+ console.error(` also absent — ${line}`);
1170
+ }
943
1171
  export function compileTarget(content, target, skills = {}) {
944
1172
  const why = UNIMPLEMENTED_TARGETS[target];
945
1173
  if (why) {
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';
@@ -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/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).