@knowzai/cli 0.1.0 → 0.3.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/assets/portable/.env.example +3 -0
- package/assets/portable/docker-compose.yml +18 -0
- package/assets/portable/releases.json +22 -0
- package/assets/selfhosted/.env.example +19 -0
- package/assets/selfhosted/docker-compose.yml +96 -0
- package/assets/selfhosted/releases.json +28 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/base-command.d.ts +21 -2
- package/dist/base-command.d.ts.map +1 -1
- package/dist/base-command.js +47 -4
- package/dist/base-command.js.map +1 -1
- package/dist/commands/ask.d.ts.map +1 -1
- package/dist/commands/ask.js +5 -1
- package/dist/commands/ask.js.map +1 -1
- package/dist/commands/auth/status.d.ts +1 -1
- package/dist/commands/auth/status.d.ts.map +1 -1
- package/dist/commands/auth/status.js +4 -0
- package/dist/commands/auth/status.js.map +1 -1
- package/dist/commands/chat.d.ts +5 -0
- package/dist/commands/chat.d.ts.map +1 -1
- package/dist/commands/chat.js +32 -13
- package/dist/commands/chat.js.map +1 -1
- package/dist/commands/config/get.d.ts.map +1 -1
- package/dist/commands/config/get.js +3 -1
- package/dist/commands/config/get.js.map +1 -1
- package/dist/commands/config/list.d.ts.map +1 -1
- package/dist/commands/config/list.js +12 -4
- package/dist/commands/config/list.js.map +1 -1
- package/dist/commands/doctor.js +1 -1
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/down.d.ts +9 -0
- package/dist/commands/down.d.ts.map +1 -1
- package/dist/commands/down.js +16 -1
- package/dist/commands/down.js.map +1 -1
- package/dist/commands/export.d.ts +27 -0
- package/dist/commands/export.d.ts.map +1 -0
- package/dist/commands/export.js +155 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/import.d.ts +27 -0
- package/dist/commands/import.d.ts.map +1 -0
- package/dist/commands/import.js +124 -0
- package/dist/commands/import.js.map +1 -0
- package/dist/commands/index/scan.d.ts.map +1 -1
- package/dist/commands/index/scan.js +24 -5
- package/dist/commands/index/scan.js.map +1 -1
- package/dist/commands/knowledge/amend.d.ts +1 -0
- package/dist/commands/knowledge/amend.d.ts.map +1 -1
- package/dist/commands/knowledge/amend.js +11 -2
- package/dist/commands/knowledge/amend.js.map +1 -1
- package/dist/commands/knowledge/attach.d.ts +19 -0
- package/dist/commands/knowledge/attach.d.ts.map +1 -0
- package/dist/commands/knowledge/attach.js +51 -0
- package/dist/commands/knowledge/attach.js.map +1 -0
- package/dist/commands/knowledge/create.d.ts +9 -1
- package/dist/commands/knowledge/create.d.ts.map +1 -1
- package/dist/commands/knowledge/create.js +26 -4
- package/dist/commands/knowledge/create.js.map +1 -1
- package/dist/commands/knowledge/update.d.ts +1 -0
- package/dist/commands/knowledge/update.d.ts.map +1 -1
- package/dist/commands/knowledge/update.js +4 -1
- package/dist/commands/knowledge/update.js.map +1 -1
- package/dist/commands/login.d.ts +19 -3
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +113 -64
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logout.d.ts +2 -0
- package/dist/commands/logout.d.ts.map +1 -1
- package/dist/commands/logout.js +35 -1
- package/dist/commands/logout.js.map +1 -1
- package/dist/commands/mcp/serve.d.ts +16 -0
- package/dist/commands/mcp/serve.d.ts.map +1 -0
- package/dist/commands/mcp/serve.js +50 -0
- package/dist/commands/mcp/serve.js.map +1 -0
- package/dist/commands/menu.d.ts.map +1 -1
- package/dist/commands/menu.js +39 -3
- package/dist/commands/menu.js.map +1 -1
- package/dist/commands/peer/accept-fingerprint.d.ts +17 -0
- package/dist/commands/peer/accept-fingerprint.d.ts.map +1 -0
- package/dist/commands/peer/accept-fingerprint.js +35 -0
- package/dist/commands/peer/accept-fingerprint.js.map +1 -0
- package/dist/commands/peer/add.d.ts +22 -0
- package/dist/commands/peer/add.d.ts.map +1 -0
- package/dist/commands/peer/add.js +44 -0
- package/dist/commands/peer/add.js.map +1 -0
- package/dist/commands/peer/cancel.d.ts +13 -0
- package/dist/commands/peer/cancel.d.ts.map +1 -0
- package/dist/commands/peer/cancel.js +20 -0
- package/dist/commands/peer/cancel.js.map +1 -0
- package/dist/commands/peer/link.d.ts +16 -0
- package/dist/commands/peer/link.d.ts.map +1 -0
- package/dist/commands/peer/link.js +32 -0
- package/dist/commands/peer/link.js.map +1 -0
- package/dist/commands/peer/links.d.ts +12 -0
- package/dist/commands/peer/links.d.ts.map +1 -0
- package/dist/commands/peer/links.js +25 -0
- package/dist/commands/peer/links.js.map +1 -0
- package/dist/commands/peer/list.d.ts +10 -0
- package/dist/commands/peer/list.d.ts.map +1 -0
- package/dist/commands/peer/list.js +22 -0
- package/dist/commands/peer/list.js.map +1 -0
- package/dist/commands/peer/pull.d.ts +19 -0
- package/dist/commands/peer/pull.d.ts.map +1 -0
- package/dist/commands/peer/pull.js +30 -0
- package/dist/commands/peer/pull.js.map +1 -0
- package/dist/commands/peer/push.d.ts +19 -0
- package/dist/commands/peer/push.d.ts.map +1 -0
- package/dist/commands/peer/push.js +30 -0
- package/dist/commands/peer/push.js.map +1 -0
- package/dist/commands/peer/remove.d.ts +12 -0
- package/dist/commands/peer/remove.d.ts.map +1 -0
- package/dist/commands/peer/remove.js +19 -0
- package/dist/commands/peer/remove.js.map +1 -0
- package/dist/commands/peer/rotate-key.d.ts +14 -0
- package/dist/commands/peer/rotate-key.d.ts.map +1 -0
- package/dist/commands/peer/rotate-key.js +26 -0
- package/dist/commands/peer/rotate-key.js.map +1 -0
- package/dist/commands/peer/run.d.ts +13 -0
- package/dist/commands/peer/run.d.ts.map +1 -0
- package/dist/commands/peer/run.js +31 -0
- package/dist/commands/peer/run.js.map +1 -0
- package/dist/commands/peer/runs.d.ts +15 -0
- package/dist/commands/peer/runs.d.ts.map +1 -0
- package/dist/commands/peer/runs.js +32 -0
- package/dist/commands/peer/runs.js.map +1 -0
- package/dist/commands/peer/test.d.ts +13 -0
- package/dist/commands/peer/test.d.ts.map +1 -0
- package/dist/commands/peer/test.js +30 -0
- package/dist/commands/peer/test.js.map +1 -0
- package/dist/commands/peer/unlink.d.ts +13 -0
- package/dist/commands/peer/unlink.d.ts.map +1 -0
- package/dist/commands/peer/unlink.js +20 -0
- package/dist/commands/peer/unlink.js.map +1 -0
- package/dist/commands/pg/status.d.ts.map +1 -1
- package/dist/commands/pg/status.js +6 -3
- package/dist/commands/pg/status.js.map +1 -1
- package/dist/commands/pg/up.d.ts.map +1 -1
- package/dist/commands/pg/up.js +9 -4
- package/dist/commands/pg/up.js.map +1 -1
- package/dist/commands/platform/status.d.ts.map +1 -1
- package/dist/commands/platform/status.js +4 -4
- package/dist/commands/platform/status.js.map +1 -1
- package/dist/commands/profile/purge.d.ts +20 -0
- package/dist/commands/profile/purge.d.ts.map +1 -0
- package/dist/commands/profile/purge.js +43 -0
- package/dist/commands/profile/purge.js.map +1 -0
- package/dist/commands/repo/context.d.ts.map +1 -1
- package/dist/commands/repo/context.js +3 -1
- package/dist/commands/repo/context.js.map +1 -1
- package/dist/commands/repo/graph.d.ts +3 -6
- package/dist/commands/repo/graph.d.ts.map +1 -1
- package/dist/commands/repo/graph.js +24 -40
- package/dist/commands/repo/graph.js.map +1 -1
- package/dist/commands/repo/index/index.d.ts +1 -0
- package/dist/commands/repo/index/index.d.ts.map +1 -1
- package/dist/commands/repo/index/index.js +100 -12
- package/dist/commands/repo/index/index.js.map +1 -1
- package/dist/commands/repo/search.d.ts.map +1 -1
- package/dist/commands/repo/search.js +2 -0
- package/dist/commands/repo/search.js.map +1 -1
- package/dist/commands/repo/setup.d.ts +9 -2
- package/dist/commands/repo/setup.d.ts.map +1 -1
- package/dist/commands/repo/setup.js +84 -8
- package/dist/commands/repo/setup.js.map +1 -1
- package/dist/commands/status.d.ts +4 -0
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +21 -3
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/transfer.d.ts +30 -0
- package/dist/commands/transfer.d.ts.map +1 -0
- package/dist/commands/transfer.js +140 -0
- package/dist/commands/transfer.js.map +1 -0
- package/dist/commands/tui.js +1 -1
- package/dist/commands/tui.js.map +1 -1
- package/dist/commands/up.d.ts +6 -27
- package/dist/commands/up.d.ts.map +1 -1
- package/dist/commands/up.js +63 -21
- package/dist/commands/up.js.map +1 -1
- package/dist/lib/attach.d.ts +48 -0
- package/dist/lib/attach.d.ts.map +1 -0
- package/dist/lib/attach.js +91 -0
- package/dist/lib/attach.js.map +1 -0
- package/dist/lib/chat-render.d.ts +39 -0
- package/dist/lib/chat-render.d.ts.map +1 -0
- package/dist/lib/chat-render.js +77 -0
- package/dist/lib/chat-render.js.map +1 -0
- package/dist/lib/cmek-guard.d.ts +52 -0
- package/dist/lib/cmek-guard.d.ts.map +1 -0
- package/dist/lib/cmek-guard.js +73 -0
- package/dist/lib/cmek-guard.js.map +1 -0
- package/dist/lib/content.d.ts +7 -0
- package/dist/lib/content.d.ts.map +1 -1
- package/dist/lib/content.js +9 -2
- package/dist/lib/content.js.map +1 -1
- package/dist/lib/credential-purge.d.ts +52 -0
- package/dist/lib/credential-purge.d.ts.map +1 -0
- package/dist/lib/credential-purge.js +37 -0
- package/dist/lib/credential-purge.js.map +1 -0
- package/dist/lib/ingest.d.ts.map +1 -1
- package/dist/lib/ingest.js +7 -3
- package/dist/lib/ingest.js.map +1 -1
- package/dist/lib/local-mcp-server.d.ts +82 -0
- package/dist/lib/local-mcp-server.d.ts.map +1 -0
- package/dist/lib/local-mcp-server.js +252 -0
- package/dist/lib/local-mcp-server.js.map +1 -0
- package/dist/lib/local-mcp-stdio.d.ts +8 -0
- package/dist/lib/local-mcp-stdio.d.ts.map +1 -0
- package/dist/lib/local-mcp-stdio.js +50 -0
- package/dist/lib/local-mcp-stdio.js.map +1 -0
- package/dist/lib/login-guided.d.ts +20 -0
- package/dist/lib/login-guided.d.ts.map +1 -0
- package/dist/lib/login-guided.js +89 -0
- package/dist/lib/login-guided.js.map +1 -0
- package/dist/lib/login.d.ts +58 -12
- package/dist/lib/login.d.ts.map +1 -1
- package/dist/lib/login.js +170 -12
- package/dist/lib/login.js.map +1 -1
- package/dist/lib/onboarding.d.ts +56 -0
- package/dist/lib/onboarding.d.ts.map +1 -0
- package/dist/lib/onboarding.js +67 -0
- package/dist/lib/onboarding.js.map +1 -0
- package/dist/lib/peer-command.d.ts +51 -0
- package/dist/lib/peer-command.d.ts.map +1 -0
- package/dist/lib/peer-command.js +120 -0
- package/dist/lib/peer-command.js.map +1 -0
- package/dist/lib/peer-support.d.ts +67 -0
- package/dist/lib/peer-support.d.ts.map +1 -0
- package/dist/lib/peer-support.js +154 -0
- package/dist/lib/peer-support.js.map +1 -0
- package/dist/lib/platform-edition.d.ts +34 -0
- package/dist/lib/platform-edition.d.ts.map +1 -0
- package/dist/lib/platform-edition.js +47 -0
- package/dist/lib/platform-edition.js.map +1 -0
- package/dist/lib/platform-frontdoor-runtime.d.ts.map +1 -1
- package/dist/lib/platform-frontdoor-runtime.js +32 -1
- package/dist/lib/platform-frontdoor-runtime.js.map +1 -1
- package/dist/lib/platform-frontdoor.d.ts +26 -2
- package/dist/lib/platform-frontdoor.d.ts.map +1 -1
- package/dist/lib/platform-frontdoor.js +363 -126
- package/dist/lib/platform-frontdoor.js.map +1 -1
- package/dist/lib/platform-lifecycle.d.ts +7 -0
- package/dist/lib/platform-lifecycle.d.ts.map +1 -1
- package/dist/lib/platform-lifecycle.js +14 -3
- package/dist/lib/platform-lifecycle.js.map +1 -1
- package/dist/lib/platform-onboarding.d.ts +1 -0
- package/dist/lib/platform-onboarding.d.ts.map +1 -1
- package/dist/lib/platform-onboarding.js +13 -2
- package/dist/lib/platform-onboarding.js.map +1 -1
- package/dist/lib/platform-profile-purge.d.ts +1 -1
- package/dist/lib/platform-profile-purge.d.ts.map +1 -1
- package/dist/lib/platform-profile-purge.js +2 -1
- package/dist/lib/platform-profile-purge.js.map +1 -1
- package/dist/lib/platform-provider-prompt.d.ts +4 -0
- package/dist/lib/platform-provider-prompt.d.ts.map +1 -1
- package/dist/lib/platform-provider-prompt.js +4 -0
- package/dist/lib/platform-provider-prompt.js.map +1 -1
- package/dist/lib/platform-release-manifest.d.ts +15 -1
- package/dist/lib/platform-release-manifest.d.ts.map +1 -1
- package/dist/lib/platform-release-manifest.js +24 -0
- package/dist/lib/platform-release-manifest.js.map +1 -1
- package/dist/lib/portability-shared.d.ts +49 -0
- package/dist/lib/portability-shared.d.ts.map +1 -0
- package/dist/lib/portability-shared.js +220 -0
- package/dist/lib/portability-shared.js.map +1 -0
- package/dist/lib/project-mcp-config.d.ts +14 -0
- package/dist/lib/project-mcp-config.d.ts.map +1 -0
- package/dist/lib/project-mcp-config.js +78 -0
- package/dist/lib/project-mcp-config.js.map +1 -0
- package/dist/lib/release-package-graph.d.ts +154 -0
- package/dist/lib/release-package-graph.d.ts.map +1 -0
- package/dist/lib/release-package-graph.js +249 -0
- package/dist/lib/release-package-graph.js.map +1 -0
- package/dist/lib/repo-binding.d.ts +7 -2
- package/dist/lib/repo-binding.d.ts.map +1 -1
- package/dist/lib/repo-binding.js +131 -18
- package/dist/lib/repo-binding.js.map +1 -1
- package/dist/lib/repo-command-support.d.ts +3 -1
- package/dist/lib/repo-command-support.d.ts.map +1 -1
- package/dist/lib/repo-command-support.js.map +1 -1
- package/dist/lib/repo-local-mcp-backend.d.ts +65 -0
- package/dist/lib/repo-local-mcp-backend.d.ts.map +1 -0
- package/dist/lib/repo-local-mcp-backend.js +288 -0
- package/dist/lib/repo-local-mcp-backend.js.map +1 -0
- package/dist/lib/repo-local-mcp-runtime.d.ts +17 -0
- package/dist/lib/repo-local-mcp-runtime.d.ts.map +1 -0
- package/dist/lib/repo-local-mcp-runtime.js +136 -0
- package/dist/lib/repo-local-mcp-runtime.js.map +1 -0
- package/dist/lib/repo-scope-migration.d.ts +4 -0
- package/dist/lib/repo-scope-migration.d.ts.map +1 -0
- package/dist/lib/repo-scope-migration.js +55 -0
- package/dist/lib/repo-scope-migration.js.map +1 -0
- package/dist/lib/repo-scope.d.ts +9 -0
- package/dist/lib/repo-scope.d.ts.map +1 -0
- package/dist/lib/repo-scope.js +15 -0
- package/dist/lib/repo-scope.js.map +1 -0
- package/dist/lib/safe-file.d.ts +141 -0
- package/dist/lib/safe-file.d.ts.map +1 -0
- package/dist/lib/safe-file.js +296 -0
- package/dist/lib/safe-file.js.map +1 -0
- package/dist/lib/selfhosted-lifecycle.d.ts +78 -0
- package/dist/lib/selfhosted-lifecycle.d.ts.map +1 -0
- package/dist/lib/selfhosted-lifecycle.js +195 -0
- package/dist/lib/selfhosted-lifecycle.js.map +1 -0
- package/dist/lib/setup-console.d.ts +1 -1
- package/dist/lib/setup-console.d.ts.map +1 -1
- package/dist/lib/setup-console.js +3 -1
- package/dist/lib/setup-console.js.map +1 -1
- package/dist/lib/setup-page.d.ts.map +1 -1
- package/dist/lib/setup-page.js +28 -10
- package/dist/lib/setup-page.js.map +1 -1
- package/dist/lib/setup-plan.d.ts +4 -1
- package/dist/lib/setup-plan.d.ts.map +1 -1
- package/dist/lib/setup-plan.js +10 -2
- package/dist/lib/setup-plan.js.map +1 -1
- package/dist/lib/setup-server.d.ts.map +1 -1
- package/dist/lib/setup-server.js +19 -3
- package/dist/lib/setup-server.js.map +1 -1
- package/dist/lib/sso-login.d.ts +42 -0
- package/dist/lib/sso-login.d.ts.map +1 -0
- package/dist/lib/sso-login.js +135 -0
- package/dist/lib/sso-login.js.map +1 -0
- package/dist/lib/transfer.d.ts +80 -0
- package/dist/lib/transfer.d.ts.map +1 -0
- package/dist/lib/transfer.js +173 -0
- package/dist/lib/transfer.js.map +1 -0
- package/dist/lib/tui.d.ts +0 -6
- package/dist/lib/tui.d.ts.map +1 -1
- package/dist/lib/tui.js +6 -1
- package/dist/lib/tui.js.map +1 -1
- package/dist/lib/ui.js +1 -1
- package/dist/lib/ui.js.map +1 -1
- package/dist/lib/up-result.d.ts +46 -0
- package/dist/lib/up-result.d.ts.map +1 -0
- package/dist/lib/up-result.js +25 -0
- package/dist/lib/up-result.js.map +1 -0
- package/dist/menu/run.d.ts +7 -0
- package/dist/menu/run.d.ts.map +1 -1
- package/dist/menu/run.js +38 -2
- package/dist/menu/run.js.map +1 -1
- package/oclif.manifest.json +3585 -1532
- package/package.json +19 -13
package/dist/lib/login.d.ts
CHANGED
|
@@ -1,16 +1,32 @@
|
|
|
1
1
|
import { type CredentialStore, type KnowzConfig, type KeyType } from '@knowzai/core';
|
|
2
|
-
import type { RegisterResult, VerifyResult } from '@knowzai/types';
|
|
3
|
-
export type LoginMode = 'paste' | 'register' | 'self-hosted';
|
|
2
|
+
import type { CreateApiKeyRequest, CreatedApiKey, LoginTokenResult, RegisterResult, RegisterTenantRequest, VerifyResult } from '@knowzai/types';
|
|
3
|
+
export type LoginMode = 'paste' | 'register' | 'self-hosted' | 'sso';
|
|
4
|
+
/**
|
|
5
|
+
* 13+ attestation the API requires on new-account creation. Mirrors
|
|
6
|
+
* `AgeEligibilityCopy` on the server and `AGE_ELIGIBILITY_COPY_VERSION` in the
|
|
7
|
+
* web client — bump together when the copy changes.
|
|
8
|
+
*/
|
|
9
|
+
export declare const AGE_ELIGIBILITY_COPY_VERSION = "age_eligibility.v1";
|
|
10
|
+
export declare const AGE_ELIGIBILITY_SURFACE = "cli_register";
|
|
11
|
+
export declare const AGE_ELIGIBILITY_TEXT = "I confirm I am at least 13 years old. Knowz is not available to people under 13.";
|
|
12
|
+
export declare const AGE_ELIGIBILITY_UNDER_13_MESSAGE = "Knowz is not available to people under 13. No account was created.";
|
|
13
|
+
export interface RegisterInput {
|
|
14
|
+
name: string;
|
|
15
|
+
email: string;
|
|
16
|
+
/**
|
|
17
|
+
* Required whenever the server does not hand back an API key at registration
|
|
18
|
+
* (the current contract): the CLI signs in with it and then creates a key.
|
|
19
|
+
*/
|
|
20
|
+
password?: string;
|
|
21
|
+
/** The person explicitly confirmed the 13+ attestation. */
|
|
22
|
+
ageAttested?: boolean;
|
|
23
|
+
}
|
|
4
24
|
export interface LoginInput {
|
|
5
25
|
profile: string;
|
|
6
26
|
apiUrl: string;
|
|
7
27
|
mode: LoginMode;
|
|
8
28
|
key?: string;
|
|
9
|
-
register?:
|
|
10
|
-
name: string;
|
|
11
|
-
email: string;
|
|
12
|
-
password?: string;
|
|
13
|
-
};
|
|
29
|
+
register?: RegisterInput;
|
|
14
30
|
storeTenantKey?: boolean;
|
|
15
31
|
force?: boolean;
|
|
16
32
|
}
|
|
@@ -19,17 +35,47 @@ export interface LoginDeps {
|
|
|
19
35
|
config: KnowzConfig;
|
|
20
36
|
saveConfig: (cfg: KnowzConfig) => void;
|
|
21
37
|
validateKey: (apiKey: string) => Promise<VerifyResult>;
|
|
22
|
-
register: (req:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
38
|
+
register: (req: RegisterTenantRequest) => Promise<RegisterResult>;
|
|
39
|
+
/** Email/password sign-in (`POST /api/v1/users/login`) — yields a bearer token. */
|
|
40
|
+
signIn: (req: {
|
|
41
|
+
usernameOrEmail: string;
|
|
42
|
+
password: string;
|
|
43
|
+
}) => Promise<LoginTokenResult>;
|
|
44
|
+
/** Explicit key creation (`POST /api/v1/api-keys`) authenticated with that token. */
|
|
45
|
+
createApiKey: (req: CreateApiKeyRequest, token: string) => Promise<CreatedApiKey>;
|
|
46
|
+
/**
|
|
47
|
+
* Interactive "replace the credentials this profile already holds?" prompt.
|
|
48
|
+
* Absent means non-interactive (scripts, `--json`, no TTY): a wrong-tenant
|
|
49
|
+
* overwrite is refused outright and a same-tenant key rotation goes through.
|
|
50
|
+
*/
|
|
51
|
+
confirmReplace?: (ctx: ReplaceContext) => Promise<boolean>;
|
|
52
|
+
}
|
|
53
|
+
/** Which tenant a profile is bound to, as far as we can name it. */
|
|
54
|
+
export interface TenantRef {
|
|
55
|
+
id?: string;
|
|
56
|
+
name?: string;
|
|
57
|
+
}
|
|
58
|
+
/** What `confirmReplace` is being asked about. Never carries a key. */
|
|
59
|
+
export interface ReplaceContext {
|
|
60
|
+
profile: string;
|
|
61
|
+
/** True when the incoming key belongs to the tenant the profile already holds. */
|
|
62
|
+
sameTenant: boolean;
|
|
63
|
+
current: TenantRef;
|
|
64
|
+
incoming: TenantRef;
|
|
27
65
|
}
|
|
66
|
+
/** "Alex Space (0f0…)"-style label: name when the server gave us one, else the id. */
|
|
67
|
+
export declare function tenantLabel(ref: TenantRef | undefined): string;
|
|
28
68
|
export interface LoginResult {
|
|
29
69
|
profile: string;
|
|
30
70
|
keyType?: KeyType;
|
|
31
71
|
tenantId?: string;
|
|
72
|
+
/** Display name of the tenant, when the server reported one. */
|
|
73
|
+
tenantName?: string;
|
|
32
74
|
email?: string;
|
|
75
|
+
/** True when the key was minted explicitly after registering (the normal path). */
|
|
76
|
+
createdApiKey?: boolean;
|
|
77
|
+
/** True when the profile already held a key for this same tenant (rotation). */
|
|
78
|
+
alreadyRegistered?: boolean;
|
|
33
79
|
}
|
|
34
80
|
/**
|
|
35
81
|
* Verify-on-login, persist-after-verify (S-N3-6). Never returns or logs the key.
|
package/dist/lib/login.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/lib/login.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/lib/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,OAAO,EACb,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAEV,mBAAmB,EACnB,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,YAAY,EACb,MAAM,gBAAgB,CAAC;AAGxB,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,UAAU,GAAG,aAAa,GAAG,KAAK,CAAC;AAErE;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,uBAAuB,CAAC;AACjE,eAAO,MAAM,uBAAuB,iBAAiB,CAAC;AACtD,eAAO,MAAM,oBAAoB,qFACmD,CAAC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AAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,uEAAuE;AACvE,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,kFAAkF;IAClF,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,SAAS,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,sFAAsF;AACtF,wBAAgB,WAAW,CAAC,GAAG,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,CAK9D;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gEAAgE;IAChE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mFAAmF;IACnF,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,gFAAgF;IAChF,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAkHD;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAwG3F"}
|
package/dist/lib/login.js
CHANGED
|
@@ -1,4 +1,118 @@
|
|
|
1
|
-
import { KnowzError, ExitCode, enforceTls, validateKeyFormat, keyType, } from '@knowzai/core';
|
|
1
|
+
import { KnowzError, ExitCode, enforceTls, registerSecret, validateKeyFormat, keyType, } from '@knowzai/core';
|
|
2
|
+
import { quoteArg } from './claude-hooks.js';
|
|
3
|
+
/**
|
|
4
|
+
* 13+ attestation the API requires on new-account creation. Mirrors
|
|
5
|
+
* `AgeEligibilityCopy` on the server and `AGE_ELIGIBILITY_COPY_VERSION` in the
|
|
6
|
+
* web client — bump together when the copy changes.
|
|
7
|
+
*/
|
|
8
|
+
export const AGE_ELIGIBILITY_COPY_VERSION = 'age_eligibility.v1';
|
|
9
|
+
export const AGE_ELIGIBILITY_SURFACE = 'cli_register';
|
|
10
|
+
export const AGE_ELIGIBILITY_TEXT = 'I confirm I am at least 13 years old. Knowz is not available to people under 13.';
|
|
11
|
+
export const AGE_ELIGIBILITY_UNDER_13_MESSAGE = 'Knowz is not available to people under 13. No account was created.';
|
|
12
|
+
/** "Alex Space (0f0…)"-style label: name when the server gave us one, else the id. */
|
|
13
|
+
export function tenantLabel(ref) {
|
|
14
|
+
const name = ref?.name?.trim();
|
|
15
|
+
const id = ref?.id?.trim();
|
|
16
|
+
if (name && id)
|
|
17
|
+
return `${name} (${id})`;
|
|
18
|
+
return name || id || 'an unknown tenant';
|
|
19
|
+
}
|
|
20
|
+
/** Label the key carries in the workspace's key list, so it is recognizable there. */
|
|
21
|
+
function apiKeyName(profile) {
|
|
22
|
+
return `knowz CLI (${profile})`;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Register, then obtain a real API key. Registration no longer returns one
|
|
26
|
+
* (#661: `PersonalApiKey` is documented as always null), so the CLI signs in
|
|
27
|
+
* with the password and calls `POST /api/v1/api-keys`. A legacy build that
|
|
28
|
+
* still mints keys is honored as-is — no second key is created.
|
|
29
|
+
*/
|
|
30
|
+
async function keyForRegistration(input, deps, reg) {
|
|
31
|
+
const wantTenantKey = Boolean(input.storeTenantKey);
|
|
32
|
+
const res = await deps
|
|
33
|
+
.register({
|
|
34
|
+
name: reg.name,
|
|
35
|
+
email: reg.email,
|
|
36
|
+
...(reg.password === undefined ? {} : { password: reg.password }),
|
|
37
|
+
// Only sent when the person actually attested — never auto-checked.
|
|
38
|
+
...(reg.ageAttested
|
|
39
|
+
? {
|
|
40
|
+
ageEligibilityAttested: true,
|
|
41
|
+
ageEligibilityCopyVersion: AGE_ELIGIBILITY_COPY_VERSION,
|
|
42
|
+
ageEligibilitySurface: AGE_ELIGIBILITY_SURFACE,
|
|
43
|
+
}
|
|
44
|
+
: {}),
|
|
45
|
+
})
|
|
46
|
+
.catch((e) => {
|
|
47
|
+
// The server enforces the 13+ gate; point at the flag that satisfies it.
|
|
48
|
+
const text = e instanceof Error ? e.message : String(e);
|
|
49
|
+
if (!reg.ageAttested && /at least 13|age confirmation|AGE_ELIGIBILITY/i.test(text)) {
|
|
50
|
+
throw new KnowzError(`${text} Pass --age-13-plus to confirm.`, ExitCode.Usage);
|
|
51
|
+
}
|
|
52
|
+
throw e;
|
|
53
|
+
});
|
|
54
|
+
const legacy = wantTenantKey ? res.apiKey : res.userApiKey;
|
|
55
|
+
if (legacy && validateKeyFormat(legacy.trim()).ok) {
|
|
56
|
+
return { key: legacy.trim(), created: false, tenantId: res.tenantId, userId: res.userId };
|
|
57
|
+
}
|
|
58
|
+
// No usable key in the response → sign in (or reuse a token the register
|
|
59
|
+
// endpoint issued) and create one explicitly.
|
|
60
|
+
let token = res.token;
|
|
61
|
+
let tenantId = res.tenantId;
|
|
62
|
+
let userId = res.userId;
|
|
63
|
+
if (!token) {
|
|
64
|
+
if (!reg.password) {
|
|
65
|
+
throw new KnowzError('Registration does not return an API key any more; the CLI has to sign in and create one. ' +
|
|
66
|
+
'Re-run with --password (it is also the password for the web app).', ExitCode.Usage);
|
|
67
|
+
}
|
|
68
|
+
const session = await deps.signIn({ usernameOrEmail: reg.email, password: reg.password });
|
|
69
|
+
token = session.token;
|
|
70
|
+
tenantId = session.tenantId || tenantId;
|
|
71
|
+
userId = session.userId ?? userId;
|
|
72
|
+
}
|
|
73
|
+
registerSecret(token);
|
|
74
|
+
const wanted = wantTenantKey ? 'tenant' : 'user';
|
|
75
|
+
const created = await deps.createApiKey({ name: apiKeyName(input.profile), keyType: wanted }, token);
|
|
76
|
+
const key = created.key?.trim();
|
|
77
|
+
if (!key) {
|
|
78
|
+
throw new KnowzError('Creating an API key after registration failed: the server returned no key.', ExitCode.Auth);
|
|
79
|
+
}
|
|
80
|
+
const fmt = validateKeyFormat(key);
|
|
81
|
+
if (!fmt.ok) {
|
|
82
|
+
throw new KnowzError(`Creating an API key after registration failed: ${fmt.reason}`, ExitCode.Auth);
|
|
83
|
+
}
|
|
84
|
+
return { key, created: true, tenantId, userId };
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Best-effort display name for the tenant a profile is already bound to. The
|
|
88
|
+
* stored key is the only thing that knows it, so we re-validate it — but a
|
|
89
|
+
* revoked/offline key must not turn an explanatory message into a failure, so
|
|
90
|
+
* every error degrades to "no name" and the caller falls back to the id.
|
|
91
|
+
*/
|
|
92
|
+
async function storedTenantName(storedKey, storedTenantId, deps) {
|
|
93
|
+
try {
|
|
94
|
+
const v = await deps.validateKey(storedKey);
|
|
95
|
+
if (!v.isValid)
|
|
96
|
+
return undefined;
|
|
97
|
+
// Guard against a stale binding: only trust the name if it is this tenant.
|
|
98
|
+
if (storedTenantId && v.tenant?.id && v.tenant.id !== storedTenantId)
|
|
99
|
+
return undefined;
|
|
100
|
+
return v.tenant?.name;
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function sameApiUrl(left, right) {
|
|
107
|
+
if (!left)
|
|
108
|
+
return false;
|
|
109
|
+
try {
|
|
110
|
+
return new URL(left).href.replace(/\/+$/u, '') === new URL(right).href.replace(/\/+$/u, '');
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
2
116
|
/**
|
|
3
117
|
* Verify-on-login, persist-after-verify (S-N3-6). Never returns or logs the key.
|
|
4
118
|
* Throws KnowzError(Auth) on rejected credentials, KnowzError(Usage) on bad
|
|
@@ -9,14 +123,22 @@ export async function performLogin(input, deps) {
|
|
|
9
123
|
let key;
|
|
10
124
|
let verify;
|
|
11
125
|
let email;
|
|
126
|
+
let createdApiKey = false;
|
|
127
|
+
if (input.mode === 'sso') {
|
|
128
|
+
throw new KnowzError('SSO login must mint a key before persist', ExitCode.Usage);
|
|
129
|
+
}
|
|
12
130
|
if (input.mode === 'register') {
|
|
13
131
|
if (!input.register?.email || !input.register?.name) {
|
|
14
132
|
throw new KnowzError('register requires --email and --name', ExitCode.Usage);
|
|
15
133
|
}
|
|
16
|
-
const
|
|
17
|
-
key =
|
|
134
|
+
const reg = await keyForRegistration(input, deps, input.register);
|
|
135
|
+
key = reg.key;
|
|
136
|
+
createdApiKey = reg.created;
|
|
18
137
|
email = input.register.email;
|
|
19
|
-
|
|
138
|
+
// The key was just issued by an authenticated call, so it needs no second
|
|
139
|
+
// round-trip to validate — re-verifying would also fail on a tenant that
|
|
140
|
+
// starts in the Pending activation state.
|
|
141
|
+
verify = { isValid: true, tenant: { id: reg.tenantId ?? '' }, user: { id: reg.userId ?? '', email } };
|
|
20
142
|
}
|
|
21
143
|
else {
|
|
22
144
|
if (!input.key)
|
|
@@ -31,26 +153,62 @@ export async function performLogin(input, deps) {
|
|
|
31
153
|
}
|
|
32
154
|
email = verify.user?.email;
|
|
33
155
|
}
|
|
34
|
-
|
|
156
|
+
registerSecret(key);
|
|
157
|
+
// Already-registered guard (S-N3-6, #669). A profile that already holds a key
|
|
158
|
+
// is never silently re-pointed: a different tenant is refused without --force,
|
|
159
|
+
// and even a same-tenant rotation asks first when there is someone to ask.
|
|
35
160
|
const existing = await deps.store.getSecret(input.profile);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
161
|
+
const existingTenantId = deps.config.profiles[input.profile]?.tenantId;
|
|
162
|
+
const incoming = { id: verify.tenant?.id, name: verify.tenant?.name };
|
|
163
|
+
const sameTenant = Boolean(existing && existingTenantId && incoming.id && existingTenantId === incoming.id);
|
|
164
|
+
const differentTenant = Boolean(existing && existingTenantId && incoming.id && existingTenantId !== incoming.id);
|
|
165
|
+
// Without a prompt, a same-tenant rotation needs no decision and no explanation,
|
|
166
|
+
// so it must not pay for the extra round-trip the tenant name costs.
|
|
167
|
+
const needsDecision = !input.force && (sameTenant || differentTenant) && (Boolean(deps.confirmReplace) || differentTenant);
|
|
168
|
+
if (needsDecision) {
|
|
169
|
+
// Only now is a name worth a round-trip: we are about to talk to a human.
|
|
170
|
+
const storedApiUrl = deps.config.profiles[input.profile]?.apiUrl;
|
|
171
|
+
const current = {
|
|
172
|
+
id: existingTenantId,
|
|
173
|
+
name: sameApiUrl(storedApiUrl, input.apiUrl)
|
|
174
|
+
? await storedTenantName(existing, existingTenantId, deps)
|
|
175
|
+
: undefined,
|
|
176
|
+
};
|
|
177
|
+
const ctx = { profile: input.profile, sameTenant, current, incoming };
|
|
178
|
+
const confirmed = deps.confirmReplace
|
|
179
|
+
? await deps.confirmReplace(ctx)
|
|
180
|
+
: // No prompt available: rotating the same tenant's key is safe, moving the
|
|
181
|
+
// profile to another tenant is not.
|
|
182
|
+
sameTenant;
|
|
183
|
+
if (!confirmed) {
|
|
184
|
+
const quotedProfile = quoteArg(input.profile);
|
|
185
|
+
throw new KnowzError(differentTenant
|
|
186
|
+
? `Profile '${input.profile}' is already registered to tenant ${tenantLabel(current)}. ` +
|
|
187
|
+
`The key you provided belongs to tenant ${tenantLabel(incoming)}. ` +
|
|
188
|
+
`Nothing was changed. To replace it, re-run: knowz login --profile ${quotedProfile} --force`
|
|
189
|
+
: `Profile '${input.profile}' is already registered to tenant ${tenantLabel(current)}. ` +
|
|
190
|
+
`The stored key was left unchanged. To replace it, re-run: knowz login --profile ${quotedProfile} --force`, ExitCode.Usage);
|
|
41
191
|
}
|
|
42
192
|
}
|
|
43
193
|
await deps.store.setSecret(input.profile, key);
|
|
44
194
|
const prev = deps.config.profiles[input.profile];
|
|
45
195
|
deps.config.profiles[input.profile] = {
|
|
46
196
|
apiUrl: input.apiUrl,
|
|
47
|
-
tenantId: verify.tenant?.id
|
|
197
|
+
tenantId: verify.tenant?.id || prev?.tenantId,
|
|
48
198
|
email: email ?? prev?.email,
|
|
49
199
|
label: prev?.label,
|
|
50
200
|
defaultVaultId: prev?.defaultVaultId,
|
|
51
201
|
};
|
|
52
202
|
deps.config.activeProfile = input.profile;
|
|
53
203
|
deps.saveConfig(deps.config);
|
|
54
|
-
return {
|
|
204
|
+
return {
|
|
205
|
+
profile: input.profile,
|
|
206
|
+
keyType: keyType(key),
|
|
207
|
+
tenantId: verify.tenant?.id || undefined,
|
|
208
|
+
...(verify.tenant?.name ? { tenantName: verify.tenant.name } : {}),
|
|
209
|
+
email,
|
|
210
|
+
...(createdApiKey ? { createdApiKey: true } : {}),
|
|
211
|
+
...(sameTenant ? { alreadyRegistered: true } : {}),
|
|
212
|
+
};
|
|
55
213
|
}
|
|
56
214
|
//# sourceMappingURL=login.js.map
|
package/dist/lib/login.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/lib/login.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,QAAQ,EACR,UAAU,EACV,iBAAiB,EACjB,OAAO,GAIR,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/lib/login.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,QAAQ,EACR,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,OAAO,GAIR,MAAM,eAAe,CAAC;AAUvB,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAI7C;;;;GAIG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,oBAAoB,CAAC;AACjE,MAAM,CAAC,MAAM,uBAAuB,GAAG,cAAc,CAAC;AACtD,MAAM,CAAC,MAAM,oBAAoB,GAC/B,kFAAkF,CAAC;AACrF,MAAM,CAAC,MAAM,gCAAgC,GAC3C,oEAAoE,CAAC;AAyDvE,sFAAsF;AACtF,MAAM,UAAU,WAAW,CAAC,GAA0B;IACpD,MAAM,IAAI,GAAG,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAC/B,MAAM,EAAE,GAAG,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;IAC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AAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClE,KAAK;QACL,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACjD,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACnD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* First-run onboarding + the client-side auth gate.
|
|
3
|
+
*
|
|
4
|
+
* Two problems this module owns:
|
|
5
|
+
*
|
|
6
|
+
* 1. A freshly installed CLI had no idea whether you were signed in. Every
|
|
7
|
+
* cloud command built an *anonymous* api-client, fired the request, and let
|
|
8
|
+
* the server answer 401. That is a slow, confusing "it let me do it and
|
|
9
|
+
* then it didn't" experience — and in an interactive terminal there was
|
|
10
|
+
* nothing telling the user that `knowz login` even exists.
|
|
11
|
+
* 2. Nothing ever offered to sign you in. Login was buried at
|
|
12
|
+
* Settings → Authentication → Log in.
|
|
13
|
+
*
|
|
14
|
+
* The decision logic lives here as pure functions so it is unit-testable
|
|
15
|
+
* without a TTY, a keychain, or a network. `base-command.ts` and `menu.ts` are
|
|
16
|
+
* the only IO shells that consume it.
|
|
17
|
+
*/
|
|
18
|
+
/** Everything the gate needs to know about the current invocation. */
|
|
19
|
+
export interface AuthGateContext {
|
|
20
|
+
/** A credential is present for the resolved profile. */
|
|
21
|
+
authenticated: boolean;
|
|
22
|
+
/** Both stdin and stdout are TTYs — we may prompt. */
|
|
23
|
+
interactive: boolean;
|
|
24
|
+
/** `--json` was passed: output must stay a single machine-readable document. */
|
|
25
|
+
jsonMode: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* What a command needing the cloud API should do.
|
|
29
|
+
* - `proceed` — a credential exists, carry on.
|
|
30
|
+
* - `prompt` — interactive human terminal: offer guided login inline, then retry.
|
|
31
|
+
* - `fail` — script/CI/`--json`: never block on stdin, fail fast with exit 3.
|
|
32
|
+
*/
|
|
33
|
+
export type AuthGateDecision = 'proceed' | 'prompt' | 'fail';
|
|
34
|
+
export declare function decideAuthGate(ctx: AuthGateContext): AuthGateDecision;
|
|
35
|
+
/** True when both standard streams are a terminal, i.e. a human is watching. */
|
|
36
|
+
export declare function isInteractiveTty(streams?: {
|
|
37
|
+
stdin?: unknown;
|
|
38
|
+
stdout?: unknown;
|
|
39
|
+
}): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* The message shown when we cannot (or must not) prompt. It names the profile
|
|
42
|
+
* and backend deliberately: the single most common support question is "why is
|
|
43
|
+
* my data missing", and the answer is almost always that the CLI is pointed at
|
|
44
|
+
* a different estate than the user assumed.
|
|
45
|
+
*/
|
|
46
|
+
export declare function notAuthenticatedMessage(profile: string, apiUrl: string): string;
|
|
47
|
+
/** The inline offer shown in an interactive terminal before the guided login. */
|
|
48
|
+
export declare function loginInvitation(profile: string, apiUrl: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* Whether the interactive shell should open onboarding instead of the normal
|
|
51
|
+
* menu. Kept separate from `decideAuthGate` because the menu tolerates an
|
|
52
|
+
* anonymous session (you must be able to reach "Log in" without being logged
|
|
53
|
+
* in) — it just shouldn't *start* there silently on a fresh install.
|
|
54
|
+
*/
|
|
55
|
+
export declare function shouldOnboard(ctx: AuthGateContext): boolean;
|
|
56
|
+
//# sourceMappingURL=onboarding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onboarding.d.ts","sourceRoot":"","sources":["../../src/lib/onboarding.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,sEAAsE;AACtE,MAAM,WAAW,eAAe;IAC9B,wDAAwD;IACxD,aAAa,EAAE,OAAO,CAAC;IACvB,sDAAsD;IACtD,WAAW,EAAE,OAAO,CAAC;IACrB,gFAAgF;IAChF,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE7D,wBAAgB,cAAc,CAAC,GAAG,EAAE,eAAe,GAAG,gBAAgB,CAIrE;AAED,gFAAgF;AAChF,wBAAgB,gBAAgB,CAAC,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAY,GAAG,OAAO,CAGlG;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAW/E;AAED,iFAAiF;AACjF,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAQvE;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAE3D"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* First-run onboarding + the client-side auth gate.
|
|
3
|
+
*
|
|
4
|
+
* Two problems this module owns:
|
|
5
|
+
*
|
|
6
|
+
* 1. A freshly installed CLI had no idea whether you were signed in. Every
|
|
7
|
+
* cloud command built an *anonymous* api-client, fired the request, and let
|
|
8
|
+
* the server answer 401. That is a slow, confusing "it let me do it and
|
|
9
|
+
* then it didn't" experience — and in an interactive terminal there was
|
|
10
|
+
* nothing telling the user that `knowz login` even exists.
|
|
11
|
+
* 2. Nothing ever offered to sign you in. Login was buried at
|
|
12
|
+
* Settings → Authentication → Log in.
|
|
13
|
+
*
|
|
14
|
+
* The decision logic lives here as pure functions so it is unit-testable
|
|
15
|
+
* without a TTY, a keychain, or a network. `base-command.ts` and `menu.ts` are
|
|
16
|
+
* the only IO shells that consume it.
|
|
17
|
+
*/
|
|
18
|
+
export function decideAuthGate(ctx) {
|
|
19
|
+
if (ctx.authenticated)
|
|
20
|
+
return 'proceed';
|
|
21
|
+
if (ctx.jsonMode || !ctx.interactive)
|
|
22
|
+
return 'fail';
|
|
23
|
+
return 'prompt';
|
|
24
|
+
}
|
|
25
|
+
/** True when both standard streams are a terminal, i.e. a human is watching. */
|
|
26
|
+
export function isInteractiveTty(streams = process) {
|
|
27
|
+
const s = streams;
|
|
28
|
+
return Boolean(s.stdin?.isTTY) && Boolean(s.stdout?.isTTY);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The message shown when we cannot (or must not) prompt. It names the profile
|
|
32
|
+
* and backend deliberately: the single most common support question is "why is
|
|
33
|
+
* my data missing", and the answer is almost always that the CLI is pointed at
|
|
34
|
+
* a different estate than the user assumed.
|
|
35
|
+
*/
|
|
36
|
+
export function notAuthenticatedMessage(profile, apiUrl) {
|
|
37
|
+
let host = apiUrl;
|
|
38
|
+
try {
|
|
39
|
+
host = new URL(apiUrl).host;
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
/* keep the raw string when it isn't a URL */
|
|
43
|
+
}
|
|
44
|
+
return (`Not signed in — profile '${profile}' (${host}) has no stored API key. ` +
|
|
45
|
+
`Run \`knowz login\` to sign in, register, or connect a self-hosted instance.`);
|
|
46
|
+
}
|
|
47
|
+
/** The inline offer shown in an interactive terminal before the guided login. */
|
|
48
|
+
export function loginInvitation(profile, apiUrl) {
|
|
49
|
+
let host = apiUrl;
|
|
50
|
+
try {
|
|
51
|
+
host = new URL(apiUrl).host;
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
/* keep the raw string when it isn't a URL */
|
|
55
|
+
}
|
|
56
|
+
return `You're not signed in yet (profile '${profile}' → ${host}). Let's fix that.`;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Whether the interactive shell should open onboarding instead of the normal
|
|
60
|
+
* menu. Kept separate from `decideAuthGate` because the menu tolerates an
|
|
61
|
+
* anonymous session (you must be able to reach "Log in" without being logged
|
|
62
|
+
* in) — it just shouldn't *start* there silently on a fresh install.
|
|
63
|
+
*/
|
|
64
|
+
export function shouldOnboard(ctx) {
|
|
65
|
+
return !ctx.authenticated && ctx.interactive && !ctx.jsonMode;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=onboarding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onboarding.js","sourceRoot":"","sources":["../../src/lib/onboarding.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAoBH,MAAM,UAAU,cAAc,CAAC,GAAoB;IACjD,IAAI,GAAG,CAAC,aAAa;QAAE,OAAO,SAAS,CAAC;IACxC,IAAI,GAAG,CAAC,QAAQ,IAAI,CAAC,GAAG,CAAC,WAAW;QAAE,OAAO,MAAM,CAAC;IACpD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,gBAAgB,CAAC,UAAiD,OAAO;IACvF,MAAM,CAAC,GAAG,OAAwE,CAAC;IACnF,OAAO,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAC7D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAe,EAAE,MAAc;IACrE,IAAI,IAAI,GAAG,MAAM,CAAC;IAClB,IAAI,CAAC;QACH,IAAI,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;IAC9B,CAAC;IAAC,MAAM,CAAC;QACP,6CAA6C;IAC/C,CAAC;IACD,OAAO,CACL,4BAA4B,OAAO,MAAM,IAAI,2BAA2B;QACxE,8EAA8E,CAC/E,CAAC;AACJ,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,eAAe,CAAC,OAAe,EAAE,MAAc;IAC7D,IAAI,IAAI,GAAG,MAAM,CAAC;IAClB,IAAI,CAAC;QACH,IAAI,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;IAC9B,CAAC;IAAC,MAAM,CAAC;QACP,6CAA6C;IAC/C,CAAC;IACD,OAAO,sCAAsC,OAAO,OAAO,IAAI,oBAAoB,CAAC;AACtF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,GAAoB;IAChD,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,GAAG,CAAC,WAAW,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type KnowzApiClient, type FederationPeer, type FederationSyncOptionsInput } from '@knowzai/api-client';
|
|
2
|
+
import { BaseCommand, type GlobalFlags } from '../base-command.js';
|
|
3
|
+
export interface PeerGlobalFlags extends GlobalFlags {
|
|
4
|
+
email?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Shared shell for every `knowz peer` command (CLI_InstanceTransfer R8):
|
|
8
|
+
* builds a per-invocation Bearer-token client via `users/login` — the
|
|
9
|
+
* federation plane is JWT-only, the stored API key cannot reach it — and
|
|
10
|
+
* decorates federation refusals with actionable hints (R10). The credential
|
|
11
|
+
* store keeps holding ONLY the API key; the password/token never persist.
|
|
12
|
+
*/
|
|
13
|
+
export declare abstract class PeerCommand extends BaseCommand {
|
|
14
|
+
static readonly peerAuthFlags: {
|
|
15
|
+
email: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
};
|
|
17
|
+
protected peerInteractive(): boolean;
|
|
18
|
+
/** Bearer-token client for the active profile (R8). */
|
|
19
|
+
protected peerApiClient(flags: PeerGlobalFlags): Promise<KnowzApiClient>;
|
|
20
|
+
/** Attach the R10 follow-up hint to federation refusals, then rethrow. */
|
|
21
|
+
protected withFederationHints<T>(fn: () => Promise<T>): Promise<T>;
|
|
22
|
+
/** Resolve `<peerRef>` (GUID or slug) to the peer row. */
|
|
23
|
+
protected resolvePeer(client: KnowzApiClient, ref: string): Promise<FederationPeer>;
|
|
24
|
+
/** Source + preflight the peer credential (R9). */
|
|
25
|
+
protected resolveKeyInput(keyFlag: string | undefined): Promise<string>;
|
|
26
|
+
/** Compact human rendering for a peer row. */
|
|
27
|
+
protected describePeer(peer: FederationPeer): string;
|
|
28
|
+
/**
|
|
29
|
+
* Shared `peer pull` / `peer push` body (R12): 202 + runId; `--wait` polls
|
|
30
|
+
* every 2 s to a terminal status; exit 0 ONLY on Succeeded/NoOp — the server
|
|
31
|
+
* status is trusted, never re-interpreted.
|
|
32
|
+
*/
|
|
33
|
+
protected enqueueSyncRun(direction: 'pull' | 'push', input: {
|
|
34
|
+
client: KnowzApiClient;
|
|
35
|
+
peerRef: string;
|
|
36
|
+
vaultLinkId: string;
|
|
37
|
+
options: FederationSyncOptionsInput;
|
|
38
|
+
wait: boolean;
|
|
39
|
+
timeoutSeconds: number;
|
|
40
|
+
}): Promise<unknown>;
|
|
41
|
+
}
|
|
42
|
+
/** Flag set shared by `peer pull` and `peer push`. */
|
|
43
|
+
export declare const syncRunFlags: {
|
|
44
|
+
link: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
45
|
+
since: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
46
|
+
'skip-re-enrichment': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
47
|
+
'max-file-mb': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
48
|
+
wait: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
49
|
+
timeout: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=peer-command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"peer-command.d.ts","sourceRoot":"","sources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