Merge remote-tracking branch 'origin/master' into fresh-1e8f1127-eff3-404e-b55f-d43d5a88f65a

This commit is contained in:
cryppadotta committed 2026-12-05 00:27:00 +00:00
commit ee62c52c98
36 files changed
+1307 -130

No files matched your search

+8
View File
@@ -75,6 +75,14 @@ Mobile task conversations size their shell to the visible viewport, with one
message scroller and a normal flex footer for the composer. Navigation stays at
the layout viewport bottom, behind the keyboard.
A task conversation is the one exception to stable page padding. Its message
scroller drives the navigation, measured from the latest message. Reading back
through the thread slides the composer and the navigation away together, and
the thread takes the freed height. The chrome hides only after the reader is
farther back than that freed height, so hiding never snaps the thread to the
latest message. Moving back toward the latest message, or reaching it, brings
both back. An open keyboard always keeps the composer on screen.
Cold task opens reveal the instruction and recent conversation independently of
recovery, related metadata, and historical run activity. Saved document cards,
the saved plan, and the bounded latest turn arrive before first reveal so they
+1
View File
@@ -133,6 +133,7 @@ DATABASE_PREPARED_STATEMENTS=false # use false when the pooler does not suppor
DATABASE_POOL_MAX=25 # connection pool size; default: 10
DATABASE_IDLE_TIMEOUT_SECONDS=60 # close idle pooled connections; default: 60 (0 = keep open)
DATABASE_CONNECT_TIMEOUT_SECONDS=10 # default: 30
DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS=2000 # time for each address of the host before the next; default: 2000
DATABASE_MAX_LIFETIME_SECONDS=1800 # recycle a pooled connection after this long; default: 30-60 min (random)
DATABASE_APPLICATION_NAME=paperclip # application_name in pg_stat_activity; default for the server's main pool: paperclip:<boot id>
```
+2 -1
View File
@@ -73,7 +73,7 @@ statements longer than 8 KB. If a prepared statement fails because the pooler's
stale after a schema change or was lost, Paperclip stops preparing that
statement and retries it once unprepared.
Related optional client tuning: `DATABASE_POOL_MAX`, `DATABASE_IDLE_TIMEOUT_SECONDS`, `DATABASE_CONNECT_TIMEOUT_SECONDS`, `DATABASE_MAX_LIFETIME_SECONDS`, `DATABASE_APPLICATION_NAME`. Driver defaults apply when unset, except that idle pooled connections close after 60 seconds (`DATABASE_IDLE_TIMEOUT_SECONDS=0` keeps them open) and the server's main pool reports `application_name=paperclip:<boot id>` (other pools use names that start with `paperclip`). See [Connection pool settings](#connection-pool-settings).
Related optional client tuning: `DATABASE_POOL_MAX`, `DATABASE_IDLE_TIMEOUT_SECONDS`, `DATABASE_CONNECT_TIMEOUT_SECONDS`, `DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS`, `DATABASE_MAX_LIFETIME_SECONDS`, `DATABASE_APPLICATION_NAME`. Driver defaults apply when unset, except that idle pooled connections close after 60 seconds (`DATABASE_IDLE_TIMEOUT_SECONDS=0` keeps them open), each address of the database host gets 2 seconds to answer a connection attempt, and the server's main pool reports `application_name=paperclip:<boot id>` (other pools use names that start with `paperclip`). See [Connection pool settings](#connection-pool-settings).
## Connection Pool Settings
@@ -84,6 +84,7 @@ The server opens one postgres.js pool for its own queries (and a second one when
| `DATABASE_POOL_MAX` | `10` (driver) | Maximum pooled connections. |
| `DATABASE_IDLE_TIMEOUT_SECONDS` | `60` | Close a pooled connection after this much idle time. `0` keeps idle connections open forever (the driver default). |
| `DATABASE_CONNECT_TIMEOUT_SECONDS` | `30` (driver) | Give up on a connection attempt after this long. |
| `DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS` | `2000` | When the database host name resolves to several addresses, wait this long for one address before trying the next. Node's own default (250 ms) is shorter than one TCP retransmission, so a single dropped packet could fail the connection. `DATABASE_CONNECT_TIMEOUT_SECONDS` still bounds the whole attempt. |
| `DATABASE_MAX_LIFETIME_SECONDS` | 30–60 min, randomized (driver) | Recycle a pooled connection once it is this old. |
| `DATABASE_APPLICATION_NAME` | `paperclip:<boot id>` (server main pool) | Value of `application_name` in `pg_stat_activity`. The boot id tells the sessions of each server process apart after a restart. Find Paperclip's backends with `SELECT * FROM pg_stat_activity WHERE application_name LIKE 'paperclip%';` |
| `DATABASE_DEDICATED_CONNECTION_MAX` | `24` | Dedicated lock connections in use at once per process before new callers wait. Nested callers do not wait. |
+13 -2
View File
@@ -1,6 +1,7 @@
import { describe, expect, it } from "vitest";
import {
DEFAULT_DATABASE_APPLICATION_NAME,
DEFAULT_DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS,
DEFAULT_DATABASE_IDLE_TIMEOUT_SECONDS,
databaseClientOptionsFromEnv,
postgresJsOptions,
@@ -35,6 +36,7 @@ describe("databaseClientOptionsFromEnv", () => {
DATABASE_POOL_MAX: "25",
DATABASE_IDLE_TIMEOUT_SECONDS: "60",
DATABASE_CONNECT_TIMEOUT_SECONDS: "10",
DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS: "1500",
DATABASE_MAX_LIFETIME_SECONDS: "1800",
DATABASE_APPLICATION_NAME: " paperclip-web ",
}),
@@ -42,6 +44,7 @@ describe("databaseClientOptionsFromEnv", () => {
maxConnections: 25,
idleTimeoutSeconds: 60,
connectTimeoutSeconds: 10,
connectAttemptTimeoutMs: 1500,
maxLifetimeSeconds: 1800,
applicationName: "paperclip-web",
});
@@ -60,6 +63,9 @@ describe("databaseClientOptionsFromEnv", () => {
expect(() => databaseClientOptionsFromEnv({ DATABASE_CONNECT_TIMEOUT_SECONDS: "1.5" })).toThrow(
/DATABASE_CONNECT_TIMEOUT_SECONDS/,
);
expect(() => databaseClientOptionsFromEnv({ DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS: "0" })).toThrow(
/DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS/,
);
expect(() => databaseClientOptionsFromEnv({ DATABASE_IDLE_TIMEOUT_SECONDS: "-1" })).toThrow(
/DATABASE_IDLE_TIMEOUT_SECONDS/,
);
@@ -81,6 +87,7 @@ describe("databaseClientOptionsFromEnv", () => {
maxConnections: 25,
idleTimeoutSeconds: 60,
connectTimeoutSeconds: 10,
connectAttemptTimeoutMs: 1500,
maxLifetimeSeconds: 1800,
applicationName: "paperclip-web",
}),
@@ -89,6 +96,7 @@ describe("databaseClientOptionsFromEnv", () => {
max: 25,
idle_timeout: 60,
connect_timeout: 10,
auto_select_family_attempt_timeout: 1500,
max_lifetime: 1800,
connection: { application_name: "paperclip-web" },
});
@@ -102,13 +110,15 @@ describe("databaseClientOptionsFromEnv", () => {
});
describe("resolveDatabaseClientOptions", () => {
it("reaps idle connections and names the pool when the environment sets nothing", () => {
it("reaps idle connections, bounds each address attempt and names the pool when the environment sets nothing", () => {
expect(resolveDatabaseClientOptions({})).toEqual({
idleTimeoutSeconds: DEFAULT_DATABASE_IDLE_TIMEOUT_SECONDS,
connectAttemptTimeoutMs: DEFAULT_DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS,
applicationName: DEFAULT_DATABASE_APPLICATION_NAME,
});
expect(postgresJsOptions(resolveDatabaseClientOptions(databaseClientOptionsFromEnv({})))).toEqual({
idle_timeout: DEFAULT_DATABASE_IDLE_TIMEOUT_SECONDS,
auto_select_family_attempt_timeout: DEFAULT_DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS,
connection: { application_name: DEFAULT_DATABASE_APPLICATION_NAME },
});
});
@@ -118,9 +128,10 @@ describe("resolveDatabaseClientOptions", () => {
resolveDatabaseClientOptions({
maxConnections: 3,
idleTimeoutSeconds: 0,
connectAttemptTimeoutMs: 500,
applicationName: "paperclip-cli",
}),
).toEqual({ maxConnections: 3, idleTimeoutSeconds: 0, applicationName: "paperclip-cli" });
).toEqual({ maxConnections: 3, idleTimeoutSeconds: 0, connectAttemptTimeoutMs: 500, applicationName: "paperclip-cli" });
expect(postgresJsOptions(resolveDatabaseClientOptions({ idleTimeoutSeconds: 0 }))).toMatchObject({
idle_timeout: 0,
});
+28 -3
View File
@@ -151,6 +151,13 @@ export interface DatabaseClientOptions {
idleTimeoutSeconds?: number;
/** postgres.js `connect_timeout` in seconds (driver default: 30). */
connectTimeoutSeconds?: number;
/**
* Time in milliseconds that one connection attempt gives each address of the
* database host before it tries the next one (Node's
* `autoSelectFamilyAttemptTimeout`, default 250). The whole attempt is still
* bounded by `connectTimeoutSeconds`.
*/
connectAttemptTimeoutMs?: number;
/**
* postgres.js `max_lifetime` in seconds. Bounds how long one pooled
* connection is reused before the client replaces it (driver default: a
@@ -183,6 +190,16 @@ export interface DatabaseClientOptions {
export const DEFAULT_DATABASE_IDLE_TIMEOUT_SECONDS = 60;
/** `application_name` reported to PostgreSQL unless `DATABASE_APPLICATION_NAME` overrides it. */
export const DEFAULT_DATABASE_APPLICATION_NAME = "paperclip";
/**
* Each address of the database host gets this many milliseconds unless
* `DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS` says otherwise. Node's own default of
* 250 ms is shorter than the first SYN retransmission (1 s on Linux). When the
* host name also has AAAA records and this machine has no IPv6 route, the last
* address fails at once, so a connection failed after about 750 ms when one
* packet was dropped, long before `connect_timeout`. 2 s lets each address
* answer a retransmitted SYN.
*/
export const DEFAULT_DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS = 2_000;
function envBoolean(env: NodeJS.ProcessEnv, name: string): boolean | undefined {
const value = env[name]?.trim().toLowerCase();
@@ -235,6 +252,8 @@ export function databaseClientOptionsFromEnv(env: NodeJS.ProcessEnv = process.en
if (idleTimeoutSeconds !== undefined) options.idleTimeoutSeconds = idleTimeoutSeconds;
const connectTimeoutSeconds = envPositiveInteger(env, "DATABASE_CONNECT_TIMEOUT_SECONDS");
if (connectTimeoutSeconds !== undefined) options.connectTimeoutSeconds = connectTimeoutSeconds;
const connectAttemptTimeoutMs = envPositiveInteger(env, "DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS");
if (connectAttemptTimeoutMs !== undefined) options.connectAttemptTimeoutMs = connectAttemptTimeoutMs;
const maxLifetimeSeconds = envPositiveInteger(env, "DATABASE_MAX_LIFETIME_SECONDS");
if (maxLifetimeSeconds !== undefined) options.maxLifetimeSeconds = maxLifetimeSeconds;
const applicationName = envNonEmptyString(env, "DATABASE_APPLICATION_NAME");
@@ -248,15 +267,17 @@ export function databaseClientOptionsFromEnv(env: NodeJS.ProcessEnv = process.en
/**
* Fills in Paperclip's defaults for the options the caller left unset: idle
* connections are reaped after `DEFAULT_DATABASE_IDLE_TIMEOUT_SECONDS`, and the
* pool identifies itself as `DEFAULT_DATABASE_APPLICATION_NAME`. Everything
* else stays at the driver default. An explicit value (including
* connections are reaped after `DEFAULT_DATABASE_IDLE_TIMEOUT_SECONDS`, each
* address of the database host gets `DEFAULT_DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS`,
* and the pool identifies itself as `DEFAULT_DATABASE_APPLICATION_NAME`.
* Everything else stays at the driver default. An explicit value (including
* `idleTimeoutSeconds: 0`) always wins over the default.
*/
export function resolveDatabaseClientOptions(options: DatabaseClientOptions): DatabaseClientOptions {
return {
...options,
idleTimeoutSeconds: options.idleTimeoutSeconds ?? DEFAULT_DATABASE_IDLE_TIMEOUT_SECONDS,
connectAttemptTimeoutMs: options.connectAttemptTimeoutMs ?? DEFAULT_DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS,
applicationName: options.applicationName ?? DEFAULT_DATABASE_APPLICATION_NAME,
};
}
@@ -267,6 +288,10 @@ export function postgresJsOptions(options: DatabaseClientOptions): Record<string
if (options.maxConnections !== undefined) driverOptions.max = options.maxConnections;
if (options.idleTimeoutSeconds !== undefined) driverOptions.idle_timeout = options.idleTimeoutSeconds;
if (options.connectTimeoutSeconds !== undefined) driverOptions.connect_timeout = options.connectTimeoutSeconds;
// Read by the patched postgres.js connect (patches/postgres@3.4.9.patch).
if (options.connectAttemptTimeoutMs !== undefined) {
driverOptions.auto_select_family_attempt_timeout = options.connectAttemptTimeoutMs;
}
if (options.maxLifetimeSeconds !== undefined) driverOptions.max_lifetime = options.maxLifetimeSeconds;
const connection: Record<string, string> = {};
if (options.applicationName !== undefined) connection.application_name = options.applicationName;
@@ -0,0 +1,48 @@
import net from "node:net";
import postgres from "postgres";
import { afterEach, describe, expect, it, vi } from "vitest";
import {
DEFAULT_DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS,
postgresJsOptions,
resolveDatabaseClientOptions,
} from "./client.js";
// Node tries each address of a database host name in turn (happy eyeballs) and
// by default gives every address but the last only 250 ms. When the last
// address is IPv6 on a host with no IPv6 route, it fails at once, so a host
// name with three A and three AAAA records fails to connect after about 750 ms
// whatever `connect_timeout` says. A single dropped SYN then fails the query.
describe("database connect attempt timeout", () => {
afterEach(() => {
vi.restoreAllMocks();
});
it("gives each address of the database host enough time for a retransmitted SYN by default", () => {
expect(DEFAULT_DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS).toBeGreaterThanOrEqual(1_000);
expect(postgresJsOptions(resolveDatabaseClientOptions({}))).toMatchObject({
auto_select_family_attempt_timeout: DEFAULT_DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS,
});
});
it("passes the per-address budget to the socket that postgres.js opens", async () => {
const connect = vi.spyOn(net.Socket.prototype, "connect");
// Port 1 on loopback refuses at once; only the connect arguments matter.
const sql = postgres("postgres://paperclip:unused@127.0.0.1:1/paperclip", {
...postgresJsOptions(resolveDatabaseClientOptions({ connectTimeoutSeconds: 5 })),
max: 1,
onnotice: () => {},
});
try {
await expect(sql`select 1`).rejects.toMatchObject({ code: "ECONNREFUSED" });
} finally {
await sql.end({ timeout: 0 });
}
expect(connect).toHaveBeenCalled();
expect(connect.mock.calls[0]?.[0]).toMatchObject({
host: "127.0.0.1",
port: 1,
autoSelectFamilyAttemptTimeout: DEFAULT_DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS,
});
});
});
@@ -51,7 +51,7 @@
"postpack": "if [ -f package.dev.json ]; then mv package.dev.json package.json; fi"
},
"dependencies": {
"novita-sandbox": "^1.0.3-b2"
"novita-sandbox": "^2.1.5"
},
"devDependencies": {
"@types/node": "^24.0.0",
+54 -8
View File
@@ -1,5 +1,5 @@
diff --git a/cjs/src/connection.js b/cjs/src/connection.js
index 07f6716702ac888215c86ad6e0071aaf55ae519c..4ee75faa8ae47555576e3b4e0ec6b7c4b140ec2f 100644
index 07f6716702ac888215c86ad6e0071aaf55ae519c..3ecac096b4d757364d4a9b33add6ded4eecbd80f 100644
--- a/cjs/src/connection.js
+++ b/cjs/src/connection.js
@@ -173,8 +173,8 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
@@ -21,7 +21,22 @@ index 07f6716702ac888215c86ad6e0071aaf55ae519c..4ee75faa8ae47555576e3b4e0ec6b7c4
}
async function connect() {
@@ -438,6 +440,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
@@ -351,7 +353,13 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
return socket.connect(options.path)
socket.ssl = ssl
- socket.connect(port[hostIndex], host[hostIndex])
+ socket.connect({
+ port: port[hostIndex],
+ host: host[hostIndex],
+ ...(options.auto_select_family_attempt_timeout
+ ? { autoSelectFamilyAttemptTimeout: options.auto_select_family_attempt_timeout }
+ : {})
+ })
socket.host = host[hostIndex]
socket.port = port[hostIndex]
@@ -438,6 +446,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
remaining = 0
incomings = null
clearImmediate(nextWriteTimer)
@@ -29,7 +44,7 @@ index 07f6716702ac888215c86ad6e0071aaf55ae519c..4ee75faa8ae47555576e3b4e0ec6b7c4
socket.removeListener('data', data)
socket.removeListener('connect', connected)
idleTimer.cancel()
@@ -451,6 +454,9 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
@@ -451,6 +460,9 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
return reconnect()
!hadError && (query || sent.length) && error(Errors.connection('CONNECTION_CLOSED', options, socket))
@@ -40,7 +55,7 @@ index 07f6716702ac888215c86ad6e0071aaf55ae519c..4ee75faa8ae47555576e3b4e0ec6b7c4
hadError && options.shared.retries++
delay = (typeof backoff === 'function' ? backoff(options.shared.retries) : backoff) * 1000
diff --git a/cjs/src/index.js b/cjs/src/index.js
index f09c61c7e998f411560b95c9a8e1ed6a97972c11..04dded5c7e2cdc34ac01b29a87cc93248ec8c9c6 100644
index f09c61c7e998f411560b95c9a8e1ed6a97972c11..5ae05848b627d4e7b849eb093a3d9ceb7f922b6d 100644
--- a/cjs/src/index.js
+++ b/cjs/src/index.js
@@ -216,8 +216,19 @@ function Postgres(a, b) {
@@ -102,6 +117,14 @@ index f09c61c7e998f411560b95c9a8e1ed6a97972c11..04dded5c7e2cdc34ac01b29a87cc9324
c.queue === full
? queries.push(q)
: c.execute(q) || move(c, full)
@@ -493,6 +514,7 @@ function parseOptions(a, b) {
onclose : o.onclose,
onparameter : o.onparameter,
socket : o.socket,
+ auto_select_family_attempt_timeout: o.auto_select_family_attempt_timeout,
transform : parseTransform(o.transform || { undefined: undefined }),
parameters : {},
shared : { retries: 0, typeArrayMap: {} },
diff --git a/cjs/src/queue.js b/cjs/src/queue.js
index 8438f5da92cf7637d98a33491d75c75b1c817c25..1c9a330fa173ecae84219055368cf630feadbda2 100644
--- a/cjs/src/queue.js
@@ -131,7 +154,7 @@ index 8438f5da92cf7637d98a33491d75c75b1c817c25..1c9a330fa173ecae84219055368cf630
xs[index - 1] = undefined
}
diff --git a/src/connection.js b/src/connection.js
index 1b1cccde43b4570d5d071d6ffaab2669b3c2065a..0a4c4cc185f14afa30c7c6a294bafe689e685683 100644
index 1b1cccde43b4570d5d071d6ffaab2669b3c2065a..a5057f0d1b03898b4c22b8711498871f200cce69 100644
--- a/src/connection.js
+++ b/src/connection.js
@@ -173,8 +173,8 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
@@ -153,7 +176,22 @@ index 1b1cccde43b4570d5d071d6ffaab2669b3c2065a..0a4c4cc185f14afa30c7c6a294bafe68
}
async function connect() {
@@ -438,6 +440,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
@@ -351,7 +353,13 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
return socket.connect(options.path)
socket.ssl = ssl
- socket.connect(port[hostIndex], host[hostIndex])
+ socket.connect({
+ port: port[hostIndex],
+ host: host[hostIndex],
+ ...(options.auto_select_family_attempt_timeout
+ ? { autoSelectFamilyAttemptTimeout: options.auto_select_family_attempt_timeout }
+ : {})
+ })
socket.host = host[hostIndex]
socket.port = port[hostIndex]
@@ -438,6 +446,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
remaining = 0
incomings = null
clearImmediate(nextWriteTimer)
@@ -161,7 +199,7 @@ index 1b1cccde43b4570d5d071d6ffaab2669b3c2065a..0a4c4cc185f14afa30c7c6a294bafe68
socket.removeListener('data', data)
socket.removeListener('connect', connected)
idleTimer.cancel()
@@ -451,6 +454,9 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
@@ -451,6 +460,9 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
return reconnect()
!hadError && (query || sent.length) && error(Errors.connection('CONNECTION_CLOSED', options, socket))
@@ -172,7 +210,7 @@ index 1b1cccde43b4570d5d071d6ffaab2669b3c2065a..0a4c4cc185f14afa30c7c6a294bafe68
hadError && options.shared.retries++
delay = (typeof backoff === 'function' ? backoff(options.shared.retries) : backoff) * 1000
diff --git a/src/index.js b/src/index.js
index c7fba3dace20173f4cb13f3f138bb6d213b43683..f0888986add8ba02c8853f792ae42dd1cec88c82 100644
index c7fba3dace20173f4cb13f3f138bb6d213b43683..59fcbc0d44e709e86abdf34e47ad6bc98a9e6974 100644
--- a/src/index.js
+++ b/src/index.js
@@ -216,8 +216,19 @@ function Postgres(a, b) {
@@ -234,6 +272,14 @@ index c7fba3dace20173f4cb13f3f138bb6d213b43683..f0888986add8ba02c8853f792ae42dd1
c.queue === full
? queries.push(q)
: c.execute(q) || move(c, full)
@@ -493,6 +514,7 @@ function parseOptions(a, b) {
onclose : o.onclose,
onparameter : o.onparameter,
socket : o.socket,
+ auto_select_family_attempt_timeout: o.auto_select_family_attempt_timeout,
transform : parseTransform(o.transform || { undefined: undefined }),
parameters : {},
shared : { retries: 0, typeArrayMap: {} },
diff --git a/src/queue.js b/src/queue.js
index c4ef97164f057db99dce1b9af3401dbb1af37e31..46e7ade55c0a3250137a21117c03ce9166b40bc2 100644
--- a/src/queue.js
+17 -17
View File
@@ -46,7 +46,7 @@ patchedDependencies:
hash: 55uhvnotpqyiy37rn3pqpukhei
path: patches/embedded-postgres@18.1.0-beta.16.patch
postgres@3.4.9:
hash: 7s673zkrux4f7d7y4kyzk7opyu
hash: 2ucarb2ongic7ioq4v4x67fgri
path: patches/postgres@3.4.9.patch
importers:
@@ -139,7 +139,7 @@ importers:
version: 17.4.2
drizzle-orm:
specifier: 0.45.2
version: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu))
version: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri))
embedded-postgres:
specifier: ^18.1.0-beta.16
version: 18.1.0-beta.16(patch_hash=55uhvnotpqyiy37rn3pqpukhei)
@@ -411,13 +411,13 @@ importers:
version: link:../shared
drizzle-orm:
specifier: ^0.45.2
version: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu))
version: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri))
embedded-postgres:
specifier: ^18.1.0-beta.16
version: 18.1.0-beta.16(patch_hash=55uhvnotpqyiy37rn3pqpukhei)
postgres:
specifier: ^3.4.9
version: 3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)
version: 3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)
devDependencies:
'@types/node':
specifier: ^24.0.0
@@ -1024,7 +1024,7 @@ importers:
version: 2.2.0(@grpc/grpc-js@1.14.5)(nice-grpc-common@2.0.4)(nice-grpc@2.1.17)
'@vercel/connect':
specifier: 2.3.3
version: 2.3.3(@chat-adapter/slack@4.39.0(patch_hash=eskb5kxp7eud5v3ostluhynfoa)(ai@7.0.130(zod@4.6.7))(zod@4.6.7))(@modelcontextprotocol/sdk@1.31.0(zod@4.6.7))(ai@7.0.130(zod@4.6.7))(better-auth@1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1))))
version: 2.3.3(@chat-adapter/slack@4.39.0(patch_hash=eskb5kxp7eud5v3ostluhynfoa)(ai@7.0.130(zod@4.6.7))(zod@4.6.7))(@modelcontextprotocol/sdk@1.31.0(zod@4.6.7))(ai@7.0.130(zod@4.6.7))(better-auth@1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1))))
acorn:
specifier: 8.18.0
version: 8.18.0
@@ -1042,7 +1042,7 @@ importers:
version: 3.0.1(ajv@8.20.0)
better-auth:
specifier: 1.7.16
version: 1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1)))
version: 1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1)))
chat:
specifier: 4.39.0
version: 4.39.0(ai@7.0.130(zod@4.6.7))(zod@4.6.7)
@@ -1063,7 +1063,7 @@ importers:
version: 17.4.2
drizzle-orm:
specifier: ^0.45.2
version: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu))
version: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri))
embedded-postgres:
specifier: ^18.1.0-beta.16
version: 18.1.0-beta.16(patch_hash=55uhvnotpqyiy37rn3pqpukhei)
@@ -10356,12 +10356,12 @@ snapshots:
optionalDependencies:
'@opentelemetry/api': 1.9.1
'@better-auth/drizzle-adapter@1.7.16(@better-auth/core@1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3))(@better-auth/utils@0.5.1)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)))':
'@better-auth/drizzle-adapter@1.7.16(@better-auth/core@1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3))(@better-auth/utils@0.5.1)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)))':
dependencies:
'@better-auth/core': 1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3)
'@better-auth/utils': 0.5.1
optionalDependencies:
drizzle-orm: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu))
drizzle-orm: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri))
'@better-auth/kysely-adapter@1.7.16(@better-auth/core@1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3))(@better-auth/utils@0.5.1)(kysely@0.29.5)':
dependencies:
@@ -14313,14 +14313,14 @@ snapshots:
dependencies:
execa: 5.1.1
'@vercel/connect@2.3.3(@chat-adapter/slack@4.39.0(patch_hash=eskb5kxp7eud5v3ostluhynfoa)(ai@7.0.130(zod@4.6.7))(zod@4.6.7))(@modelcontextprotocol/sdk@1.31.0(zod@4.6.7))(ai@7.0.130(zod@4.6.7))(better-auth@1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1))))':
'@vercel/connect@2.3.3(@chat-adapter/slack@4.39.0(patch_hash=eskb5kxp7eud5v3ostluhynfoa)(ai@7.0.130(zod@4.6.7))(zod@4.6.7))(@modelcontextprotocol/sdk@1.31.0(zod@4.6.7))(ai@7.0.130(zod@4.6.7))(better-auth@1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1))))':
dependencies:
'@vercel/oidc': 3.8.9
optionalDependencies:
'@chat-adapter/slack': 4.39.0(patch_hash=eskb5kxp7eud5v3ostluhynfoa)(ai@7.0.130(zod@4.6.7))(zod@4.6.7)
'@modelcontextprotocol/sdk': 1.31.0(zod@4.6.7)
ai: 7.0.130(zod@4.6.7)
better-auth: 1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1)))
better-auth: 1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1)))
'@vercel/oidc@3.2.0': {}
@@ -14579,10 +14579,10 @@ snapshots:
before-after-hook@4.0.0: {}
better-auth@1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1))):
better-auth@1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1))):
dependencies:
'@better-auth/core': 1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3)
'@better-auth/drizzle-adapter': 1.7.16(@better-auth/core@1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3))(@better-auth/utils@0.5.1)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)))
'@better-auth/drizzle-adapter': 1.7.16(@better-auth/core@1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3))(@better-auth/utils@0.5.1)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)))
'@better-auth/kysely-adapter': 1.7.16(@better-auth/core@1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3))(@better-auth/utils@0.5.1)(kysely@0.29.5)
'@better-auth/memory-adapter': 1.7.16(@better-auth/core@1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3))(@better-auth/utils@0.5.1)
'@better-auth/mongo-adapter': 1.7.16(@better-auth/core@1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3))(@better-auth/utils@0.5.1)
@@ -14600,7 +14600,7 @@ snapshots:
zod: 4.6.7
optionalDependencies:
drizzle-kit: 0.31.11
drizzle-orm: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu))
drizzle-orm: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri))
pg: 8.18.0
react: 19.2.8
react-dom: 19.2.8(react@19.2.8)
@@ -15195,12 +15195,12 @@ snapshots:
esbuild: 0.25.12
tsx: 4.23.15
drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)):
drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)):
optionalDependencies:
'@opentelemetry/api': 1.9.1
kysely: 0.29.5
pg: 8.18.0
postgres: 3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)
postgres: 3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)
dunder-proto@1.0.1:
dependencies:
@@ -17113,7 +17113,7 @@ snapshots:
dependencies:
xtend: 4.0.2
postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu): {}
postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri): {}
posthog-node@5.38.2(rxjs@7.8.2):
dependencies:
+101 -30
View File
@@ -137,8 +137,8 @@ importers:
../../packages/plugins/sandbox-providers/novita:
dependencies:
novita-sandbox:
specifier: ^1.0.3-b2
version: 1.0.3-b2
specifier: ^2.1.5
version: 2.1.5
devDependencies:
'@types/node':
specifier: ^24.0.0
@@ -156,9 +156,6 @@ packages:
resolution: {integrity: sha512-aUhnhF3nN/0iqP82hclSLH0YWbG6A4vB7iBWR94lMaQfQkMHjT0YX+RYcNY8QAO3y9iZniYDJCC3+zqQLgGcrA==}
engines: {node: '>=20'}
'@bufbuild/protobuf@2.16.0':
resolution: {integrity: sha512-FWa0sPlqYGJgpTs6OxBRcL/AW4JT0OIO+W1ajerluoTVh8CV0B7XM1qsNCRgnkSCkRCgOICKHRQlY17jrsm0+Q==}
'@bufbuild/protobuf@2.17.0':
resolution: {integrity: sha512-hcPkSz6D7MiTU/5VBBhK+kxaYDoOdQ6yJRFJ3kS8Nydp+VZXfg1vrpABKPNod8bXMufsVCmiUJVIKFzCzta4uw==}
@@ -1075,6 +1072,10 @@ packages:
resolution: {integrity: sha512-Vh3dmFbc4wZeox7M9I/0L9GfFd83Su4+yCck/OF9Gi/P/dAHn0RT7X4K9R7gMNMhDck3DvhR6QXsnQdjjgwNvQ==}
engines: {node: 20 || >=22}
brace-expansion@5.1.2:
resolution: {integrity: sha512-ELhY3JEerIBbhgW+rh0/8glkZAaMqn1x3BAvp3yTULSEGozMK/5PT6WTdBgsdvJqwwmv7MAQNOydfYbvK1Vgfw==}
engines: {node: 20 || >=22}
call-bind-apply-helpers@1.0.2:
resolution: {integrity: sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==}
engines: {node: '>= 0.4'}
@@ -1147,6 +1148,9 @@ packages:
devtools-protocol@0.0.1182435:
resolution: {integrity: sha512-EmlkWb62wSbQNE1gRZZsi4KZYRaF5Skpp183LhRU7+sadKR06O1dHCjZmFSEG6Kv7P6S/UYLxcY3NlYwqKM99w==}
dockerfile-ast@0.7.1:
resolution: {integrity: sha512-oX/A4I0EhSkGqrFv0YuvPkBUSYp1XiY8O8zAKc8Djglx8ocz+JfOr8gP0ryRMC2myqvDLagmnZaU9ot1vG2ijw==}
dotenv@16.3.1:
resolution: {integrity: sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==}
engines: {node: '>=12'}
@@ -1257,6 +1261,10 @@ packages:
resolution: {integrity: sha512-OwXjVP2svY5EyLY75Vek96C8qK43gqrt4xsZ+qSILdnaEiJPXkd62mcfUSNx/TQErQRdu5uM5kF67sfONragKw==}
engines: {node: 18 || 20 || >=22}
glob@14.0.7:
resolution: {integrity: sha512-ob8P0VbyEjcLG2ycNYmzYhZj65kkcN5b7tt5moGhTq3rkXtuU8MB+i0GIzPtLnSHVF2DkK4M+nQRojDvsOGVJw==}
engines: {node: 18 || 20 || >=22}
gopd@1.2.0:
resolution: {integrity: sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==}
engines: {node: '>= 0.4'}
@@ -1323,6 +1331,10 @@ packages:
resolution: {integrity: sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==}
engines: {node: 20 || >=22}
lru-cache@11.5.4:
resolution: {integrity: sha512-B8nJCTi8JuSaDBg0tBdnImV6j5O2CXaqKfdj24ZTCFbyivN8KZ2Z+RL3aHjwJAfLutD9cNnObG4SIgW4gMufiw==}
engines: {node: 20 || >=22}
magic-string@1.4.5:
resolution: {integrity: sha512-oLLC2+YvQUfAa+vxoufE/yc1icb87M9iXIRqAoR/2EhE/8cb3SF/+Gi0c2By1B+5Vz2e2vQtUvHiu1+63Znh+w==}
@@ -1347,6 +1359,10 @@ packages:
kerberos:
optional: true
minimatch@11.0.10:
resolution: {integrity: sha512-L3/cjhQ5E6lft0VCp/2mO3Ic74RnutKy3rz7iGwp/6w1hKcO262g2rbfacFyw6eBig5OdI0nu5PpuA0/WQs9Tw==}
engines: {node: 20 || >=22}
minimatch@11.0.9:
resolution: {integrity: sha512-KCFkfyjqerNlSstjlhIGNXIKZGA/6O4V4RlhZ+Dsr621SPPw0mzlypE9D9ZOoPiVefHID+j7/XuMMlqfD/F60Q==}
engines: {node: 20 || >=22}
@@ -1394,9 +1410,9 @@ packages:
resolution: {integrity: sha512-+P72GAjVAbTxjjwUmwjVrqrdZROD4nf8KgpBoDxqXXTiYZZt/ud60dE5yvCSr9lRO8e8yv6kgJIC0K0PfZFVQw==}
hasBin: true
novita-sandbox@1.0.3-b2:
resolution: {integrity: sha512-W0TbVfacreckxdbw1Tbh9dPYVZKjr4e0qRnMj/oxNj+gw01CRKA5Nf8uwSPaMI5daRazyo+ZVnV7WZchKhHbNQ==}
engines: {node: '>=16.0.0'}
novita-sandbox@2.1.5:
resolution: {integrity: sha512-CMDW+NqbrjoN/db+qr4ZGQ1UlwCMTm3To9ITFTVk/j6/lmivfvm3l6RVWwP24FlDwoX5f/LEWje/v5lusII1qg==}
engines: {node: '>=20'}
oauth4webapi@3.8.8:
resolution: {integrity: sha512-8N28E+a/oxfXWBgOMt+ZP/JUf/XR+IFbvkAEPP3gznXOMv9BpAAwiIj0TFNz3tGTPc0ZQ8zmWBNgN1nAys0gng==}
@@ -1408,14 +1424,14 @@ packages:
once@1.4.0:
resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==}
openapi-fetch@0.14.1:
resolution: {integrity: sha512-l7RarRHxlEZYjMLd/PR0slfMVse2/vvIAGm75/F7J6MlQ8/b9uUQmUF2kCPrQhJqMXSxmYWObVgeYXbFYzZR+A==}
openapi-fetch@0.17.0:
resolution: {integrity: sha512-PsbZR1wAPcG91eEthKhN+Zn92FMHxv+/faECIwjXdxfTODGSGegYv0sc1Olz+HYPvKOuoXfp+0pA2XVt2cI0Ig==}
openapi-fetch@0.9.8:
resolution: {integrity: sha512-zM6elH0EZStD/gSiNlcPrzXcVQ/pZo3BDvC6CDwRDUt1dDzxlshpmQnpD6cZaJ39THaSmwVCxxRrPKNM1hHrDg==}
openapi-typescript-helpers@0.0.8:
resolution: {integrity: sha512-1eNjQtbfNi5Z/kFhagDIaIRj6qqDzhjNJKz8cmMW0CVdGwT6e1GLbAfgI0d28VTJa1A8jz82jm/4dG8qNoNS8g==}
openapi-typescript-helpers@0.0.15:
resolution: {integrity: sha512-opyTPaunsklCBpTK8JGef6mfPhLSnyy5a0IN9vKtx3+4aExf+KxEqYwIy3hqkedXIB97u357uLMJsOnm3GVjsw==}
openapi-typescript-helpers@0.1.0:
resolution: {integrity: sha512-OKTGPthhivLw/fHz6c3OPtg72vi86qaMlqbJuVJ23qOvQ+53uw1n7HdmkJFibloF7QEjDrDkzJiOJuockM/ljw==}
@@ -1427,6 +1443,10 @@ packages:
resolution: {integrity: sha512-1pTbQqH1wIwMi/eleQ5leFTTCkzFsPcgXNjwOA8YGGW/W4/kHT3dssE7Z6NH+zuqNLOzOB0uaD61yl7cAcVhgg==}
engines: {node: 18 || 20 || >=22}
path-scurry@3.0.3:
resolution: {integrity: sha512-Ie3c3F+7WJOUCr0r8V8uEunY5Sj4PGFDoBZvFw7JmHJs/+H5GZK+GsIM8tHMcZy7c27Zj+U1NOcVzqlC7tBJpg==}
engines: {node: 18 || 20 || >=22}
path-to-regexp@6.3.0:
resolution: {integrity: sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==}
@@ -1532,6 +1552,10 @@ packages:
resolution: {integrity: sha512-lkukzdoGngZHJZXxW4S/E4Fp9ghTDlyZXrQGRNoJ/LXvDKcXUTq2sg5yQe74po7Voea6n/IN09+wE/QvJMiifA==}
engines: {node: '>=18'}
tar@7.5.24:
resolution: {integrity: sha512-to/OxuCk5DeVONcjjODT7aeoRq5NIPPlfPc0tNML+wLlnf6u5BcJz97Uukv3pT3jzorkFhUevylkAiBr+ZmV2w==}
engines: {node: '>=18'}
teex@1.0.1:
resolution: {integrity: sha512-eYE6iEI62Ni1H8oIa7KlDU6uQBtqr4Eajni3wX7rpfXD8ysFx8z0+dri+KWEPWpBsxXfxu58x/0jvTVT1ekOSg==}
@@ -1666,6 +1690,12 @@ packages:
jsdom:
optional: true
vscode-languageserver-textdocument@1.0.16:
resolution: {integrity: sha512-qeNEuOi9a3qkqRf7Gfez2WL2VwlBTLCNekHBGO9kxPVUp9XuY15yfTJ9jwvOwKI0I2MhUUfZq95NSp+LK1CLQg==}
vscode-languageserver-types@3.18.6:
resolution: {integrity: sha512-DEDtik4YupS+nOg4JxqJ2H5ec/m4tTD9a5mGcBVGYkQKZQo1AIF3ZToiP8+A0kUzyhyqX5dMnPDEnhtmzts7GA==}
web-streams-polyfill@4.0.0-beta.3:
resolution: {integrity: sha512-QW95TCTaHmsYfHDybGMwO5IJIM93I/6vTRk+daHTWFPhwh+C8Cg7j7XyKrwrj8Ib6vYXe0ocYNrmzY4xAAN6ug==}
engines: {node: '>= 14'}
@@ -1764,8 +1794,6 @@ snapshots:
'@bufbuild/protobuf': 2.17.0
'@grpc/grpc-js': 1.14.7
'@bufbuild/protobuf@2.16.0': {}
'@bufbuild/protobuf@2.17.0': {}
'@cbor-extract/cbor-extract-darwin-arm64@2.2.3':
@@ -1827,19 +1855,19 @@ snapshots:
optionalDependencies:
vitest: 5.1.2(@opentelemetry/api@1.10.0)(@types/node@24.19.2)(vite@7.3.7(@types/node@24.19.2)(yaml@2.9.1))
'@connectrpc/connect-web@2.0.0-rc.3(@bufbuild/protobuf@2.16.0)(@connectrpc/connect@2.0.0-rc.3(@bufbuild/protobuf@2.16.0))':
'@connectrpc/connect-web@2.0.0-rc.3(@bufbuild/protobuf@2.17.0)(@connectrpc/connect@2.0.0-rc.3(@bufbuild/protobuf@2.17.0))':
dependencies:
'@bufbuild/protobuf': 2.16.0
'@connectrpc/connect': 2.0.0-rc.3(@bufbuild/protobuf@2.16.0)
'@bufbuild/protobuf': 2.17.0
'@connectrpc/connect': 2.0.0-rc.3(@bufbuild/protobuf@2.17.0)
'@connectrpc/connect-web@2.3.0(@bufbuild/protobuf@2.17.0)(@connectrpc/connect@2.3.0(@bufbuild/protobuf@2.17.0))':
dependencies:
'@bufbuild/protobuf': 2.17.0
'@connectrpc/connect': 2.3.0(@bufbuild/protobuf@2.17.0)
'@connectrpc/connect@2.0.0-rc.3(@bufbuild/protobuf@2.16.0)':
'@connectrpc/connect@2.0.0-rc.3(@bufbuild/protobuf@2.17.0)':
dependencies:
'@bufbuild/protobuf': 2.16.0
'@bufbuild/protobuf': 2.17.0
'@connectrpc/connect@2.3.0(@bufbuild/protobuf@2.17.0)':
dependencies:
@@ -2394,6 +2422,10 @@ snapshots:
dependencies:
balanced-match: 4.0.4
brace-expansion@5.1.2:
dependencies:
balanced-match: 4.0.4
call-bind-apply-helpers@1.0.2:
dependencies:
es-errors: 1.3.0
@@ -2465,6 +2497,11 @@ snapshots:
devtools-protocol@0.0.1182435: {}
dockerfile-ast@0.7.1:
dependencies:
vscode-languageserver-textdocument: 1.0.16
vscode-languageserver-types: 3.18.6
dotenv@16.3.1: {}
dunder-proto@1.0.1:
@@ -2609,6 +2646,12 @@ snapshots:
minipass: 7.1.3
path-scurry: 3.0.0
glob@14.0.7:
dependencies:
minimatch: 11.0.10
minipass: 7.1.3
path-scurry: 3.0.3
gopd@1.2.0: {}
has-symbols@1.1.0: {}
@@ -2657,6 +2700,8 @@ snapshots:
lru-cache@11.5.3: {}
lru-cache@11.5.4: {}
magic-string@1.4.5:
dependencies:
'@jridgewell/sourcemap-codec': 1.6.0
@@ -2682,6 +2727,11 @@ snapshots:
- bufferutil
- utf-8-validate
minimatch@11.0.10:
dependencies:
'@isaacs/nonrecursive-glob-match': 1.1.0
brace-expansion: 5.1.2
minimatch@11.0.9:
dependencies:
'@isaacs/nonrecursive-glob-match': 1.1.0
@@ -2727,14 +2777,18 @@ snapshots:
detect-libc: 2.1.2
optional: true
novita-sandbox@1.0.3-b2:
novita-sandbox@2.1.5:
dependencies:
'@bufbuild/protobuf': 2.16.0
'@connectrpc/connect': 2.0.0-rc.3(@bufbuild/protobuf@2.16.0)
'@connectrpc/connect-web': 2.0.0-rc.3(@bufbuild/protobuf@2.16.0)(@connectrpc/connect@2.0.0-rc.3(@bufbuild/protobuf@2.16.0))
'@bufbuild/protobuf': 2.17.0
'@connectrpc/connect': 2.0.0-rc.3(@bufbuild/protobuf@2.17.0)
'@connectrpc/connect-web': 2.0.0-rc.3(@bufbuild/protobuf@2.17.0)(@connectrpc/connect@2.0.0-rc.3(@bufbuild/protobuf@2.17.0))
chalk: 5.6.2
compare-versions: 6.1.1
openapi-fetch: 0.9.8
dockerfile-ast: 0.7.1
glob: 14.0.7
openapi-fetch: 0.14.1
platform: 1.3.6
tar: 7.5.24
oauth4webapi@3.8.8: {}
@@ -2744,15 +2798,15 @@ snapshots:
dependencies:
wrappy: 1.0.2
openapi-fetch@0.14.1:
dependencies:
openapi-typescript-helpers: 0.0.15
openapi-fetch@0.17.0:
dependencies:
openapi-typescript-helpers: 0.1.0
openapi-fetch@0.9.8:
dependencies:
openapi-typescript-helpers: 0.0.8
openapi-typescript-helpers@0.0.8: {}
openapi-typescript-helpers@0.0.15: {}
openapi-typescript-helpers@0.1.0: {}
@@ -2766,6 +2820,11 @@ snapshots:
lru-cache: 11.5.3
minipass: 7.1.3
path-scurry@3.0.3:
dependencies:
lru-cache: 11.5.4
minipass: 7.1.3
path-to-regexp@6.3.0: {}
pathe@2.0.3: {}
@@ -2947,6 +3006,14 @@ snapshots:
minizlib: 3.1.0
yallist: 5.0.0
tar@7.5.24:
dependencies:
'@isaacs/fs-minipass': 4.0.1
chownr: 3.0.0
minipass: 7.1.3
minizlib: 3.1.0
yallist: 5.0.0
teex@1.0.1:
dependencies:
streamx: 2.28.1
@@ -3048,6 +3115,10 @@ snapshots:
transitivePeerDependencies:
- msw
vscode-languageserver-textdocument@1.0.16: {}
vscode-languageserver-types@3.18.6: {}
web-streams-polyfill@4.0.0-beta.3: {}
webidl-conversions@3.0.1: {}
@@ -779,7 +779,7 @@ describe("agent lifecycle retry authorization", () => {
const res = await requestApp(app, base => request(base).post(`/api/agents/${agentId}/lifecycle/retry`).send({}));
expect(res.status).toBe(200);
expect(res.body).toMatchObject({ id: agentId, lifecycleState: "preparing", lifecycleError: null });
expect(mockAgentService.retryLifecycle).toHaveBeenCalledWith(agentId);
expect(mockAgentService.retryLifecycle).toHaveBeenCalledWith(agentId, "board");
expect(mockLogActivity).toHaveBeenCalledWith(expect.anything(), expect.objectContaining({
companyId, entityId: agentId, action: "agent.lifecycle_retried", actorType: "user", actorId: "board",
}));
+1
View File
@@ -76,6 +76,7 @@ export interface ClaudeLoginContext {
}
export interface UpdateAgentOptions {
responsibleUserId?: string | null;
expectedConfigurationRevision?: string;
expectedConfiguration?: Pick<AgentConfigurationRecord, "adapterType" | "adapterConfig" | "runtimeConfig" | "defaultEnvironmentId">;
recordRevision?: RevisionMetadata;
@@ -165,13 +165,19 @@ const support = await getEmbeddedPostgresTestSupport();
});
it.each(["idle", "running"])("automatically pauses an %s agent, prepares its new environment, and verifies before readiness", async status => {
const id = await agent(otherEnvironmentId, { status, lifecycleRequiredPluginIds: [] });
const saved = await agentConfiguration(db).update(id, { defaultEnvironmentId: boundEnvironmentId });
const id = await agent(otherEnvironmentId, { status, lifecycleRequiredPluginIds: [],
lifecycleOperation: { id: randomUUID(), hostComplete: true, completedPluginIds: [], attempts: 0, responsibleUserId: "earlier-configurer" } });
const saved = await agentConfiguration(db).update(id, { defaultEnvironmentId: boundEnvironmentId }, {
recordRevision: { createdByUserId: "current-configurer", source: "patch" },
});
expect(saved).toMatchObject({ defaultEnvironmentId: boundEnvironmentId, lifecycleState: "pausing", status: "paused" });
expect(await current(id)).toMatchObject({ lifecycleHolds: [], lifecycleOperation: { resumeState: "verifying" } });
const phases: string[] = [];
const runHost = vi.fn(async (row: LifecycleAgent) => { phases.push(row.lifecycleState); return "complete" as const; });
const runHost = vi.fn(async (row: LifecycleAgent) => {
expect(row.lifecycleOperation?.responsibleUserId).toBe("current-configurer");
phases.push(row.lifecycleState); return "complete" as const;
});
await worker(runHost).process(id);
expect(phases).toEqual(["pausing", "resuming", "verifying"]);
expect(call.mock.calls.map(args => args[2].phase)).toEqual(["resuming", "verifying"]);
@@ -186,14 +192,22 @@ const support = await getEmbeddedPostgresTestSupport();
principalId, membershipRole: "member", status: "active" });
await db.insert(principalPermissionGrants).values({ companyId, principalType: type === "board" ? "user" : "agent",
principalId, permissionKey: "agents:configure" });
const responsibleUserId = type === "board" ? principalId : randomUUID();
if (type === "agent") {
await db.insert(companyMemberships).values({ companyId, principalType: "user", principalId: responsibleUserId,
membershipRole: "member", status: "active" });
await db.insert(principalPermissionGrants).values({ companyId, principalType: "user", principalId: responsibleUserId, permissionKey: "agents:configure" });
}
const actor: Express.Request["actor"] = type === "board"
? { type, source: "session", userId: principalId, companyIds: [companyId],
memberships: [{ companyId, membershipRole: "member", status: "active" }] }
: { type, source: "agent_key", agentId: principalId, companyId };
: { type, source: "agent_key", agentId: principalId, companyId, onBehalfOfUserId: responsibleUserId,
onBehalfOfMemberships: [{ companyId, membershipRole: "member", status: "active" }] };
await request(app(actor)).post(`/api/agents/${id}/pause`).send({}).expect(403);
const response = await request(app(actor)).patch(`/api/agents/${id}`).send({ defaultEnvironmentId: boundEnvironmentId });
expect(response.status, JSON.stringify(response.body)).toBe(200);
expect(await current(id)).toMatchObject({ defaultEnvironmentId: boundEnvironmentId, lifecycleState: "pausing", status: "paused" });
expect((await current(id)).lifecycleOperation?.responsibleUserId).toBe(responsibleUserId);
});
it.each(["board", "agent"] as const)("rejects a %s without configuration permission before saving the environment or pausing", async type => {
@@ -1246,10 +1246,11 @@ const support = external ? { supported: true } : await getEmbeddedPostgresTestSu
await db.insert(companyMemberships).values({ companyId, principalType: "user", principalId: "board", membershipRole: "admin" });
await db.insert(principalPermissionGrants).values(["agents:create", "agents:configure"].map(permissionKey => ({ companyId, principalType: "user", principalId: "board", permissionKey })));
const url = `/api/agents/${agent.id}/lifecycle/retry`;
const response = await request(app(board)).post(url).send({});
const response = await request(app(board)).post(url).send({ responsibleUserId: "untrusted-user" });
expect(response.status, JSON.stringify(response.body)).toBe(200);
expect(response.body.lifecycleState).toBe("preparing");
expect(response.body).not.toHaveProperty("lifecycleOperation");
expect((await current(agent.id)).lifecycleOperation?.responsibleUserId).toBe("board");
expect(await db.select().from(activityLog).where(and(eq(activityLog.entityId, agent.id), eq(activityLog.action, "agent.lifecycle_retried"))))
.toEqual([expect.objectContaining({ actorType: "user", actorId: "board" })]);
await request(app({ type: "agent", source: "agent_key", companyId, agentId: agent.id })).post(url).send({}).expect(403);
@@ -173,20 +173,47 @@ const support = external ? { supported: true } : await getEmbeddedPostgresTestSu
expect(await store.claim(agent!.id, "new-check", new Date())).not.toBeNull();
});
it("permits an explicit retry of the same operation and completes verification before readiness", async () => {
it.each([false, true].flatMap(leased => [undefined, "saved-owner"].map(responsibleUserId => ({ leased, responsibleUserId }))))(
"repairs missing retry identity and fences older attempts: %j", async ({ leased, responsibleUserId }) => {
const operation: NonNullable<LifecycleAgent["lifecycleOperation"]> = { id: randomUUID(), hostComplete: false, completedPluginIds: [], attempts: 0, responsibleUserId,
...(leased ? { leaseOwner: "active-verifier", leaseUntil: new Date(Date.now() + 60_000).toISOString() } : { retryRequired: true }) };
const [agent] = await db.insert(agents).values({ companyId, name: "Retry identity", status: "paused",
lifecycleState: "verifying", lifecycleRequiredPluginIds: [], lifecycleOperation: operation }).returning();
const store = createLifecycleStore(db, createAgentLifecycleEffects());
await createAgentLifecycle(db).retry(agent.id, "requesting-user");
const retried = await current(agent.id);
if (!responsibleUserId) {
expect(retried.lifecycleOperation).toMatchObject({ responsibleUserId: "requesting-user", hostComplete: false, completedPluginIds: [] });
expect(retried.lifecycleOperation).not.toHaveProperty("leaseOwner");
expect(retried.lifecycleOperation!.id).not.toBe(operation.id);
expect(retried.lifecycleVersion).toBe(agent.lifecycleVersion + 1);
expect(await store.completeHost(agent, "active-verifier")).toBe(false);
return;
}
expect(retried.lifecycleOperation).toMatchObject({ id: operation.id,
responsibleUserId: responsibleUserId ?? "requesting-user",
...(leased ? { leaseOwner: operation.leaseOwner, leaseUntil: operation.leaseUntil, recheckRequested: true } : {}) });
expect(retried.lifecycleVersion).toBe(agent.lifecycleVersion);
},
);
it("completes verification under the repaired identity before readiness", async () => {
const { agent, work, runHost } = await failed();
let release!: () => void;
const verification = new Promise<void>(resolve => { release = resolve; });
runHost.mockImplementation(async () => { await verification; return "complete"; });
runHost.mockImplementation(async agent => {
expect(agent.lifecycleOperation?.responsibleUserId).toBe("requesting-user");
await verification; return "complete";
});
let processing: Promise<void> | undefined;
try {
await createAgentLifecycle(db).retry(agent.id);
await createAgentLifecycle(db).retry(agent.id, "requesting-user");
processing = work.process(agent.id);
const retried = await current(agent.id);
expect(retried).toMatchObject({ lifecycleState: "verifying", status: "paused" });
expect(retried.lifecycleOperation).not.toHaveProperty("retryRequired");
expect(retried.lifecycleOperation).not.toHaveProperty("verificationFailures");
expect(retried.lifecycleOperation!.id).toBe(agent.lifecycleOperation!.id);
expect(retried.lifecycleOperation!.id).not.toBe(agent.lifecycleOperation!.id);
} finally {
release();
await processing;
@@ -55,7 +55,9 @@ export async function updateAgentConfiguration(tx: Db, effects: LifecycleEffects
...(prepareSetup || prepareEnvironment ? { lifecycleState: "preparing" as const } : {}),
...(pauseForEnvironment ? { lifecycleState: "pausing" as const, status: "paused", pausedAt: new Date() } : {}),
...(stopSetup ? { lifecycleState: "pausing" as const } : {}),
lifecycleOperation: { ...current.lifecycleOperation!, id: randomUUID(), hostComplete: false,
lifecycleOperation: { ...current.lifecycleOperation!,
responsibleUserId: options?.responsibleUserId ?? options?.recordRevision?.createdByUserId ?? current.lifecycleOperation?.responsibleUserId,
id: randomUUID(), hostComplete: false,
completedPluginIds: [], attempts: 0, leaseOwner: undefined, leaseUntil: undefined, leaseHolder: undefined,
retryAt: undefined, retryRequired: undefined, verificationFailures: undefined,
waitingForSignal: undefined, recheckRequested: undefined,
@@ -18,7 +18,7 @@ const LIFECYCLE_PENDING_MAX_MS = 60_000;
export function lifecyclePendingRetryDelayMs(passes: number) {
return Math.min(LIFECYCLE_PENDING_MAX_MS, LIFECYCLE_PENDING_BASE_MS * 2 ** Math.max(0, passes - 1));
}
type ChangeOptions = { version?: number; owner?: string; reason?: string };
type ChangeOptions = { version?: number; owner?: string; reason?: string; responsibleUserId?: string | null };
// Prepared drafts wait for the wizard; they have no background verification obligation.
export const pendingLifecycleWork = and(
@@ -119,6 +119,16 @@ async function changeLockedAgent(tx: Db, effects: LifecycleEffects, agent: Lifec
agent.lifecycleRequiredPluginIds.some(id => !agent.lifecycleOperation!.completedPluginIds.includes(id)))) return null;
if (command === "retry") {
transition(agent.lifecycleState, command);
if (options.responsibleUserId && !agent.lifecycleOperation?.responsibleUserId) {
await effects.notifyWork(tx);
const [restarted] = await tx.update(agents).set({ lifecycleError: null, lifecycleVersion: agent.lifecycleVersion + 1,
lifecycleOperation: { ...agent.lifecycleOperation, id: randomUUID(), responsibleUserId: options.responsibleUserId,
hostComplete: false, completedPluginIds: [], attempts: 0, leaseOwner: undefined, leaseUntil: undefined, leaseHolder: undefined,
retryAt: undefined, retryRequired: undefined, verificationFailures: undefined, waitingForSignal: undefined, recheckRequested: undefined },
updatedAt: new Date(),
}).where(eq(agents.id, agent.id)).returning();
return restarted;
}
if (agent.lifecycleOperation?.leaseUntil && Date.parse(agent.lifecycleOperation.leaseUntil) > Date.now()) {
await effects.notifyWork(tx);
const [requested] = await tx.update(agents).set({ lifecycleOperation:
@@ -14,7 +14,7 @@ export interface LifecycleAgent {
export interface LifecycleStore {
get(id: string): Promise<LifecycleAgent | null>;
change(id: string, command: LifecycleCommand, options?: { version?: number; owner?: string; reason?: string }): Promise<LifecycleAgent | null>;
change(id: string, command: LifecycleCommand, options?: { version?: number; owner?: string; reason?: string; responsibleUserId?: string | null }): Promise<LifecycleAgent | null>;
claim(id: string, owner: string, now: Date): Promise<LifecycleAgent | null>;
renew(agent: LifecycleAgent, owner: string, now: Date): Promise<boolean>;
setRequiredPlugins(agent: LifecycleAgent, owner: string, pluginIds: string[]): Promise<boolean>;
+3 -3
View File
@@ -106,8 +106,8 @@ export function createAgentLifecycle(db: Db, effects: LifecycleEffects) {
assertRootDatabase(db);
const records = agentRecords(db, effects);
const store = createLifecycleStore(db, effects);
async function change(id: string, command: "pause" | "resume" | "terminate" | "retry", reason?: string) {
const result = await store.change(id, command, { reason });
async function change(id: string, command: "pause" | "resume" | "terminate" | "retry", reason?: string, responsibleUserId?: string | null) {
const result = await store.change(id, command, { reason, responsibleUserId });
if (result) scheduleAgentLifecycle(db, id);
return result ? records.getById(id) : null;
}
@@ -153,7 +153,7 @@ export function createAgentLifecycle(db: Db, effects: LifecycleEffects) {
pauseAgent: (id: string, reason = "manual") => change(id, "pause", reason),
resumeAgent: (id: string, reason = "user") => change(id, "resume", reason),
terminateAgent: (id: string) => change(id, "terminate"),
retry: (id: string) => change(id, "retry"),
retry: (id: string, responsibleUserId?: string | null) => change(id, "retry", undefined, responsibleUserId),
clearError: records.clearError,
purgeAgent: (id: string) => purgeAgent(db, effects, id),
};
+2 -1
View File
@@ -6053,6 +6053,7 @@ export function agentRoutes(
const actor = getActorInfo(req);
const updateOptions = {
responsibleUserId: responsibleUserForAiRequest(req),
expectedConfigurationRevision,
...(runtimeSettings ? { expectedConfiguration: {
adapterType: existing.adapterType, adapterConfig: existing.adapterConfig,
@@ -6102,7 +6103,7 @@ export function agentRoutes(
const existing = await getAccessibleAgent(req, res, id);
if (!existing) return;
await assertCanConfigureAgentSetup(req, existing);
const agent = await svcLifecycle.retry(id);
const agent = await svcLifecycle.retry(id, responsibleUserForAiRequest(req));
if (!agent) { res.status(404).json({ error: "Agent not found" }); return; }
const actor = getActorInfo(req);
await logActivity(db, { companyId: agent.companyId, actorType: actor.actorType, actorId: actor.actorId,
+3 -3
View File
@@ -1,6 +1,6 @@
{
"inputSha256": "43742a66f2dd438c5913a34840c94188f8ec05fda7fc11c1c8889913cdcf433b",
"outputSha256": "d44e2238d0db22352b3fc884c409a47cd769b83ecec2ac5288ac1bc9ddea5eb3",
"patchSha256": "f6aab695df1f8d9819ae189386866efd3bd4dc839c7eb7540e25b9225aad5e28",
"inputSha256": "d44e2238d0db22352b3fc884c409a47cd769b83ecec2ac5288ac1bc9ddea5eb3",
"outputSha256": "f47176419e462f4a44b99634a85cd1cafeba926b1dd06ac97459a08e13ac8135",
"patchSha256": "795835e506471683a18c0faff8a04a586b480a4169b88e80546b429f48d33b2d",
"basis": "Generated with the trusted master lockfile refresh. Review this offline correction and its hashes with the dependency changes."
}
+140 -11
View File
@@ -1,14 +1,143 @@
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index b925688a..ad688a5c 100644
index ad688a5c..084c6324 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1121,6 +1121,9 @@ importers:
tar-stream:
specifier: 3.2.0
version: 3.2.0
+ tldts:
+ specifier: 7.4.10
+ version: 7.4.10
ws:
specifier: ^8.22.0
version: 8.22.0
@@ -46,7 +46,7 @@ patchedDependencies:
hash: 55uhvnotpqyiy37rn3pqpukhei
path: patches/embedded-postgres@18.1.0-beta.16.patch
postgres@3.4.9:
- hash: 7s673zkrux4f7d7y4kyzk7opyu
+ hash: 2ucarb2ongic7ioq4v4x67fgri
path: patches/postgres@3.4.9.patch
importers:
@@ -139,7 +139,7 @@ importers:
version: 17.4.2
drizzle-orm:
specifier: 0.45.2
- version: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu))
+ version: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri))
embedded-postgres:
specifier: ^18.1.0-beta.16
version: 18.1.0-beta.16(patch_hash=55uhvnotpqyiy37rn3pqpukhei)
@@ -411,13 +411,13 @@ importers:
version: link:../shared
drizzle-orm:
specifier: ^0.45.2
- version: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu))
+ version: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri))
embedded-postgres:
specifier: ^18.1.0-beta.16
version: 18.1.0-beta.16(patch_hash=55uhvnotpqyiy37rn3pqpukhei)
postgres:
specifier: ^3.4.9
- version: 3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)
+ version: 3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)
devDependencies:
'@types/node':
specifier: ^24.0.0
@@ -1024,7 +1024,7 @@ importers:
version: 2.2.0(@grpc/grpc-js@1.14.5)(nice-grpc-common@2.0.4)(nice-grpc@2.1.17)
'@vercel/connect':
specifier: 2.3.3
- version: 2.3.3(@chat-adapter/slack@4.39.0(patch_hash=eskb5kxp7eud5v3ostluhynfoa)(ai@7.0.130(zod@4.6.7))(zod@4.6.7))(@modelcontextprotocol/sdk@1.31.0(zod@4.6.7))(ai@7.0.130(zod@4.6.7))(better-auth@1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1))))
+ version: 2.3.3(@chat-adapter/slack@4.39.0(patch_hash=eskb5kxp7eud5v3ostluhynfoa)(ai@7.0.130(zod@4.6.7))(zod@4.6.7))(@modelcontextprotocol/sdk@1.31.0(zod@4.6.7))(ai@7.0.130(zod@4.6.7))(better-auth@1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1))))
acorn:
specifier: 8.18.0
version: 8.18.0
@@ -1042,7 +1042,7 @@ importers:
version: 3.0.1(ajv@8.20.0)
better-auth:
specifier: 1.7.16
- version: 1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1)))
+ version: 1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1)))
chat:
specifier: 4.39.0
version: 4.39.0(ai@7.0.130(zod@4.6.7))(zod@4.6.7)
@@ -1063,7 +1063,7 @@ importers:
version: 17.4.2
drizzle-orm:
specifier: ^0.45.2
- version: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu))
+ version: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri))
embedded-postgres:
specifier: ^18.1.0-beta.16
version: 18.1.0-beta.16(patch_hash=55uhvnotpqyiy37rn3pqpukhei)
@@ -10356,12 +10356,12 @@ snapshots:
optionalDependencies:
'@opentelemetry/api': 1.9.1
- '@better-auth/drizzle-adapter@1.7.16(@better-auth/core@1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3))(@better-auth/utils@0.5.1)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)))':
+ '@better-auth/drizzle-adapter@1.7.16(@better-auth/core@1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3))(@better-auth/utils@0.5.1)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)))':
dependencies:
'@better-auth/core': 1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3)
'@better-auth/utils': 0.5.1
optionalDependencies:
- drizzle-orm: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu))
+ drizzle-orm: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri))
'@better-auth/kysely-adapter@1.7.16(@better-auth/core@1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3))(@better-auth/utils@0.5.1)(kysely@0.29.5)':
dependencies:
@@ -14313,14 +14313,14 @@ snapshots:
dependencies:
execa: 5.1.1
- '@vercel/connect@2.3.3(@chat-adapter/slack@4.39.0(patch_hash=eskb5kxp7eud5v3ostluhynfoa)(ai@7.0.130(zod@4.6.7))(zod@4.6.7))(@modelcontextprotocol/sdk@1.31.0(zod@4.6.7))(ai@7.0.130(zod@4.6.7))(better-auth@1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1))))':
+ '@vercel/connect@2.3.3(@chat-adapter/slack@4.39.0(patch_hash=eskb5kxp7eud5v3ostluhynfoa)(ai@7.0.130(zod@4.6.7))(zod@4.6.7))(@modelcontextprotocol/sdk@1.31.0(zod@4.6.7))(ai@7.0.130(zod@4.6.7))(better-auth@1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1))))':
dependencies:
'@vercel/oidc': 3.8.9
optionalDependencies:
'@chat-adapter/slack': 4.39.0(patch_hash=eskb5kxp7eud5v3ostluhynfoa)(ai@7.0.130(zod@4.6.7))(zod@4.6.7)
'@modelcontextprotocol/sdk': 1.31.0(zod@4.6.7)
ai: 7.0.130(zod@4.6.7)
- better-auth: 1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1)))
+ better-auth: 1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1)))
'@vercel/oidc@3.2.0': {}
@@ -14579,10 +14579,10 @@ snapshots:
before-after-hook@4.0.0: {}
- better-auth@1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1))):
+ better-auth@1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1))):
dependencies:
'@better-auth/core': 1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3)
- '@better-auth/drizzle-adapter': 1.7.16(@better-auth/core@1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3))(@better-auth/utils@0.5.1)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)))
+ '@better-auth/drizzle-adapter': 1.7.16(@better-auth/core@1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3))(@better-auth/utils@0.5.1)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)))
'@better-auth/kysely-adapter': 1.7.16(@better-auth/core@1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3))(@better-auth/utils@0.5.1)(kysely@0.29.5)
'@better-auth/memory-adapter': 1.7.16(@better-auth/core@1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3))(@better-auth/utils@0.5.1)
'@better-auth/mongo-adapter': 1.7.16(@better-auth/core@1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3))(@better-auth/utils@0.5.1)
@@ -14600,7 +14600,7 @@ snapshots:
zod: 4.6.7
optionalDependencies:
drizzle-kit: 0.31.11
- drizzle-orm: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu))
+ drizzle-orm: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri))
pg: 8.18.0
react: 19.2.8
react-dom: 19.2.8(react@19.2.8)
@@ -15195,12 +15195,12 @@ snapshots:
esbuild: 0.25.12
tsx: 4.23.15
- drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)):
+ drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)):
optionalDependencies:
'@opentelemetry/api': 1.9.1
kysely: 0.29.5
pg: 8.18.0
- postgres: 3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)
+ postgres: 3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)
dunder-proto@1.0.1:
dependencies:
@@ -17113,7 +17113,7 @@ snapshots:
dependencies:
xtend: 4.0.2
- postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu): {}
+ postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri): {}
posthog-node@5.38.2(rxjs@7.8.2):
dependencies:
@@ -598,12 +598,12 @@
"packages/shared/src/worktree-seed-source.test.ts": "852856b1b5b8f4d0d3dada6501886fe50a2c2dde",
"packages/shared/src/worktree-seed-source.ts": "3d1a09bed2d969feabef3400ff84fd499c1408f4",
"packages/shared/tsconfig.json": "5a24989cd30dcf3749ca7e60d4e83d6ddbb14714",
"pnpm-lock.yaml": "ad688a5c9e7a190afa2e670d5a9a45b4781156ab",
"pnpm-lock.yaml": "084c6324c3ddee458cede84d727b837b6b6c4381",
"scripts/ensure-plugin-build-deps.mjs": "356e0e0f80e50890067027da3003485cf5d2ccbe",
"tsconfig.base.json": "2d0e41f723add0c678936eb9ae1c60eab710f8e0",
"tsconfig.json": "994ee490fb97be7cc0954f4dfd88cf0723290e6c"
},
"lockSha256": "d44e2238d0db22352b3fc884c409a47cd769b83ecec2ac5288ac1bc9ddea5eb3",
"lockSha256": "f47176419e462f4a44b99634a85cd1cafeba926b1dd06ac97459a08e13ac8135",
"compilerPackageSha256": "3722b30210616a13a3213ded11575ba6b2dbab10c32a5ef67afca8513e27017e",
"parserPackageSha256": "6d6a65b879cd7cd249a4367c0b57cce00e78c728de45056ac2a5ca1d1f528d1a",
"parserEntrySha256": "6969920ae0610df927b6b3e675d1309372c268e36d391652af8e3e0183cbe8f8",
+1
View File
@@ -548,6 +548,7 @@ export function Layout() {
<main
id="main-content"
ref={mainContentRef}
data-mobile-nav={isMobile ? (mobileNavVisible ? "visible" : "hidden") : undefined}
tabIndex={-1}
// Publish the pinned-composer bottom offset to descendants
// (PAP-495): while the auto-hiding mobile nav is on screen, raise
+1
View File
@@ -622,6 +622,7 @@ export function Layout({ sidebarSections }: { sidebarSections?: ReactNode }) {
<main
id="main-content"
ref={mainContentRef}
data-mobile-nav={isMobile ? (mobileNavVisible ? "visible" : "hidden") : undefined}
tabIndex={-1}
// Publish the pinned-composer bottom offset to descendants
// (PAP-495): while the auto-hiding mobile nav is on screen, raise
+108
View File
@@ -6418,3 +6418,111 @@ it("explains a missing provider runtime with an installation repair", () => {
expect(container.textContent).toContain("Reinstall or rebuild Paperclip");
expect(container.textContent).toContain("test the agent's runtime");
});
it("keeps each consecutive native runner turn's progress commentary on its own reply instead of stacking onto the latest message", () => {
nativeTranscriptState.transcriptByRun.set("codie-run-1", [
assistantEntry("2026-12-04T17:18:17.000Z", "I'll check the setup task's final notes.", "progress"),
assistantEntry("2026-12-04T17:18:39.000Z", "PAP-7268 is complete (first update).", "final"),
]);
nativeTranscriptState.transcriptByRun.set("codie-run-2", [
assistantEntry("2026-12-04T17:52:43.000Z", "I'll check the latest saved result for PAP-7268.", "progress"),
assistantEntry("2026-12-04T17:53:12.000Z", "PAP-7268 is Done (second update).", "final"),
]);
const codie = { id: "agent-codie", name: "Codie", urlKey: "codie", icon: null } as unknown as Agent;
renderThread({
issueId: "chat-codie",
conversationMode: true,
agentMap: new Map([[codie.id, codie]]),
comments: [
{
id: "reply-1",
companyId: "company-1",
issueId: "chat-codie",
authorType: "agent",
authorAgentId: codie.id,
authorUserId: null,
body: "PAP-7268 is complete (first update).",
presentation: null,
metadata: null,
runId: "codie-run-1",
createdByRunId: "codie-run-1",
createdAt: new Date("2026-12-04T17:18:41.000Z"),
updatedAt: new Date("2026-12-04T17:18:41.000Z"),
},
{
id: "cross-task-msg",
companyId: "company-1",
issueId: "chat-codie",
authorType: "agent",
authorAgentId: codie.id,
authorUserId: null,
body: "- Native recovery PR #23696 merged.",
presentation: null,
metadata: {
version: 1,
sections: [],
chatMessage: {
sourceTaskId: "task-7354",
sourceTaskIdentifier: "PAP-7354",
sourceRunId: "other-task-run",
contentHash: "hash-1",
},
},
runId: "other-task-run",
createdByRunId: "other-task-run",
createdAt: new Date("2026-12-04T17:35:00.000Z"),
updatedAt: new Date("2026-12-04T17:35:00.000Z"),
},
{
id: "reply-2",
companyId: "company-1",
issueId: "chat-codie",
authorType: "agent",
authorAgentId: codie.id,
authorUserId: null,
body: "PAP-7268 is Done (second update).",
presentation: null,
metadata: null,
runId: "codie-run-2",
createdByRunId: "codie-run-2",
createdAt: new Date("2026-12-04T17:53:15.000Z"),
updatedAt: new Date("2026-12-04T17:53:15.000Z"),
},
],
onAdd: async () => {},
linkedRuns: [
{
runId: "codie-run-1",
runtimeMode: "native",
status: "succeeded",
agentId: codie.id,
agentName: "Codie",
adapterType: "paperclip_runner",
createdAt: "2026-12-04T17:17:24.000Z",
startedAt: "2026-12-04T17:17:24.000Z",
finishedAt: "2026-12-04T17:18:39.000Z",
execution: { phase: "completed", label: "Completed", canStop: false, cause: null, lastConfirmedActivityAt: null, retryAt: null, attempt: 1, maxAttempts: 3, recoveryOwner: null, nextAction: null, permittedActions: [], predecessorRunId: null, successorRunId: null },
},
{
runId: "codie-run-2",
runtimeMode: "native",
status: "succeeded",
agentId: codie.id,
agentName: "Codie",
adapterType: "paperclip_runner",
createdAt: "2026-12-04T17:52:00.000Z",
startedAt: "2026-12-04T17:52:00.000Z",
finishedAt: "2026-12-04T17:53:12.000Z",
execution: { phase: "completed", label: "Completed", canStop: false, cause: null, lastConfirmedActivityAt: null, retryAt: null, attempt: 1, maxAttempts: 3, recoveryOwner: null, nextAction: null, permittedActions: [], predecessorRunId: null, successorRunId: null },
},
],
});
const firstCommentEl = container.querySelector("#comment-reply-1");
const secondCommentEl = container.querySelector("#comment-reply-2");
expect(firstCommentEl?.textContent).toContain("I'll check the setup task's final notes.");
expect(firstCommentEl?.textContent).not.toContain("I'll check the latest saved result for PAP-7268.");
expect(secondCommentEl?.textContent).toContain("I'll check the latest saved result for PAP-7268.");
expect(secondCommentEl?.textContent).not.toContain("I'll check the setup task's final notes.");
});
+11 -7
View File
@@ -2038,6 +2038,7 @@ export function TaskChatThread(props: TaskChatThreadProps) {
turnMergeMetaById.set(turnId, {
agentKey: meta?.agentId ?? "",
agentName: meta?.agentName,
anchorCommentId: null,
parts: [{ entries, durationMs, failed }],
});
settledTurns.push({
@@ -2251,9 +2252,17 @@ export function TaskChatThread(props: TaskChatThreadProps) {
Number.isFinite(segment.startMs) && Number.isFinite(segmentFinishedMs)
? Math.max(0, segmentFinishedMs - segment.startMs)
: durationMs;
const anchorCommentId = segmented
? null
: sourceIsPaperclipRunner
? sourceHasPresentationComment
? sourcePresentationCommentId
: null
: (lastCommentIdByRun.get(source.id) ?? null);
turnMergeMetaById.set(turnId, {
agentKey: meta?.agentId ?? "",
agentName: meta?.agentName,
anchorCommentId,
parts: [
{ entries: segment.entries, durationMs: segmentDurationMs, failed },
],
@@ -2283,13 +2292,7 @@ export function TaskChatThread(props: TaskChatThreadProps) {
failed,
}),
},
anchorCommentId: segmented
? null
: sourceIsPaperclipRunner
? sourceHasPresentationComment
? sourcePresentationCommentId
: null
: (lastCommentIdByRun.get(source.id) ?? null),
anchorCommentId,
// A post-steering segment ties the acknowledgement-backed human
// bubble and is therefore inserted immediately after it. The first
// segment retains the normal run-start slot.
@@ -2346,6 +2349,7 @@ export function TaskChatThread(props: TaskChatThreadProps) {
turnMergeMetaById.set(turnId, {
agentKey: liveRun.agentId ?? "",
agentName: liveRun.agentName,
anchorCommentId: null,
parts: [
{
entries: segment.entries,
@@ -9,5 +9,5 @@ export function settledPreviewReply(response: TaskChatMessageItem, entries: Para
id: `${runId}:turn`, kind: "turn", settled: true, historical: true,
items: settledRunChildren(parsed), summary: buildTurnSummary(entries, { durationMs, failed }),
};
return attachSettledTurns([response, turn], new Map([[turn.id, { agentKey: "synthetic-agent", agentName: response.authorName, parts: [{ entries, durationMs, failed }] }]]));
return attachSettledTurns([response, turn], new Map([[turn.id, { agentKey: "synthetic-agent", agentName: response.authorName, anchorCommentId: null, parts: [{ entries, durationMs, failed }] }]]));
}
@@ -16,7 +16,11 @@ export function TaskChatComposerDock({ children, mobile, streamlined, concealed
if (placeholder) return;
const dock = dockRef.current;
const thread = dock?.closest<HTMLElement>('[data-testid="task-chat-thread"]');
if (!dock || !thread || !thread.closest(".coordinator-workspace")) return;
if (!dock || !thread) return;
const coordinator = thread.closest(".coordinator-workspace") !== null;
// Coordinator overlays the dock on the thread; mobile collapses it while
// the auto-hiding chrome is tucked away. Both need its measured height.
if (!coordinator && !mobile) return;
const forwardGapWheel = (event: WheelEvent) => {
if (event.target !== dock || event.ctrlKey || event.defaultPrevented) return;
const scroller = thread.querySelector<HTMLElement>('[data-testid="task-chat-scroller"]');
@@ -35,7 +39,7 @@ export function TaskChatComposerDock({ children, mobile, streamlined, concealed
: deltaMode === WheelEvent.DOM_DELTA_PAGE ? scroller.clientWidth : 1;
scroller.scrollBy({ left: deltaX * horizontalUnit, top: deltaY * verticalUnit, behavior: "instant" });
};
dock.addEventListener("wheel", forwardGapWheel, { passive: false });
if (coordinator) dock.addEventListener("wheel", forwardGapWheel, { passive: false });
const measure = () => thread.style.setProperty("--task-composer-dock-height", `${dock.getBoundingClientRect().height}px`);
measure();
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(measure);
@@ -45,7 +49,7 @@ export function TaskChatComposerDock({ children, mobile, streamlined, concealed
observer?.disconnect();
thread.style.removeProperty("--task-composer-dock-height");
};
}, [placeholder]);
}, [placeholder, mobile]);
return <div
ref={dockRef}
data-testid={placeholder ? "task-chat-loading-composer" : "task-chat-composer-dock"}
@@ -371,6 +371,9 @@ export function TaskMessageScroller({ children, contentKey, className, scrolling
className,
)}
data-testid="task-chat-scroller"
// Mobile: reading away from the latest message tucks the bottom nav
// and composer away; heading back toward it brings them back.
data-mobile-chrome-scroll="bottom"
>
{scrollingHistory ? <>
{scrollingHistory && (scrollingHistory.hasMore || scrollingHistory.loading || scrollingHistory.error) ? (
@@ -2558,6 +2558,7 @@ describe("coalesceSettledTurns (PAP-362)", () => {
{
agentKey: "agent-1",
agentName: "CEO",
anchorCommentId: null,
parts: [{ entries: runA, durationMs: 30_000 }],
},
],
@@ -2566,6 +2567,7 @@ describe("coalesceSettledTurns (PAP-362)", () => {
{
agentKey: "agent-1",
agentName: "CEO",
anchorCommentId: null,
parts: [{ entries: runB, durationMs: 15_000 }],
},
],
@@ -2628,6 +2630,7 @@ describe("coalesceSettledTurns (PAP-362)", () => {
otherAgent.set("run-b:turn", {
agentKey: "agent-2",
agentName: "QA",
anchorCommentId: null,
parts: [{ entries: runB }],
});
const sameShape: TaskChatItem[] = [
@@ -2643,8 +2646,8 @@ describe("coalesceSettledTurns (PAP-362)", () => {
it("lets another agent's chat message end the merge when runs carry no display name", () => {
const unnamed = new Map<string, SettledTurnMergeMeta>([
["run-a:turn", { agentKey: "agent-1", parts: [{ entries: runA, durationMs: 30_000 }] }],
["run-b:turn", { agentKey: "agent-1", parts: [{ entries: runB, durationMs: 15_000 }] }],
["run-a:turn", { agentKey: "agent-1", anchorCommentId: null, parts: [{ entries: runA, durationMs: 30_000 }] }],
["run-b:turn", { agentKey: "agent-1", anchorCommentId: null, parts: [{ entries: runB, durationMs: 15_000 }] }],
]);
const fromAgent = (id: string, agentId: string, authorName: string): TaskChatItem => ({
id, kind: "message", author: "agent", authorName, agent: { id: agentId }, text: "Note.",
@@ -2693,6 +2696,89 @@ describe("coalesceSettledTurns (PAP-362)", () => {
(merged[0] as Extract<TaskChatItem, { kind: "turn" }>).animateFold,
).toBe(true);
});
it("never coalesces standaloneHeader (native runner) turns across consecutive replies", () => {
const nativeTurn = (id: string, commentary: string): TaskChatItem => ({
id,
kind: "turn",
settled: true,
historical: true,
standaloneHeader: true,
items: [
{
id: `${id}:phase:0`,
kind: "activity_phase",
active: false,
summary: "",
interstitial: {
id: `${id}:interstitial:0`,
kind: "message",
author: "agent",
channel: "progress",
interstitial: true,
text: commentary,
},
items: [],
},
],
summary: buildTurnSummary([], { durationMs: 10_000 }),
});
const nativeMeta = new Map<string, SettledTurnMergeMeta>([
["run-1:turn", { agentKey: "codie", agentName: "Codie", anchorCommentId: "msg-1", parts: [{ entries: [], durationMs: 10_000 }] }],
["run-2:turn", { agentKey: "codie", agentName: "Codie", anchorCommentId: "msg-2", parts: [{ entries: [], durationMs: 12_000 }] }],
]);
const items: TaskChatItem[] = [
{ id: "msg-1", kind: "message", author: "agent", authorName: "Codie", agent: { id: "codie" }, text: "First update.", sourceRunId: "run-1" },
nativeTurn("run-1:turn", "I'll check the setup task's final notes."),
{ id: "msg-2", kind: "message", author: "agent", authorName: "Codie", agent: { id: "codie" }, text: "Second update.", sourceRunId: "run-2" },
nativeTurn("run-2:turn", "I'll check the latest saved result for PAP-7268."),
];
const out = coalesceSettledTurns(items, nativeMeta);
expect(out.map((i) => i.id)).toEqual(["msg-1", "run-1:turn", "msg-2", "run-2:turn"]);
const firstTurn = out[1] as Extract<TaskChatItem, { kind: "turn" }>;
const secondTurn = out[3] as Extract<TaskChatItem, { kind: "turn" }>;
expect(firstTurn.items).toHaveLength(1);
expect(secondTurn.items).toHaveLength(1);
});
it("does not coalesce legacy turns across fast_response or cross-task chatMessage bubbles", () => {
const withFastResponse: TaskChatItem[] = [
agentBubble("msg-a"),
turn("run-a:turn", runA, 30_000),
{ id: "msg-fr", kind: "message", author: "agent", authorName: "CEO", origin: "fast_response", text: "On it." },
agentBubble("msg-b"),
turn("run-b:turn", runB, 15_000),
];
expect(coalesceSettledTurns(withFastResponse, metaById).map((i) => i.id)).toEqual([
"msg-a",
"run-a:turn",
"msg-fr",
"msg-b",
"run-b:turn",
]);
const withChatMessage: TaskChatItem[] = [
agentBubble("msg-a"),
turn("run-a:turn", runA, 30_000),
{
id: "msg-cross",
kind: "message",
author: "agent",
authorName: "CEO",
text: "Merged PR #123.",
chatMessage: { sourceTaskId: "task-1", sourceTaskIdentifier: "PAP-7354", sourceRunId: "other-run", contentHash: "abc" },
},
agentBubble("msg-b"),
turn("run-b:turn", runB, 15_000),
];
expect(coalesceSettledTurns(withChatMessage, metaById).map((i) => i.id)).toEqual([
"msg-a",
"run-a:turn",
"msg-cross",
"msg-b",
"run-b:turn",
]);
});
});
describe("attachSettledTurns (round 9)", () => {
@@ -2725,6 +2811,7 @@ describe("attachSettledTurns (round 9)", () => {
{
agentKey: "agent-1",
agentName: "CEO",
anchorCommentId: null,
parts: [{ entries: runA, durationMs: 30_000 }],
},
],
@@ -2771,7 +2858,7 @@ describe("attachSettledTurns (round 9)", () => {
it("matches the bubble's agent ID when the run carries no display name", () => {
const unnamed = new Map<string, SettledTurnMergeMeta>([
["run-a:turn", { agentKey: "agent-1", parts: [{ entries: runA, durationMs: 30_000 }] }],
["run-a:turn", { agentKey: "agent-1", anchorCommentId: null, parts: [{ entries: runA, durationMs: 30_000 }] }],
]);
const fromAgent = (agentId: string, authorName: string): TaskChatItem => ({
id: `msg-${agentId}`, kind: "message", author: "agent", authorName, agent: { id: agentId }, text: "Done.",
@@ -2808,6 +2895,59 @@ describe("attachSettledTurns (round 9)", () => {
(twice[0] as Extract<TaskChatItem, { kind: "message" }>).attachedTurn?.id,
).toBe("run-a:turn");
});
it("never attaches an unanchored or mismatched standaloneHeader turn, finalResponse turn, or cross-task chatMessage bubble", () => {
const standaloneTurn = (id: string, extra?: Partial<TaskChatTurnItem>): TaskChatTurnItem => ({
id,
kind: "turn",
settled: true,
standaloneHeader: true,
items: [],
summary: buildTurnSummary([], { durationMs: 10_000 }),
...extra,
});
const meta = new Map<string, SettledTurnMergeMeta>([
["run-unanchored:turn", { agentKey: "codie", agentName: "Codie", anchorCommentId: null, parts: [] }],
["run-anchored:turn", { agentKey: "codie", agentName: "Codie", anchorCommentId: "msg-1", parts: [] }],
["run-other:turn", { agentKey: "codie", agentName: "Codie", anchorCommentId: "msg-2", parts: [] }],
]);
const bubble1: TaskChatItem = {
id: "msg-1", kind: "message", author: "agent", authorName: "Codie", agent: { id: "codie" }, text: "First reply.", sourceRunId: "run-1",
};
// Unanchored native turn after an earlier reply stays standalone (must not invert above msg-1).
const unanchoredOut = attachSettledTurns([bubble1, standaloneTurn("run-unanchored:turn")], meta);
expect(unanchoredOut.map((i) => i.id)).toEqual(["msg-1", "run-unanchored:turn"]);
// Mismatched anchorCommentId native turn stays standalone.
const mismatchedOut = attachSettledTurns([bubble1, standaloneTurn("run-other:turn")], meta);
expect(mismatchedOut.map((i) => i.id)).toEqual(["msg-1", "run-other:turn"]);
// Turn carrying its own finalResponse never attaches to a preceding bubble.
const withFinal = standaloneTurn("run-anchored:turn", {
finalResponse: { id: "final-1", kind: "message", author: "agent", text: "Own final." },
});
const finalOut = attachSettledTurns([bubble1, withFinal], meta);
expect(finalOut.map((i) => i.id)).toEqual(["msg-1", "run-anchored:turn"]);
// Cross-task send_chat_message bubble never accepts an attached turn.
const crossTaskBubble: TaskChatItem = {
id: "msg-1",
kind: "message",
author: "agent",
authorName: "Codie",
agent: { id: "codie" },
text: "Merged PR #123.",
chatMessage: { sourceTaskId: "task-1", sourceTaskIdentifier: "PAP-7354", sourceRunId: "other-run", contentHash: "abc" },
};
const crossOut = attachSettledTurns([crossTaskBubble, standaloneTurn("run-anchored:turn")], meta);
expect(crossOut.map((i) => i.id)).toEqual(["msg-1", "run-anchored:turn"]);
// Matching anchored native turn attaches cleanly to its own reply bubble.
const matchedOut = attachSettledTurns([bubble1, standaloneTurn("run-anchored:turn")], meta);
expect(matchedOut).toHaveLength(1);
expect((matchedOut[0] as Extract<TaskChatItem, { kind: "message" }>).attachedTurn?.id).toBe("run-anchored:turn");
});
});
describe("assembleThreadItems (PAP-367)", () => {
@@ -2899,6 +3039,7 @@ describe("assembleThreadItems (PAP-367)", () => {
{
agentKey: "agent-1",
agentName: "CEO",
anchorCommentId: null,
parts: [{ entries: [toolCall("Read")], durationMs: 34_000 }],
},
],
@@ -2498,6 +2498,12 @@ export interface SettledTurnMergeMeta {
agentKey: string;
/** Display name, used to keep another agent's bubble from bridging a merge. */
agentName?: string;
/**
* Explicit reply comment id this turn anchored to (`null` = unanchored).
* Keeps unanchored or mismatched standaloneHeader turns from attaching above
* an earlier agent bubble and inverting chronology.
*/
anchorCommentId: string | null;
parts: TurnSummaryPart[];
}
@@ -2542,6 +2548,15 @@ export function coalesceSettledTurns(
let heldIdx = -1; // index in `out` of the last mergeable settled turn
for (const item of items) {
if (item.kind === "turn" && item.settled) {
// Paperclip Runner turns own an open chronological timeline rendered
// above their reply bubble (`beforeTurn`), including progress commentary.
// Never coalesce them across runs or replies: doing so steals earlier
// runs' timelines and stacks every prior commentary onto the newest reply.
if (item.standaloneHeader) {
out.push(item);
heldIdx = -1;
continue;
}
const meta = metaFor(item.id);
const held = heldIdx >= 0 ? (out[heldIdx] as TaskChatTurnItem) : null;
const heldMeta = held ? metaFor(held.id) : undefined;
@@ -2572,7 +2587,12 @@ export function coalesceSettledTurns(
continue;
}
out.push(item);
if (item.kind === "message" && item.author === "agent") {
if (
item.kind === "message" &&
item.author === "agent" &&
item.origin !== "fast_response" &&
!item.chatMessage
) {
// The same agent's reply bubble sits between its runs — keep merging
// across it. A different agent's bubble ends the run of turns.
const heldMeta =
@@ -2608,15 +2628,18 @@ export function attachSettledTurns(
if (
item.kind === "turn" &&
item.settled &&
!item.finalResponse &&
prev?.kind === "message" &&
prev.author === "agent" &&
prev.origin !== "fast_response" &&
!prev.chatMessage &&
!prev.interstitial &&
!prev.streaming &&
prev.attachedTurn == null
) {
const meta = metaById.get(item.id);
if (meta != null && sameTurnAgent(meta, prev)) {
const standaloneOwnershipMatches = !item.standaloneHeader || meta?.anchorCommentId === prev.id;
if (meta != null && sameTurnAgent(meta, prev) && standaloneOwnershipMatches) {
out[out.length - 1] = { ...prev, attachedTurn: item };
continue;
}
@@ -0,0 +1,217 @@
// @vitest-environment jsdom
import { act } from "react";
import { createRoot, type Root } from "react-dom/client";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { useMobileNavVisibility } from "./useMobileNavVisibility";
let visible: boolean | null = null;
function Host({ enabled = true }: { enabled?: boolean }) {
visible = useMobileNavVisibility(enabled, "/PAP/issues/PAP-1");
return null;
}
// The composer dock (50px) plus the nav offset padding (100px): how much the
// thread viewport grows at its bottom edge when the chrome tucks away.
const DOCK_HEIGHT = 50;
const NAV_PADDING = 100;
const VISIBLE_HEIGHT = 500;
const HIDDEN_HEIGHT = VISIBLE_HEIGHT + DOCK_HEIGHT + NAV_PADDING;
let root: Root;
let container: HTMLDivElement;
let frames: FrameRequestCallback[] = [];
let main: HTMLElement;
let thread: HTMLDivElement;
let geometry: { scrollHeight: number; clientHeight: number };
let rawScrollTop = 0;
function flushFrames() {
const pending = frames;
frames = [];
act(() => pending.forEach((callback) => callback(0)));
}
const maxScrollTop = () => Math.max(0, geometry.scrollHeight - geometry.clientHeight);
const fromBottom = () => maxScrollTop() - thread.scrollTop;
function emitScroll() {
thread.dispatchEvent(new Event("scroll"));
flushFrames();
}
/** Scroll the thread to `distance` CSS pixels above its latest message. */
function scrollThread(distance: number) {
thread.scrollTop = maxScrollTop() - distance;
emitScroll();
}
/**
* Apply the layout for the current chrome state, as the CSS does: hiding grows
* the thread viewport at its bottom edge, and the browser clamps `scrollTop`
* to the new maximum.
*/
function settleChrome() {
geometry.clientHeight = visible ? VISIBLE_HEIGHT : HIDDEN_HEIGHT;
main.style.paddingBottom = visible ? `${NAV_PADDING}px` : "0px";
thread.scrollTop = rawScrollTop;
emitScroll();
}
beforeEach(() => {
vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
vi.stubGlobal("requestAnimationFrame", (callback: FrameRequestCallback) => frames.push(callback));
vi.stubGlobal("cancelAnimationFrame", () => {});
const tokens = document.documentElement.style;
tokens.setProperty("--mobile-nav-scroll-top-zone", "24px");
tokens.setProperty("--mobile-nav-scroll-hide-distance", "32px");
tokens.setProperty("--mobile-nav-scroll-show-distance", "16px");
geometry = { scrollHeight: 4000, clientHeight: VISIBLE_HEIGHT };
rawScrollTop = 0;
main = document.createElement("main");
main.id = "main-content";
main.style.paddingBottom = `${NAV_PADDING}px`;
const shell = document.createElement("div");
shell.dataset.testid = "task-chat-thread";
thread = document.createElement("div");
thread.setAttribute("data-mobile-chrome-scroll", "bottom");
Object.defineProperty(thread, "scrollHeight", { configurable: true, get: () => geometry.scrollHeight });
// Browsers clamp scrollTop to the live scroll range.
Object.defineProperty(thread, "scrollTop", {
configurable: true,
get: () => Math.max(0, Math.min(rawScrollTop, maxScrollTop())),
set: (value: number) => { rawScrollTop = Math.max(0, Math.min(value, maxScrollTop())); },
});
Object.defineProperty(thread, "clientHeight", { configurable: true, get: () => geometry.clientHeight });
const dock = document.createElement("div");
dock.dataset.testid = "task-chat-composer-dock";
dock.getBoundingClientRect = () => ({ height: DOCK_HEIGHT } as DOMRect);
shell.append(thread, dock);
main.append(shell);
document.body.append(main);
container = document.createElement("div");
document.body.append(container);
root = createRoot(container);
});
afterEach(() => {
act(() => root.unmount());
container.remove();
main.remove();
document.documentElement.removeAttribute("style");
document.body.querySelectorAll(".paperclip-app-shell").forEach((node) => node.remove());
frames = [];
visible = null;
vi.unstubAllGlobals();
});
describe("useMobileNavVisibility with a bottom-anchored task thread", () => {
it("tucks the chrome away when reading back from the latest message and restores it heading back", () => {
act(() => root.render(<Host />));
scrollThread(0);
expect(visible).toBe(true);
// Reading within the space the chrome would free never hides it, so the
// thread can never be clamped to the latest message by hiding.
scrollThread(100);
scrollThread(170);
scrollThread(200);
expect(visible).toBe(true);
scrollThread(210);
expect(visible).toBe(false);
settleChrome();
expect(visible).toBe(false);
expect(fromBottom()).toBe(60);
// Keep reading older messages: the chrome stays out of the way.
scrollThread(600);
expect(visible).toBe(false);
// A deliberate drag back toward the latest message reveals it.
scrollThread(590);
expect(visible).toBe(false);
scrollThread(580);
expect(visible).toBe(true);
// The viewport shrinking back is not a swipe away from the latest message.
settleChrome();
expect(visible).toBe(true);
});
it("returns the chrome when the reader reaches the latest message", () => {
act(() => root.render(<Host />));
scrollThread(0);
scrollThread(400);
expect(visible).toBe(false);
settleChrome();
scrollThread(300);
scrollThread(320);
scrollThread(0);
expect(visible).toBe(true);
});
it("never strands the chrome hidden at the latest message after a short drag", () => {
act(() => root.render(<Host />));
scrollThread(0);
// A short drag up stays inside the space the chrome would free.
scrollThread(40);
scrollThread(120);
expect(visible).toBe(true);
// Just past that space the chrome hides; the larger viewport keeps the
// reading position, and dragging to the latest message brings it back.
scrollThread(190);
expect(visible).toBe(true);
scrollThread(210);
expect(visible).toBe(false);
settleChrome();
expect(visible).toBe(false);
expect(fromBottom()).toBeGreaterThan(0);
scrollThread(0);
expect(visible).toBe(true);
});
it("keeps the composer on screen while the keyboard is open", () => {
const shell = document.createElement("div");
shell.className = "paperclip-app-shell";
shell.dataset.keyboardOpen = "true";
document.body.append(shell);
act(() => root.render(<Host />));
scrollThread(0);
scrollThread(400);
expect(visible).toBe(true);
});
it("shows the chrome when the keyboard opens and keeps it after the keyboard closes", async () => {
const shell = document.createElement("div");
shell.className = "paperclip-app-shell";
document.body.append(shell);
act(() => root.render(<Host />));
scrollThread(0);
scrollThread(400);
expect(visible).toBe(false);
settleChrome();
await act(async () => { shell.dataset.keyboardOpen = "true"; });
expect(visible).toBe(true);
await act(async () => { delete shell.dataset.keyboardOpen; });
settleChrome();
scrollThread(fromBottom() + 10);
expect(visible).toBe(true);
});
it("ignores threads that did not opt in and stays visible on desktop", () => {
thread.removeAttribute("data-mobile-chrome-scroll");
act(() => root.render(<Host />));
scrollThread(0);
scrollThread(400);
expect(visible).toBe(true);
thread.setAttribute("data-mobile-chrome-scroll", "bottom");
act(() => root.render(<Host enabled={false} />));
scrollThread(0);
scrollThread(400);
expect(visible).toBe(true);
});
});
+109 -19
View File
@@ -1,6 +1,21 @@
import { useEffect, useState } from "react";
import { MobileNavScrollTracker } from "../lib/mobile-nav-scroll";
/**
* Opt-in marker for a nested scroll container that should drive the
* auto-hiding mobile chrome (bottom nav and pinned composer). The value is the
* container's resting edge: `"bottom"` for a chat thread that rests at its
* latest message, so moving away from the bottom hides the chrome and moving
* back toward it reveals the chrome again.
*/
export const MOBILE_CHROME_SCROLL_ATTRIBUTE = "data-mobile-chrome-scroll";
function bottomAnchoredScroller(target: EventTarget | null): HTMLElement | null {
return target instanceof HTMLElement && target.getAttribute(MOBILE_CHROME_SCROLL_ATTRIBUTE) === "bottom"
? target
: null;
}
export function useMobileNavVisibility(enabled: boolean, pathname: string): boolean {
const [visible, setVisible] = useState(true);
@@ -10,35 +25,110 @@ export function useMobileNavVisibility(enabled: boolean, pathname: string): bool
const styles = getComputedStyle(document.documentElement);
const distance = (token: string) => Number.parseFloat(styles.getPropertyValue(token)) || 0;
const scrollBounds = () => {
const options = {
topZone: distance("--mobile-nav-scroll-top-zone"),
hideDistance: distance("--mobile-nav-scroll-hide-distance"),
showDistance: distance("--mobile-nav-scroll-show-distance"),
};
const documentBounds = () => {
const root = document.scrollingElement ?? document.documentElement;
return {
top: window.scrollY || root.scrollTop || 0,
max: Math.max(0, root.scrollHeight - root.clientHeight),
};
};
const initial = scrollBounds();
const tracker = new MobileNavScrollTracker({
topZone: distance("--mobile-nav-scroll-top-zone"),
hideDistance: distance("--mobile-nav-scroll-hide-distance"),
showDistance: distance("--mobile-nav-scroll-show-distance"),
}, initial.top, initial.max);
let frame: number | null = null;
const onScroll = () => {
if (frame !== null) return;
frame = requestAnimationFrame(() => {
frame = null;
const { top, max } = scrollBounds();
const previous = tracker.visible;
const next = tracker.update(top, max);
if (next !== previous) setVisible(next);
let current = true;
// A bottom-anchored thread is measured from its latest message, so the
// tracker's resting zone is the bottom of the thread instead of the top.
// Tucking the chrome away grows the thread viewport at its bottom edge by
// the composer dock plus the nav offset. Measuring against that expanded
// viewport in both states keeps the reported position continuous across
// the change: nothing hides until the reader is far enough back that the
// growth cannot clamp them to the latest message, and once hidden,
// reaching the real bottom of the thread brings the chrome back.
const collapseGrowth = (scroller: HTMLElement) => {
if (!current) return 0;
const dock = scroller
.closest<HTMLElement>('[data-testid="task-chat-thread"]')
?.querySelector<HTMLElement>('[data-testid="task-chat-composer-dock"]');
const main = scroller.closest<HTMLElement>("#main-content");
const dockHeight = dock?.getBoundingClientRect().height ?? 0;
const padding = main ? Number.parseFloat(getComputedStyle(main).paddingBottom) || 0 : 0;
return dockHeight + padding;
};
const threadBounds = (scroller: HTMLElement) => {
const liveMax = Math.max(0, scroller.scrollHeight - scroller.clientHeight);
const scrollTop = Math.max(0, Math.min(scroller.scrollTop, liveMax));
const growth = collapseGrowth(scroller);
const max = Math.max(0, liveMax - growth);
return { top: Math.max(0, liveMax - scrollTop - growth), max };
};
const initial = documentBounds();
const documentTracker = new MobileNavScrollTracker(options, initial.top, initial.max);
let threadTrackers = new WeakMap<HTMLElement, MobileNavScrollTracker>();
// Typing in the composer keeps it on screen; the keyboard resize is not a swipe.
const keyboardOpen = () => document.querySelector('.paperclip-app-shell[data-keyboard-open="true"]') !== null;
const apply = (next: boolean) => {
if (next === current) return;
current = next;
setVisible(next);
};
let documentFrame: number | null = null;
const onDocumentScroll = () => {
if (documentFrame !== null) return;
documentFrame = requestAnimationFrame(() => {
documentFrame = null;
const { top, max } = documentBounds();
apply(documentTracker.update(top, max));
});
};
window.addEventListener("scroll", onScroll, { passive: true });
let threadFrame: number | null = null;
let pendingThread: HTMLElement | null = null;
const onNestedScroll = (event: Event) => {
const scroller = bottomAnchoredScroller(event.target);
if (!scroller) return;
pendingThread = scroller;
if (threadFrame !== null) return;
threadFrame = requestAnimationFrame(() => {
threadFrame = null;
const target = pendingThread;
pendingThread = null;
if (!target?.isConnected) return;
const { top, max } = threadBounds(target);
let tracker = threadTrackers.get(target);
if (!tracker) {
// The first event only establishes a baseline; it is never a swipe.
tracker = new MobileNavScrollTracker(options, top, max);
threadTrackers.set(target, tracker);
return;
}
const next = tracker.update(top, max);
apply(keyboardOpen() ? true : next);
});
};
// Opening the keyboard shows the chrome; re-baseline the trackers so
// closing it again does not tuck the composer away under the reader.
const keyboardObserver = typeof MutationObserver === "undefined" ? null : new MutationObserver(() => {
if (!keyboardOpen()) return;
documentTracker.visible = true;
threadTrackers = new WeakMap();
apply(true);
});
keyboardObserver?.observe(document.documentElement, { attributes: true, attributeFilter: ["data-keyboard-open"], subtree: true });
window.addEventListener("scroll", onDocumentScroll, { passive: true });
// Element scroll events do not bubble, so observe nested threads in capture.
document.addEventListener("scroll", onNestedScroll, { passive: true, capture: true });
return () => {
window.removeEventListener("scroll", onScroll);
if (frame !== null) cancelAnimationFrame(frame);
window.removeEventListener("scroll", onDocumentScroll);
document.removeEventListener("scroll", onNestedScroll, { capture: true });
keyboardObserver?.disconnect();
if (documentFrame !== null) cancelAnimationFrame(documentFrame);
if (threadFrame !== null) cancelAnimationFrame(threadFrame);
};
}, [enabled, pathname]);
+31
View File
@@ -1058,6 +1058,37 @@ html:has(.paperclip-app-shell[data-keyboard-open="true"] [data-classic-task-shel
padding-bottom: 0;
}
/* Reading away from the latest message tucks the composer away with
the auto-hiding bottom nav so the thread takes the full height; heading back
toward the latest message brings both back. The shell clips the dock as it
slides below the main column. Typing (keyboard open) never collapses it. */
.paperclip-app-shell[data-mobile="true"]:not([data-keyboard-open="true"]):has([data-task-chat-shell]) #main-content {
transition: padding-bottom var(--mobile-nav-motion-duration, var(--motion-mobile-nav-enter)) var(--mobile-nav-motion-ease, var(--motion-ease-out-expo));
}
.paperclip-app-shell[data-mobile="true"]:not([data-keyboard-open="true"]) #main-content [data-task-chat-shell] [data-testid="task-chat-composer-dock"] {
transition:
margin-bottom var(--mobile-nav-motion-duration, var(--motion-mobile-nav-enter)) var(--mobile-nav-motion-ease, var(--motion-ease-out-expo)),
visibility 0s;
}
.paperclip-app-shell[data-mobile="true"]:not([data-keyboard-open="true"]):has([data-task-chat-shell]) #main-content[data-mobile-nav="hidden"] {
padding-bottom: 0;
}
.paperclip-app-shell[data-mobile="true"]:not([data-keyboard-open="true"]) #main-content[data-mobile-nav="hidden"] [data-task-chat-shell] [data-testid="task-chat-composer-dock"] {
margin-bottom: calc(-1 * var(--task-composer-dock-height, 0px));
visibility: hidden;
pointer-events: none;
transition:
margin-bottom var(--mobile-nav-motion-duration, var(--motion-mobile-nav-exit)) var(--mobile-nav-motion-ease, var(--motion-ease-standard)),
visibility 0s linear var(--mobile-nav-motion-duration, var(--motion-mobile-nav-exit));
}
.paperclip-app-shell[data-mobile="true"]:not([data-keyboard-open="true"]) #main-content[data-mobile-nav="hidden"] [data-task-chat-shell] [data-testid="task-chat-scroller"] ~ button {
bottom: calc(var(--sz-safe-bottom) + var(--spacing) * 3);
}
@media (prefers-reduced-motion: reduce) {
:root {
--motion-mobile-nav-enter: 0ms;
@@ -0,0 +1,158 @@
import type { CSSProperties } from "react";
import type { Meta, StoryObj } from "@storybook/react-vite";
import { expect, waitFor } from "storybook/test";
import { MobileBottomNav } from "@/components/MobileBottomNav";
import { TaskChatComposer } from "@/components/task-chat/TaskChatComposer";
import { TaskChatComposerDock } from "@/components/task-chat/TaskChatComposerDock";
import { TaskChatThreadView } from "@/components/task-chat/TaskChatThreadView";
import { useMobileNavVisibility } from "@/hooks/useMobileNavVisibility";
import { useMobileVisualViewport } from "@/hooks/useMobileVisualViewport";
const paragraphs = (count: number, topic: string) =>
Array.from({ length: count }, (_, index) =>
`${topic} ${index + 1}: I checked this section against the spec, noted the differences, and recorded what still needs a decision.`,
).join("\n\n");
const items = [
{ id: "ask-1", kind: "message" as const, author: "human" as const, text: "Audit the onboarding flow and tell me what is slowing people down." },
{ id: "reply-1", kind: "message" as const, author: "agent" as const, authorName: "Researcher", text: paragraphs(10, "Finding") },
{ id: "ask-2", kind: "message" as const, author: "human" as const, text: "Which of these should we fix first?" },
{ id: "reply-2", kind: "message" as const, author: "agent" as const, authorName: "Researcher", text: paragraphs(8, "Priority") },
{ id: "ask-3", kind: "message" as const, author: "human" as const, text: "Great — draft the plan for the top three." },
{ id: "reply-3", kind: "message" as const, author: "agent" as const, authorName: "Researcher", text: paragraphs(6, "Step") },
];
/**
* The production mobile task page frame: the Layout's main column publishes
* the auto-hiding chrome state exactly as `Layout.tsx` does, and the real
* thread scroller, composer dock, and bottom navigation respond to it.
*/
function MobileChromeAutoHide() {
const viewportRef = useMobileVisualViewport(true);
const navVisible = useMobileNavVisibility(true, "/ONB/issues/ONB-12");
return <div ref={viewportRef} data-mobile="true" className="paperclip-app-shell min-h-dvh overflow-x-clip bg-background text-foreground">
<div className="app-main-row min-h-0 flex-1 w-full">
<div className="app-content-column flex w-full min-w-0 flex-col">
<header className="app-breadcrumb sticky top-0 z-20 flex h-12 shrink-0 items-center bg-background/95 px-4 text-sm font-medium backdrop-blur">
ONB-12 · Onboarding audit
</header>
<div className="app-content-row block">
<main
id="main-content"
data-mobile-nav={navVisible ? "visible" : "hidden"}
style={{
"--tc-composer-bottom": navVisible ? "var(--tc-composer-visible-nav-offset)" : "var(--tc-composer-hidden-nav-offset)",
"--mobile-nav-motion-duration": navVisible ? "var(--motion-mobile-nav-enter)" : "var(--motion-mobile-nav-exit)",
"--mobile-nav-motion-ease": navVisible ? "var(--motion-ease-out-expo)" : "var(--motion-ease-standard)",
} as CSSProperties}
className="flex-1 overflow-visible p-4 pb-(--tc-composer-visible-nav-offset) outline-none"
>
<div data-task-chat-shell="" className="-mx-4 flex h-full min-h-0 w-full flex-1 flex-col">
<div data-testid="task-chat-thread" className="relative flex min-h-0 flex-1 flex-col">
<TaskChatThreadView items={items} />
<TaskChatComposerDock mobile streamlined={false}>
<TaskChatComposer mobile workMode="standard" onAdd={async () => {}} />
</TaskChatComposerDock>
</div>
</div>
</main>
</div>
</div>
</div>
<MobileBottomNav visible={navVisible} />
</div>;
}
function scroller(canvasElement: HTMLElement) {
const element = canvasElement.ownerDocument.querySelector<HTMLElement>('[data-testid="task-chat-scroller"]');
if (!element) throw new Error("Task thread scroller is missing");
return element;
}
/** Scroll in small steps, like a finger drag, so the tracker sees deliberate movement. */
async function dragThread(element: HTMLElement, by: number) {
const step = Math.sign(by) * 8;
for (let moved = 0; Math.abs(moved) < Math.abs(by); moved += step) {
element.scrollTop += step;
await new Promise((resolve) => requestAnimationFrame(resolve));
}
}
const chromeState = (canvasElement: HTMLElement) => {
const doc = canvasElement.ownerDocument;
return {
nav: doc.querySelector(".mobile-bottom-nav")?.getAttribute("data-visible"),
main: doc.getElementById("main-content")?.getAttribute("data-mobile-nav"),
dockVisibility: getComputedStyle(doc.querySelector('[data-testid="task-chat-composer-dock"]')!).visibility,
};
};
async function settleAtLatest(canvasElement: HTMLElement) {
const element = scroller(canvasElement);
await waitFor(() => expect(element.scrollHeight).toBeGreaterThan(element.clientHeight * 2));
element.scrollTop = element.scrollHeight;
await new Promise((resolve) => requestAnimationFrame(resolve));
return element;
}
const meta = {
id: "task-chat-mobile-chrome-autohide",
title: "Tasks and conversations/Task creation and lifecycle/Task chat/Mobile chrome auto-hide",
component: MobileChromeAutoHide,
parameters: {
layout: "fullscreen",
docs: { description: { component: "On a phone, the task page rests at the latest message with the composer and bottom navigation on screen. Drag back through the conversation and both slide away so the thread uses the full height. Drag back toward the latest message, or reach it, and both return. Typing with the keyboard open never hides the composer. Reduced motion switches instantly." } },
paperclip: {
"capabilities": [
"tasks/discussion",
],
"implementation": "production",
"boundary": "fixtures",
"notes": "Production thread scroller, composer dock, bottom navigation, and useMobileNavVisibility in the Layout's mobile task-page frame. Static fixture messages; no agent or provider calls. Physical iPhone touch acceptance is still required.",
},
},
globals: { theme: "light", viewport: { value: "mobile", isRotated: false } },
} satisfies Meta<typeof MobileChromeAutoHide>;
export default meta;
type Story = StoryObj<typeof meta>;
/** Interactive: start at the latest message and drag the thread yourself. */
export const Interactive: Story = {
name: "01 · Drag the thread",
play: async ({ canvasElement }) => {
await settleAtLatest(canvasElement);
await waitFor(() => expect(chromeState(canvasElement).main).toBe("visible"));
},
};
/** Reading back through the thread tucks the composer and navigation away. */
export const ReadingBack: Story = {
name: "02 · Reading back hides composer and nav",
play: async ({ canvasElement }) => {
const element = await settleAtLatest(canvasElement);
await dragThread(element, -480);
await waitFor(() => {
const state = chromeState(canvasElement);
expect(state.main).toBe("hidden");
expect(state.nav).toBe("false");
expect(state.dockVisibility).toBe("hidden");
});
},
};
/** Heading back toward the latest message brings both back. */
export const HeadingBack: Story = {
name: "03 · Heading back restores them",
play: async ({ canvasElement }) => {
const element = await settleAtLatest(canvasElement);
await dragThread(element, -480);
await waitFor(() => expect(chromeState(canvasElement).main).toBe("hidden"));
await dragThread(element, 40);
await waitFor(() => {
const state = chromeState(canvasElement);
expect(state.main).toBe("visible");
expect(state.nav).toBe("true");
expect(state.dockVisibility).toBe("visible");
});
},
};