@kortix/sdk 0.13.48 → 0.13.50

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.
Files changed (96) hide show
  1. package/dist/core/client/kortix.d.ts +5 -0
  2. package/dist/core/client/kortix.d.ts.map +1 -1
  3. package/dist/core/client/project-core.d.ts +1 -0
  4. package/dist/core/client/project-core.d.ts.map +1 -1
  5. package/dist/core/client/session-actions-security.d.ts +2 -0
  6. package/dist/core/client/session-actions-security.d.ts.map +1 -1
  7. package/dist/core/client/session-handle.d.ts +2 -0
  8. package/dist/core/client/session-handle.d.ts.map +1 -1
  9. package/dist/core/http/auth.d.ts +3 -2
  10. package/dist/core/http/auth.d.ts.map +1 -1
  11. package/dist/core/http/auth.js +2 -1
  12. package/dist/core/http/auth.js.map +1 -1
  13. package/dist/core/rest/platform-client/connector-setup.d.ts +91 -0
  14. package/dist/core/rest/platform-client/connector-setup.d.ts.map +1 -0
  15. package/dist/core/rest/platform-client/connector-setup.js +171 -0
  16. package/dist/core/rest/platform-client/connector-setup.js.map +1 -0
  17. package/dist/core/rest/platform-client/host-boundary.d.ts +15 -3
  18. package/dist/core/rest/platform-client/host-boundary.d.ts.map +1 -1
  19. package/dist/core/rest/platform-client/host-boundary.js +19 -30
  20. package/dist/core/rest/platform-client/host-boundary.js.map +1 -1
  21. package/dist/core/rest/platform-client/index.d.ts +1 -0
  22. package/dist/core/rest/platform-client/index.d.ts.map +1 -1
  23. package/dist/core/rest/platform-client/index.js +1 -0
  24. package/dist/core/rest/platform-client/index.js.map +1 -1
  25. package/dist/core/rest/platform-client/lifecycle.d.ts +5 -0
  26. package/dist/core/rest/platform-client/lifecycle.d.ts.map +1 -1
  27. package/dist/core/rest/platform-client/lifecycle.js +6 -25
  28. package/dist/core/rest/platform-client/lifecycle.js.map +1 -1
  29. package/dist/core/rest/platform-client/shared.d.ts +0 -7
  30. package/dist/core/rest/platform-client/shared.d.ts.map +1 -1
  31. package/dist/core/rest/platform-client/shared.js +2 -8
  32. package/dist/core/rest/platform-client/shared.js.map +1 -1
  33. package/dist/core/rest/projects-client/account-secret-resources.d.ts +7 -0
  34. package/dist/core/rest/projects-client/account-secret-resources.d.ts.map +1 -1
  35. package/dist/core/rest/projects-client/account-secret-resources.js.map +1 -1
  36. package/dist/core/rest/projects-client/accounts.d.ts +3 -0
  37. package/dist/core/rest/projects-client/accounts.d.ts.map +1 -1
  38. package/dist/core/rest/projects-client/accounts.js.map +1 -1
  39. package/dist/core/rest/projects-client/billing.d.ts +4 -0
  40. package/dist/core/rest/projects-client/billing.d.ts.map +1 -1
  41. package/dist/core/rest/projects-client/billing.js.map +1 -1
  42. package/dist/core/rest/projects-client/model-defaults.d.ts +2 -2
  43. package/dist/core/rest/projects-client/model-defaults.d.ts.map +1 -1
  44. package/dist/core/rest/projects-client/projects.d.ts +28 -5
  45. package/dist/core/rest/projects-client/projects.d.ts.map +1 -1
  46. package/dist/core/rest/projects-client/projects.js +0 -1
  47. package/dist/core/rest/projects-client/projects.js.map +1 -1
  48. package/dist/core/rest/projects-client/session-sandbox.d.ts +3 -1
  49. package/dist/core/rest/projects-client/session-sandbox.d.ts.map +1 -1
  50. package/dist/core/rest/projects-client/session-sandbox.js.map +1 -1
  51. package/dist/core/rest/projects-client/sessions.d.ts +52 -6
  52. package/dist/core/rest/projects-client/sessions.d.ts.map +1 -1
  53. package/dist/core/rest/projects-client/sessions.js +28 -2
  54. package/dist/core/rest/projects-client/sessions.js.map +1 -1
  55. package/dist/core/runtime/runtime-rest-client.d.ts +5 -0
  56. package/dist/core/runtime/runtime-rest-client.d.ts.map +1 -1
  57. package/dist/core/runtime/runtime-rest-client.js +2 -0
  58. package/dist/core/runtime/runtime-rest-client.js.map +1 -1
  59. package/dist/core/session/presentation.d.ts +10 -2
  60. package/dist/core/session/presentation.d.ts.map +1 -1
  61. package/dist/core/session/presentation.js +13 -4
  62. package/dist/core/session/presentation.js.map +1 -1
  63. package/dist/core/session/wire-message-id.d.ts +6 -7
  64. package/dist/core/session/wire-message-id.d.ts.map +1 -1
  65. package/dist/core/session/wire-message-id.js +6 -7
  66. package/dist/core/session/wire-message-id.js.map +1 -1
  67. package/dist/core/stream/fetch-sse.d.ts +7 -3
  68. package/dist/core/stream/fetch-sse.d.ts.map +1 -1
  69. package/dist/core/stream/fetch-sse.js +10 -11
  70. package/dist/core/stream/fetch-sse.js.map +1 -1
  71. package/dist/kortix.esm.min.js +33 -33
  72. package/dist/kortix.global.js +26 -26
  73. package/dist/react/connector-setup.d.ts +48 -0
  74. package/dist/react/connector-setup.d.ts.map +1 -0
  75. package/dist/react/connector-setup.js +173 -0
  76. package/dist/react/connector-setup.js.map +1 -0
  77. package/dist/react/index.d.ts +2 -0
  78. package/dist/react/index.d.ts.map +1 -1
  79. package/dist/react/index.js +10 -0
  80. package/dist/react/index.js.map +1 -1
  81. package/dist/react/use-admin-accounts.d.ts +7 -4
  82. package/dist/react/use-admin-accounts.d.ts.map +1 -1
  83. package/dist/react/use-admin-accounts.js +7 -4
  84. package/dist/react/use-admin-accounts.js.map +1 -1
  85. package/dist/react/use-opencode-sessions/sessions.d.ts +9 -0
  86. package/dist/react/use-opencode-sessions/sessions.d.ts.map +1 -1
  87. package/dist/react/use-opencode-sessions/sessions.js +34 -0
  88. package/dist/react/use-opencode-sessions/sessions.js.map +1 -1
  89. package/dist/react/use-project-apps.d.ts +2 -2
  90. package/dist/react/use-provider-secrets.d.ts +18 -0
  91. package/dist/react/use-provider-secrets.d.ts.map +1 -1
  92. package/dist/react/use-sandbox-image.d.ts +52 -0
  93. package/dist/react/use-sandbox-image.d.ts.map +1 -0
  94. package/dist/react/use-sandbox-image.js +144 -0
  95. package/dist/react/use-sandbox-image.js.map +1 -0
  96. package/package.json +2 -2
