copilotkit 1.0.2 → 2.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/index.js +89779 -0
- package/package.json +4 -108
- package/src/commands/docs.d.ts +17 -0
- package/src/commands/docs.d.ts.map +1 -0
- package/src/commands/init.d.ts +103 -0
- package/src/commands/init.d.ts.map +1 -0
- package/src/commands/kite.d.ts +8 -0
- package/src/commands/kite.d.ts.map +1 -0
- package/src/commands/license.d.ts +17 -0
- package/src/commands/license.d.ts.map +1 -0
- package/src/commands/login.d.ts +13 -0
- package/src/commands/login.d.ts.map +1 -0
- package/src/commands/logs.d.ts +32 -0
- package/src/commands/logs.d.ts.map +1 -0
- package/src/commands/version.d.ts +8 -0
- package/src/commands/version.d.ts.map +1 -0
- package/src/config.d.ts +31 -0
- package/src/config.d.ts.map +1 -0
- package/src/index.d.ts +21 -0
- package/src/index.d.ts.map +1 -0
- package/src/services/api-client.d.ts +106 -0
- package/src/services/api-client.d.ts.map +1 -0
- package/src/services/auth.service.d.ts +107 -0
- package/src/services/auth.service.d.ts.map +1 -0
- package/src/services/cli-auth-diagnostics.d.ts +71 -0
- package/src/services/cli-auth-diagnostics.d.ts.map +1 -0
- package/src/services/cli-logs.d.ts +45 -0
- package/src/services/cli-logs.d.ts.map +1 -0
- package/src/services/config.service.d.ts +53 -0
- package/src/services/config.service.d.ts.map +1 -0
- package/src/services/feature-flags.d.ts +14 -0
- package/src/services/feature-flags.d.ts.map +1 -0
- package/src/services/kite-game-engine.d.ts +99 -0
- package/src/services/kite-game-engine.d.ts.map +1 -0
- package/src/services/kite-game-score.d.ts +33 -0
- package/src/services/kite-game-score.d.ts.map +1 -0
- package/src/services/project-scaffold.d.ts +49 -0
- package/src/services/project-scaffold.d.ts.map +1 -0
- package/src/types.d.ts +205 -0
- package/src/types.d.ts.map +1 -0
- package/src/ui/banner.d.ts +3 -0
- package/src/ui/banner.d.ts.map +1 -0
- package/src/ui/browser-login.d.ts +71 -0
- package/src/ui/browser-login.d.ts.map +1 -0
- package/src/ui/init-flow.d.ts +35 -0
- package/src/ui/init-flow.d.ts.map +1 -0
- package/src/ui/kite-game.d.ts +26 -0
- package/src/ui/kite-game.d.ts.map +1 -0
- package/src/ui/login-flow.d.ts +22 -0
- package/src/ui/login-flow.d.ts.map +1 -0
- package/src/ui/spinner.d.ts +9 -0
- package/src/ui/spinner.d.ts.map +1 -0
- package/LICENSE +0 -21
- package/README.md +0 -83
- package/bin/dev.cmd +0 -3
- package/bin/dev.js +0 -8
- package/bin/run.cmd +0 -3
- package/bin/run.js +0 -17
- package/dist/commands/base-command.d.ts +0 -12
- package/dist/commands/base-command.js +0 -65
- package/dist/commands/base-command.js.map +0 -1
- package/dist/commands/create.d.ts +0 -27
- package/dist/commands/create.js +0 -710
- package/dist/commands/create.js.map +0 -1
- package/dist/commands/dev.d.ts +0 -25
- package/dist/commands/dev.js +0 -776
- package/dist/commands/dev.js.map +0 -1
- package/dist/commands/init.d.ts +0 -11
- package/dist/commands/init.js +0 -726
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/login.d.ts +0 -13
- package/dist/commands/login.js +0 -374
- package/dist/commands/login.js.map +0 -1
- package/dist/commands/logout.d.ts +0 -13
- package/dist/commands/logout.js +0 -375
- package/dist/commands/logout.js.map +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -6
- package/dist/index.js.map +0 -1
- package/dist/lib/init/ide-docs.d.ts +0 -25
- package/dist/lib/init/ide-docs.js +0 -170
- package/dist/lib/init/ide-docs.js.map +0 -1
- package/dist/lib/init/index.d.ts +0 -14
- package/dist/lib/init/index.js +0 -1106
- package/dist/lib/init/index.js.map +0 -1
- package/dist/lib/init/questions.d.ts +0 -9
- package/dist/lib/init/questions.js +0 -508
- package/dist/lib/init/questions.js.map +0 -1
- package/dist/lib/init/scaffold/agent.d.ts +0 -20
- package/dist/lib/init/scaffold/agent.js +0 -173
- package/dist/lib/init/scaffold/agent.js.map +0 -1
- package/dist/lib/init/scaffold/crew-inputs.d.ts +0 -3
- package/dist/lib/init/scaffold/crew-inputs.js +0 -59
- package/dist/lib/init/scaffold/crew-inputs.js.map +0 -1
- package/dist/lib/init/scaffold/env.d.ts +0 -7
- package/dist/lib/init/scaffold/env.js +0 -126
- package/dist/lib/init/scaffold/env.js.map +0 -1
- package/dist/lib/init/scaffold/github.d.ts +0 -17
- package/dist/lib/init/scaffold/github.js +0 -114
- package/dist/lib/init/scaffold/github.js.map +0 -1
- package/dist/lib/init/scaffold/index.d.ts +0 -10
- package/dist/lib/init/scaffold/index.js +0 -692
- package/dist/lib/init/scaffold/index.js.map +0 -1
- package/dist/lib/init/scaffold/langgraph-assistants.d.ts +0 -18
- package/dist/lib/init/scaffold/langgraph-assistants.js +0 -28
- package/dist/lib/init/scaffold/langgraph-assistants.js.map +0 -1
- package/dist/lib/init/scaffold/packages.d.ts +0 -7
- package/dist/lib/init/scaffold/packages.js +0 -62
- package/dist/lib/init/scaffold/packages.js.map +0 -1
- package/dist/lib/init/scaffold/shadcn.d.ts +0 -7
- package/dist/lib/init/scaffold/shadcn.js +0 -279
- package/dist/lib/init/scaffold/shadcn.js.map +0 -1
- package/dist/lib/init/types/index.d.ts +0 -4
- package/dist/lib/init/types/index.js +0 -238
- package/dist/lib/init/types/index.js.map +0 -1
- package/dist/lib/init/types/questions.d.ts +0 -209
- package/dist/lib/init/types/questions.js +0 -214
- package/dist/lib/init/types/questions.js.map +0 -1
- package/dist/lib/init/types/templates.d.ts +0 -17
- package/dist/lib/init/types/templates.js +0 -26
- package/dist/lib/init/types/templates.js.map +0 -1
- package/dist/lib/init/utils.d.ts +0 -3
- package/dist/lib/init/utils.js +0 -8
- package/dist/lib/init/utils.js.map +0 -1
- package/dist/services/analytics.service.d.ts +0 -38
- package/dist/services/analytics.service.js +0 -134
- package/dist/services/analytics.service.js.map +0 -1
- package/dist/services/auth.service.d.ts +0 -26
- package/dist/services/auth.service.js +0 -299
- package/dist/services/auth.service.js.map +0 -1
- package/dist/services/events.d.ts +0 -119
- package/dist/services/events.js +0 -1
- package/dist/services/events.js.map +0 -1
- package/dist/services/tunnel.service.d.ts +0 -15
- package/dist/services/tunnel.service.js +0 -21
- package/dist/services/tunnel.service.js.map +0 -1
- package/dist/utils/detect-endpoint-type.utils.d.ts +0 -15
- package/dist/utils/detect-endpoint-type.utils.js +0 -157
- package/dist/utils/detect-endpoint-type.utils.js.map +0 -1
- package/dist/utils/trpc.d.ts +0 -4
- package/dist/utils/trpc.js +0 -25
- package/dist/utils/trpc.js.map +0 -1
- package/dist/utils/version.d.ts +0 -3
- package/dist/utils/version.js +0 -6
- package/dist/utils/version.js.map +0 -1
- package/oclif.manifest.json +0 -216
package/package.json
CHANGED
|
@@ -1,112 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "copilotkit",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "CopilotKit CLI",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"oclif"
|
|
7
|
-
],
|
|
8
|
-
"homepage": "https://github.com/CopilotKit/CopilotKit/tree/main/packages/cli",
|
|
9
|
-
"bugs": "https://github.com/CopilotKit/CopilotKit/issues",
|
|
10
|
-
"license": "MIT",
|
|
11
|
-
"author": "CopilotKit",
|
|
12
|
-
"repository": {
|
|
13
|
-
"type": "git",
|
|
14
|
-
"url": "https://github.com/CopilotKit/CopilotKit.git",
|
|
15
|
-
"directory": "packages/cli"
|
|
16
|
-
},
|
|
17
|
-
"bin": {
|
|
18
|
-
"copilotkit": "./bin/run.js",
|
|
19
|
-
"cpk": "./bin/run.js"
|
|
20
|
-
},
|
|
21
|
-
"files": [
|
|
22
|
-
"/bin",
|
|
23
|
-
"/dist",
|
|
24
|
-
"/oclif.manifest.json"
|
|
25
|
-
],
|
|
3
|
+
"version": "2.0.0",
|
|
26
4
|
"type": "module",
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
"publishConfig": {
|
|
30
|
-
"access": "public"
|
|
31
|
-
},
|
|
32
|
-
"dependencies": {
|
|
33
|
-
"@oclif/core": "^4.2.0",
|
|
34
|
-
"@paralleldrive/cuid2": "^2.2.2",
|
|
35
|
-
"@segment/analytics-node": "^2.1.2",
|
|
36
|
-
"@sentry/node": "^7.116.0",
|
|
37
|
-
"@trpc/client": "^11.0.1",
|
|
38
|
-
"@trpc/server": "^11.0.1",
|
|
39
|
-
"ansis": "^3.3.2",
|
|
40
|
-
"axios": "^1.7.8",
|
|
41
|
-
"chalk": "^5.3.0",
|
|
42
|
-
"conf": "^13.1.0",
|
|
43
|
-
"cors": "^2.8.5",
|
|
44
|
-
"cross-spawn": "^7.0.6",
|
|
45
|
-
"execa": "^8.0.1",
|
|
46
|
-
"express": "^4.21.2",
|
|
47
|
-
"fs-extra": "^11.2.0",
|
|
48
|
-
"get-port": "^7.1.0",
|
|
49
|
-
"inquirer": "^12.3.0",
|
|
50
|
-
"localtunnel": "^2.0.2",
|
|
51
|
-
"open": "^10.1.0",
|
|
52
|
-
"ora": "^8.1.1",
|
|
53
|
-
"posthog-node": "^4.0.1",
|
|
54
|
-
"superjson": "^2.2.1",
|
|
55
|
-
"tar": "^7.4.3",
|
|
56
|
-
"zod": "^3.22.4"
|
|
57
|
-
},
|
|
58
|
-
"devDependencies": {
|
|
59
|
-
"@jest/globals": "30.0.0-beta.3",
|
|
60
|
-
"@oclif/prettier-config": "^0.2.1",
|
|
61
|
-
"@oclif/test": "^4",
|
|
62
|
-
"@types/chai": "^4.3.20",
|
|
63
|
-
"@types/cors": "^2.8.17",
|
|
64
|
-
"@types/cross-spawn": "^6.0.6",
|
|
65
|
-
"@types/express": "^5.0.0",
|
|
66
|
-
"@types/fs-extra": "^11.0.4",
|
|
67
|
-
"@types/jest": "^29.5.2",
|
|
68
|
-
"@types/localtunnel": "^2.0.4",
|
|
69
|
-
"@types/mocha": "^10",
|
|
70
|
-
"@types/node": "^18",
|
|
71
|
-
"@types/sinon": "^17.0.3",
|
|
72
|
-
"@types/sinon-chai": "^4.0.0",
|
|
73
|
-
"chai": "^4",
|
|
74
|
-
"jest": "^29.5.0",
|
|
75
|
-
"mocha": "^10",
|
|
76
|
-
"oclif": "^4",
|
|
77
|
-
"shx": "^0.3.3",
|
|
78
|
-
"sinon": "^19.0.2",
|
|
79
|
-
"sinon-chai": "^4.0.0",
|
|
80
|
-
"ts-jest": "^29.1.0",
|
|
81
|
-
"ts-node": "^10",
|
|
82
|
-
"tsup": "^8.0.2",
|
|
83
|
-
"typescript": "^5"
|
|
84
|
-
},
|
|
85
|
-
"oclif": {
|
|
86
|
-
"bin": "copilotkit",
|
|
87
|
-
"commands": "./dist/commands",
|
|
88
|
-
"dirname": "copilotkit",
|
|
89
|
-
"topicSeparator": " ",
|
|
90
|
-
"topics": {
|
|
91
|
-
"login": {
|
|
92
|
-
"description": "Authenticate with Copilot Cloud"
|
|
93
|
-
},
|
|
94
|
-
"tunnel": {
|
|
95
|
-
"description": "Create a local tunnel to expose your agent to the internet"
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
"engines": {
|
|
100
|
-
"node": ">=18.0.0"
|
|
101
|
-
},
|
|
102
|
-
"scripts": {
|
|
103
|
-
"clean": "shx rm -rf dist",
|
|
104
|
-
"extract-version": "node -p \"'// This is auto generated!\\nexport const LIB_VERSION = ' + JSON.stringify(require('./package.json').version) + ';'\" > src/utils/version.ts",
|
|
105
|
-
"prebuild": "pnpm run clean && pnpm run extract-version",
|
|
106
|
-
"build": "tsup",
|
|
107
|
-
"generate-manifest": "oclif manifest",
|
|
108
|
-
"test": "jest",
|
|
109
|
-
"version": "oclif readme && git add README.md",
|
|
110
|
-
"validate": "node validate-package.js"
|
|
5
|
+
"bin": {
|
|
6
|
+
"copilotkit": "./index.js"
|
|
111
7
|
}
|
|
112
|
-
}
|
|
8
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** CopilotKit documentation URL opened by `copilotkit docs`. */
|
|
2
|
+
export declare const COPILOTKIT_DOCS_URL = "https://docs.copilotkit.ai";
|
|
3
|
+
/**
|
|
4
|
+
* Detects whether browser automation should be skipped for the current process.
|
|
5
|
+
*
|
|
6
|
+
* @param env - Process environment variables.
|
|
7
|
+
* @returns `true` when the command should print the URL instead of opening it.
|
|
8
|
+
*/
|
|
9
|
+
export declare function shouldSkipBrowserOpen(env?: NodeJS.ProcessEnv): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Opens the CopilotKit documentation in the user's browser.
|
|
12
|
+
*
|
|
13
|
+
* In CI, or when browser opening fails, the command prints the URL so it can be
|
|
14
|
+
* opened manually.
|
|
15
|
+
*/
|
|
16
|
+
export declare function runDocs(): Promise<void>;
|
|
17
|
+
//# sourceMappingURL=docs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../../../../apps/cli/src/commands/docs.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,eAAO,MAAM,mBAAmB,+BAA+B,CAAC;AAEhE;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,OAAO,CAInF;AAED;;;;;GAKG;AACH,wBAAsB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAY7C"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { InitOptions, InitTemplateDefinition } from '../types.js';
|
|
2
|
+
import { login, verifyAndRefresh } from '../services/auth.service.js';
|
|
3
|
+
import { createApiClient } from '../services/api-client.js';
|
|
4
|
+
import { scaffoldProject, copyEnvExample } from '../services/project-scaffold.js';
|
|
5
|
+
import { getOpsApiUrl } from '../config.js';
|
|
6
|
+
/**
|
|
7
|
+
* Flags accepted by the `copilotkit init` command.
|
|
8
|
+
*/
|
|
9
|
+
export interface InitFlags {
|
|
10
|
+
/** Human-readable project name (sets the directory name). */
|
|
11
|
+
name?: string;
|
|
12
|
+
/** Pre-select the Intelligence (threads) path. */
|
|
13
|
+
intelligence?: boolean;
|
|
14
|
+
/** Pre-select a framework (skips intelligence question). */
|
|
15
|
+
framework?: string;
|
|
16
|
+
}
|
|
17
|
+
/** Phases of the scaffolding flow rendered after options are collected. */
|
|
18
|
+
type ScaffoldPhase = 'auth' | 'scaffold' | 'license' | 'git' | 'success' | 'error';
|
|
19
|
+
/** Writes a license key into the project's .env file. */
|
|
20
|
+
declare function writeLicenseKey(projectDir: string, licenseKey: string): void;
|
|
21
|
+
/** Runs git init and creates an initial commit if identity is configured. */
|
|
22
|
+
declare function initGit(projectDir: string): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Checks whether a command is available on PATH.
|
|
25
|
+
*
|
|
26
|
+
* @param command - Executable name to check.
|
|
27
|
+
* @param environment - Environment variables that provide PATH/PATHEXT.
|
|
28
|
+
* @param platform - Platform used to apply executable extension rules.
|
|
29
|
+
* @returns `true` when the command can be resolved.
|
|
30
|
+
*/
|
|
31
|
+
export declare function commandExists(command: string, environment?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): boolean;
|
|
32
|
+
/** Outcome from preparing environment files during scaffolding. */
|
|
33
|
+
export interface InitScaffoldResult {
|
|
34
|
+
/** Absolute project directory created by init. */
|
|
35
|
+
projectDir: string;
|
|
36
|
+
/** Whether `.env` was created from `.env.example`. */
|
|
37
|
+
envCreatedFromExample: boolean;
|
|
38
|
+
/** Whether a license token was written to `.env`. */
|
|
39
|
+
licenseWritten: boolean;
|
|
40
|
+
/** Prerequisite commands missing from PATH. */
|
|
41
|
+
missingPrerequisites: string[];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Dependencies used by the `copilotkit init` scaffold flow.
|
|
45
|
+
*
|
|
46
|
+
* Extracted so the behavior split can be tested without rendering Ink or
|
|
47
|
+
* touching the network/filesystem.
|
|
48
|
+
*/
|
|
49
|
+
export interface InitScaffoldDependencies {
|
|
50
|
+
/** Verifies the current CLI session, refreshing persisted auth when valid. */
|
|
51
|
+
verifyAndRefresh: typeof verifyAndRefresh;
|
|
52
|
+
/** Launches the browser login flow when no valid CLI session exists. */
|
|
53
|
+
login: typeof login;
|
|
54
|
+
/** Reads the persisted CLI session token after authentication. */
|
|
55
|
+
getCliToken: () => string | null;
|
|
56
|
+
/** Creates an authenticated ops API client. */
|
|
57
|
+
createApiClient: typeof createApiClient;
|
|
58
|
+
/** Resolves the ops API base URL used by the API client. */
|
|
59
|
+
getOpsApiUrl: typeof getOpsApiUrl;
|
|
60
|
+
/** Downloads and copies the selected starter template. */
|
|
61
|
+
scaffoldProject: typeof scaffoldProject;
|
|
62
|
+
/** Initializes git in the scaffolded project directory. */
|
|
63
|
+
initGit: typeof initGit;
|
|
64
|
+
/** Copies `.env.example` to `.env` when present. */
|
|
65
|
+
copyEnvExample: typeof copyEnvExample;
|
|
66
|
+
/** Writes the issued license key into the scaffolded project. */
|
|
67
|
+
writeLicenseKey: typeof writeLicenseKey;
|
|
68
|
+
/** Checks whether a prerequisite command is available on PATH. */
|
|
69
|
+
commandExists: typeof commandExists;
|
|
70
|
+
/** Resolves the final project directory for the supplied project name. */
|
|
71
|
+
resolveProjectDir: (projectName: string) => string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Builds the final onboarding copy from template metadata and scaffold results.
|
|
75
|
+
*
|
|
76
|
+
* @param templateDefinition - Selected template metadata.
|
|
77
|
+
* @param projectName - Directory name chosen by the user.
|
|
78
|
+
* @param result - Filesystem and prerequisite outcomes from scaffolding.
|
|
79
|
+
* @returns Lines rendered as post-init next steps.
|
|
80
|
+
*/
|
|
81
|
+
export declare function buildInitNextSteps(templateDefinition: InitTemplateDefinition, projectName: string, result: InitScaffoldResult): string[];
|
|
82
|
+
/**
|
|
83
|
+
* Runs the `copilotkit init` scaffold steps for the resolved template.
|
|
84
|
+
*
|
|
85
|
+
* The template metadata decides whether auth and license issuance are required,
|
|
86
|
+
* allowing non-license templates to scaffold without touching auth at all.
|
|
87
|
+
*
|
|
88
|
+
* @param options - Fully resolved init options.
|
|
89
|
+
* @param dependencies - Injectable dependencies for IO and auth operations.
|
|
90
|
+
* @param onPhaseChange - Optional callback used by the Ink UI to update progress.
|
|
91
|
+
*/
|
|
92
|
+
export declare function scaffoldInitProject(options: InitOptions, dependencies?: InitScaffoldDependencies, onPhaseChange?: (phase: Exclude<ScaffoldPhase, 'success' | 'error'>) => void, onTerminalSessionInvalidation?: () => void): Promise<InitScaffoldResult>;
|
|
93
|
+
/**
|
|
94
|
+
* Entry point for the `copilotkit init` command.
|
|
95
|
+
*
|
|
96
|
+
* Parses and validates flags, then renders the interactive Ink UI that
|
|
97
|
+
* guides the user through prompts and scaffolding.
|
|
98
|
+
*
|
|
99
|
+
* @param flags - Raw flags passed from the CLI argument parser.
|
|
100
|
+
*/
|
|
101
|
+
export declare function runInit(flags: InitFlags): Promise<void>;
|
|
102
|
+
export {};
|
|
103
|
+
//# sourceMappingURL=init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../apps/cli/src/commands/init.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAEV,WAAW,EACX,sBAAsB,EACvB,MAAM,aAAa,CAAC;AAOrB,OAAO,EAEL,KAAK,EAEL,gBAAgB,EACjB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EACL,eAAe,EAIf,cAAc,EACf,MAAM,iCAAiC,CAAC;AAWzC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,6DAA6D;IAC7D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,2EAA2E;AAC3E,KAAK,aAAa,GACd,MAAM,GACN,UAAU,GACV,SAAS,GACT,KAAK,GACL,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,EAAE,MAAM,KAAK,MAAM,CAAC;CACpD;AAiBD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,kBAAkB,EAAE,sBAAsB,EAC1C,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,kBAAkB,GACzB,MAAM,EAAE,CA6DV;AA0FD;;;;;;;;;GASG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,WAAW,EACpB,YAAY,GAAE,wBAA0D,EACxE,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,aAAa,EAAE,SAAS,GAAG,OAAO,CAAC,KAAK,IAAI,EAC5E,6BAA6B,CAAC,EAAE,MAAM,IAAI,GACzC,OAAO,CAAC,kBAAkB,CAAC,CAsD7B;AAmOD;;;;;;;GAOG;AACH,wBAAsB,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAoB7D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kite.d.ts","sourceRoot":"","sources":["../../../../../apps/cli/src/commands/kite.tsx"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,wBAAsB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAS7C"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CliLicenseScope } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Parsed `copilotkit license` command variants.
|
|
4
|
+
*/
|
|
5
|
+
export type LicenseCommand = {
|
|
6
|
+
action: "create";
|
|
7
|
+
} | {
|
|
8
|
+
action: "list";
|
|
9
|
+
scope: CliLicenseScope;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Entry point for the `copilotkit license` command.
|
|
13
|
+
*
|
|
14
|
+
* @param command - Resolved license command variant.
|
|
15
|
+
*/
|
|
16
|
+
export declare function runLicense(command: LicenseCommand): Promise<void>;
|
|
17
|
+
//# sourceMappingURL=license.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"license.d.ts","sourceRoot":"","sources":["../../../../../apps/cli/src/commands/license.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAEV,eAAe,EAChB,MAAM,aAAa,CAAC;AAIrB;;GAEG;AACH,MAAM,MAAM,cAAc,GACtB;IAAE,MAAM,EAAE,QAAQ,CAAA;CAAE,GACpB;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,eAAe,CAAA;CAAE,CAAC;AAuT/C;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAmBvE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs the ink-based login command.
|
|
3
|
+
*
|
|
4
|
+
* Renders {@link LoginFlow} inside an ink instance and returns a promise that
|
|
5
|
+
* resolves when the user authenticates successfully or rejects when the login
|
|
6
|
+
* attempt fails. A short delay before unmounting ensures all output is flushed
|
|
7
|
+
* to the terminal before the process continues.
|
|
8
|
+
*
|
|
9
|
+
* @returns A promise that resolves on successful login.
|
|
10
|
+
* @throws When the browser-based login flow fails.
|
|
11
|
+
*/
|
|
12
|
+
export declare function runLogin(): Promise<void>;
|
|
13
|
+
//# sourceMappingURL=login.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../../../apps/cli/src/commands/login.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AACH,wBAAsB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAmB9C"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Supported `copilotkit logs` actions. */
|
|
2
|
+
export interface LogsFlags {
|
|
3
|
+
lines?: number;
|
|
4
|
+
path?: boolean;
|
|
5
|
+
tail?: boolean;
|
|
6
|
+
}
|
|
7
|
+
/** Normalized `copilotkit logs` action after validating flag combinations. */
|
|
8
|
+
type NormalizedLogsAction = {
|
|
9
|
+
type: 'path';
|
|
10
|
+
} | {
|
|
11
|
+
lines: number;
|
|
12
|
+
type: 'tail';
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Validates raw `copilotkit logs` flags and resolves the intended action.
|
|
16
|
+
*
|
|
17
|
+
* @param flags - Parsed command flags.
|
|
18
|
+
* @returns Normalized action to run.
|
|
19
|
+
*/
|
|
20
|
+
export declare function normalizeLogsFlags(flags: LogsFlags): NormalizedLogsAction;
|
|
21
|
+
/**
|
|
22
|
+
* Runs the CLI logs command.
|
|
23
|
+
*
|
|
24
|
+
* `--path` prints the resolved log file path.
|
|
25
|
+
* `--tail` prints the most recent log lines.
|
|
26
|
+
* With no flags, this defaults to `--path`.
|
|
27
|
+
*
|
|
28
|
+
* @param flags - Parsed command flags.
|
|
29
|
+
*/
|
|
30
|
+
export declare function runLogs(flags: LogsFlags): Promise<void>;
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=logs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../../../../../apps/cli/src/commands/logs.ts"],"names":[],"mappings":"AAEA,2CAA2C;AAC3C,MAAM,WAAW,SAAS;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,8EAA8E;AAC9E,KAAK,oBAAoB,GACrB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpC;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,SAAS,GAAG,oBAAoB,CAiBzE;AAED;;;;;;;;GAQG;AACH,wBAAsB,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAe7D"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prints the CLI's build identity: semantic version, GitHub Actions run id,
|
|
3
|
+
* and the commit sha the binary was built from.
|
|
4
|
+
*
|
|
5
|
+
* `buildNumber` and `commitSha` are `"dev"` for local (non-CI) builds.
|
|
6
|
+
*/
|
|
7
|
+
export declare function runVersion(): void;
|
|
8
|
+
//# sourceMappingURL=version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../../../apps/cli/src/commands/version.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,UAAU,IAAI,IAAI,CAKjC"}
|
package/src/config.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build-time configuration injected via esbuild `define`.
|
|
3
|
+
*
|
|
4
|
+
* These values are replaced at build time with the corresponding
|
|
5
|
+
* environment variables. If not set during build, the build fails.
|
|
6
|
+
*
|
|
7
|
+
* {@link OPS_API_URL} can be overridden at runtime via the hidden
|
|
8
|
+
* `--ops-api-url` flag, which calls {@link setOpsApiUrl}.
|
|
9
|
+
*/
|
|
10
|
+
/** Base URL for the CopilotKit operations API. */
|
|
11
|
+
export declare function getOpsApiUrl(): string;
|
|
12
|
+
/** Override the ops API URL at runtime. */
|
|
13
|
+
export declare function setOpsApiUrl(url: string): void;
|
|
14
|
+
/** Base URL for the CopilotKit operations frontend (serves CLI auth page). */
|
|
15
|
+
export declare function getOpsFrontendUrl(): string;
|
|
16
|
+
/** Override the ops frontend URL at runtime. */
|
|
17
|
+
export declare function setOpsFrontendUrl(url: string): void;
|
|
18
|
+
/**
|
|
19
|
+
* Build identity for this CLI binary.
|
|
20
|
+
*
|
|
21
|
+
* - `version` — semantic version from `apps/cli/package.json`.
|
|
22
|
+
* - `buildNumber` — GitHub Actions run id of the build, or `"dev"` for local builds.
|
|
23
|
+
* Maps back to a workflow run at github.com/<repo>/actions/runs/<buildNumber>.
|
|
24
|
+
* - `commitSha` — git commit the binary was built from, or `"dev"` for local builds.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getBuildInfo(): {
|
|
27
|
+
version: string;
|
|
28
|
+
buildNumber: string;
|
|
29
|
+
commitSha: string;
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../apps/cli/src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAaH,kDAAkD;AAClD,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED,2CAA2C;AAC3C,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE9C;AAED,8EAA8E;AAC9E,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,gDAAgD;AAChD,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEnD;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,IAAI;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB,CAMA"}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Returns help text for a CLI argv list when it requests help.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getHelpTextForArgs(argv: readonly string[]): string | null;
|
|
6
|
+
/**
|
|
7
|
+
* Main CLI entrypoint.
|
|
8
|
+
*/
|
|
9
|
+
export declare function main(rawArgv?: string[]): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Detects whether this module is the process entrypoint.
|
|
12
|
+
*
|
|
13
|
+
* Package managers often execute bin shims through symlinks, so both sides are
|
|
14
|
+
* compared after resolving their real filesystem paths.
|
|
15
|
+
*
|
|
16
|
+
* @param entrypoint - The process entrypoint path, usually `process.argv[1]`.
|
|
17
|
+
* @param moduleUrl - The current module URL.
|
|
18
|
+
* @returns `true` when the entrypoint resolves to the current module.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isDirectInvocation(entrypoint: string | undefined, moduleUrl: string): boolean;
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../apps/cli/src/index.ts"],"names":[],"mappings":";AAoOA;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAIzE;AAgPD;;GAEG;AACH,wBAAsB,IAAI,CAAC,OAAO,WAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiEzE;AAkBD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,SAAS,EAAE,MAAM,GAChB,OAAO,CAMT"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { AuthPayload, CliLicenseRecord, CliLicenseScope } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Error raised when ops-api returns a structured non-OK response.
|
|
4
|
+
*/
|
|
5
|
+
export declare class ApiClientError extends Error {
|
|
6
|
+
/** HTTP status returned by the API. */
|
|
7
|
+
readonly status: number;
|
|
8
|
+
/** Stable API error code when present. */
|
|
9
|
+
readonly code?: string;
|
|
10
|
+
/**
|
|
11
|
+
* @param status - HTTP status from the failed response.
|
|
12
|
+
* @param message - User-facing error message.
|
|
13
|
+
* @param code - Optional stable API error code.
|
|
14
|
+
*/
|
|
15
|
+
constructor(status: number, message: string, code?: string);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Shape of the response from the session verification endpoint.
|
|
19
|
+
*/
|
|
20
|
+
export interface VerifySessionResponse {
|
|
21
|
+
/** The authenticated user record returned by ops-api. */
|
|
22
|
+
user: {
|
|
23
|
+
id: string;
|
|
24
|
+
email: string;
|
|
25
|
+
name: string | null;
|
|
26
|
+
};
|
|
27
|
+
/** The organization the user authenticated under. */
|
|
28
|
+
organization: {
|
|
29
|
+
clerkOrgId: string;
|
|
30
|
+
organizationName?: string;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* HTTP client for the CopilotKit ops-api CLI endpoints.
|
|
35
|
+
*
|
|
36
|
+
* Encapsulates auth, session verification, logout, and license management
|
|
37
|
+
* requests against the configured `baseUrl`.
|
|
38
|
+
*/
|
|
39
|
+
export interface ApiClient {
|
|
40
|
+
/**
|
|
41
|
+
* Exchanges a Clerk short-lived token for a CLI session token.
|
|
42
|
+
*
|
|
43
|
+
* POSTs to `/api/cli/auth/session` without an auth header since this is
|
|
44
|
+
* a pre-login exchange. Throws if the response is not OK.
|
|
45
|
+
*
|
|
46
|
+
* @param clerkToken - The Clerk token returned from the browser OAuth flow.
|
|
47
|
+
* @returns The parsed {@link AuthPayload} containing the CLI session token.
|
|
48
|
+
*/
|
|
49
|
+
exchangeClerkToken(clerkToken: string): Promise<AuthPayload>;
|
|
50
|
+
/**
|
|
51
|
+
* Verifies the current CLI session token against ops-api.
|
|
52
|
+
*
|
|
53
|
+
* GETs `/api/cli/auth/verify` with a Bearer authorization header.
|
|
54
|
+
* Throws with the server-provided auth guidance on non-OK responses.
|
|
55
|
+
*
|
|
56
|
+
* @returns The session user/org data.
|
|
57
|
+
*/
|
|
58
|
+
verifySession(): Promise<VerifySessionResponse>;
|
|
59
|
+
/**
|
|
60
|
+
* Terminates the current CLI session on the server.
|
|
61
|
+
*
|
|
62
|
+
* POSTs to `/api/cli/auth/logout` with a Bearer authorization header.
|
|
63
|
+
*/
|
|
64
|
+
logout(): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Lists licenses for the authenticated organization or current user.
|
|
67
|
+
*
|
|
68
|
+
* GETs `/api/cli/license?scope=...` with a Bearer authorization header.
|
|
69
|
+
* Throws if the response is not OK.
|
|
70
|
+
*
|
|
71
|
+
* @param scope - Whether to list organization-wide or user-only licenses.
|
|
72
|
+
* @returns The parsed list of license metadata.
|
|
73
|
+
*/
|
|
74
|
+
listLicenses(scope: CliLicenseScope): Promise<CliLicenseRecord[]>;
|
|
75
|
+
/**
|
|
76
|
+
* Issues a new license key for the current authenticated organization.
|
|
77
|
+
*
|
|
78
|
+
* POSTs to `/api/cli/license` with a Bearer authorization header. Throws if
|
|
79
|
+
* the response is not OK.
|
|
80
|
+
*
|
|
81
|
+
* @returns An object containing the newly issued `licenseKey`.
|
|
82
|
+
*/
|
|
83
|
+
issueLicense(): Promise<{
|
|
84
|
+
licenseKey: string;
|
|
85
|
+
}>;
|
|
86
|
+
/**
|
|
87
|
+
* Registers the user's interest in threads access (mailing list signup).
|
|
88
|
+
*
|
|
89
|
+
* POSTs to `/api/cli/threads-interest`. The user is already authenticated,
|
|
90
|
+
* so this just records their opt-in on the server side.
|
|
91
|
+
*/
|
|
92
|
+
requestThreadsAccess(): Promise<void>;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Creates an HTTP client bound to the given base URL and optional bearer token.
|
|
96
|
+
*
|
|
97
|
+
* Methods that require authentication use the supplied `token` as a Bearer
|
|
98
|
+
* credential. The `exchangeClerkToken` method intentionally omits the auth
|
|
99
|
+
* header because it is used before a session exists.
|
|
100
|
+
*
|
|
101
|
+
* @param baseUrl - The root URL of the ops-api instance (no trailing slash).
|
|
102
|
+
* @param token - Optional CLI session token for authenticated requests.
|
|
103
|
+
* @returns An {@link ApiClient} instance.
|
|
104
|
+
*/
|
|
105
|
+
export declare function createApiClient(baseUrl: string, token?: string): ApiClient;
|
|
106
|
+
//# sourceMappingURL=api-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../../../../../apps/cli/src/services/api-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAA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C,EAAE,MAAM,GAAG,SAAS,CA8E1E"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import * as http from "http";
|
|
2
|
+
import { ApiClientError } from "./api-client.js";
|
|
3
|
+
import type { VerifySessionResponse } from "./api-client.js";
|
|
4
|
+
/**
|
|
5
|
+
* Result of a successful callback from the browser-based login flow.
|
|
6
|
+
*/
|
|
7
|
+
export interface CallbackResult {
|
|
8
|
+
/** Short-lived Clerk token returned from the frontend callback. */
|
|
9
|
+
clerkToken: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Starts a temporary HTTP server on a random port bound to 127.0.0.1 that
|
|
13
|
+
* handles the CLI auth callback from the browser.
|
|
14
|
+
*
|
|
15
|
+
* The browser redirects (GET) to `/callback?clerkToken=…&state=…` after
|
|
16
|
+
* sign-in. The server validates `state`, resolves the result promise with
|
|
17
|
+
* the received `clerkToken`, and responds with a small HTML page telling
|
|
18
|
+
* the user they can close the tab. A full-page navigation is used rather
|
|
19
|
+
* than `fetch` so the flow works in Safari 15+ and Chrome 130+, which
|
|
20
|
+
* block HTTPS → private-network `fetch` requests.
|
|
21
|
+
*
|
|
22
|
+
* @param expectedState - The CSRF state token to validate against the callback
|
|
23
|
+
* payload.
|
|
24
|
+
* @returns A promise that resolves once the server is listening, providing the
|
|
25
|
+
* bound `port`, a `resultPromise` that resolves/rejects based on the callback
|
|
26
|
+
* payload, and the raw `server` handle for cleanup.
|
|
27
|
+
*/
|
|
28
|
+
export declare function startCallbackServer(expectedState: string): Promise<{
|
|
29
|
+
port: number;
|
|
30
|
+
resultPromise: Promise<CallbackResult>;
|
|
31
|
+
server: http.Server;
|
|
32
|
+
}>;
|
|
33
|
+
/**
|
|
34
|
+
* Launches the browser-based login flow, waits for the callback, exchanges
|
|
35
|
+
* the Clerk token for a CLI session token, persists the credentials, and
|
|
36
|
+
* returns the authenticated user and organization.
|
|
37
|
+
*
|
|
38
|
+
* Steps:
|
|
39
|
+
* 1. Generate a random CSRF state token.
|
|
40
|
+
* 2. Start a local callback server.
|
|
41
|
+
* 3. Open the browser to the ops-frontend CLI auth page.
|
|
42
|
+
* 4. Wait for the callback with the Clerk token.
|
|
43
|
+
* 5. Exchange the Clerk token for a CLI session via ops-api.
|
|
44
|
+
* 6. Persist credentials to the auth store.
|
|
45
|
+
*
|
|
46
|
+
* @returns The authenticated user and organization from the ops-api response.
|
|
47
|
+
*/
|
|
48
|
+
export declare function login(): Promise<{
|
|
49
|
+
user: {
|
|
50
|
+
id: string;
|
|
51
|
+
email: string;
|
|
52
|
+
name: string | null;
|
|
53
|
+
};
|
|
54
|
+
organization: {
|
|
55
|
+
clerkOrgId: string;
|
|
56
|
+
organizationName?: string;
|
|
57
|
+
};
|
|
58
|
+
}>;
|
|
59
|
+
export interface VerifyAndRefreshOptions {
|
|
60
|
+
/** When true, preserve the specific auth/session error instead of returning null. */
|
|
61
|
+
throwOnInvalid?: boolean;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* User-facing guidance shown when a stored CLI session is no longer usable
|
|
65
|
+
* after the Clerk cutover and the user must authenticate again.
|
|
66
|
+
*/
|
|
67
|
+
export declare const TERMINAL_SESSION_INVALID_MESSAGE = "Existing CLI sessions are invalid after the Clerk cutover. Please log in again.";
|
|
68
|
+
/**
|
|
69
|
+
* Checks whether an API error means the current stored CLI auth is no longer
|
|
70
|
+
* recoverable and must be cleared before the user logs in again.
|
|
71
|
+
*
|
|
72
|
+
* Treats all CLI session retirement errors, plus Clerk active-organization
|
|
73
|
+
* resolution failures, as terminal invalidation signals.
|
|
74
|
+
*
|
|
75
|
+
* @param error - Error raised by the API client.
|
|
76
|
+
* @returns `true` when local auth should be cleared and the user reauthenticated.
|
|
77
|
+
*/
|
|
78
|
+
export declare function isTerminalSessionInvalidationError(error: unknown): error is ApiClientError;
|
|
79
|
+
/**
|
|
80
|
+
* Clears the local auth store when the error represents a terminal CLI auth
|
|
81
|
+
* invalidation that requires a fresh login.
|
|
82
|
+
*
|
|
83
|
+
* @param error - Error raised by the API client.
|
|
84
|
+
* @returns `true` when local auth was cleared.
|
|
85
|
+
*/
|
|
86
|
+
export declare function clearAuthOnTerminalSessionInvalidation(error: unknown): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Verifies the stored CLI session token against ops-api and refreshes the
|
|
89
|
+
* locally persisted credentials if still valid.
|
|
90
|
+
*
|
|
91
|
+
* Returns `null` and clears the local auth store only when the server confirms
|
|
92
|
+
* the session is invalid. Missing local auth also returns `null`. Transport or
|
|
93
|
+
* server failures are rethrown so the caller can preserve the local session.
|
|
94
|
+
*
|
|
95
|
+
* @param options - Controls how invalid sessions are surfaced to the caller.
|
|
96
|
+
* @returns The fresh session user/org data, or `null` if unauthenticated.
|
|
97
|
+
*/
|
|
98
|
+
export declare function verifyAndRefresh(options?: VerifyAndRefreshOptions): Promise<VerifySessionResponse | null>;
|
|
99
|
+
/**
|
|
100
|
+
* Terminates the current CLI session on ops-api (best-effort) and clears all
|
|
101
|
+
* locally stored credentials.
|
|
102
|
+
*
|
|
103
|
+
* Any network error from the server-side logout is swallowed; the local
|
|
104
|
+
* credentials are always cleared.
|
|
105
|
+
*/
|
|
106
|
+
export declare function logout(): Promise<void>;
|
|
107
|
+
//# sourceMappingURL=auth.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.service.d.ts","sourceRoot":"","sources":["../../../../../apps/cli/src/services/auth.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,cAAc,EAAmB,MAAM,iBAAiB,CAAC;AASlE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAI7D;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,mEAAmE;IACnE,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,MAAM,GAAG,OA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