@usenaive-sdk/cli 0.15.1 → 1.0.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 +43 -402
- package/dist/index.js +51775 -502
- package/package.json +22 -18
- package/dist/client.d.ts +0 -108
- package/dist/client.js +0 -458
- package/dist/client.js.map +0 -1
- package/dist/commands/account-kits.d.ts +0 -2
- package/dist/commands/account-kits.js +0 -71
- package/dist/commands/account-kits.js.map +0 -1
- package/dist/commands/aeo.d.ts +0 -2
- package/dist/commands/aeo.js +0 -451
- package/dist/commands/aeo.js.map +0 -1
- package/dist/commands/agent-profiles.d.ts +0 -11
- package/dist/commands/agent-profiles.js +0 -120
- package/dist/commands/agent-profiles.js.map +0 -1
- package/dist/commands/agents.d.ts +0 -2
- package/dist/commands/agents.js +0 -916
- package/dist/commands/agents.js.map +0 -1
- package/dist/commands/app-data.d.ts +0 -2
- package/dist/commands/app-data.js +0 -445
- package/dist/commands/app-data.js.map +0 -1
- package/dist/commands/approvals.d.ts +0 -2
- package/dist/commands/approvals.js +0 -242
- package/dist/commands/approvals.js.map +0 -1
- package/dist/commands/apps.d.ts +0 -9
- package/dist/commands/apps.js +0 -844
- package/dist/commands/apps.js.map +0 -1
- package/dist/commands/audio.d.ts +0 -9
- package/dist/commands/audio.js +0 -391
- package/dist/commands/audio.js.map +0 -1
- package/dist/commands/auth.d.ts +0 -31
- package/dist/commands/auth.js +0 -428
- package/dist/commands/auth.js.map +0 -1
- package/dist/commands/billing.d.ts +0 -2
- package/dist/commands/billing.js +0 -250
- package/dist/commands/billing.js.map +0 -1
- package/dist/commands/brain.d.ts +0 -2
- package/dist/commands/brain.js +0 -1300
- package/dist/commands/brain.js.map +0 -1
- package/dist/commands/browser.d.ts +0 -2
- package/dist/commands/browser.js +0 -378
- package/dist/commands/browser.js.map +0 -1
- package/dist/commands/business.d.ts +0 -2
- package/dist/commands/business.js +0 -566
- package/dist/commands/business.js.map +0 -1
- package/dist/commands/cards.d.ts +0 -2
- package/dist/commands/cards.js +0 -419
- package/dist/commands/cards.js.map +0 -1
- package/dist/commands/ceo.d.ts +0 -2
- package/dist/commands/ceo.js +0 -369
- package/dist/commands/ceo.js.map +0 -1
- package/dist/commands/clone.d.ts +0 -2
- package/dist/commands/clone.js +0 -203
- package/dist/commands/clone.js.map +0 -1
- package/dist/commands/companies.d.ts +0 -10
- package/dist/commands/companies.js +0 -283
- package/dist/commands/companies.js.map +0 -1
- package/dist/commands/company-data.d.ts +0 -2
- package/dist/commands/company-data.js +0 -168
- package/dist/commands/company-data.js.map +0 -1
- package/dist/commands/compute.d.ts +0 -2
- package/dist/commands/compute.js +0 -498
- package/dist/commands/compute.js.map +0 -1
- package/dist/commands/config.d.ts +0 -2
- package/dist/commands/config.js +0 -36
- package/dist/commands/config.js.map +0 -1
- package/dist/commands/connections.d.ts +0 -8
- package/dist/commands/connections.js +0 -137
- package/dist/commands/connections.js.map +0 -1
- package/dist/commands/cron-jobs.d.ts +0 -2
- package/dist/commands/cron-jobs.js +0 -245
- package/dist/commands/cron-jobs.js.map +0 -1
- package/dist/commands/domains.d.ts +0 -2
- package/dist/commands/domains.js +0 -474
- package/dist/commands/domains.js.map +0 -1
- package/dist/commands/ecommerce.d.ts +0 -2
- package/dist/commands/ecommerce.js +0 -277
- package/dist/commands/ecommerce.js.map +0 -1
- package/dist/commands/email.d.ts +0 -2
- package/dist/commands/email.js +0 -336
- package/dist/commands/email.js.map +0 -1
- package/dist/commands/employees.d.ts +0 -2
- package/dist/commands/employees.js +0 -190
- package/dist/commands/employees.js.map +0 -1
- package/dist/commands/env.d.ts +0 -7
- package/dist/commands/env.js +0 -112
- package/dist/commands/env.js.map +0 -1
- package/dist/commands/formation.d.ts +0 -2
- package/dist/commands/formation.js +0 -273
- package/dist/commands/formation.js.map +0 -1
- package/dist/commands/identity.d.ts +0 -2
- package/dist/commands/identity.js +0 -110
- package/dist/commands/identity.js.map +0 -1
- package/dist/commands/images.d.ts +0 -2
- package/dist/commands/images.js +0 -371
- package/dist/commands/images.js.map +0 -1
- package/dist/commands/init.d.ts +0 -5
- package/dist/commands/init.js +0 -43
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/jobs.d.ts +0 -2
- package/dist/commands/jobs.js +0 -144
- package/dist/commands/jobs.js.map +0 -1
- package/dist/commands/keys.d.ts +0 -2
- package/dist/commands/keys.js +0 -156
- package/dist/commands/keys.js.map +0 -1
- package/dist/commands/legacy-auth.d.ts +0 -27
- package/dist/commands/legacy-auth.js +0 -64
- package/dist/commands/legacy-auth.js.map +0 -1
- package/dist/commands/llm.d.ts +0 -2
- package/dist/commands/llm.js +0 -125
- package/dist/commands/llm.js.map +0 -1
- package/dist/commands/login.d.ts +0 -2
- package/dist/commands/login.js +0 -65
- package/dist/commands/login.js.map +0 -1
- package/dist/commands/logout.d.ts +0 -7
- package/dist/commands/logout.js +0 -55
- package/dist/commands/logout.js.map +0 -1
- package/dist/commands/logs.d.ts +0 -2
- package/dist/commands/logs.js +0 -42
- package/dist/commands/logs.js.map +0 -1
- package/dist/commands/loops.d.ts +0 -2
- package/dist/commands/loops.js +0 -260
- package/dist/commands/loops.js.map +0 -1
- package/dist/commands/media.d.ts +0 -2
- package/dist/commands/media.js +0 -183
- package/dist/commands/media.js.map +0 -1
- package/dist/commands/memory.d.ts +0 -2
- package/dist/commands/memory.js +0 -151
- package/dist/commands/memory.js.map +0 -1
- package/dist/commands/mobile.d.ts +0 -4
- package/dist/commands/mobile.js +0 -382
- package/dist/commands/mobile.js.map +0 -1
- package/dist/commands/module.d.ts +0 -8
- package/dist/commands/module.js +0 -48
- package/dist/commands/module.js.map +0 -1
- package/dist/commands/objectives.d.ts +0 -2
- package/dist/commands/objectives.js +0 -243
- package/dist/commands/objectives.js.map +0 -1
- package/dist/commands/payments.d.ts +0 -2
- package/dist/commands/payments.js +0 -131
- package/dist/commands/payments.js.map +0 -1
- package/dist/commands/people.d.ts +0 -2
- package/dist/commands/people.js +0 -197
- package/dist/commands/people.js.map +0 -1
- package/dist/commands/phone.d.ts +0 -2
- package/dist/commands/phone.js +0 -289
- package/dist/commands/phone.js.map +0 -1
- package/dist/commands/projects.d.ts +0 -13
- package/dist/commands/projects.js +0 -220
- package/dist/commands/projects.js.map +0 -1
- package/dist/commands/queue.d.ts +0 -2
- package/dist/commands/queue.js +0 -121
- package/dist/commands/queue.js.map +0 -1
- package/dist/commands/register.d.ts +0 -2
- package/dist/commands/register.js +0 -88
- package/dist/commands/register.js.map +0 -1
- package/dist/commands/report.d.ts +0 -17
- package/dist/commands/report.js +0 -109
- package/dist/commands/report.js.map +0 -1
- package/dist/commands/sandbox.d.ts +0 -2
- package/dist/commands/sandbox.js +0 -558
- package/dist/commands/sandbox.js.map +0 -1
- package/dist/commands/search.d.ts +0 -2
- package/dist/commands/search.js +0 -223
- package/dist/commands/search.js.map +0 -1
- package/dist/commands/seo.d.ts +0 -2
- package/dist/commands/seo.js +0 -528
- package/dist/commands/seo.js.map +0 -1
- package/dist/commands/sessions.d.ts +0 -6
- package/dist/commands/sessions.js +0 -109
- package/dist/commands/sessions.js.map +0 -1
- package/dist/commands/social-data.d.ts +0 -2
- package/dist/commands/social-data.js +0 -245
- package/dist/commands/social-data.js.map +0 -1
- package/dist/commands/social.d.ts +0 -2
- package/dist/commands/social.js +0 -407
- package/dist/commands/social.js.map +0 -1
- package/dist/commands/status.d.ts +0 -2
- package/dist/commands/status.js +0 -79
- package/dist/commands/status.js.map +0 -1
- package/dist/commands/support.d.ts +0 -2
- package/dist/commands/support.js +0 -134
- package/dist/commands/support.js.map +0 -1
- package/dist/commands/tasks.d.ts +0 -2
- package/dist/commands/tasks.js +0 -409
- package/dist/commands/tasks.js.map +0 -1
- package/dist/commands/teams.d.ts +0 -69
- package/dist/commands/teams.js +0 -503
- package/dist/commands/teams.js.map +0 -1
- package/dist/commands/trading.d.ts +0 -2
- package/dist/commands/trading.js +0 -333
- package/dist/commands/trading.js.map +0 -1
- package/dist/commands/up.d.ts +0 -551
- package/dist/commands/up.js +0 -1149
- package/dist/commands/up.js.map +0 -1
- package/dist/commands/usage.d.ts +0 -2
- package/dist/commands/usage.js +0 -73
- package/dist/commands/usage.js.map +0 -1
- package/dist/commands/use.d.ts +0 -12
- package/dist/commands/use.js +0 -96
- package/dist/commands/use.js.map +0 -1
- package/dist/commands/users.d.ts +0 -10
- package/dist/commands/users.js +0 -82
- package/dist/commands/users.js.map +0 -1
- package/dist/commands/vault.d.ts +0 -2
- package/dist/commands/vault.js +0 -101
- package/dist/commands/vault.js.map +0 -1
- package/dist/commands/verification.d.ts +0 -2
- package/dist/commands/verification.js +0 -152
- package/dist/commands/verification.js.map +0 -1
- package/dist/commands/verify-email.d.ts +0 -19
- package/dist/commands/verify-email.js +0 -130
- package/dist/commands/verify-email.js.map +0 -1
- package/dist/commands/video.d.ts +0 -2
- package/dist/commands/video.js +0 -417
- package/dist/commands/video.js.map +0 -1
- package/dist/commands/voice.d.ts +0 -2
- package/dist/commands/voice.js +0 -516
- package/dist/commands/voice.js.map +0 -1
- package/dist/commands/wallet.d.ts +0 -2
- package/dist/commands/wallet.js +0 -244
- package/dist/commands/wallet.js.map +0 -1
- package/dist/commands/webhooks.d.ts +0 -13
- package/dist/commands/webhooks.js +0 -119
- package/dist/commands/webhooks.js.map +0 -1
- package/dist/commands/whoami.d.ts +0 -2
- package/dist/commands/whoami.js +0 -53
- package/dist/commands/whoami.js.map +0 -1
- package/dist/config.d.ts +0 -42
- package/dist/config.js +0 -83
- package/dist/config.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.js.map +0 -1
- package/dist/lib/brain-select.d.ts +0 -193
- package/dist/lib/brain-select.js +0 -403
- package/dist/lib/brain-select.js.map +0 -1
- package/dist/lib/cli-validation.d.ts +0 -12
- package/dist/lib/cli-validation.js +0 -46
- package/dist/lib/cli-validation.js.map +0 -1
- package/dist/lib/config-errors.d.ts +0 -4
- package/dist/lib/config-errors.js +0 -13
- package/dist/lib/config-errors.js.map +0 -1
- package/dist/lib/deprecation.d.ts +0 -158
- package/dist/lib/deprecation.js +0 -140
- package/dist/lib/deprecation.js.map +0 -1
- package/dist/lib/duration.d.ts +0 -8
- package/dist/lib/duration.js +0 -11
- package/dist/lib/duration.js.map +0 -1
- package/dist/lib/http-response.d.ts +0 -11
- package/dist/lib/http-response.js +0 -96
- package/dist/lib/http-response.js.map +0 -1
- package/dist/lib/llm-paywall.d.ts +0 -82
- package/dist/lib/llm-paywall.js +0 -231
- package/dist/lib/llm-paywall.js.map +0 -1
- package/dist/lib/pricing.d.ts +0 -132
- package/dist/lib/pricing.js +0 -148
- package/dist/lib/pricing.js.map +0 -1
- package/dist/lib/starter-config.d.ts +0 -13
- package/dist/lib/starter-config.js +0 -71
- package/dist/lib/starter-config.js.map +0 -1
- package/dist/lib/stream-frames.d.ts +0 -114
- package/dist/lib/stream-frames.js +0 -169
- package/dist/lib/stream-frames.js.map +0 -1
- package/dist/lib/teams-catalog.d.ts +0 -141
- package/dist/lib/teams-catalog.js +0 -841
- package/dist/lib/teams-catalog.js.map +0 -1
- package/dist/lib/unknown-command.d.ts +0 -71
- package/dist/lib/unknown-command.js +0 -132
- package/dist/lib/unknown-command.js.map +0 -1
- package/dist/lib/version-check.d.ts +0 -26
- package/dist/lib/version-check.js +0 -21
- package/dist/lib/version-check.js.map +0 -1
- package/dist/output.d.ts +0 -246
- package/dist/output.js +0 -539
- package/dist/output.js.map +0 -1
- package/dist/prompt.d.ts +0 -17
- package/dist/prompt.js +0 -70
- package/dist/prompt.js.map +0 -1
- package/dist/version.d.ts +0 -2
- package/dist/version.js +0 -14
- package/dist/version.js.map +0 -1
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import { type NextStep } from "../output.js";
|
|
2
|
-
/** The public knowledge-base shape (`formatKnowledgeBaseRow`, contracts/brain.ts:196). */
|
|
3
|
-
export interface BrainRow {
|
|
4
|
-
id: string;
|
|
5
|
-
name: string;
|
|
6
|
-
provider?: string;
|
|
7
|
-
status?: string;
|
|
8
|
-
is_default?: boolean;
|
|
9
|
-
created_at?: string;
|
|
10
|
-
updated_at?: string;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* One agent as the roster reports it — the whole `agents` row, so `metadata`
|
|
14
|
-
* rides along. `hermesProfileName` is the slug the runtime knows the agent by;
|
|
15
|
-
* both it and `name` are accepted as a reference.
|
|
16
|
-
*/
|
|
17
|
-
export interface AgentRow {
|
|
18
|
-
id: string;
|
|
19
|
-
name: string;
|
|
20
|
-
role?: string | null;
|
|
21
|
-
title?: string | null;
|
|
22
|
-
hermesProfileName?: string | null;
|
|
23
|
-
enabled?: boolean;
|
|
24
|
-
archived?: boolean;
|
|
25
|
-
metadata?: Record<string, unknown> | null;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* THE BINDING KEY, and it is deliberately NOT a new word.
|
|
29
|
-
*
|
|
30
|
-
* `brain_knowledge_base_id` is the exact spelling `POST /v1/runs` already
|
|
31
|
-
* accepts to point a run's reflexive-brain attach at a knowledge base
|
|
32
|
-
* (platform/brain/src/contracts/brain-ops.ts:98, packages/api/src/routes/runs.ts:104).
|
|
33
|
-
* Binding an AGENT to a brain records the value that surface already consumes
|
|
34
|
-
* under the name it already uses, rather than minting a second one.
|
|
35
|
-
*/
|
|
36
|
-
export declare const BRAIN_BINDING_KEY = "brain_knowledge_base_id";
|
|
37
|
-
/**
|
|
38
|
-
* THE COMPANION KEY, written by the brain surface and by nothing else.
|
|
39
|
-
*
|
|
40
|
-
* `brain_connected_at` is stamped by `connectBrainToAgent`
|
|
41
|
-
* (packages/api/src/routes/brain.ts:1121-1131) in the same atomic jsonb merge as
|
|
42
|
-
* the binding, and removed by `disconnectBrainFromAgent`. It is what
|
|
43
|
-
* `GET /v1/brain/connections` reports as `connected_at`, so a binding written
|
|
44
|
-
* without it reads back as `connected_at: null` — or, worse, carries the
|
|
45
|
-
* timestamp of an EARLIER binding to a DIFFERENT brain, which is what the roster
|
|
46
|
-
* PATCH used to leave behind here.
|
|
47
|
-
*/
|
|
48
|
-
export declare const BRAIN_CONNECTED_AT_KEY = "brain_connected_at";
|
|
49
|
-
/**
|
|
50
|
-
* THE BRAIN BINDING SURFACE — the routes that carry the brain gate.
|
|
51
|
-
*
|
|
52
|
-
* 🔴 THESE REPLACED A ROSTER PATCH, AND THAT IS THE WHOLE POINT. This CLI used
|
|
53
|
-
* to write the binding with `PATCH {@link ROSTER_PATH}/:id {metadata:{…}}`, which
|
|
54
|
-
* is mounted on the ROSTER's own primitive gate rather than the brain's.
|
|
55
|
-
* `packages/api/src/routes/brain.ts:17-22`
|
|
56
|
-
* says exactly why that must not exist — "a second mount is how a route reaches
|
|
57
|
-
* the same data without the same gate" — and it was measured live on one tenant,
|
|
58
|
-
* one agent, one field: `POST /v1/users/{tu}/brain/connect` → 403
|
|
59
|
-
* `subprocessor_consent_required`, while the roster PATCH of
|
|
60
|
-
* `metadata.brain_knowledge_base_id` on the same agent → 200. The shipped
|
|
61
|
-
* `naive brain connect` was the caller of the ungated door.
|
|
62
|
-
*
|
|
63
|
-
* Three things came back with the move, none of which the roster PATCH did:
|
|
64
|
-
* 1. the `brain` primitive gate, so a company with brain disabled is refused
|
|
65
|
-
* here the way it is refused everywhere else;
|
|
66
|
-
* 2. the `brain.agent.connected` `activity_events` row — the ledger entry that
|
|
67
|
-
* makes a binding auditable;
|
|
68
|
-
* 3. `brain_connected_at`, stamped in the same statement as the binding.
|
|
69
|
-
* And one hazard went away: the roster PATCH read-modify-wrote the whole
|
|
70
|
-
* metadata bag, so two concurrent writers lost each other's keys. `connect` is a
|
|
71
|
-
* single `COALESCE(metadata,'{}') || {…}` merge in Postgres.
|
|
72
|
-
*/
|
|
73
|
-
export declare const BRAIN_CONNECT_PATH = "/v1/brain/connect";
|
|
74
|
-
export declare const BRAIN_CONNECTIONS_PATH = "/v1/brain/connections";
|
|
75
|
-
/**
|
|
76
|
-
* THE ROSTER SURFACE, NAMED ONCE — READ-ONLY FROM HERE.
|
|
77
|
-
*
|
|
78
|
-
* This is the only place in the multi-brain code that spells the retired noun,
|
|
79
|
-
* and it is spelled because it is a WIRE NAME: the route and the key of the
|
|
80
|
-
* array it answers with. `ci/vocabulary.test.ts` §3.1 retires the word for
|
|
81
|
-
* every other use — one governed worker identity is an AGENT — so everything
|
|
82
|
-
* downstream of these two constants says `agent`, including the errors a user
|
|
83
|
-
* reads. The surface is also DEPRECATED (its router carries a deprecation id).
|
|
84
|
-
*
|
|
85
|
-
* 🔴 IT IS NOW ONLY EVER READ. Nothing in this CLI PATCHes it: the one write
|
|
86
|
-
* that used to go here — the brain binding — moved to
|
|
87
|
-
* {@link BRAIN_CONNECT_PATH}. `__tests__/brain-multi.test.ts` asserts the roster
|
|
88
|
-
* sees no PATCH, so a future edit cannot quietly put the write back.
|
|
89
|
-
*
|
|
90
|
-
* TWO constants, not three. There was a third, `ROSTER_ITEM_KEY`, naming the
|
|
91
|
-
* envelope key of the SINGLE-agent response — and the only thing that ever read
|
|
92
|
-
* it was the PATCH's own reply. With the write gone it had no reader, and a dead
|
|
93
|
-
* constant spelling a retired noun is the shape a future edit reaches for when it
|
|
94
|
-
* wants to write here again. Deleted with the write. The list read below uses
|
|
95
|
-
* {@link ROSTER_LIST_KEY}; nothing in this CLI reads a single roster row.
|
|
96
|
-
*/
|
|
97
|
-
export declare const ROSTER_PATH = "/v1/employees";
|
|
98
|
-
export declare const ROSTER_LIST_KEY = "employees";
|
|
99
|
-
/** True when a reference is already the id the API wants — no lookup needed. */
|
|
100
|
-
export declare function looksLikeId(ref: string): boolean;
|
|
101
|
-
/** `GET /v1/brain`. Exits via handleApiError on a non-2xx, like every other command. */
|
|
102
|
-
export declare function listBrains(action: string): Promise<BrainRow[]>;
|
|
103
|
-
/**
|
|
104
|
-
* Name (or id) -> id. THE HELPFUL-ERROR PATH: naming a brain that does not
|
|
105
|
-
* exist lists the ones that do, in the envelope AND in the recovery steps, so
|
|
106
|
-
* an agent recovers from the response instead of guessing a second time.
|
|
107
|
-
*/
|
|
108
|
-
export declare function resolveBrainId(action: string, ref: string): Promise<string>;
|
|
109
|
-
/** The three ways a command may name a brain. All optional; all mutually exclusive. */
|
|
110
|
-
export interface BrainSelector {
|
|
111
|
-
/** `--brain <name|id>` — the canonical spelling. */
|
|
112
|
-
brain?: string;
|
|
113
|
-
/** `--kb <id>` — the shipped spelling. Same concept, same resolver, unchanged for ids. */
|
|
114
|
-
kb?: string;
|
|
115
|
-
/** `--agent <id|name>` — use whatever brain that agent is bound to. */
|
|
116
|
-
agent?: string;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Resolve a command's brain selection to a `knowledge_base_id`, or `undefined`
|
|
120
|
-
* to mean "say nothing and let the server use the company default" — which is
|
|
121
|
-
* exactly what every one of these commands did before when no flag was passed.
|
|
122
|
-
*
|
|
123
|
-
* THE DEFAULT PATH IS UNTOUCHED: no selector -> `undefined` -> no
|
|
124
|
-
* `knowledge_base_id` in the body -> `resolveKnowledgeBase(companyId)` ->
|
|
125
|
-
* `ensureDefaultKnowledgeBase`. No extra request is made.
|
|
126
|
-
*/
|
|
127
|
-
export declare function selectBrainId(action: string, sel: BrainSelector): Promise<string | undefined>;
|
|
128
|
-
/**
|
|
129
|
-
* The roster, WITHOUT exiting on failure.
|
|
130
|
-
*
|
|
131
|
-
* `naive brain list` reports bindings as an ENRICHMENT of the brain list. The
|
|
132
|
-
* roster lives behind a different primitive, and a deprecated one, so a company
|
|
133
|
-
* that has it switched off must still get its brains
|
|
134
|
-
* listed — with the reason the bindings column is absent, not a silent empty
|
|
135
|
-
* one. An empty list and an unreadable roster are different facts.
|
|
136
|
-
*/
|
|
137
|
-
export declare function tryListAgents(): Promise<{
|
|
138
|
-
ok: true;
|
|
139
|
-
agents: AgentRow[];
|
|
140
|
-
} | {
|
|
141
|
-
ok: false;
|
|
142
|
-
because: string;
|
|
143
|
-
}>;
|
|
144
|
-
/** The roster, exiting on failure — for the commands that cannot proceed without it. */
|
|
145
|
-
export declare function listAgents(action: string): Promise<AgentRow[]>;
|
|
146
|
-
/** The brain an agent is connected to, or undefined. */
|
|
147
|
-
export declare function boundBrainId(agent: AgentRow): string | undefined;
|
|
148
|
-
/**
|
|
149
|
-
* Reference (id | display name | hermes profile slug) -> the roster row. Same
|
|
150
|
-
* helpful-error contract as `resolveBrainId`: an unknown agent lists the known
|
|
151
|
-
* ones.
|
|
152
|
-
*/
|
|
153
|
-
export declare function resolveAgent(action: string, ref: string): Promise<AgentRow>;
|
|
154
|
-
/** `GET /v1/brain/connections` reports one of these per bound agent. */
|
|
155
|
-
export interface BrainConnection {
|
|
156
|
-
agent_id: string;
|
|
157
|
-
agent_name?: string;
|
|
158
|
-
agent_role?: string;
|
|
159
|
-
knowledge_base_id: string;
|
|
160
|
-
knowledge_base_name?: string | null;
|
|
161
|
-
connected_at?: string | null;
|
|
162
|
-
}
|
|
163
|
-
/** What a binding write reports back: the agent as it now stands, and the connection. */
|
|
164
|
-
export interface BindingResult {
|
|
165
|
-
agent: AgentRow;
|
|
166
|
-
/** The connection the API confirmed. `null` on a disconnect — there is none. */
|
|
167
|
-
connection: BrainConnection | null;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Write (or clear) an agent's brain binding, THROUGH THE BRAIN SURFACE.
|
|
171
|
-
*
|
|
172
|
-
* 🔴 NOT THE ROSTER PATCH. See {@link BRAIN_CONNECT_PATH} for the measurement:
|
|
173
|
-
* `PATCH {@link ROSTER_PATH}/:id` reaches `metadata.brain_knowledge_base_id`
|
|
174
|
-
* behind the ROSTER's primitive gate rather than the `brain` gate, so it wrote a
|
|
175
|
-
* binding on a company whose brain primitive was OFF. It also read-modify-wrote the whole
|
|
176
|
-
* metadata bag (lost-update racy), skipped the `brain.agent.connected` ledger
|
|
177
|
-
* event, and never stamped `brain_connected_at` — which is why
|
|
178
|
-
* `GET /v1/brain/connections` reported a `connected_at` belonging to an earlier
|
|
179
|
-
* binding to a different brain.
|
|
180
|
-
*
|
|
181
|
-
* `POST /v1/brain/connect` and `DELETE /v1/brain/connections/:agentId` do all
|
|
182
|
-
* four correctly and are the routes `naive brain list` already reads back. This
|
|
183
|
-
* function no longer sends `metadata` at all: it sends two ids, and the merge
|
|
184
|
-
* happens in one Postgres statement on the server.
|
|
185
|
-
*
|
|
186
|
-
* The returned `agent` carries the metadata as it now stands — the caller's row
|
|
187
|
-
* with the two brain-owned keys applied — so callers that print `metadata` keep
|
|
188
|
-
* printing something true without a second round trip. The authority is
|
|
189
|
-
* `connection`.
|
|
190
|
-
*/
|
|
191
|
-
export declare function setAgentBrain(action: string, agent: AgentRow, knowledgeBaseId: string | null): Promise<BindingResult>;
|
|
192
|
-
/** The `next_steps` every binding command ends with. */
|
|
193
|
-
export declare function bindingNextSteps(brain: BrainRow | undefined, agentId: string): NextStep[];
|
package/dist/lib/brain-select.js
DELETED
|
@@ -1,403 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MULTI-BRAIN ADDRESSING FOR THE CLI.
|
|
3
|
-
*
|
|
4
|
-
* ── the model this reconciles toward ────────────────────────────────────────
|
|
5
|
-
* `brain_knowledge_bases` (packages/db/src/product/brain.ts:50-92) is
|
|
6
|
-
* `(company_id, name, is_default, …)` with a PARTIAL unique index on ONE default
|
|
7
|
-
* per company. The database has always supported N brains per company; so has
|
|
8
|
-
* the API (`GET /v1/brain` lists, `POST /v1/brain` creates, and every content
|
|
9
|
-
* verb takes `knowledge_base_id`). What neither supports is addressing a brain
|
|
10
|
-
* by NAME: `resolveKnowledgeBase` (platform/brain/src/brain.ts:318-330) rejects
|
|
11
|
-
* a non-UUID with `resource_not_found` before it ever looks at the row.
|
|
12
|
-
*
|
|
13
|
-
* So the naming layer lives here, in the client, where it costs no route and no
|
|
14
|
-
* governance decision: `--brain <name|id>` is resolved against `GET /v1/brain`
|
|
15
|
-
* and only ever a UUID reaches the wire.
|
|
16
|
-
*
|
|
17
|
-
* ── what does NOT change ────────────────────────────────────────────────────
|
|
18
|
-
* `--kb <uuid>` is the shipped spelling and stays byte-identical: a value that
|
|
19
|
-
* already looks like a UUID is passed straight through with ZERO extra
|
|
20
|
-
* requests, exactly as before. The list is fetched only for a value that could
|
|
21
|
-
* not have worked before (a non-UUID, which the API refused) or for `--brain`,
|
|
22
|
-
* which is new. See __tests__/brain-multi.test.ts.
|
|
23
|
-
*/
|
|
24
|
-
import { apiRequest, handleApiError } from "../client.js";
|
|
25
|
-
import { agentError } from "../output.js";
|
|
26
|
-
/**
|
|
27
|
-
* THE BINDING KEY, and it is deliberately NOT a new word.
|
|
28
|
-
*
|
|
29
|
-
* `brain_knowledge_base_id` is the exact spelling `POST /v1/runs` already
|
|
30
|
-
* accepts to point a run's reflexive-brain attach at a knowledge base
|
|
31
|
-
* (platform/brain/src/contracts/brain-ops.ts:98, packages/api/src/routes/runs.ts:104).
|
|
32
|
-
* Binding an AGENT to a brain records the value that surface already consumes
|
|
33
|
-
* under the name it already uses, rather than minting a second one.
|
|
34
|
-
*/
|
|
35
|
-
export const BRAIN_BINDING_KEY = "brain_knowledge_base_id";
|
|
36
|
-
/**
|
|
37
|
-
* THE COMPANION KEY, written by the brain surface and by nothing else.
|
|
38
|
-
*
|
|
39
|
-
* `brain_connected_at` is stamped by `connectBrainToAgent`
|
|
40
|
-
* (packages/api/src/routes/brain.ts:1121-1131) in the same atomic jsonb merge as
|
|
41
|
-
* the binding, and removed by `disconnectBrainFromAgent`. It is what
|
|
42
|
-
* `GET /v1/brain/connections` reports as `connected_at`, so a binding written
|
|
43
|
-
* without it reads back as `connected_at: null` — or, worse, carries the
|
|
44
|
-
* timestamp of an EARLIER binding to a DIFFERENT brain, which is what the roster
|
|
45
|
-
* PATCH used to leave behind here.
|
|
46
|
-
*/
|
|
47
|
-
export const BRAIN_CONNECTED_AT_KEY = "brain_connected_at";
|
|
48
|
-
/**
|
|
49
|
-
* THE BRAIN BINDING SURFACE — the routes that carry the brain gate.
|
|
50
|
-
*
|
|
51
|
-
* 🔴 THESE REPLACED A ROSTER PATCH, AND THAT IS THE WHOLE POINT. This CLI used
|
|
52
|
-
* to write the binding with `PATCH {@link ROSTER_PATH}/:id {metadata:{…}}`, which
|
|
53
|
-
* is mounted on the ROSTER's own primitive gate rather than the brain's.
|
|
54
|
-
* `packages/api/src/routes/brain.ts:17-22`
|
|
55
|
-
* says exactly why that must not exist — "a second mount is how a route reaches
|
|
56
|
-
* the same data without the same gate" — and it was measured live on one tenant,
|
|
57
|
-
* one agent, one field: `POST /v1/users/{tu}/brain/connect` → 403
|
|
58
|
-
* `subprocessor_consent_required`, while the roster PATCH of
|
|
59
|
-
* `metadata.brain_knowledge_base_id` on the same agent → 200. The shipped
|
|
60
|
-
* `naive brain connect` was the caller of the ungated door.
|
|
61
|
-
*
|
|
62
|
-
* Three things came back with the move, none of which the roster PATCH did:
|
|
63
|
-
* 1. the `brain` primitive gate, so a company with brain disabled is refused
|
|
64
|
-
* here the way it is refused everywhere else;
|
|
65
|
-
* 2. the `brain.agent.connected` `activity_events` row — the ledger entry that
|
|
66
|
-
* makes a binding auditable;
|
|
67
|
-
* 3. `brain_connected_at`, stamped in the same statement as the binding.
|
|
68
|
-
* And one hazard went away: the roster PATCH read-modify-wrote the whole
|
|
69
|
-
* metadata bag, so two concurrent writers lost each other's keys. `connect` is a
|
|
70
|
-
* single `COALESCE(metadata,'{}') || {…}` merge in Postgres.
|
|
71
|
-
*/
|
|
72
|
-
export const BRAIN_CONNECT_PATH = "/v1/brain/connect";
|
|
73
|
-
export const BRAIN_CONNECTIONS_PATH = "/v1/brain/connections";
|
|
74
|
-
/**
|
|
75
|
-
* THE ROSTER SURFACE, NAMED ONCE — READ-ONLY FROM HERE.
|
|
76
|
-
*
|
|
77
|
-
* This is the only place in the multi-brain code that spells the retired noun,
|
|
78
|
-
* and it is spelled because it is a WIRE NAME: the route and the key of the
|
|
79
|
-
* array it answers with. `ci/vocabulary.test.ts` §3.1 retires the word for
|
|
80
|
-
* every other use — one governed worker identity is an AGENT — so everything
|
|
81
|
-
* downstream of these two constants says `agent`, including the errors a user
|
|
82
|
-
* reads. The surface is also DEPRECATED (its router carries a deprecation id).
|
|
83
|
-
*
|
|
84
|
-
* 🔴 IT IS NOW ONLY EVER READ. Nothing in this CLI PATCHes it: the one write
|
|
85
|
-
* that used to go here — the brain binding — moved to
|
|
86
|
-
* {@link BRAIN_CONNECT_PATH}. `__tests__/brain-multi.test.ts` asserts the roster
|
|
87
|
-
* sees no PATCH, so a future edit cannot quietly put the write back.
|
|
88
|
-
*
|
|
89
|
-
* TWO constants, not three. There was a third, `ROSTER_ITEM_KEY`, naming the
|
|
90
|
-
* envelope key of the SINGLE-agent response — and the only thing that ever read
|
|
91
|
-
* it was the PATCH's own reply. With the write gone it had no reader, and a dead
|
|
92
|
-
* constant spelling a retired noun is the shape a future edit reaches for when it
|
|
93
|
-
* wants to write here again. Deleted with the write. The list read below uses
|
|
94
|
-
* {@link ROSTER_LIST_KEY}; nothing in this CLI reads a single roster row.
|
|
95
|
-
*/
|
|
96
|
-
export const ROSTER_PATH = "/v1/employees";
|
|
97
|
-
export const ROSTER_LIST_KEY = "employees";
|
|
98
|
-
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
99
|
-
/** True when a reference is already the id the API wants — no lookup needed. */
|
|
100
|
-
export function looksLikeId(ref) {
|
|
101
|
-
return UUID_RE.test(ref.trim());
|
|
102
|
-
}
|
|
103
|
-
/** `GET /v1/brain`. Exits via handleApiError on a non-2xx, like every other command. */
|
|
104
|
-
export async function listBrains(action) {
|
|
105
|
-
const resp = await apiRequest("GET", "/v1/brain");
|
|
106
|
-
handleApiError(action, resp);
|
|
107
|
-
const data = resp.data;
|
|
108
|
-
return data.knowledge_bases ?? [];
|
|
109
|
-
}
|
|
110
|
-
/** A one-line rendering of a brain for an error message's recovery steps. */
|
|
111
|
-
function brainLabel(b) {
|
|
112
|
-
return `${b.name}${b.is_default ? " (default)" : ""} — ${b.id}`;
|
|
113
|
-
}
|
|
114
|
-
function shellQuote(arg) {
|
|
115
|
-
return /[\s"'$`\\]/.test(arg) ? `"${arg.replace(/(["\\$`])/g, "\\$1")}"` : arg;
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* THE RECOVERY STEP IS THE USER'S OWN COMMAND, REPAIRED.
|
|
119
|
-
*
|
|
120
|
-
* A recovery step whose `command` is a bare fragment like `--brain "Support"`
|
|
121
|
-
* is not runnable, and the whole point of the envelope is that a model can
|
|
122
|
-
* execute the next step without reconstructing anything. So the failing
|
|
123
|
-
* argument is substituted back into the argv the caller actually typed.
|
|
124
|
-
*/
|
|
125
|
-
function rerunWith(wrong, right) {
|
|
126
|
-
const argv = process.argv.slice(2);
|
|
127
|
-
const i = argv.lastIndexOf(wrong);
|
|
128
|
-
const repaired = i >= 0 ? [...argv.slice(0, i), right, ...argv.slice(i + 1)] : [...argv, right];
|
|
129
|
-
return `naive ${repaired.map(shellQuote).join(" ")}`;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Name (or id) -> id. THE HELPFUL-ERROR PATH: naming a brain that does not
|
|
133
|
-
* exist lists the ones that do, in the envelope AND in the recovery steps, so
|
|
134
|
-
* an agent recovers from the response instead of guessing a second time.
|
|
135
|
-
*/
|
|
136
|
-
export async function resolveBrainId(action, ref) {
|
|
137
|
-
if (looksLikeId(ref))
|
|
138
|
-
return ref.trim();
|
|
139
|
-
const brains = await listBrains(action);
|
|
140
|
-
const wanted = ref.trim().toLowerCase();
|
|
141
|
-
const matches = brains.filter((b) => (b.name ?? "").trim().toLowerCase() === wanted);
|
|
142
|
-
if (matches.length === 1)
|
|
143
|
-
return matches[0].id;
|
|
144
|
-
if (matches.length > 1) {
|
|
145
|
-
// Names are NOT unique in the schema — `brain_knowledge_bases` has a unique
|
|
146
|
-
// index on the DEFAULT flag and on the provider db, never on the name. Two
|
|
147
|
-
// brains may legitimately share one. Refusing with both ids is the only
|
|
148
|
-
// answer that cannot pick the wrong brain on the user's behalf.
|
|
149
|
-
agentError({
|
|
150
|
-
action,
|
|
151
|
-
error: {
|
|
152
|
-
code: "invalid_input",
|
|
153
|
-
message: `${matches.length} knowledge bases are named "${ref}". Name is not unique — pass an id.`,
|
|
154
|
-
available_brains: matches.map((b) => ({ id: b.id, name: b.name, is_default: b.is_default ?? false })),
|
|
155
|
-
},
|
|
156
|
-
recovery_steps: matches.map((b) => ({
|
|
157
|
-
command: rerunWith(ref, b.id),
|
|
158
|
-
description: brainLabel(b),
|
|
159
|
-
})),
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
agentError({
|
|
163
|
-
action,
|
|
164
|
-
error: {
|
|
165
|
-
code: "resource_not_found",
|
|
166
|
-
message: brains.length === 0
|
|
167
|
-
? `No knowledge base named "${ref}" — this company has none yet.`
|
|
168
|
-
: `No knowledge base named "${ref}". This company has ${brains.length}: ${brains.map((b) => b.name).join(", ")}.`,
|
|
169
|
-
hint: "Brains are addressed by name or id. `naive brain list` shows both.",
|
|
170
|
-
available_brains: brains.map((b) => ({ id: b.id, name: b.name, is_default: b.is_default ?? false })),
|
|
171
|
-
},
|
|
172
|
-
recovery_steps: [
|
|
173
|
-
{ command: "naive brain list", description: "List this company's knowledge bases" },
|
|
174
|
-
...brains.slice(0, 5).map((b) => ({ command: rerunWith(ref, b.name), description: brainLabel(b) })),
|
|
175
|
-
{ command: `naive brain create "${ref}"`, description: "Create a knowledge base with this name" },
|
|
176
|
-
],
|
|
177
|
-
});
|
|
178
|
-
throw new Error("unreachable"); // agentError exits; this keeps the return type honest.
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Resolve a command's brain selection to a `knowledge_base_id`, or `undefined`
|
|
182
|
-
* to mean "say nothing and let the server use the company default" — which is
|
|
183
|
-
* exactly what every one of these commands did before when no flag was passed.
|
|
184
|
-
*
|
|
185
|
-
* THE DEFAULT PATH IS UNTOUCHED: no selector -> `undefined` -> no
|
|
186
|
-
* `knowledge_base_id` in the body -> `resolveKnowledgeBase(companyId)` ->
|
|
187
|
-
* `ensureDefaultKnowledgeBase`. No extra request is made.
|
|
188
|
-
*/
|
|
189
|
-
export async function selectBrainId(action, sel) {
|
|
190
|
-
const given = [
|
|
191
|
-
sel.brain !== undefined && "--brain",
|
|
192
|
-
sel.kb !== undefined && "--kb",
|
|
193
|
-
sel.agent !== undefined && "--agent",
|
|
194
|
-
].filter(Boolean);
|
|
195
|
-
if (given.length > 1) {
|
|
196
|
-
agentError({
|
|
197
|
-
action,
|
|
198
|
-
error: {
|
|
199
|
-
code: "invalid_input",
|
|
200
|
-
message: `A call reads ONE brain. Pass one of ${given.join(", ")}, not ${given.length}.`,
|
|
201
|
-
hint: "`--kb` is the id-only spelling of `--brain`; `--agent` means 'the brain that agent is bound to'.",
|
|
202
|
-
},
|
|
203
|
-
recovery_steps: [
|
|
204
|
-
{ command: "naive brain list", description: "See the brains and what is bound to each" },
|
|
205
|
-
],
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
if (sel.brain !== undefined)
|
|
209
|
-
return resolveBrainId(action, sel.brain);
|
|
210
|
-
if (sel.kb !== undefined)
|
|
211
|
-
return resolveBrainId(action, sel.kb);
|
|
212
|
-
if (sel.agent !== undefined) {
|
|
213
|
-
const agent = await resolveAgent(action, sel.agent);
|
|
214
|
-
const bound = boundBrainId(agent);
|
|
215
|
-
if (!bound) {
|
|
216
|
-
agentError({
|
|
217
|
-
action,
|
|
218
|
-
error: {
|
|
219
|
-
code: "resource_not_found",
|
|
220
|
-
message: `Agent "${agent.name}" is not connected to a brain, so there is no brain to read from.`,
|
|
221
|
-
agent: { id: agent.id, name: agent.name },
|
|
222
|
-
},
|
|
223
|
-
recovery_steps: [
|
|
224
|
-
{ command: `naive brain connect <brain> --agent ${agent.id}`, description: "Connect this agent to a brain" },
|
|
225
|
-
{ command: "naive brain list", description: "See the brains and what is bound to each" },
|
|
226
|
-
],
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
// A BINDING CAN OUTLIVE ITS BRAIN. `DELETE /v1/brain/:id` cannot reach into
|
|
230
|
-
// the roster, so deleting a knowledge base leaves every agent connected to
|
|
231
|
-
// it pointing at a row that is gone. Sending the stale id would come back as
|
|
232
|
-
// a bare `Knowledge base not found` naming an id the caller never typed;
|
|
233
|
-
// resolving it here costs one GET on a NEW flag and names the actual fault.
|
|
234
|
-
const brains = await listBrains(action);
|
|
235
|
-
if (!brains.some((b) => b.id === bound)) {
|
|
236
|
-
agentError({
|
|
237
|
-
action,
|
|
238
|
-
error: {
|
|
239
|
-
code: "resource_not_found",
|
|
240
|
-
message: `Agent "${agent.name}" is connected to knowledge base ${bound}, which no longer exists.`,
|
|
241
|
-
hint: "The brain was deleted after the agent was connected to it. Connect the agent to a brain that exists.",
|
|
242
|
-
agent: { id: agent.id, name: agent.name },
|
|
243
|
-
knowledge_base_id: bound,
|
|
244
|
-
available_brains: brains.map((b) => ({ id: b.id, name: b.name, is_default: b.is_default ?? false })),
|
|
245
|
-
},
|
|
246
|
-
recovery_steps: [
|
|
247
|
-
...brains.slice(0, 5).map((b) => ({
|
|
248
|
-
command: `naive brain connect "${b.name}" --agent ${agent.id}`,
|
|
249
|
-
description: brainLabel(b),
|
|
250
|
-
})),
|
|
251
|
-
{ command: `naive brain disconnect --agent ${agent.id}`, description: "Clear the stale binding and fall back to the company default" },
|
|
252
|
-
],
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
return bound;
|
|
256
|
-
}
|
|
257
|
-
return undefined;
|
|
258
|
-
}
|
|
259
|
-
/* ══════════════════════════════════════════════════════════════════════════
|
|
260
|
-
* THE AGENT SIDE
|
|
261
|
-
* ════════════════════════════════════════════════════════════════════════ */
|
|
262
|
-
/**
|
|
263
|
-
* The roster, WITHOUT exiting on failure.
|
|
264
|
-
*
|
|
265
|
-
* `naive brain list` reports bindings as an ENRICHMENT of the brain list. The
|
|
266
|
-
* roster lives behind a different primitive, and a deprecated one, so a company
|
|
267
|
-
* that has it switched off must still get its brains
|
|
268
|
-
* listed — with the reason the bindings column is absent, not a silent empty
|
|
269
|
-
* one. An empty list and an unreadable roster are different facts.
|
|
270
|
-
*/
|
|
271
|
-
export async function tryListAgents() {
|
|
272
|
-
const resp = await apiRequest("GET", ROSTER_PATH);
|
|
273
|
-
if (resp.status >= 400) {
|
|
274
|
-
const err = resp.data?.error;
|
|
275
|
-
return {
|
|
276
|
-
ok: false,
|
|
277
|
-
because: `the agent roster could not be read (GET ${ROSTER_PATH} -> ${resp.status}${err?.code ? ` ${err.code}` : ""}${err?.message ? `: ${err.message}` : ""})`,
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
const data = (resp.data ?? {});
|
|
281
|
-
return { ok: true, agents: data[ROSTER_LIST_KEY] ?? [] };
|
|
282
|
-
}
|
|
283
|
-
/** The roster, exiting on failure — for the commands that cannot proceed without it. */
|
|
284
|
-
export async function listAgents(action) {
|
|
285
|
-
const roster = await tryListAgents();
|
|
286
|
-
if (!roster.ok) {
|
|
287
|
-
agentError({
|
|
288
|
-
action,
|
|
289
|
-
error: { code: "upstream_error", message: `Cannot resolve an agent because ${roster.because}.` },
|
|
290
|
-
recovery_steps: [{ command: "naive brain list", description: "See the brains and what is bound to each" }],
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
return roster.agents;
|
|
294
|
-
}
|
|
295
|
-
/** The brain an agent is connected to, or undefined. */
|
|
296
|
-
export function boundBrainId(agent) {
|
|
297
|
-
const raw = (agent.metadata ?? {})[BRAIN_BINDING_KEY];
|
|
298
|
-
return typeof raw === "string" && raw.length > 0 ? raw : undefined;
|
|
299
|
-
}
|
|
300
|
-
function agentLabel(a) {
|
|
301
|
-
return `${a.name}${a.role ? ` (${a.role})` : ""} — ${a.id}`;
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* Reference (id | display name | hermes profile slug) -> the roster row. Same
|
|
305
|
-
* helpful-error contract as `resolveBrainId`: an unknown agent lists the known
|
|
306
|
-
* ones.
|
|
307
|
-
*/
|
|
308
|
-
export async function resolveAgent(action, ref) {
|
|
309
|
-
const agents = await listAgents(action);
|
|
310
|
-
const wanted = ref.trim().toLowerCase();
|
|
311
|
-
const byId = agents.find((a) => a.id === ref.trim());
|
|
312
|
-
if (byId)
|
|
313
|
-
return byId;
|
|
314
|
-
const matches = agents.filter((a) => (a.name ?? "").trim().toLowerCase() === wanted ||
|
|
315
|
-
(a.hermesProfileName ?? "").trim().toLowerCase() === wanted);
|
|
316
|
-
if (matches.length === 1)
|
|
317
|
-
return matches[0];
|
|
318
|
-
if (matches.length > 1) {
|
|
319
|
-
agentError({
|
|
320
|
-
action,
|
|
321
|
-
error: {
|
|
322
|
-
code: "invalid_input",
|
|
323
|
-
message: `${matches.length} agents answer to "${ref}". Pass an id.`,
|
|
324
|
-
available_agents: matches.map((a) => ({ id: a.id, name: a.name })),
|
|
325
|
-
},
|
|
326
|
-
recovery_steps: matches.map((a) => ({ command: rerunWith(ref, a.id), description: agentLabel(a) })),
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
agentError({
|
|
330
|
-
action,
|
|
331
|
-
error: {
|
|
332
|
-
code: "resource_not_found",
|
|
333
|
-
message: agents.length === 0
|
|
334
|
-
? `No agent named "${ref}" — this company's roster is empty.`
|
|
335
|
-
: `No agent named "${ref}". This company has ${agents.length}: ${agents.map((a) => a.name).join(", ")}.`,
|
|
336
|
-
hint: "An agent is addressed by id, display name, or runtime profile name. All three are listed below.",
|
|
337
|
-
available_agents: agents.map((a) => ({ id: a.id, name: a.name })),
|
|
338
|
-
},
|
|
339
|
-
recovery_steps: [
|
|
340
|
-
...agents.slice(0, 5).map((a) => ({ command: rerunWith(ref, a.id), description: agentLabel(a) })),
|
|
341
|
-
],
|
|
342
|
-
});
|
|
343
|
-
throw new Error("unreachable");
|
|
344
|
-
}
|
|
345
|
-
/**
|
|
346
|
-
* Write (or clear) an agent's brain binding, THROUGH THE BRAIN SURFACE.
|
|
347
|
-
*
|
|
348
|
-
* 🔴 NOT THE ROSTER PATCH. See {@link BRAIN_CONNECT_PATH} for the measurement:
|
|
349
|
-
* `PATCH {@link ROSTER_PATH}/:id` reaches `metadata.brain_knowledge_base_id`
|
|
350
|
-
* behind the ROSTER's primitive gate rather than the `brain` gate, so it wrote a
|
|
351
|
-
* binding on a company whose brain primitive was OFF. It also read-modify-wrote the whole
|
|
352
|
-
* metadata bag (lost-update racy), skipped the `brain.agent.connected` ledger
|
|
353
|
-
* event, and never stamped `brain_connected_at` — which is why
|
|
354
|
-
* `GET /v1/brain/connections` reported a `connected_at` belonging to an earlier
|
|
355
|
-
* binding to a different brain.
|
|
356
|
-
*
|
|
357
|
-
* `POST /v1/brain/connect` and `DELETE /v1/brain/connections/:agentId` do all
|
|
358
|
-
* four correctly and are the routes `naive brain list` already reads back. This
|
|
359
|
-
* function no longer sends `metadata` at all: it sends two ids, and the merge
|
|
360
|
-
* happens in one Postgres statement on the server.
|
|
361
|
-
*
|
|
362
|
-
* The returned `agent` carries the metadata as it now stands — the caller's row
|
|
363
|
-
* with the two brain-owned keys applied — so callers that print `metadata` keep
|
|
364
|
-
* printing something true without a second round trip. The authority is
|
|
365
|
-
* `connection`.
|
|
366
|
-
*/
|
|
367
|
-
export async function setAgentBrain(action, agent, knowledgeBaseId) {
|
|
368
|
-
const before = { ...(agent.metadata ?? {}) };
|
|
369
|
-
if (knowledgeBaseId === null) {
|
|
370
|
-
const resp = await apiRequest("DELETE", `${BRAIN_CONNECTIONS_PATH}/${encodeURIComponent(agent.id)}`);
|
|
371
|
-
handleApiError(action, resp);
|
|
372
|
-
delete before[BRAIN_BINDING_KEY];
|
|
373
|
-
delete before[BRAIN_CONNECTED_AT_KEY];
|
|
374
|
-
return { agent: { ...agent, metadata: before }, connection: null };
|
|
375
|
-
}
|
|
376
|
-
const resp = await apiRequest("POST", BRAIN_CONNECT_PATH, {
|
|
377
|
-
agent_id: agent.id,
|
|
378
|
-
knowledge_base_id: knowledgeBaseId,
|
|
379
|
-
});
|
|
380
|
-
handleApiError(action, resp);
|
|
381
|
-
const connection = (resp.data ?? {});
|
|
382
|
-
before[BRAIN_BINDING_KEY] = knowledgeBaseId;
|
|
383
|
-
// Only when the route said so. A CLI that invented a timestamp the server did
|
|
384
|
-
// not write would reintroduce, in the client, the exact drift the roster PATCH
|
|
385
|
-
// caused on the server.
|
|
386
|
-
if (typeof connection.connected_at === "string") {
|
|
387
|
-
before[BRAIN_CONNECTED_AT_KEY] = connection.connected_at;
|
|
388
|
-
}
|
|
389
|
-
return { agent: { ...agent, metadata: before }, connection };
|
|
390
|
-
}
|
|
391
|
-
/** The `next_steps` every binding command ends with. */
|
|
392
|
-
export function bindingNextSteps(brain, agentId) {
|
|
393
|
-
return [
|
|
394
|
-
{ command: "naive brain list", description: "See every brain and what is bound to each" },
|
|
395
|
-
{
|
|
396
|
-
command: `naive brain attach "<goal>" --agent ${agentId}`,
|
|
397
|
-
description: brain
|
|
398
|
-
? `Read a capsule from "${brain.name}" as this agent`
|
|
399
|
-
: "Read a capsule from this agent's brain",
|
|
400
|
-
},
|
|
401
|
-
];
|
|
402
|
-
}
|
|
403
|
-
//# sourceMappingURL=brain-select.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"brain-select.js","sourceRoot":"","sources":["../../src/lib/brain-select.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAiB,MAAM,cAAc,CAAC;AA6BzD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,yBAAyB,CAAC;AAE3D;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AACtD,MAAM,CAAC,MAAM,sBAAsB,GAAG,uBAAuB,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|
-
import { type Command } from "commander";
|
|
2
|
-
export declare function isTenantUserRef(value: string): boolean;
|
|
3
|
-
/**
|
|
4
|
-
* Fail-closed for malformed `--user` before any HTTP call.
|
|
5
|
-
* Mirrors API subject-resolver: non-uuid ids never match → not_found (never a DB 500 / rate-limit burn).
|
|
6
|
-
*/
|
|
7
|
-
export declare function assertTenantUserRef(user: string | undefined): void;
|
|
8
|
-
export declare function configureStructuredValidation(command: Command): void;
|
|
9
|
-
export declare function parseIntegerOption(value: string, name: string, min: number, max?: number): number;
|
|
10
|
-
export declare function commandAction(args: readonly string[]): string;
|
|
11
|
-
export declare function cleanCommanderMessage(message: string): string;
|
|
12
|
-
export declare function helpCommand(args: readonly string[]): string;
|