@@ -9,6 +9,8 @@ export declare function useSessionProviderSecretPools(projectId: string | null |
9
9
  data: {
10
10
  pools: import("../index.js").SessionProviderSecretPool[];
11
11
  can_edit: boolean;
12
+ personal_user_id?: string | null;
13
+ personal_keys_reason?: "shared" | "prompted_by_another_member" | "no_person" | null;
12
14
  };
13
15
  error: Error;
14
16
  isError: true;
@@ -35,6 +37,8 @@ export declare function useSessionProviderSecretPools(projectId: string | null |
35
37
  refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
36
38
  pools: import("../index.js").SessionProviderSecretPool[];
37
39
  can_edit: boolean;
40
+ personal_user_id?: string | null;
41
+ personal_keys_reason?: "shared" | "prompted_by_another_member" | "no_person" | null;
38
42
  }, Error>>;
39
43
  fetchStatus: import("@tanstack/react-query").FetchStatus;
40
44
  } | {
@@ -45,6 +49,8 @@ export declare function useSessionProviderSecretPools(projectId: string | null |
45
49
  data: {
46
50
  pools: import("../index.js").SessionProviderSecretPool[];
47
51
  can_edit: boolean;
52
+ personal_user_id?: string | null;
53
+ personal_keys_reason?: "shared" | "prompted_by_another_member" | "no_person" | null;
48
54
  };
49
55
  error: null;
50
56
  isError: false;
@@ -71,6 +77,8 @@ export declare function useSessionProviderSecretPools(projectId: string | null |
71
77
  refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
72
78
  pools: import("../index.js").SessionProviderSecretPool[];
73
79
  can_edit: boolean;
80
+ personal_user_id?: string | null;
81
+ personal_keys_reason?: "shared" | "prompted_by_another_member" | "no_person" | null;
74
82
  }, Error>>;
75
83
  fetchStatus: import("@tanstack/react-query").FetchStatus;
76
84
  } | {
@@ -104,6 +112,8 @@ export declare function useSessionProviderSecretPools(projectId: string | null |
104
112
  refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
105
113
  pools: import("../index.js").SessionProviderSecretPool[];
106
114
  can_edit: boolean;
115
+ personal_user_id?: string | null;
116
+ personal_keys_reason?: "shared" | "prompted_by_another_member" | "no_person" | null;
107
117
  }, Error>>;
108
118
  fetchStatus: import("@tanstack/react-query").FetchStatus;
109
119
  } | {
@@ -137,6 +147,8 @@ export declare function useSessionProviderSecretPools(projectId: string | null |
137
147
  refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
138
148
  pools: import("../index.js").SessionProviderSecretPool[];
139
149
  can_edit: boolean;
150
+ personal_user_id?: string | null;
151
+ personal_keys_reason?: "shared" | "prompted_by_another_member" | "no_person" | null;
140
152
  }, Error>>;
141
153
  fetchStatus: import("@tanstack/react-query").FetchStatus;
142
154
  } | {
@@ -170,6 +182,8 @@ export declare function useSessionProviderSecretPools(projectId: string | null |
170
182
  refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
171
183
  pools: import("../index.js").SessionProviderSecretPool[];
172
184
  can_edit: boolean;
185
+ personal_user_id?: string | null;
186
+ personal_keys_reason?: "shared" | "prompted_by_another_member" | "no_person" | null;
173
187
  }, Error>>;
174
188
  fetchStatus: import("@tanstack/react-query").FetchStatus;
175
189
  } | {
@@ -180,6 +194,8 @@ export declare function useSessionProviderSecretPools(projectId: string | null |
180
194
  data: {
181
195
  pools: import("../index.js").SessionProviderSecretPool[];
182
196
  can_edit: boolean;
197
+ personal_user_id?: string | null;
198
+ personal_keys_reason?: "shared" | "prompted_by_another_member" | "no_person" | null;
183
199
  };
184
200
  isError: false;
185
201
  error: null;
@@ -206,6 +222,8 @@ export declare function useSessionProviderSecretPools(projectId: string | null |
206
222
  refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
207
223
  pools: import("../index.js").SessionProviderSecretPool[];
208
224
  can_edit: boolean;
225
+ personal_user_id?: string | null;
226
+ personal_keys_reason?: "shared" | "prompted_by_another_member" | "no_person" | null;
209
227
  }, Error>>;
210
228
  fetchStatus: import("@tanstack/react-query").FetchStatus;
211
229
  };
@@ -1 +1 @@
1
- {"version":3,"file":"use-provider-secrets.d.ts","sourceRoot":"","sources":["../../src/react/use-provider-secrets.ts"],"names":[],"mappings":"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;;;;;;;;oBAAlC,MAAM;mBAAa,MAAM,EAAE,GAAG,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAAlC,MAAM;mBAAa,MAAM,EAAE,GAAG,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAAlC,MAAM;mBAAa,MAAM,EAAE,GAAG,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAAlC,MAAM;mBAAa,MAAM,EAAE,GAAG,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAY3F"}
@@ -0,0 +1,52 @@
1
+ /** Images at or below this size auto-load; larger ones wait for a tap. */
2
+ export declare const IMAGE_AUTO_LOAD_LIMIT_BYTES: number;
3
+ type SandboxImagePhase = 'probing' | 'load' | 'tap-to-load' | 'error';
4
+ export declare function decideImageLoad({ contentLength, limitBytes, }: {
5
+ contentLength: number | null;
6
+ limitBytes: number;
7
+ }): 'load' | 'tap-to-load';
8
+ /** Parses a `content-length` header value. Returns null when absent or invalid. */
9
+ export declare function parseContentLength(header: string | null): number | null;
10
+ /** "8.5 MB" below 10 MB, "25 MB" from 10 MB up. */
11
+ export declare function formatMegabytes(bytes: number): string;
12
+ export interface ProbeCache {
13
+ has(url: string): boolean;
14
+ get(url: string): number | null | undefined;
15
+ set(url: string, contentLength: number | null): void;
16
+ size(): number;
17
+ }
18
+ /** Bounded least-recently-used cache of HEAD probe results keyed by raw file URL. */
19
+ export declare function createProbeCache(limit: number): ProbeCache;
20
+ /**
21
+ * The sandbox-image load state, moved from `apps/mobile`'s hook: the SDK owns
22
+ * the raw-file URL, the HEAD probe, the auth headers, the size gate, the probe
23
+ * cache and the one fresh-token retry. The host binds the sandbox origin and
24
+ * the native image events (`onError` → `handleError`, remount on `attempt`).
25
+ *
26
+ * The probe is a HEAD through `authenticatedFetch` — the one configured
27
+ * token/header seam, so no host builds a second one. Behavior kept explicit
28
+ * from the mobile hook it replaces: without a token the seam sends nothing
29
+ * (synthetic 401) and the length reads as unknown, so the native loader still
30
+ * runs unauthenticated; `retryOnAuthError: false` keeps a 401 probe an unknown
31
+ * length (no probe-level retry — the native image load is the retry);
32
+ * `timeoutMs: null` keeps the probe deadline-free, as before.
33
+ */
34
+ export declare function useSandboxImage({ sandboxUrl, filePath, enabled, }: {
35
+ sandboxUrl: string | undefined;
36
+ filePath: string;
37
+ enabled: boolean;
38
+ }): {
39
+ phase: SandboxImagePhase;
40
+ source: {
41
+ uri: string;
42
+ headers: {
43
+ Authorization: string;
44
+ } | undefined;
45
+ } | undefined;
46
+ sizeBytes: number | null;
47
+ attempt: number;
48
+ loadAnyway: () => void;
49
+ handleError: () => void;
50
+ };
51
+ export {};
52
+ //# sourceMappingURL=use-sandbox-image.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-sandbox-image.d.ts","sourceRoot":"","sources":["../../src/react/use-sandbox-image.ts"],"names":[],"mappings":"AAGA,0EAA0E;AAC1E,eAAO,MAAM,2BAA2B,QAAkB,CAAC;AAE3D,KAAK,iBAAiB,GAAG,SAAS,GAAG,MAAM,GAAG,aAAa,GAAG,OAAO,CAAC;AAEtE,wBAAgB,eAAe,CAAC,EAC9B,aAAa,EACb,UAAU,GACX,EAAE;IACD,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG,MAAM,GAAG,aAAa,CAGzB;AAED,mFAAmF;AACnF,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAMvE;AAED,mDAAmD;AACnD,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGrD;AAED,MAAM,WAAW,UAAU;IACzB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC5C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;IACrD,IAAI,IAAI,MAAM,CAAC;CAChB;AAED,qFAAqF;AACrF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAsB1D;AAMD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,EAC9B,UAAU,EACV,QAAQ,EACR,OAAO,GACR,EAAE;IACD,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;CAClB;;;;;;;;;;;;EAoFA"}
@@ -0,0 +1,144 @@
1
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
+ import { authenticatedFetch, getAuthToken } from '../core/http/auth.js';
3
+ /** Images at or below this size auto-load; larger ones wait for a tap. */
4
+ export const IMAGE_AUTO_LOAD_LIMIT_BYTES = 8 * 1024 * 1024;
5
+ export function decideImageLoad({ contentLength, limitBytes, }) {
6
+ if (contentLength === null)
7
+ return 'load';
8
+ return contentLength > limitBytes ? 'tap-to-load' : 'load';
9
+ }
10
+ /** Parses a `content-length` header value. Returns null when absent or invalid. */
11
+ export function parseContentLength(header) {
12
+ if (header === null)
13
+ return null;
14
+ const trimmed = header.trim();
15
+ if (!/^\d+$/.test(trimmed))
16
+ return null;
17
+ const value = Number(trimmed);
18
+ return Number.isSafeInteger(value) ? value : null;
19
+ }
20
+ /** "8.5 MB" below 10 MB, "25 MB" from 10 MB up. */
21
+ export function formatMegabytes(bytes) {
22
+ const mb = bytes / (1024 * 1024);
23
+ return mb < 10 ? `${mb.toFixed(1)} MB` : `${Math.round(mb)} MB`;
24
+ }
25
+ /** Bounded least-recently-used cache of HEAD probe results keyed by raw file URL. */
26
+ export function createProbeCache(limit) {
27
+ const entries = new Map();
28
+ return {
29
+ has: (url) => entries.has(url),
30
+ get(url) {
31
+ if (!entries.has(url))
32
+ return undefined;
33
+ const value = entries.get(url);
34
+ entries.delete(url);
35
+ entries.set(url, value);
36
+ return value;
37
+ },
38
+ set(url, contentLength) {
39
+ entries.delete(url);
40
+ entries.set(url, contentLength);
41
+ while (entries.size > limit) {
42
+ const oldest = entries.keys().next().value;
43
+ if (oldest === undefined)
44
+ break;
45
+ entries.delete(oldest);
46
+ }
47
+ },
48
+ size: () => entries.size,
49
+ };
50
+ }
51
+ // The sandbox daemon serves HEAD through its GET handler and reads the whole
52
+ // file, so each URL is probed once per app session, not on every cell remount.
53
+ const imageProbeCache = createProbeCache(200);
54
+ /**
55
+ * The sandbox-image load state, moved from `apps/mobile`'s hook: the SDK owns
56
+ * the raw-file URL, the HEAD probe, the auth headers, the size gate, the probe
57
+ * cache and the one fresh-token retry. The host binds the sandbox origin and
58
+ * the native image events (`onError` → `handleError`, remount on `attempt`).
59
+ *
60
+ * The probe is a HEAD through `authenticatedFetch` — the one configured
61
+ * token/header seam, so no host builds a second one. Behavior kept explicit
62
+ * from the mobile hook it replaces: without a token the seam sends nothing
63
+ * (synthetic 401) and the length reads as unknown, so the native loader still
64
+ * runs unauthenticated; `retryOnAuthError: false` keeps a 401 probe an unknown
65
+ * length (no probe-level retry — the native image load is the retry);
66
+ * `timeoutMs: null` keeps the probe deadline-free, as before.
67
+ */
68
+ export function useSandboxImage({ sandboxUrl, filePath, enabled, }) {
69
+ const rawUrl = sandboxUrl && filePath ? `${sandboxUrl}/file/raw?path=${encodeURIComponent(filePath)}` : null;
70
+ const [phase, setPhase] = useState('probing');
71
+ const [token, setToken] = useState(null);
72
+ const [sizeBytes, setSizeBytes] = useState(null);
73
+ // Bumped on retry so the host's Image remounts and requests the file again.
74
+ const [attempt, setAttempt] = useState(0);
75
+ const retriedRef = useRef(false);
76
+ const aliveRef = useRef(true);
77
+ useEffect(() => {
78
+ aliveRef.current = true;
79
+ return () => {
80
+ aliveRef.current = false;
81
+ };
82
+ }, []);
83
+ useEffect(() => {
84
+ if (!enabled || !rawUrl)
85
+ return;
86
+ const controller = new AbortController();
87
+ let cancelled = false;
88
+ retriedRef.current = false;
89
+ setPhase('probing');
90
+ (async () => {
91
+ const authToken = await getAuthToken().catch(() => null);
92
+ if (cancelled)
93
+ return;
94
+ let contentLength = null;
95
+ if (imageProbeCache.has(rawUrl)) {
96
+ contentLength = imageProbeCache.get(rawUrl) ?? null;
97
+ }
98
+ else {
99
+ try {
100
+ const res = await authenticatedFetch(rawUrl, { method: 'HEAD', signal: controller.signal }, { retryOnAuthError: false, timeoutMs: null });
101
+ if (res.ok) {
102
+ contentLength = parseContentLength(res.headers.get('content-length'));
103
+ imageProbeCache.set(rawUrl, contentLength);
104
+ }
105
+ }
106
+ catch {
107
+ // Unknown length: let the native loader try; onError handles failures.
108
+ }
109
+ }
110
+ if (cancelled)
111
+ return;
112
+ setToken(authToken);
113
+ setSizeBytes(contentLength);
114
+ setPhase(decideImageLoad({ contentLength, limitBytes: IMAGE_AUTO_LOAD_LIMIT_BYTES }));
115
+ })();
116
+ return () => {
117
+ cancelled = true;
118
+ controller.abort();
119
+ };
120
+ }, [enabled, rawUrl]);
121
+ const loadAnyway = useCallback(() => setPhase('load'), []);
122
+ // First native failure: retry once with a fresh token (the cached one may
123
+ // have expired). Second failure: show the error fallback.
124
+ const handleError = useCallback(() => {
125
+ if (retriedRef.current) {
126
+ setPhase('error');
127
+ return;
128
+ }
129
+ retriedRef.current = true;
130
+ getAuthToken()
131
+ .catch(() => null)
132
+ .then((fresh) => {
133
+ if (!aliveRef.current)
134
+ return;
135
+ setToken(fresh);
136
+ setAttempt((n) => n + 1);
137
+ });
138
+ }, []);
139
+ const source = useMemo(() => rawUrl
140
+ ? { uri: rawUrl, headers: token ? { Authorization: `Bearer ${token}` } : undefined }
141
+ : undefined, [rawUrl, token]);
142
+ return { phase, source, sizeBytes, attempt, loadAnyway, handleError };
143
+ }
144
+ //# sourceMappingURL=use-sandbox-image.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-sandbox-image.js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Q,CAAC,OAAO,CAAC,CAAC;YAClB,OAAO;QACT,CAAC;QACD,UAAU,CAAC,OAAO,GAAG,IAAI,CAAC;QAC1B,YAAY,EAAE;aACX,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC;aACjB,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;YACd,IAAI,CAAC,QAAQ,CAAC,OAAO;gBAAE,OAAO;YAC9B,QAAQ,CAAC,KAAK,CAAC,CAAC;YAChB,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACP,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,MAAM,GAAG,OAAO,CACpB,GAAG,EAAE,CACH,MAAM;QACJ,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,UAAU,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE;QACpF,CAAC,CAAC,SAAS,EACf,CAAC,MAAM,EAAE,KAAK,CAAC,CAChB,CAAC;IAEF,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC;AACxE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kortix/sdk",
3
- "version": "0.13.48",
3
+ "version": "0.13.50",
4
4
  "description": "Official Kortix frontend TypeScript SDK — one typed client for the Kortix API. Unifies project/session lifecycle and live agent streaming behind a single ergonomic Session handle, so web, mobile, and white-label apps never touch the raw HTTP API or OpenCode semantics.",
5
5
  "type": "module",
6
6
  "license": "Elastic-2.0",
@@ -19,7 +19,7 @@
19
19
  ],
20
20
  "sideEffects": false,
21
21
  "dependencies": {
22
- "@kortix/llm-catalog": "0.13.48",
22
+ "@kortix/llm-catalog": "0.13.50",
23
23
  "zustand": "^5.0.3"
24
24
  },
25
25
  "peerDependencies": {