@prudai/cli 0.0.0-stage → 0.1.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.
@@ -0,0 +1,54 @@
1
+ import type { Environment } from './config';
2
+ /**
3
+ * Keycloak (realm prudai) is the only identity of the CLI: the device flow (RFC 8628)
4
+ * with the public client `prudai-cli`, and a refresh token that stays on this machine. The CLI never
5
+ * exchanges tokens itself (Keycloak 26.4 does not let public clients do that); it asks the broker, see exchange.ts.
6
+ */
7
+ export declare const CLIENT_ID = "prudai-cli";
8
+ export declare const DEVICE_SCOPE = "offline_access";
9
+ export interface Endpoints {
10
+ issuer: string;
11
+ device: string;
12
+ token: string;
13
+ revoke: string;
14
+ }
15
+ /** The issuer receives the refresh token, so it must be a trusted origin and a plain realm URL. */
16
+ export declare function endpoints(issuer: string, env: Environment): Endpoints;
17
+ export interface Claims {
18
+ sub?: string;
19
+ exp?: number;
20
+ iat?: number;
21
+ aud?: string[];
22
+ azp?: string;
23
+ scope?: string;
24
+ name?: string;
25
+ email?: string;
26
+ username?: string;
27
+ organizationId?: string;
28
+ organizationName?: string;
29
+ }
30
+ /** Reads a JWT for display and expiry only. The CLI does not verify signatures; every server does. */
31
+ export declare function readClaims(token: string): Claims | undefined;
32
+ export interface Tokens {
33
+ accessToken: string;
34
+ refreshToken: string;
35
+ accessExpiresAt: number;
36
+ claims: Claims;
37
+ }
38
+ export interface DeviceOptions {
39
+ fetch: typeof fetch;
40
+ env: Environment;
41
+ stderr: (s: string) => void;
42
+ now: () => number;
43
+ sleep: (ms: number) => Promise<void>;
44
+ openBrowser?: (url: string) => void;
45
+ }
46
+ /**
47
+ * Device flow. The person approves in the browser on login.prudai.com (their own Keycloak login, with MFA where required);
48
+ * the CLI only polls. Returns the tokens; storing them is the caller's job.
49
+ */
50
+ export declare function deviceLogin(issuer: string, options: DeviceOptions): Promise<Tokens>;
51
+ /** Refresh. `invalid_grant` means the session is gone (logged out, revoked, idle too long): the person logs in again. */
52
+ export declare function refreshLogin(issuer: string, refreshToken: string, options: Pick<DeviceOptions, 'fetch' | 'env' | 'now'>): Promise<Tokens>;
53
+ /** Ends the offline session at Keycloak. Returns the HTTP status (200 = revoked; 4xx = Keycloak no longer knew the token). */
54
+ export declare function revokeLogin(issuer: string, refreshToken: string, options: Pick<DeviceOptions, 'fetch' | 'env'>): Promise<number>;
@@ -0,0 +1,111 @@
1
+ /**
2
+ * list/get/create/update/replace/delete are CRUD on a collection; restore and action are task
3
+ * actions (POST on a non-collection path); read is a GET that is neither list nor get.
4
+ */
5
+ export type CommandKind = "list" | "get" | "create" | "update" | "replace" | "delete" | "restore" | "action" | "read";
6
+ /** Kept for library callers of round 1; prefer CommandKind. */
7
+ export type CommandAction = CommandKind;
8
+ export interface GeneratedParameter {
9
+ name: string;
10
+ in: string;
11
+ required?: boolean;
12
+ schema?: unknown;
13
+ [key: string]: unknown;
14
+ }
15
+ export interface GeneratedCommand {
16
+ product: string;
17
+ /** Command words after the product, e.g. "risks history" or "context". */
18
+ name: string;
19
+ words: string[];
20
+ /** All words but the last (or the only word); with `action` the round-1 view of `name`. */
21
+ resource: string;
22
+ action: string;
23
+ kind: CommandKind;
24
+ method: string;
25
+ /** Request path including the server base path, e.g. /v1/models. */
26
+ path: string;
27
+ operationId: string;
28
+ summary: string;
29
+ approval: string;
30
+ parameters: GeneratedParameter[];
31
+ /** Positional arguments in order: path parameters, then required query parameters. */
32
+ positionals: string[];
33
+ /** True when the CLI adds an Idempotency-Key: every write (POST/PUT/PATCH/DELETE). */
34
+ idempotencyKey: boolean;
35
+ /** True when the spec declares the Idempotency-Key header, i.e. promises replay protection. */
36
+ idempotencyDeclared: boolean;
37
+ /**
38
+ * True when a write can be dry-run: the operation declares a `dryRun` query parameter, or the
39
+ * operation or document sets `x-prudai-dry-run: true`. Other writes are never sent by default.
40
+ */
41
+ dryRun: boolean;
42
+ /**
43
+ * A POST that only reads (the question is in the body, nothing is stored or changed). Set by the platform
44
+ * binding for query/search commands: no dry-run gate, no Idempotency-Key, and a JSON body is allowed.
45
+ */
46
+ readsViaPost?: boolean;
47
+ inputSchema?: unknown;
48
+ bodyRequired?: boolean;
49
+ /** The request body is multipart/form-data (one file part), not JSON: only the commands that take a file can send it. */
50
+ multipart?: boolean;
51
+ scopes?: string[];
52
+ /** Where the approval level came from: the spec, or (lenient catalogue mode only) the verb default. */
53
+ approvalSource?: "spec" | "default";
54
+ description?: string;
55
+ tags?: string[];
56
+ /** x-prudai-status of the operation (e.g. implemented, planned), when the spec states one. */
57
+ status?: string;
58
+ /** What a call costs: an explicit x-prudai-cost/x-prudai-credits, or "credits (metered)" when its scope object spends credits. */
59
+ cost?: string;
60
+ /** Documented response statuses with their description. */
61
+ responses?: Array<{
62
+ status: string;
63
+ description: string;
64
+ }>;
65
+ deprecated?: boolean;
66
+ /** Command line when it differs from `prudai <product> <name>` (platform commands such as `prudai keys create`). */
67
+ commandLine?: string;
68
+ /** False when the command exists but the platform does not serve its route yet. */
69
+ available?: boolean;
70
+ }
71
+ export interface GenerateOptions {
72
+ /**
73
+ * Catalogue mode: a write without x-prudai-approval gets the standard verb default
74
+ * (POST/PUT/PATCH confirm, DELETE review) and approvalSource "default", instead of failing
75
+ * the whole product. Writes stay dry-run-gated either way.
76
+ */
77
+ lenientApproval?: boolean;
78
+ }
79
+ /** Base path of the first server, e.g. "/v1" for https://api.prudai.com/v1; "" when absent. */
80
+ export declare function serverBasePath(spec: unknown): string;
81
+ /** Origin of the first absolute server URL, if any. Token delivery still needs a trusted origin. */
82
+ export declare function serverOrigin(spec: unknown): string | undefined;
83
+ /**
84
+ * Build command descriptors from an OpenAPI 3.1 spec. Names follow the path, never the
85
+ * operationId: CRUD on collections (`risks list|get|create|update|delete`), other GETs and
86
+ * task actions as first and last path word (`risks history`, `audit summary`, `control-years close`),
87
+ * one word for single-segment reads (`context`, `search`). If short names collide, the
88
+ * colliding commands use all path words. `x-prudai-cli` pins a name.
89
+ */
90
+ export declare function generateCommands(product: string, spec: unknown, options?: GenerateOptions): GeneratedCommand[];
91
+ /** The largest specification (file or download) the CLI parses; the biggest bundled one is about 2.5 MB. */
92
+ export declare const MAX_SPEC_BYTES: number;
93
+ /** Local JSON/YAML file or configurable registry specification URL. No credentials in URLs. */
94
+ export declare function loadSpec(source: string, fetchImpl?: typeof fetch): Promise<unknown>;
95
+ export interface OperationArguments {
96
+ id?: string;
97
+ params?: Record<string, string>;
98
+ query?: Record<string, unknown>;
99
+ headers?: Record<string, string>;
100
+ body?: unknown;
101
+ dryRun?: boolean;
102
+ idempotencyKey?: string;
103
+ }
104
+ /** Credentials belong to config/env; routing and transport headers remain controlled by the client. */
105
+ export declare function isSafeHeaderName(name: string): boolean;
106
+ export declare function buildOperationRequest(command: GeneratedCommand, args?: OperationArguments): {
107
+ method: string;
108
+ path: string;
109
+ body?: unknown;
110
+ headers: Record<string, string>;
111
+ };
@@ -0,0 +1,27 @@
1
+ import type { ProductCatalog } from "./catalog";
2
+ import { CliError, type Envelope } from "./core";
3
+ /** The CLI's own answers use the same six-field /v1 envelope as the products, so an agent parses one shape. */
4
+ export declare function localEnvelope(data: unknown, parts?: {
5
+ context?: Record<string, unknown>;
6
+ completeness?: Record<string, unknown>;
7
+ notIncluded?: unknown[];
8
+ provenance?: Record<string, unknown>;
9
+ next?: unknown[];
10
+ }): Envelope;
11
+ export type Emit = (value: unknown, human?: string) => void;
12
+ /** A failure that carries structured details next to the message (candidates, the planned route, …). */
13
+ export declare class DetailedCliError extends CliError {
14
+ readonly details: Record<string, unknown>;
15
+ constructor(message: string, code: string, details: Record<string, unknown>, exitCode?: 1 | 2);
16
+ }
17
+ /** A capability the platform has decided on but does not serve yet. Never a fake success. */
18
+ export declare class NotAvailableError extends DetailedCliError {
19
+ constructor(message: string, details: Record<string, unknown>);
20
+ }
21
+ /** The product has no commands for this person right now, for a reason other than "it has none": say which. */
22
+ export declare function throwIfUnusable(catalog: ProductCatalog): void;
23
+ /** A known product without any spec (not live yet, nothing bundled): every command of it is not available. */
24
+ export declare function productNotAvailable(catalog: ProductCatalog): NotAvailableError;
25
+ /** Failure document: stable `error` code, `message`, `exitCode`, plus details where they help the next step. */
26
+ export declare function errorDocument(error: CliError): Record<string, unknown>;
27
+ export declare function isEnvelopeLike(body: unknown): boolean;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Parity rule: nothing in the console or the API that you cannot do via
3
+ * the CLI. Every operation in a product spec is a generated command; the few that are not, and
4
+ * the console capabilities that map onto hand-made commands, are listed here with a reason.
5
+ * tests/agent.test.ts enforces both directions; docs/parity.md is the generated, human-readable copy.
6
+ */
7
+ /** /v1/auth/* is never a generated command. The CLI logs in with the Keycloak device flow (`prudai auth login`); the platform's own device-login routes are not used. */
8
+ export declare const AUTH_OPERATIONS: Record<string, string>;
9
+ export interface ParityException {
10
+ what: string;
11
+ reason: string;
12
+ instead: string;
13
+ }
14
+ export declare const EXCEPTIONS: ParityException[];
15
+ /** Console capabilities (the Prudai Console) and the command that gives parity. */
16
+ export declare const CONSOLE_CAPABILITIES: Record<string, string>;
@@ -0,0 +1,110 @@
1
+ import { type ProductCatalog } from "./catalog";
2
+ import type { RunContext } from "./context";
3
+ import { type ExitCode } from "./core";
4
+ import type { GeneratedCommand } from "./openapi";
5
+ import { NotAvailableError } from "./output";
6
+ import { type ScopeCatalog } from "./scopes";
7
+ export type PlatformStatus = "contract" | "planned" | "proposed";
8
+ /** "file" = the one multipart file part: `--file <path>` or the last positional. */
9
+ export interface BodyFlag {
10
+ flag: string;
11
+ field: string;
12
+ kind: "string" | "csv" | "number" | "credits-mcr" | "file" | "kb-selection"; /** Other spellings of the same flag. */
13
+ aliases?: string[];
14
+ }
15
+ /**
16
+ * The `knowledge_bases` request field: "all" (the server default), "none", or 1 to 50 knowledge base
17
+ * ids. Checked here so a typo never travels; the server stays the authority on whether an id exists in your organisation.
18
+ */
19
+ export declare function knowledgeBaseSelection(raw: string, flag?: string): "all" | "none" | string[];
20
+ /**
21
+ * The same rule for a `knowledge_bases` value that arrives through --data (a string, or a JSON array
22
+ * of ids), so the claim "a typo never travels" holds for every way of giving it.
23
+ */
24
+ export declare function checkKnowledgeBaseField(value: unknown): void;
25
+ export interface PlatformOp {
26
+ /** Console capability this command gives parity for. */
27
+ capability: string;
28
+ words: string[];
29
+ method: string;
30
+ path: string;
31
+ operationIds: string[];
32
+ scope: string;
33
+ approval: "none" | "confirm" | "review" | "forbidden_for_agents";
34
+ summary: string;
35
+ positionals?: string[];
36
+ body?: BodyFlag[];
37
+ query?: string[];
38
+ /** contract = in the platform's published contract; planned = decided, not built; proposed = route proposed, not agreed yet. */
39
+ status: PlatformStatus;
40
+ /** The current account dashboard already offers this, so a person can do it there today. */
41
+ consoleToday?: boolean;
42
+ /** Changes what the organisation pays: a person approves and pays, never an agent. */
43
+ costsMoney?: boolean;
44
+ /** Extra local check before anything is sent. */
45
+ check?: "scopes";
46
+ /** A POST that only reads: it runs without --no-dry-run --yes and without an Idempotency-Key. */
47
+ readsViaPost?: boolean;
48
+ /** When the command is typed without its positionals, this other command (capability) runs instead: `kb query` = one knowledge base, without an id = across several. */
49
+ withoutPositionalsUse?: string;
50
+ /** Other paths the same operation may have in the platform spec. */
51
+ altPaths?: string[];
52
+ /** The {id} in the path is the organisation: --org <id>, else the organisation of the current login. */
53
+ orgScoped?: boolean;
54
+ /**
55
+ * The call works in a project. "arg": the first positional is the project, a UUID or an exact name (any case),
56
+ * resolved to its id first. "memo": the project is --project, else PRUDAI_MEMOS_PROJECT, else "Transcribe".
57
+ */
58
+ project?: "arg" | "memo";
59
+ /** The answer is not an envelope to print: "bytes" = the file, written to --out (required); "text" = plain text on stdout, or --out. */
60
+ output?: "bytes" | "text";
61
+ /** The final removal (purge): a dry run by default, and the output says it cannot be undone. A delete to the trash is not this. */
62
+ irreversible?: boolean;
63
+ /** The server accepts this with HTTP 202 and the document in the answer (restore: processed again in the background). */
64
+ queued?: boolean;
65
+ /** The step that undoes or follows this one, shown in `next` and in the dry run text. */
66
+ after?: {
67
+ action: string;
68
+ why: string;
69
+ };
70
+ /** Flags the CLI reads itself (not request fields). With `query`, a given flag sets that query parameter to true. */
71
+ flags?: Array<{
72
+ flag: string;
73
+ note: string;
74
+ query?: string;
75
+ }>;
76
+ /** Handled by the CLI itself instead of one request. */
77
+ custom?: "memos-list";
78
+ /** Where a person can do this today, when it is not the account dashboard. */
79
+ today?: string;
80
+ }
81
+ export declare const PLATFORM_OPS: PlatformOp[];
82
+ /** Groups whose first word routes here. */
83
+ export declare const PLATFORM_GROUPS: Set<string>;
84
+ /** The spec operation behind a platform command, if the platform spec has it. */
85
+ export declare function bindOperation(op: PlatformOp, catalog: ProductCatalog): GeneratedCommand | undefined;
86
+ /**
87
+ * The platform commands as a catalogue, so ops search, ops list and describe show them next to
88
+ * the product operations: bound ones with the spec's details, the rest marked not available yet.
89
+ */
90
+ export declare function platformCatalog(platform: ProductCatalog): ProductCatalog;
91
+ /** Platform spec operations that a platform command already covers (shown once, under the platform command). */
92
+ export declare function coveredByPlatform(platform: ProductCatalog): Set<string>;
93
+ export declare function matchPlatform(words: string[]): {
94
+ op: PlatformOp;
95
+ positionals: string[];
96
+ } | undefined;
97
+ export declare function notAvailable(op: PlatformOp, extra?: Record<string, unknown>, typedAs?: string): NotAvailableError;
98
+ /**
99
+ * Scope catalogue: GET /v1/scopes when the platform serves it. Nothing is bundled (the token service
100
+ * is not live yet), so without it the CLI checks scope shape only and leaves the rest to the server.
101
+ */
102
+ export declare function scopeCatalog(ctx: RunContext, platform: ProductCatalog): Promise<{
103
+ catalog?: ScopeCatalog;
104
+ source: string;
105
+ bundles?: Record<string, string[]>;
106
+ }>;
107
+ export declare function platformCommand(words: string[], ctx: RunContext): Promise<ExitCode>;
108
+ /** `prudai mcp`: where the MCP servers are, how to connect, and (with --check) whether they answer. */
109
+ export declare function mcpCommand(words: string[], ctx: RunContext): Promise<ExitCode>;
110
+ export declare function platformHelp(): string[];
@@ -0,0 +1,31 @@
1
+ /**
2
+ * The Prudai products the central CLI knows. A product supplies only its /v1 API and its
3
+ * OpenAPI spec; everything else is shared here.
4
+ * Origins are defaults; profile, environment and flags can override them (trust rules apply).
5
+ * Other commands can be added as extensions: an executable `prudai-<name>` on PATH handles
6
+ * `prudai <name> …` (like git).
7
+ */
8
+ export interface ProductInfo {
9
+ /** Command word: `prudai <product> …`. */
10
+ product: string;
11
+ aliases: string[];
12
+ title: string;
13
+ /** Scope prefixes this API serves (`<product>:<object>:<verb>`). */
14
+ scopeProducts: string[];
15
+ /** Default API origin. */
16
+ origin: string;
17
+ /** Path of the live spec on the origin; fetched without credentials. */
18
+ liveSpecPath?: string;
19
+ /** Bundled fallback in specs/ (refreshed with scripts/sync-specs.ts). Only for an API that is live in production. */
20
+ bundled?: string;
21
+ /** Product approvals API (pending HITL requests), relative to the origin. */
22
+ approvalsPath?: string;
23
+ /** Remote MCP endpoint of the product, when it has one. */
24
+ mcpUrl?: string;
25
+ }
26
+ export declare const PRODUCTS: ProductInfo[];
27
+ /** The platform API (keys, account, usage, credits) lives on the LEO/platform origin. */
28
+ export declare const PLATFORM_PRODUCT = "leo";
29
+ export declare const MCP_GATEWAY = "https://mcp.prudai.com";
30
+ export declare const CONSOLE_URL = "https://account.prudai.com";
31
+ export declare function findProduct(word: string): ProductInfo | undefined;
@@ -0,0 +1,36 @@
1
+ import type { RunContext } from "./context";
2
+ import { type ExitCode } from "./core";
3
+ import { type GeneratedCommand } from "./openapi";
4
+ export declare const MEMOS_DEFAULT_PROJECT = "Transcribe";
5
+ /** What `memos list` shows: recordings and transcripts. */
6
+ export declare const MEMO_KINDS: Set<string>;
7
+ export interface ApiAccess {
8
+ ctx: RunContext;
9
+ apiUrl: string;
10
+ token: string;
11
+ }
12
+ export interface ProjectRef {
13
+ id: string;
14
+ name: string | null;
15
+ }
16
+ export interface ProjectCommands {
17
+ list?: GeneratedCommand;
18
+ get?: GeneratedCommand;
19
+ }
20
+ /** The origin and credential of the platform, checked like every command does (trusted origin before a token is attached). */
21
+ export declare function apiAccess(ctx: RunContext, product: string, origin: string | undefined): Promise<ApiAccess>;
22
+ /**
23
+ * A project reference is a UUID or the exact name (any case). A UUID is used as it is (`verify` also asks
24
+ * for the project, to show its name and to fail early on an unknown one). A name must match exactly one
25
+ * project of the ones you can see; 0 or more than 1 is a refusal with the candidates, before anything is sent.
26
+ */
27
+ export declare function resolveProject(access: ApiAccess, reference: string, commands: ProjectCommands, options?: {
28
+ verify?: boolean;
29
+ }): Promise<ProjectRef>;
30
+ /** The project a memo command works in: --project, else PRUDAI_MEMOS_PROJECT, else "Transcribe". */
31
+ export declare function memoProjectReference(ctx: RunContext): string;
32
+ /**
33
+ * `memos list`: the documents of the project that are recordings or transcripts. The API has no kind filter,
34
+ * so the CLI reads the pages and filters; `completeness` says honestly whether it saw them all.
35
+ */
36
+ export declare function listMemos(access: ApiAccess, command: GeneratedCommand, project: ProjectRef, ctx: RunContext): Promise<ExitCode>;
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Scope rules of the token service and the attenuation rules for keys that create keys. The server
3
+ * is authoritative; the CLI checks first so an agent learns WHY a scope is refused before anything
4
+ * is sent.
5
+ */
6
+ export type Verb = "read" | "write" | "delete";
7
+ export interface CatalogScope {
8
+ scope: string;
9
+ verb: Verb;
10
+ issuable: boolean;
11
+ hitl: boolean;
12
+ operations?: Array<{
13
+ operationId?: string;
14
+ method?: string;
15
+ path?: string;
16
+ approval?: string;
17
+ }>;
18
+ }
19
+ export interface CatalogObject {
20
+ object: string;
21
+ description: string;
22
+ label_nl?: string;
23
+ explicit_only: boolean;
24
+ scopes: CatalogScope[];
25
+ }
26
+ export interface ScopeCatalog {
27
+ schema: 1;
28
+ wildcards?: unknown;
29
+ products: Array<{
30
+ product: string;
31
+ status: "available" | "reserved";
32
+ objects: CatalogObject[];
33
+ }>;
34
+ }
35
+ export interface ScopeProblem {
36
+ scope: string;
37
+ code: string;
38
+ reason: string;
39
+ }
40
+ /** What the creating credential may pass on. Unknown fields mean "the CLI cannot check this; the server will". */
41
+ export interface ParentGrant {
42
+ scopes?: string[];
43
+ expiresAt?: string | null;
44
+ monthlyCreditCap?: number | null;
45
+ }
46
+ export interface ChildRequest {
47
+ scopes: string[];
48
+ expiresAt?: string | null;
49
+ monthlyCreditCap?: number | null;
50
+ }
51
+ export declare const KEY_WRITE_SCOPE = "account:api_keys:write";
52
+ /** Products the token service reserves (contract §2) even when the catalogue does not list them. */
53
+ export declare const RESERVED_PRODUCTS: string[];
54
+ /** Does `held` grant `wanted`? A wildcard covers concrete objects except explicit_only ones; only the same wildcard covers a wildcard. */
55
+ export declare function covers(held: string[], wanted: string, catalog?: ScopeCatalog): boolean;
56
+ /** Validate requested scopes against the catalogue; returns problems (refusals) and warnings (allowed, but read this). */
57
+ export declare function checkScopes(requested: string[], catalog?: ScopeCatalog): {
58
+ problems: ScopeProblem[];
59
+ warnings: string[];
60
+ };
61
+ /**
62
+ * Attenuation: a key creates only keys with a subset of its own rights, a shorter or equal
63
+ * lifetime and a lower or equal credit limit; it needs account:api_keys:write itself.
64
+ */
65
+ export declare function checkAttenuation(parent: ParentGrant, child: ChildRequest, catalog?: ScopeCatalog): ScopeProblem[];
66
+ export declare function isScopeCatalog(value: unknown): value is ScopeCatalog;
@@ -0,0 +1,49 @@
1
+ import type { Environment, FileConfig, ResolvedConfig } from './config';
2
+ import { CliError } from './core';
3
+ import { readClaims } from './keycloak';
4
+ /** A token is reused until 30 s before it expires. */
5
+ export declare const SKEW_MS = 30000;
6
+ export interface SessionOptions {
7
+ config: ResolvedConfig;
8
+ file: FileConfig;
9
+ env: Environment;
10
+ fetch: typeof fetch;
11
+ now: () => number;
12
+ /** Reads the config file again right before a write, so a parallel login or logout is never overwritten. */
13
+ load?: () => FileConfig;
14
+ save: (cfg: FileConfig) => void;
15
+ /** Called with every credential the session obtains, so output filters can hide it. */
16
+ onSecret?: (secret: string) => void;
17
+ /** Embedding hook (CliOptions.credentials): product tokens supplied by the host process. */
18
+ override?: {
19
+ productToken(product: string): Promise<string | undefined>;
20
+ };
21
+ }
22
+ /**
23
+ * The credentials of one CLI process. The refresh token is the only durable secret (profile file, or
24
+ * PRUDAI_REFRESH_TOKEN on a runner). The login access token may be cached in the profile; product tokens
25
+ * live in memory only and are never written anywhere.
26
+ */
27
+ export declare class Session {
28
+ private o;
29
+ private login;
30
+ private products;
31
+ private pending;
32
+ constructor(o: SessionOptions);
33
+ get hasLogin(): boolean;
34
+ /** The cached login access token, if any (may be expired). Never a network call. */
35
+ get cachedLoginToken(): string | undefined;
36
+ /** The refresh token, for `auth export` only. */
37
+ get refreshTokenValue(): string | undefined;
38
+ private once;
39
+ /** A login access token that is valid for at least the skew; refreshes (and stores the rotated refresh token) when it is not. */
40
+ loginToken(force?: boolean): Promise<string>;
41
+ private adopt;
42
+ /** The token for one CLI product group (irma, ordo, or the platform for everything else), from memory when still valid. */
43
+ productToken(product: string): Promise<string>;
44
+ /** Forget a product token the product rejected (401), so the next call exchanges again. */
45
+ forget(product: string): void;
46
+ }
47
+ export declare function notAuthenticated(why?: string): CliError;
48
+ /** Who the login says it is, without a network call: the cached access token if there is one. */
49
+ export declare function loginClaims(session: Session): ReturnType<typeof readClaims>;
@@ -0,0 +1,6 @@
1
+ import { type ProductCatalog } from "./catalog";
2
+ import type { RunContext } from "./context";
3
+ import { type ExitCode } from "./core";
4
+ export declare const SKILL_MARKER = "generated by `prudai skill install`";
5
+ export declare function skillMarkdown(catalogs: ProductCatalog[], today: string): string;
6
+ export declare function skillCommand(words: string[], ctx: RunContext): Promise<ExitCode>;