@kortix/sdk 0.14.17 → 0.14.19
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/dist/core/client/kortix.d.ts +11 -0
- package/dist/core/client/kortix.d.ts.map +1 -1
- package/dist/core/client/project-core.d.ts.map +1 -1
- package/dist/core/client/project-operations-review.d.ts +2 -2
- package/dist/core/client/project-operations-review.d.ts.map +1 -1
- package/dist/core/client/project-operations-review.js +2 -2
- package/dist/core/client/project-operations-review.js.map +1 -1
- package/dist/core/client/project-platform-security.d.ts +15 -0
- package/dist/core/client/project-platform-security.d.ts.map +1 -1
- package/dist/core/client/project-platform-security.js +15 -0
- package/dist/core/client/project-platform-security.js.map +1 -1
- package/dist/core/rest/platform-client/host-boundary.d.ts +10 -0
- package/dist/core/rest/platform-client/host-boundary.d.ts.map +1 -1
- package/dist/core/rest/platform-client/host-boundary.js +9 -0
- package/dist/core/rest/platform-client/host-boundary.js.map +1 -1
- package/dist/core/rest/projects-client/channels.d.ts +26 -1
- package/dist/core/rest/projects-client/channels.d.ts.map +1 -1
- package/dist/core/rest/projects-client/channels.js +33 -1
- package/dist/core/rest/projects-client/channels.js.map +1 -1
- package/dist/core/rest/projects-client/connectors.d.ts +1 -1
- package/dist/core/rest/projects-client/connectors.d.ts.map +1 -1
- package/dist/core/rest/projects-client/drives.d.ts +16 -8
- package/dist/core/rest/projects-client/drives.d.ts.map +1 -1
- package/dist/core/rest/projects-client/drives.js +2 -3
- package/dist/core/rest/projects-client/drives.js.map +1 -1
- package/dist/core/rest/projects-client/projects.d.ts +11 -5
- package/dist/core/rest/projects-client/projects.d.ts.map +1 -1
- package/dist/core/rest/projects-client/projects.js +3 -2
- package/dist/core/rest/projects-client/projects.js.map +1 -1
- package/dist/core/rest/projects-client/sessions.d.ts +12 -21
- package/dist/core/rest/projects-client/sessions.d.ts.map +1 -1
- package/dist/core/rest/projects-client/sessions.js +13 -31
- package/dist/core/rest/projects-client/sessions.js.map +1 -1
- package/dist/core/rest/projects-client/triggers.d.ts +4 -3
- package/dist/core/rest/projects-client/triggers.d.ts.map +1 -1
- package/dist/core/rest/projects-client/triggers.js.map +1 -1
- package/dist/core/warm-session-pool.d.ts +27 -52
- package/dist/core/warm-session-pool.d.ts.map +1 -1
- package/dist/core/warm-session-pool.js +21 -170
- package/dist/core/warm-session-pool.js.map +1 -1
- package/dist/kortix.esm.min.js +44 -44
- package/dist/kortix.global.js +45 -45
- package/dist/react/invalidate-project.d.ts +5 -0
- package/dist/react/invalidate-project.d.ts.map +1 -1
- package/dist/react/invalidate-project.js +5 -0
- package/dist/react/invalidate-project.js.map +1 -1
- package/dist/react/prefetch-session-start.d.ts +2 -4
- package/dist/react/prefetch-session-start.d.ts.map +1 -1
- package/dist/react/prefetch-session-start.js +2 -4
- package/dist/react/prefetch-session-start.js.map +1 -1
- package/dist/react/session-start-stash.d.ts +2 -2
- package/dist/react/session-start-stash.js +2 -2
- package/dist/react/session-title-sync.d.ts +1 -5
- package/dist/react/session-title-sync.d.ts.map +1 -1
- package/dist/react/session-title-sync.js +9 -21
- package/dist/react/session-title-sync.js.map +1 -1
- package/dist/react/use-feature-flag.d.ts +4 -3
- package/dist/react/use-feature-flag.d.ts.map +1 -1
- package/dist/react/use-feature-flag.js +6 -14
- package/dist/react/use-feature-flag.js.map +1 -1
- package/dist/react/use-project-name.d.ts +8 -8
- package/dist/react/use-project-name.d.ts.map +1 -1
- package/dist/react/use-project-name.js +14 -27
- package/dist/react/use-project-name.js.map +1 -1
- package/dist/react/use-project-row.d.ts +12 -0
- package/dist/react/use-project-row.d.ts.map +1 -0
- package/dist/react/use-project-row.js +24 -0
- package/dist/react/use-project-row.js.map +1 -0
- package/package.json +4 -4
|
@@ -1,180 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The warm-session pool
|
|
3
|
-
* session per project" (`POST /projects/:id/sessions/warm`).
|
|
2
|
+
* The warm-session pool, kept only for semver.
|
|
4
3
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* the user has not typed into yet: the server hides it from the session list
|
|
10
|
-
* (`metadata.warm`) until its first prompt lands.
|
|
4
|
+
* Warm sessions were removed on 2026-11-03. The API answers 410 to
|
|
5
|
+
* `POST /projects/:id/sessions/warm` and `/warm/claim`, and sends
|
|
6
|
+
* `experimental.warm_sessions: false` for every project. A session boots fast
|
|
7
|
+
* enough on its own, and 66 % of the pre-created sessions were never used.
|
|
11
8
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* injectable `fits` predicate and timer, so it unit-tests with plain fakes.
|
|
18
|
-
*
|
|
19
|
-
* A host adapter keeps only what is genuinely platform-specific:
|
|
20
|
-
* - the send shape and `fits` predicate (mobile: agent/model/files; web adds
|
|
21
|
-
* sandbox slug, connector bindings and provider secret pools),
|
|
22
|
-
* - the claim input's extra fields (web adds `sandbox_slug`),
|
|
23
|
-
* - presence gating and cross-tab registries around `take`/`ensure`.
|
|
24
|
-
*
|
|
25
|
-
* Creates happen at three moments, no timers: on entry, when the host returns
|
|
26
|
-
* to the foreground, and to replace one a send used.
|
|
27
|
-
*
|
|
28
|
-
* ABANDON, NEVER ADAPT: a warm session is born with the project's default
|
|
29
|
-
* agent and model. A send that asks for anything else consumes it and runs
|
|
30
|
-
* the ordinary create; the unused box is reaped like any idle session.
|
|
9
|
+
* `createWarmSessionPool` still returns a pool with the same shape, so a host
|
|
10
|
+
* pinned to this major keeps compiling. That pool never holds a session and
|
|
11
|
+
* never calls its client: `take` returns null and `prime` returns false, so
|
|
12
|
+
* the host always runs its ordinary create. Every name here is removed in the
|
|
13
|
+
* next major.
|
|
31
14
|
*/
|
|
32
|
-
/** Failures that say nothing about whether the server committed. */
|
|
33
|
-
function isAmbiguousCreateFailure(code) {
|
|
34
|
-
return code === 'TIMEOUT' || code === 'request_deadline';
|
|
35
|
-
}
|
|
36
|
-
/** The string `code` an SDK `ApiError` (or any error-like value) carries. */
|
|
37
|
-
function errorCode(error) {
|
|
38
|
-
const code = isRecord(error) ? error.code : undefined;
|
|
39
|
-
return typeof code === 'string' ? code : undefined;
|
|
40
|
-
}
|
|
41
|
-
const isRecord = (value) => typeof value === 'object' && value !== null;
|
|
42
|
-
function isWarmRow(row) {
|
|
43
|
-
const metadata = row?.metadata;
|
|
44
|
-
return !!isRecord(metadata) && metadata.warm === true;
|
|
45
|
-
}
|
|
46
|
-
const COMMIT_CONFIRM_ATTEMPTS = 5;
|
|
47
|
-
const COMMIT_CONFIRM_DELAY_MS = 2_000;
|
|
48
|
-
const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
49
15
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* Polls because the commit can land AFTER the client's abort. A probe that
|
|
53
|
-
* throws (a 404 before the row is visible) counts as "not yet".
|
|
16
|
+
* @deprecated Warm sessions were removed (2026-11-03). Returns a pool that
|
|
17
|
+
* never holds a session and never calls `client`. Removed in the next major.
|
|
54
18
|
*/
|
|
55
|
-
|
|
56
|
-
for (let attempt = 0; attempt < attempts; attempt++) {
|
|
57
|
-
if (attempt > 0)
|
|
58
|
-
await sleep(delayMs);
|
|
59
|
-
try {
|
|
60
|
-
if (await probe())
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
catch {
|
|
64
|
-
// Not visible yet.
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
export function createWarmSessionPool(client, options) {
|
|
70
|
-
const ready = new Map();
|
|
71
|
-
const creating = new Set();
|
|
72
|
-
/** Every id this app took. A server echo of one must never be held again. */
|
|
73
|
-
const taken = new Set();
|
|
74
|
-
const inFlight = new Set();
|
|
75
|
-
/** Bumped by `reset`, so an ensure that started before sign-out is dropped. */
|
|
76
|
-
let generation = 0;
|
|
77
|
-
const runEnsure = (projectId, excludeSessionId, retriesLeft) => {
|
|
78
|
-
if (creating.has(projectId) || ready.has(projectId))
|
|
79
|
-
return Promise.resolve();
|
|
80
|
-
creating.add(projectId);
|
|
81
|
-
const startedIn = generation;
|
|
82
|
-
const run = (async () => {
|
|
83
|
-
let retryExclude = null;
|
|
84
|
-
try {
|
|
85
|
-
const session = await client.ensure(projectId, excludeSessionId);
|
|
86
|
-
if (startedIn !== generation)
|
|
87
|
-
return;
|
|
88
|
-
if (taken.has(session.sessionId))
|
|
89
|
-
retryExclude = session.sessionId;
|
|
90
|
-
else
|
|
91
|
-
ready.set(projectId, session);
|
|
92
|
-
}
|
|
93
|
-
catch {
|
|
94
|
-
// Invisible on purpose: the ordinary create is unchanged and still the
|
|
95
|
-
// authority on every gate (billing, connectors).
|
|
96
|
-
}
|
|
97
|
-
finally {
|
|
98
|
-
if (startedIn === generation)
|
|
99
|
-
creating.delete(projectId);
|
|
100
|
-
}
|
|
101
|
-
// One retry, excluding the echoed id, so a server that keeps offering a
|
|
102
|
-
// taken session cannot become a loop.
|
|
103
|
-
if (retryExclude && retriesLeft > 0) {
|
|
104
|
-
await runEnsure(projectId, retryExclude, retriesLeft - 1);
|
|
105
|
-
}
|
|
106
|
-
})();
|
|
107
|
-
inFlight.add(run);
|
|
108
|
-
void run.finally(() => inFlight.delete(run));
|
|
109
|
-
return run;
|
|
110
|
-
};
|
|
19
|
+
export function createWarmSessionPool(_client, _options) {
|
|
111
20
|
return {
|
|
112
|
-
ensure: (
|
|
113
|
-
take: (
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
void runEnsure(projectId, warm.sessionId, 1);
|
|
121
|
-
return options.fits(warm, send) ? warm : null;
|
|
122
|
-
},
|
|
123
|
-
prime: async (projectId, warm, input) => {
|
|
124
|
-
try {
|
|
125
|
-
await client.claim(projectId, input);
|
|
126
|
-
return true;
|
|
127
|
-
}
|
|
128
|
-
catch (error) {
|
|
129
|
-
if (!isAmbiguousCreateFailure(errorCode(error)))
|
|
130
|
-
return false;
|
|
131
|
-
// A timed-out claim can still commit. The claim drops the warm marker
|
|
132
|
-
// in the same transaction that stores the prompt, so a row without the
|
|
133
|
-
// marker already holds this prompt: answering false would send it
|
|
134
|
-
// through a second create — two sessions, two answers.
|
|
135
|
-
return confirmCommitted(async () => !isWarmRow(await client.read(projectId, warm.sessionId)), options.sleep ? { sleep: options.sleep } : {});
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
dropBySessionId: (sessionId) => {
|
|
139
|
-
for (const [projectId, warm] of ready) {
|
|
140
|
-
if (warm.sessionId !== sessionId)
|
|
141
|
-
continue;
|
|
142
|
-
ready.delete(projectId);
|
|
143
|
-
taken.add(sessionId);
|
|
144
|
-
return projectId;
|
|
145
|
-
}
|
|
146
|
-
return null;
|
|
147
|
-
},
|
|
148
|
-
revalidate: async (projectId) => {
|
|
149
|
-
const held = ready.get(projectId);
|
|
150
|
-
if (!held)
|
|
151
|
-
return false;
|
|
152
|
-
try {
|
|
153
|
-
if (isWarmRow(await client.read(projectId, held.sessionId)))
|
|
154
|
-
return false;
|
|
155
|
-
}
|
|
156
|
-
catch {
|
|
157
|
-
// Fail open: a network blip must not discard a good warm session.
|
|
158
|
-
return false;
|
|
159
|
-
}
|
|
160
|
-
// Drop only if a send did not take it while the read was in flight.
|
|
161
|
-
if (ready.get(projectId)?.sessionId !== held.sessionId)
|
|
162
|
-
return false;
|
|
163
|
-
ready.delete(projectId);
|
|
164
|
-
taken.add(held.sessionId);
|
|
165
|
-
return true;
|
|
166
|
-
},
|
|
167
|
-
held: (projectId) => ready.get(projectId) ?? null,
|
|
168
|
-
reset: () => {
|
|
169
|
-
generation += 1;
|
|
170
|
-
ready.clear();
|
|
171
|
-
creating.clear();
|
|
172
|
-
taken.clear();
|
|
173
|
-
},
|
|
174
|
-
settled: async () => {
|
|
175
|
-
while (inFlight.size > 0)
|
|
176
|
-
await Promise.all([...inFlight]);
|
|
177
|
-
},
|
|
21
|
+
ensure: async () => { },
|
|
22
|
+
take: () => null,
|
|
23
|
+
prime: async () => false,
|
|
24
|
+
dropBySessionId: () => null,
|
|
25
|
+
revalidate: async () => false,
|
|
26
|
+
held: () => null,
|
|
27
|
+
reset: () => { },
|
|
28
|
+
settled: async () => { },
|
|
178
29
|
};
|
|
179
30
|
}
|
|
180
31
|
//# sourceMappingURL=warm-session-pool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"warm-session-pool.js","sourceRoot":"","sources":["../../src/core/warm-session-pool.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"warm-session-pool.js","sourceRoot":"","sources":["../../src/core/warm-session-pool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAwCH;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CACnC,OAAmD,EACnD,QAAmD;IAEnD,OAAO;QACL,MAAM,EAAE,KAAK,IAAI,EAAE,GAAE,CAAC;QACtB,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI;QAChB,KAAK,EAAE,KAAK,IAAI,EAAE,CAAC,KAAK;QACxB,eAAe,EAAE,GAAG,EAAE,CAAC,IAAI;QAC3B,UAAU,EAAE,KAAK,IAAI,EAAE,CAAC,KAAK;QAC7B,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI;QAChB,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;QACf,OAAO,EAAE,KAAK,IAAI,EAAE,GAAE,CAAC;KACxB,CAAC;AACJ,CAAC"}
|