@iblai/data-layer 1.39.0 → 1.40.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.
@@ -7,7 +7,9 @@ import type { CreateVirtualMachineNetworkPolicyArgs, CreateVirtualMachineSecretA
7
7
  * Hand-written: these endpoints are newer than the pinned `@iblai/iblai-api`
8
8
  * release. Records are keyed in the body (PATCH) or the query string (DELETE),
9
9
  * never in the URL. A 403 on either list means the caller lacks the matching
10
- * `Ibl.Mentor/VirtualMachine…/list` permission — hosts hide the pages then.
10
+ * `Ibl.Mentor/VirtualMachine…/list` permission — hosts hide the pages then,
11
+ * which needs the status: the base query returns failures rather than throwing
12
+ * them, since RTK Query keeps only `{}` of a thrown `{ status, data }`.
11
13
  */
12
14
  export declare const virtualMachineApiSlice: import("@reduxjs/toolkit/query").Api<import("@reduxjs/toolkit/query").BaseQueryFn<import("@data-layer/features/utils").CustomQueryArgs, unknown, import("@data-layer/features/utils").ExtendedFetchBaseQueryError, Record<string, unknown>, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, {
13
15
  listVirtualMachineNetworkPolicies: import("@reduxjs/toolkit/query").QueryDefinition<ListVirtualMachineNetworkPoliciesArgs, import("@reduxjs/toolkit/query").BaseQueryFn<import("@data-layer/features/utils").CustomQueryArgs, unknown, import("@data-layer/features/utils").ExtendedFetchBaseQueryError, Record<string, unknown>, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, "VirtualMachineNetworkPolicies" | "VirtualMachineSecrets", VirtualMachineNetworkPolicy[], "virtualMachineApiSlice", unknown>;
@@ -81,7 +83,7 @@ export declare const useListVirtualMachineNetworkPoliciesQuery: <R extends Recor
81
83
  isError: false;
82
84
  }, "error">>)>> & {
83
85
  status: import("@reduxjs/toolkit/query").QueryStatus;
84
- }>(arg: typeof import("@reduxjs/toolkit/query").skipToken | ListVirtualMachineNetworkPoliciesArgs, options?: (import("@reduxjs/toolkit/query").SubscriptionOptions & {
86
+ }>(arg: ListVirtualMachineNetworkPoliciesArgs | typeof import("@reduxjs/toolkit/query").skipToken, options?: (import("@reduxjs/toolkit/query").SubscriptionOptions & {
85
87
  skip?: boolean;
86
88
  refetchOnMountOrArgChange?: boolean | number;
87
89
  } & {
@@ -824,7 +826,7 @@ export declare const useListVirtualMachineNetworkPoliciesQuery: <R extends Recor
824
826
  isError: false;
825
827
  }, "error">>)>> & {
826
828
  status: import("@reduxjs/toolkit/query").QueryStatus;
827
- }>(arg: typeof import("@reduxjs/toolkit/query").skipToken | ListVirtualMachineSecretsArgs, options?: (import("@reduxjs/toolkit/query").SubscriptionOptions & {
829
+ }>(arg: ListVirtualMachineSecretsArgs | typeof import("@reduxjs/toolkit/query").skipToken, options?: (import("@reduxjs/toolkit/query").SubscriptionOptions & {
828
830
  skip?: boolean;
829
831
  refetchOnMountOrArgChange?: boolean | number;
830
832
  } & {
@@ -46,11 +46,30 @@ export declare const VIRTUAL_MACHINE_REJECTED_HOSTS: readonly ["localhost", "met
46
46
  export declare const VIRTUAL_MACHINE_REJECTED_HOST_SUFFIXES: readonly [".local", ".internal", ".localhost"];
47
47
  /** `env_var` of a VM secret: a POSIX-style environment variable name. */
48
48
  export declare const VIRTUAL_MACHINE_ENV_VAR_PATTERN: RegExp;
49
+ /** The backend caps `env_var` at 128 characters. */
50
+ export declare const VIRTUAL_MACHINE_ENV_VAR_MAX_LENGTH = 128;
51
+ /**
52
+ * Variable names the UI refuses for a secret. The backend only checks the
53
+ * POSIX shape, but the sandbox sets `env_var` in the VM's environment, so a
54
+ * secret named PATH or LD_PRELOAD would break every command run there.
55
+ */
56
+ export declare const VIRTUAL_MACHINE_RESERVED_ENV_VARS: readonly ["PATH", "HOME", "USER", "LOGNAME", "SHELL", "PWD", "OLDPWD", "TMPDIR", "TERM", "LANG", "LANGUAGE", "LC_ALL", "LD_PRELOAD", "LD_LIBRARY_PATH", "PYTHONPATH", "PYTHONHOME", "NODE_OPTIONS", "HTTP_PROXY", "HTTPS_PROXY", "NO_PROXY"];
57
+ /** Prefixes the sandbox and ibl.ai keep for their own variables. */
58
+ export declare const VIRTUAL_MACHINE_RESERVED_ENV_VAR_PREFIXES: readonly ["MSB_", "IBLAI_"];
59
+ /**
60
+ * The port a bare hostname gets in an allowlist. Secrets are only ever
61
+ * swapped into HTTPS requests, so `api.acme.com` means `api.acme.com:443`.
62
+ */
63
+ export declare const VIRTUAL_MACHINE_DEFAULT_HOST_PORT = 443;
49
64
  /** A network policy holds between 1 and 100 hosts. */
50
65
  export declare const VIRTUAL_MACHINE_MAX_POLICY_HOSTS = 100;
51
66
  /** An agent may bind at most 20 VM secrets. */
52
67
  export declare const VIRTUAL_MACHINE_MAX_SECRETS_PER_MENTOR = 20;
53
- /** A pasted secret value must be at least this long. */
68
+ /**
69
+ * The backend's floor for a pasted secret value (its output scrubber blanks
70
+ * every occurrence of a bound value, so a very short one would blank too
71
+ * much). The UI no longer checks it; a refusal is shown under the Key field.
72
+ */
54
73
  export declare const VIRTUAL_MACHINE_SECRET_VALUE_MIN_LENGTH = 8;
55
74
  /**
56
75
  * Default VM runtime billing: charged to the chatting user's credits, prorated
@@ -69,7 +69,7 @@ export interface VirtualMachineSecret {
69
69
  updated_at: string;
70
70
  }
71
71
  /**
72
- * Create with **either** `value` (a pasted key, min 8 characters) **or**
72
+ * Create with **either** `value` (a pasted key; the backend refuses fewer than 8 characters) **or**
73
73
  * `source_credential_id` + `source_field` (read from an integration
74
74
  * credential at run time), never both.
75
75
  */
@@ -4,8 +4,31 @@ import type { VirtualMachineApiError, VirtualMachineEgress, VirtualMachineHostPo
4
4
  * lowercased.
5
5
  */
6
6
  export declare function normalizeHostPort(value: string): string;
7
+ export interface HostInputOptions {
8
+ /**
9
+ * Port appended to an entry that names none (`api.acme.com` →
10
+ * `api.acme.com:443`). An explicit port, or the one a pasted URL's scheme
11
+ * implies, is kept.
12
+ */
13
+ defaultPort?: number;
14
+ }
15
+ /**
16
+ * Turn what a person typed or pasted into the `host:port` the backend stores.
17
+ * People paste the address from a service's instructions, so a whole URL
18
+ * (`https://api.acme.com/v1/keys`) is reduced to its host, with the scheme's
19
+ * port unless the URL names one; `api.acme.com/v1` loses its path; a trailing
20
+ * dot goes. Anything unparseable comes back trimmed and lowercased so
21
+ * `validateHostPort` can explain it.
22
+ */
23
+ export declare function normalizeHostInput(value: string, options?: HostInputOptions): string;
7
24
  /** Split a pasted or typed string into candidate `host:port` entries. */
8
- export declare function splitHostPortInput(value: string): string[];
25
+ export declare function splitHostPortInput(value: string, options?: HostInputOptions): string[];
26
+ /**
27
+ * The `host:port` a person reads: the standard HTTPS port is implied, so
28
+ * `api.acme.com:443` shows as `api.acme.com`; any other port stays visible.
29
+ * The stored and compared form is never changed by this.
30
+ */
31
+ export declare function formatHostPort(entry: string): string;
9
32
  /** Whether the host part is an IPv4 literal (the `host:port` grammar admits no IPv6). */
10
33
  export declare function isIpAddressHost(host: string): boolean;
11
34
  /**
@@ -53,3 +76,28 @@ export declare function findUncoveredSecretHosts(secrets: ReadonlyArray<{
53
76
  env_var: string;
54
77
  allow_hosts: string[];
55
78
  }>, allowedHosts: ReadonlyArray<string>): VirtualMachineUncoveredSecretHosts[];
79
+ /** Whether a variable name is one the VM itself relies on (see the reserved list). */
80
+ export declare function isReservedEnvVar(name: string): boolean;
81
+ export interface DeriveSecretEnvVarOptions {
82
+ /** Variables already used by the org's secrets; the result is made unique against them. */
83
+ taken?: ReadonlyArray<string>;
84
+ }
85
+ /**
86
+ * The variable name a secret gets from its display name, so a person never
87
+ * has to invent one: "Acme API key" → `ACME_API_KEY`, "Clé Stripe" →
88
+ * `CLE_STRIPE_KEY`. Accents are folded, every other run of characters becomes
89
+ * an underscore, a leading digit gets `KEY_` in front, a name without
90
+ * KEY/TOKEN/SECRET/PASSWORD gets `_KEY` (which also keeps "Path" from
91
+ * becoming the VM's PATH), nothing derivable falls back to `SECRET`, and a
92
+ * clash with `taken` gets `_2`, `_3`, …
93
+ */
94
+ export declare function deriveSecretEnvVar(name: string, options?: DeriveSecretEnvVarOptions): string;
95
+ /** Why a typed variable name is refused, or `null` when it is fine. */
96
+ export type SecretEnvVarIssue = 'required' | 'format' | 'reserved' | 'taken' | 'too_long';
97
+ export declare function validateSecretEnvVar(value: string, options?: DeriveSecretEnvVarOptions): SecretEnvVarIssue | null;
98
+ /**
99
+ * The backend refuses a duplicate variable with a plain-string 400
100
+ * (`"ACME_KEY already exists for this organization."`), not a field error,
101
+ * so the form has to recognise it to put the message under the right field.
102
+ */
103
+ export declare function isSecretEnvVarTakenMessage(message: string | null | undefined): boolean;