@sixb/sqlite 0.1.25 → 0.1.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/agents/messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAG1C,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EAEtB,KAAK,uBAAuB,EAC5B,KAAK,6BAA6B,EAClC,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC7B,MAAM,oBAAoB,CAAA;AAK3B,qBAAa,uBAAwB,YAAW,iBAAiB;IACnD,OAAO,CAAC,QAAQ,CAAC,EAAE;gBAAF,EAAE,EAAE,QAAQ;IAEnC,MAAM,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAqGnE,aAAa,CAAC,KAAK,EAAE,6BAA6B,GAAG,OAAO,CAAC,MAAM,CAAC;IAiDpE,OAAO,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAQtF,IAAI,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAgC3E,OAAO,CAAC,cAAc;CAcvB"}
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/agents/messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAG1C,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EAEtB,KAAK,uBAAuB,EAC5B,KAAK,6BAA6B,EAClC,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC7B,MAAM,oBAAoB,CAAA;AAK3B,qBAAa,uBAAwB,YAAW,iBAAiB;IACnD,OAAO,CAAC,QAAQ,CAAC,EAAE;gBAAF,EAAE,EAAE,QAAQ;IAEnC,MAAM,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAqGnE,aAAa,CAAC,KAAK,EAAE,6BAA6B,GAAG,OAAO,CAAC,MAAM,CAAC;IA8DpE,OAAO,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAQtF,IAAI,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAgC3E,OAAO,CAAC,cAAc;CAcvB"}
@@ -14,6 +14,8 @@ export interface AgentThreadRow {
14
14
  title: string | null;
15
15
  sandbox_params: string | null;
16
16
  sandbox_state: string | null;
17
+ runs_on: "computer" | null;
18
+ computer_id: string | null;
17
19
  status: AgentThreadRecord["status"];
18
20
  active_run_id: string | null;
19
21
  last_message_at: string | null;
@@ -49,6 +51,7 @@ export interface AgentRunRow {
49
51
  attempt: number;
50
52
  execution_token: string | null;
51
53
  execution_queue_lease_expires_at: string | null;
54
+ cancel_requested_at: string | null;
52
55
  created_at: string;
53
56
  started_at: string | null;
54
57
  completed_at: string | null;
@@ -1 +1 @@
1
- {"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../../src/agents/rows.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,KAAK,EAAoB,SAAS,EAAE,MAAM,YAAY,CAAA;AAG7D,OAAO,EAEL,KAAK,4BAA4B,EACjC,KAAK,kBAAkB,EAEvB,KAAK,cAAc,EACnB,KAAK,4BAA4B,EACjC,KAAK,iBAAiB,EAMvB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAIpD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kBAAkB,CAiB3E;AAED,wBAAgB,4BAA4B,CAC1C,GAAG,EAAE,yBAAyB,GAC7B,4BAA4B,CAsB9B;AAED,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,yBAAyB,GAC7B,4BAA4B,CAQ9B;AAWD,wBAAgB,cAAc,CAAC,IAAI,EAAE,KAAK,EAAE;IAC1C,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAA;IACrB,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,gBAAgB,CAAA;IAClD,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAA;IACxC,QAAQ,CAAC,IAAI,EAAE,SAAS,WAAW,EAAE,CAAA;IACrC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CACzB,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,IAAI,EAAE,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAsBxF"}
@@ -1,5 +1,5 @@
1
1
  import type { Database } from "bun:sqlite";
2
- import { type AgentRunRecord, type AgentRunStore, type ConfirmAgentRunExecutionOwnershipInput, type ConversationAgentRunRecord, type CreateAgentRunInput, type CreateSubagentRunInput, type ExecutionStorage, type FinishAgentRunInput, type FinishQueuedAgentRunInput, type ListAgentRunsInput, type ListAgentRunsResult, type ListThreadSubagentsInput, type ReclaimAgentRunInput, type StartAgentRunInput, type SubagentRunRecord } from "@sixb/core/storage";
2
+ import { type AgentRunRecord, type AgentRunStore, type ConfirmAgentRunExecutionOwnershipInput, type ConversationAgentRunRecord, type CreateAgentRunInput, type CreateSubagentRunInput, type ExecutionStorage, type FinishAgentRunInput, type FinishQueuedAgentRunInput, type ListAgentRunsInput, type ListAgentRunsResult, type ListThreadSubagentsInput, type ReclaimAgentRunInput, type RequestAgentRunCancelInput, type StartAgentRunInput, type SubagentRunRecord } from "@sixb/core/storage";
3
3
  export declare class SqliteAgentRunStore implements AgentRunStore {
4
4
  private readonly db;
5
5
  private readonly executions;
@@ -10,6 +10,7 @@ export declare class SqliteAgentRunStore implements AgentRunStore {
10
10
  finishQueued(input: FinishQueuedAgentRunInput): Promise<AgentRunRecord>;
11
11
  reclaim(input: ReclaimAgentRunInput): Promise<AgentRunRecord>;
12
12
  confirmExecutionOwnership(input: ConfirmAgentRunExecutionOwnershipInput): Promise<AgentRunRecord>;
13
+ requestCancel(input: RequestAgentRunCancelInput): Promise<AgentRunRecord>;
13
14
  finish(input: FinishAgentRunInput): Promise<AgentRunRecord>;
14
15
  /**
15
16
  * A turn that pauses keeps its calls for their decision. A turn that ends any other way cancels
@@ -1 +1 @@
1
- {"version":3,"file":"runs.d.ts","sourceRoot":"","sources":["../../src/agents/runs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAe1C,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,aAAa,EAElB,KAAK,sCAAsC,EAC3C,KAAK,0BAA0B,EAC/B,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAC9B,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACvB,MAAM,oBAAoB,CAAA;AAa3B,qBAAa,mBAAoB,YAAW,aAAa;IAErD,OAAO,CAAC,QAAQ,CAAC,EAAE;IACnB,OAAO,CAAC,QAAQ,CAAC,UAAU;gBADV,EAAE,EAAE,QAAQ,EACZ,UAAU,EAAE,gBAAgB;IAGzC,MAAM,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,0BAA0B,CAA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KAAE,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAQlF,QAAQ,CAAC,MAAM,EAAE;QACrB,SAAS,EAAE,MAAM,CAAA;QACjB,GAAG,EAAE,SAAS,MAAM,EAAE,CAAA;KACvB,GAAG,OAAO,CAAC,SAAS,cAAc,EAAE,CAAC;IAuBhC,mBAAmB,CACvB,KAAK,EAAE,wBAAwB,GAC9B,OAAO,CAAC,SAAS,iBAAiB,EAAE,CAAC;IAiClC,IAAI,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAsCnE,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,aAAa;IA0BrB;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAwExB,oEAAoE;IACpE,OAAO,CAAC,aAAa;IAYrB,OAAO,CAAC,UAAU;CAcnB"}
@@ -1,5 +1,5 @@
1
1
  import type { Database } from "bun:sqlite";
2
- import { type AddAgentThreadParticipantsInput, type AgentThreadParticipantRecord, type AgentThreadRecord, type AgentThreadSandboxState, type AgentThreadStore, type CreateAgentThreadInput, type ForkAgentThreadInput, type ListAgentThreadChildrenInput, type ListAgentThreadParticipantsInput, type ListAgentThreadsInput, type ListAgentThreadsResult, type RemoveAgentThreadParticipantInput, type TransitionAgentThreadSandboxInput } from "@sixb/core/storage";
2
+ import { type AddAgentThreadParticipantsInput, type AgentThreadParticipantRecord, type AgentThreadRecord, type AgentThreadSandboxState, type AgentThreadStore, type AssignAgentThreadComputerInput, type CreateAgentThreadInput, type ForkAgentThreadInput, type ListAgentThreadChildrenInput, type ListAgentThreadParticipantsInput, type ListAgentThreadsInput, type ListAgentThreadsResult, type RemoveAgentThreadParticipantInput, type TransitionAgentThreadSandboxInput } from "@sixb/core/storage";
3
3
  export declare class SqliteAgentThreadStore implements AgentThreadStore {
4
4
  private readonly db;
5
5
  constructor(db: Database);
@@ -18,6 +18,7 @@ export declare class SqliteAgentThreadStore implements AgentThreadStore {
18
18
  list(input: ListAgentThreadsInput): Promise<ListAgentThreadsResult>;
19
19
  addParticipants(input: AddAgentThreadParticipantsInput): Promise<readonly AgentThreadParticipantRecord[]>;
20
20
  removeParticipant(input: RemoveAgentThreadParticipantInput): Promise<boolean>;
21
+ assignComputer(input: AssignAgentThreadComputerInput): Promise<AgentThreadRecord>;
21
22
  listParticipants(input: ListAgentThreadParticipantsInput): Promise<readonly AgentThreadParticipantRecord[]>;
22
23
  private selectParticipants;
23
24
  private findActiveRun;
@@ -1 +1 @@
1
- {"version":3,"file":"threads.d.ts","sourceRoot":"","sources":["../../src/agents/threads.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAS1C,OAAO,EACL,KAAK,+BAA+B,EAGpC,KAAK,4BAA4B,EACjC,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,4BAA4B,EACjC,KAAK,gCAAgC,EACrC,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,iCAAiC,EACtC,KAAK,iCAAiC,EACvC,MAAM,oBAAoB,CAAA;AAgB3B,qBAAa,sBAAuB,YAAW,gBAAgB;IACjD,OAAO,CAAC,QAAQ,CAAC,EAAE;gBAAF,EAAE,EAAE,QAAQ;IAEnC,iBAAiB,CACrB,KAAK,EAAE,iCAAiC,GACvC,OAAO,CAAC,uBAAuB,CAAC;IAmB7B,MAAM,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAqDjE,IAAI,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA4H7D,OAAO,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAQrF,QAAQ,CAAC,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IAC5E,OAAO,CAAC,gBAAgB;IAyBxB,OAAO,CAAC,aAAa;CActB"}
package/dist/index.js CHANGED
@@ -5962,6 +5962,19 @@ CREATE INDEX idx_agent_runs_paused_on_question
5962
5962
  WHERE kind = 'subagent' AND finish_reason = 'awaiting_answer';
5963
5963
  `;
5964
5964
 
5965
+ // src/migrations/080-agent-run-cancel-requests.sql
5966
+ var _080_agent_run_cancel_requests_default = `-- A cancel is recorded on the run, not only broadcast: a runner that never hears the broker learns
5967
+ -- of it at its next lease renewal, and the run token stops working at once.
5968
+ ALTER TABLE agent_runs ADD COLUMN cancel_requested_at TEXT;
5969
+ `;
5970
+
5971
+ // src/migrations/081-agent-thread-runs-on.sql
5972
+ var _081_agent_thread_runs_on_default = `-- Where a conversation's turns run: NULL in the cloud, 'computer' on its owner's computer.
5973
+ ALTER TABLE agent_threads ADD COLUMN runs_on TEXT CHECK (runs_on IS NULL OR runs_on = 'computer');
5974
+ -- Which of its owner's computers runs a computer's thread: NULL until one claims its first turn.
5975
+ ALTER TABLE agent_threads ADD COLUMN computer_id TEXT;
5976
+ `;
5977
+
5965
5978
  // src/migrations.ts
5966
5979
  var MIGRATIONS_TABLE_SQL = `
5967
5980
  CREATE TABLE IF NOT EXISTS sixb_migrations (
@@ -6095,7 +6108,9 @@ var sqliteStorageMigrations = defineMigrations({
6095
6108
  throw new Error("[SixbSqliteStorage] Agent runs, threads or messages were lost while giving sub-agents their threads.");
6096
6109
  }
6097
6110
  }, { checksum: checksum(_078_subagent_threads_default) }),
6098
- sqliteSql("079-subagent-questions", _079_subagent_questions_default)
6111
+ sqliteSql("079-subagent-questions", _079_subagent_questions_default),
6112
+ sqliteSql("080-agent-run-cancel-requests", _080_agent_run_cancel_requests_default),
6113
+ sqliteSql("081-agent-thread-runs-on", _081_agent_thread_runs_on_default)
6099
6114
  ]
6100
6115
  });
6101
6116
  function sqliteStoragePath(basePath) {
@@ -7061,6 +7076,8 @@ function rowToThreadRecord(row) {
7061
7076
  sandboxState: JSON.parse(row.sandbox_state)
7062
7077
  },
7063
7078
  ...row.sandbox_params == null ? {} : { sandboxParams: snapshotAgentThreadSandboxParams(JSON.parse(row.sandbox_params)) },
7079
+ ...row.runs_on == null ? {} : { runsOn: row.runs_on },
7080
+ ...row.computer_id == null ? {} : { computerId: row.computer_id },
7064
7081
  status: row.status,
7065
7082
  activeRunId: row.active_run_id,
7066
7083
  lastMessageAt: row.last_message_at ? new Date(row.last_message_at) : undefined,
@@ -7084,6 +7101,7 @@ function rowToRunRecord(row) {
7084
7101
  token: row.execution_token,
7085
7102
  queueLeaseExpiresAt: new Date(row.execution_queue_lease_expires_at)
7086
7103
  } : undefined,
7104
+ cancelRequestedAt: row.cancel_requested_at ? new Date(row.cancel_requested_at) : undefined,
7087
7105
  createdAt: new Date(row.created_at),
7088
7106
  startedAt: row.started_at ? new Date(row.started_at) : undefined,
7089
7107
  completedAt: row.completed_at ? new Date(row.completed_at) : undefined
@@ -7708,6 +7726,12 @@ class SqliteAgentMessageStore {
7708
7726
  }
7709
7727
  async deleteByRunId(input) {
7710
7728
  return this.db.transaction(() => {
7729
+ if (input.fence) {
7730
+ const owner = this.db.query("SELECT 1 AS present FROM agent_runs WHERE project_id = ? AND id = ? AND status = 'running' AND execution_token = ?").get(input.projectId, input.fence.runId, input.fence.executionToken);
7731
+ if (!owner) {
7732
+ throw new AgentStorageError3("execution_lost", `[SixbSqlite] Execution token is no longer current on agent run '${input.fence.runId}'.`);
7733
+ }
7734
+ }
7711
7735
  const thread = this.db.query("SELECT 1 AS present FROM agent_threads WHERE project_id = ? AND id = ?").get(input.projectId, input.threadId);
7712
7736
  if (!thread) {
7713
7737
  throw new AgentStorageError3("thread_not_found", `[SixbSqlite] Agent thread '${input.threadId}' not found for project '${input.projectId}'.`);
@@ -8001,7 +8025,10 @@ class SqliteAgentRunStore {
8001
8025
  }
8002
8026
  async reclaim(input) {
8003
8027
  return this.db.transaction(() => {
8004
- this.requireRunning(input.projectId, input.id);
8028
+ const run = this.requireRunning(input.projectId, input.id);
8029
+ if (input.ifLapsedBy && run.execution_queue_lease_expires_at !== null && new Date(run.execution_queue_lease_expires_at).getTime() > input.ifLapsedBy.getTime()) {
8030
+ throw new AgentStorageError4("invalid_state", `[SixbSqlite] Agent run '${input.id}' is still held by its runner, whose lease has not lapsed.`);
8031
+ }
8005
8032
  this.db.query(`
8006
8033
  UPDATE agent_runs
8007
8034
  SET
@@ -8027,6 +8054,16 @@ class SqliteAgentRunStore {
8027
8054
  return this.requireRun(input.projectId, input.id);
8028
8055
  })();
8029
8056
  }
8057
+ async requestCancel(input) {
8058
+ return this.db.transaction(() => {
8059
+ this.db.query(`
8060
+ UPDATE agent_runs
8061
+ SET cancel_requested_at = ?
8062
+ WHERE project_id = ? AND id = ? AND status = 'running' AND cancel_requested_at IS NULL
8063
+ `).run((input.at ?? new Date).toISOString(), input.projectId, input.id);
8064
+ return this.requireRun(input.projectId, input.id);
8065
+ })();
8066
+ }
8030
8067
  async finish(input) {
8031
8068
  const completedAt = input.completedAt ?? new Date;
8032
8069
  const errorValue = input.status === "succeeded" || input.error === undefined ? null : serializeSixbFailure(input.error, AGENT_RUN_FAILURE_CODES2);
@@ -8259,7 +8296,10 @@ class SqliteAgentApprovalModeStore {
8259
8296
 
8260
8297
  // src/agents/threads.ts
8261
8298
  import {
8299
+ assertAssignableComputer,
8300
+ assertComputerId,
8262
8301
  assertConversationThreadRow as assertConversationThreadRow2,
8302
+ assertRunsOn,
8263
8303
  participantsToAdd,
8264
8304
  planAgentThreadFork,
8265
8305
  remapArtifactIds,
@@ -8284,6 +8324,7 @@ class SqliteAgentThreadStore {
8284
8324
  }).immediate();
8285
8325
  }
8286
8326
  async create(input) {
8327
+ assertRunsOn(input.runsOn, "Agent thread", "SixbSqlite");
8287
8328
  const sandboxParams = input.sandboxParams === undefined ? null : JSON.stringify(snapshotAgentThreadSandboxParams2(input.sandboxParams));
8288
8329
  const createdAt = input.createdAt ?? new Date;
8289
8330
  const updatedAt = input.updatedAt ?? createdAt;
@@ -8296,14 +8337,15 @@ class SqliteAgentThreadStore {
8296
8337
  owner_principal_id,
8297
8338
  title,
8298
8339
  sandbox_params,
8340
+ runs_on,
8299
8341
  status,
8300
8342
  active_run_id,
8301
8343
  last_message_at,
8302
8344
  message_count,
8303
8345
  created_at,
8304
8346
  updated_at
8305
- ) VALUES (?, ?, ?, ?, ?, ?, ?, NULL, NULL, 0, ?, ?)
8306
- `).run(input.projectId, input.id, input.ownerPrincipal.type, input.ownerPrincipal.id, input.title ?? null, sandboxParams, input.status ?? "active", createdAt.toISOString(), updatedAt.toISOString());
8347
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, NULL, NULL, 0, ?, ?)
8348
+ `).run(input.projectId, input.id, input.ownerPrincipal.type, input.ownerPrincipal.id, input.title ?? null, sandboxParams, input.runsOn ?? null, input.status ?? "active", createdAt.toISOString(), updatedAt.toISOString());
8307
8349
  } catch (error) {
8308
8350
  if (isUniqueConstraintError(error)) {
8309
8351
  throw new AgentStorageError6("duplicate_id", `[SixbSqlite] Agent thread '${input.id}' already exists for project '${input.projectId}'.`);
@@ -8484,6 +8526,18 @@ class SqliteAgentThreadStore {
8484
8526
  `).run(input.projectId, input.threadId, input.principal.type, input.principal.id);
8485
8527
  return result.changes > 0;
8486
8528
  }
8529
+ async assignComputer(input) {
8530
+ assertComputerId(input.computerId, "SixbSqlite");
8531
+ this.db.query(`
8532
+ UPDATE agent_threads SET computer_id = ?
8533
+ WHERE project_id = ? AND id = ? AND runs_on = 'computer'
8534
+ ${input.ifUnassigned ? "AND computer_id IS NULL" : ""}
8535
+ `).run(input.computerId, input.projectId, input.id);
8536
+ const row = this.db.query("SELECT * FROM agent_threads WHERE project_id = ? AND id = ?").get(input.projectId, input.id);
8537
+ const thread = row ? rowToThreadRecord(row) : null;
8538
+ assertAssignableComputer(thread, input.id, "SixbSqlite");
8539
+ return thread;
8540
+ }
8487
8541
  async listParticipants(input) {
8488
8542
  return this.selectParticipants(input.projectId, [...new Set(input.threadIds)]);
8489
8543
  }
@@ -13658,8 +13712,7 @@ function compileExpansionValue(expansion, parent, path, ctx) {
13658
13712
  whereParts.push(`${edge}.source_type_id = ?`);
13659
13713
  whereArgs.push(expansion.sourceObjectTypeId);
13660
13714
  }
13661
- const inner = `
13662
- SELECT ${child.sql} AS elem, row_number() OVER (ORDER BY ${order.sql}) AS _ord
13715
+ const from = `
13663
13716
  FROM ${ctx.source.linksTable} AS ${edge}
13664
13717
  JOIN ${ctx.source.objectsTable} AS ${target}
13665
13718
  ON ${target}.project_id = ${edge}.project_id
@@ -13667,17 +13720,21 @@ function compileExpansionValue(expansion, parent, path, ctx) {
13667
13720
  AND ${target}.primary_id = ${neighborId}
13668
13721
  WHERE ${whereParts.join(" AND ")}
13669
13722
  `;
13670
- const innerArgs = [...child.args, ...order.args, ...whereArgs];
13671
13723
  if (expansion.cardinality === "one") {
13672
13724
  return {
13673
- sql: `(SELECT ${ranked}.elem FROM (${inner}) AS ${ranked} WHERE ${ranked}._ord = 1)`,
13674
- args: innerArgs
13725
+ sql: `(SELECT ${child.sql} ${from} ORDER BY ${order.sql} LIMIT 1)`,
13726
+ args: [...child.args, ...whereArgs, ...order.args]
13675
13727
  };
13676
13728
  }
13677
13729
  const limit = expansion.limit ?? DEFAULT_EXPANSION_FANOUT;
13678
13730
  return {
13679
- sql: `COALESCE((SELECT json_group_array(json(${ranked}.elem) ORDER BY ${ranked}._ord) FROM (${inner}) AS ${ranked} WHERE ${ranked}._ord <= ?), '[]')`,
13680
- args: [...innerArgs, limit]
13731
+ sql: `COALESCE((SELECT json_group_array(json(${ranked}.elem) ORDER BY ${ranked}._ord) FROM (
13732
+ SELECT ${child.sql} AS elem, row_number() OVER (ORDER BY ${order.sql}) AS _ord
13733
+ ${from}
13734
+ ORDER BY ${order.sql}
13735
+ LIMIT ?
13736
+ ) AS ${ranked}), '[]')`,
13737
+ args: [...child.args, ...order.args, ...whereArgs, ...order.args, limit]
13681
13738
  };
13682
13739
  }
13683
13740
  function compileExpansionChildJson(expansion, edge, target, path, ctx) {
@@ -21808,4 +21865,4 @@ export {
21808
21865
  migrateSqliteStorage
21809
21866
  };
21810
21867
 
21811
- //# debugId=34FFE55D6BF6FFCE64756E2164756E21
21868
+ //# debugId=21418853CB8E412664756E2164756E21