@axiom-lattice/local-stores 5.0.0 → 5.0.2

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,5 +1,5 @@
1
1
 
2
- > @axiom-lattice/local-stores@5.0.0 build /home/runner/work/agentic/agentic/packages/local-stores
2
+ > @axiom-lattice/local-stores@5.0.2 build /home/runner/work/agentic/agentic/packages/local-stores
3
3
  > tsup src/index.ts --format cjs,esm --dts --sourcemap
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -8,13 +8,13 @@
8
8
  CLI Target: es2020
9
9
  CJS Build start
10
10
  ESM Build start
11
- CJS dist/index.js 253.25 KB
12
- CJS dist/index.js.map 459.22 KB
13
- CJS ⚡️ Build success in 867ms
14
- ESM dist/index.mjs 248.46 KB
15
- ESM dist/index.mjs.map 455.49 KB
16
- ESM ⚡️ Build success in 869ms
11
+ CJS dist/index.js 254.39 KB
12
+ CJS dist/index.js.map 461.99 KB
13
+ CJS ⚡️ Build success in 821ms
14
+ ESM dist/index.mjs 249.57 KB
15
+ ESM dist/index.mjs.map 458.34 KB
16
+ ESM ⚡️ Build success in 854ms
17
17
  DTS Build start
18
- DTS ⚡️ Build success in 13283ms
19
- DTS dist/index.d.ts 46.24 KB
20
- DTS dist/index.d.mts 46.24 KB
18
+ DTS ⚡️ Build success in 14030ms
19
+ DTS dist/index.d.ts 46.34 KB
20
+ DTS dist/index.d.mts 46.34 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,185 @@
1
1
  # @axiom-lattice/local-stores
2
2
 
3
+ ## 5.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [a756acb]
8
+ - @axiom-lattice/core@12.1.0
9
+ - @axiom-lattice/protocols@7.1.0
10
+
11
+ ## 5.0.1
12
+
13
+ ### Patch Changes
14
+
15
+ - 3c95be1: This changeset consolidates all pending release notes into a single release entry. All packages are released as patch versions for this consolidated release.
16
+
17
+ ## Pending changes
18
+
19
+ ### chat-cursor-expired-auto-recovery
20
+
21
+ Console chat now silently recovers from chunk-stream `CURSOR_EXPIRED`: it reloads durable messages, reconnects without the expired cursor, and only shows a localized retry prompt when recovery fails or exceeds the bounded recovery budget.
22
+
23
+ ### chat-quick-prompts-generic
24
+
25
+ Make `Chating` empty-state content generic by default: the question is now "How can I help you today?", the built-in data-analysis dataset is opt-in via `showQuickAnalysis`, and all quick prompts use one `QuickPromptCategory[]` shape rendered below the composer in both empty and non-empty states. Adds `quickPromptsData` / `quickPromptsTitle` props, keeps the shell `quickPromptsData` as a fallback, and exports `BusinessAnalysisPrompts`, `QuickPrompts`, `buildDataAnalysisPrompts`, and the `BusinessAnalysisPromptsProps` type. Also removes the empty→active send transition animation.
26
+
27
+ ### chat-quick-prompts-hardening
28
+
29
+ Fix chat quick prompts:
30
+
31
+ - Sender labels and descriptions are no longer duplicated, including description-only prompts and whitespace-only labels.
32
+ - Effective sender prompt text is trimmed; fully blank or whitespace-only prompts are dropped and whitespace-only descriptions are suppressed.
33
+ - The renderer honors `disabled` for generated items and guards the click and More handlers.
34
+ - Simple-mode item keys are collision-safe across categories.
35
+ - An explicit `title` takes precedence over the category title.
36
+ - Single-category items inherit the category icon when they have none.
37
+
38
+ ### fix-abort-notice-task-detail-overflow
39
+
40
+ Preserve the neutral "Response stopped." notice after a user aborts a run: terminal stream events from that same run no longer clear it immediately, while a new run's output still clears it.
41
+
42
+ Also fix task-detail horizontal overflow on narrow layouts by wrapping activity metadata and removing the mobile subtask row negative margin.
43
+
44
+ ### fix-client-sdk-delete-content-type
45
+
46
+ Fix bodyless `DELETE` requests sending `Content-Type: application/json`. `makeRequest` strips the header for bodyless deletes, but `fetchWithTimeout` merged `this.headers` back in and silently restored it, so delete requests could be rejected by servers that treat a declared JSON content type as requiring a body. `fetchWithTimeout` now trusts the already-merged request headers from `makeRequest`.
47
+
48
+ `WorkspaceClient.request` had the same problem: it always merged `this.headers` (including `Content-Type: application/json`) into every request. Bodyless `deleteWorkspace` / `deleteProject` calls now strip the `content-type` header case-insensitively from the merged map, including a lowercase `content-type` supplied through `ClientConfig.headers`.
49
+
50
+ ### fix-filesystem-write-edit-symlink-parent
51
+
52
+ Fix `FilesystemBackend` virtual-mode confinement for writes and edits: both operations now validate the resolved parent directory against the virtual root (mirroring reads and deletes), so a symlinked parent that points outside the root can no longer be used to create or modify files outside the sandbox.
53
+
54
+ Writes additionally validate the nearest existing ancestor before recursive directory creation. A nested path such as `/outside-link/created-dir/escaped.txt` is rejected before `fs.mkdir(..., { recursive: true })` runs, so no directories are created outside the virtual root either.
55
+
56
+ Directory listing and search are hardened too: in virtual mode the requested `lsInfo` directory, `globInfo` search base, and `grepRaw` base must resolve inside the root; symlink entries are hidden from scans; `globInfo`/grep fallback stop following symlinks; and ripgrep runs with `--no-follow`.
57
+
58
+ Symlink behavior is intentionally split between root scans and direct access. A symlink whose target stays inside the root is hidden from directory listings and recursive scans, but a direct `lsInfo`, `globInfo`, or `grepRaw` call whose resolved base stays inside the root is allowed, and direct file reads through an inside-root symlink remain allowed. A symlink whose target leaves the root is rejected for direct listing/search/read and is neither listed nor searched.
59
+
60
+ Residual limitations:
61
+
62
+ - Plain Node file APIs cannot make "validate ancestor, then create directory/file" atomic. The checks close the symlinked-parent escape and nested-directory side effect, but a concurrent attacker who can swap path components between the ancestor check and the create/open calls could still win a TOCTOU race. Directory-level isolation (or an OS primitive with `openat`/`O_NOFOLLOW`-style semantics for every component) would be required to eliminate that race completely.
63
+ - Hard-link escapes remain possible: hard links share inode data and cannot be distinguished from ordinary files by path checks, so a hard link inside the root can still expose content outside it.
64
+
65
+ ### fix-inmemory-workflow-run-id-collision
66
+
67
+ Fix `InMemoryWorkflowTrackingStore.createWorkflowRun` ID collisions: the generated ID is now `${threadId}_${Date.now()}_${randomUUID()}` (matching the PostgreSQL and Local stores) instead of `${threadId}_${Date.now()}`, so two runs started on the same thread within the same millisecond no longer overwrite each other in the backing `Map` (which also silently reset the earlier run's steps). Added a unit test that pins `Date.now()` and asserts both runs exist with distinct IDs and isolated steps.
68
+
69
+ ### fix-local-store-workflow-and-schedule
70
+
71
+ Fix four local-store defects found while adding coverage:
72
+
73
+ - `LocalWorkflowTrackingStore` could not be constructed: its DDL used `ALTER TABLE ... ADD COLUMN IF NOT EXISTS`, which SQLite does not support, so every constructor call threw. The `thread_id` backfill now uses the same `PRAGMA table_info` guard as the other local stores.
74
+ - `LocalWorkflowTrackingStore.createWorkflowRun` generated `${threadId}_${Date.now()}`, so two runs on the same thread within the same millisecond collided on the primary key. IDs are now `${threadId}_${Date.now()}_${randomUUID()}`, matching the PostgreSQL store.
75
+ - `LocalScheduleStorage.getAllTasks` emitted `OFFSET` without `LIMIT` when only an offset was supplied, which SQLite rejects. It now emits `LIMIT -1` first, matching `LocalWorkflowTrackingStore.queryWorkflowRuns`.
76
+ - **Security parity:** `LocalMetricsServerConfigStore` stored `apiKey`/`password` in plaintext while the PostgreSQL store encrypted them. Both fields are now encrypted on create/update (partial updates still preserve the stored ciphertext) and decrypted on read. Legacy plaintext rows are preserved unchanged on read and encrypted on the next config write; a value that looks encrypted but cannot be decrypted with the current key degrades to `""` via `safeDecrypt`, matching PostgreSQL.
77
+
78
+ **Upgrade note:** the legacy-row heuristic is shape-based. A plaintext secret that itself happens to look like canonical ciphertext (valid base64 of at least the salt+IV+tag length) cannot be distinguished from encrypted data, so it is treated as ciphertext and may read back as an empty string. There is no safe way to tell the two apart after the fact; re-enter any such metric-server secret once after upgrading. Other plaintext secrets are read unchanged and encrypted on the next write.
79
+
80
+ ### fix-opensandbox-concurrent-ensure-dedup
81
+
82
+ Fix `ensureSandbox` concurrency and `listSandboxes` status filtering.
83
+
84
+ `ensureSandbox` now keeps the early in-flight fast path, then re-checks both the cache and the in-flight create map after the asynchronous metadata lookup. A caller that was suspended during metadata recovery can no longer create a duplicate sandbox when another caller finishes first, and waiters on a failed create reject and leave `pendingCreates` cleared so a later call retries instead of hanging.
85
+
86
+ `listSandboxes` now translates the lowercase API status filter to the SDK's capitalized lifecycle states: `running` → `Running`, `stopped` → `Paused`, `crashed` → `Failed`, and `unknown` omits the states filter instead of sending an invalid state. Returned items are mapped back to the same API vocabulary instead of leaking raw SDK states: `Running` → `running`, `Paused`/`Stopping`/`Stopped`/`Terminated` → `stopped`, `Failed`/`Error` → `crashed`, and everything else → `unknown` (previously `Paused` and `Failed` came back as `paused`/`failed`, outside the response schema's allowed values).
87
+
88
+ `mapVolumes` now validates named volume definitions with the same conservative name validator used by the volume-fs routes, so a traversal name such as `../../escape` is rejected with `HttpError(400, INVALID_VOLUME_NAME)` before it can resolve outside `VOLUME_BASE_PATH` or become a PVC `subPath`. Bind volumes are unchanged and still accept arbitrary host source paths.
89
+
90
+ ### fix-pg-eval-result-and-project-defaults
91
+
92
+ Fix two `PostgreSQLEvalStore` contract gaps. `updateRunResult` now includes `interrupted` in its `RETURNING` list, so updating that field returns the new value instead of a stale `false` (follow-up reads already agreed with the database). `createProject` now defaults an omitted `judgeModelConfig` (and defensively an undefined `targetServerConfig`) to `{}` instead of writing SQL `NULL` into a `NOT NULL` JSONB column, matching the protocol's optional `judgeModelConfig`. Added DB-backed integration tests for both cases.
93
+
94
+ ### fix-pg-skill-get-sub-skills
95
+
96
+ Fix `PostgreSQLSkillStore.getSubSkills` so it returns the skills whose `subSkills` list contains the requested parent. The query bound `JSON.stringify([parentName])`, which made the JSONB containment compare against the JSON string `"[\"parent\"]"` instead of the array element `"parent"`, so it never matched. It now binds the bare parent name while keeping the lookup tenant-scoped. Added DB-backed integration coverage for the skill store, including cross-tenant isolation.
97
+
98
+ ### fix-pg-workflow-run-id-collision
99
+
100
+ Fix `PostgreSQLWorkflowTrackingStore.createWorkflowRun` ID collisions: the generated ID is now `${threadId}_${Date.now()}_${randomUUID()}` instead of `${threadId}_${Date.now()}`, so two runs started on the same thread within the same millisecond no longer collide on the primary key. The thread prefix is kept for readability. Added a DB-backed integration test that pins `Date.now()` to a fixed value and asserts both runs exist with distinct IDs.
101
+
102
+ ### fix-publish-target-json-schema
103
+
104
+ Fix `publish_target` for OpenAI-compatible function calling. The Zod schema now has an object root (instead of a root `oneOf` from `discriminatedUnion`), so providers no longer reject it with `schema must be a JSON Schema of 'type: "object"', got 'type: null'`.
105
+
106
+ ### fix-review-regressions
107
+
108
+ Fix review regressions across skills, SQL and filesystem backends:
109
+
110
+ - `FileSystemSkillStore.listSkillResources` falls back to the dirent `path` when `parentPath` is unavailable on older Node versions.
111
+ - `list_tables_sql` quotes mixed-case / non-simple identifiers only on PostgreSQL so its output round-trips through `info_sql`/`getTableInfo`; MySQL keeps raw names because its lookup is exact (unquoted input is still lowercased).
112
+ - `FilesystemBackend.write` creates a missing virtual root before validating ancestors.
113
+ - `query_checker_sql` flags data-modifying CTE `UPDATE`/`DELETE` without a `WHERE`, without misreading `FOR NO KEY UPDATE`.
114
+
115
+ Note: a cancelled workflow thread remains terminal by design — every later input on that thread (including a would-be new turn) is intentionally blocked; this wave does not change workflow abort semantics.
116
+
117
+ ### fix-sql-query-checker-schema-qualified
118
+
119
+ Harden `query_checker_sql` and fix schema-qualified PostgreSQL table lookups.
120
+
121
+ - `ISqlDatabase` gains an optional `explainQuery(query)` method. `PostgresDatabase` implements it with both guards required for safe validation: parenthesized options (`{ text: "EXPLAIN (FORMAT JSON) " + query, queryMode: "extended" }`). The parenthesized option list prevents a user query from starting with `ANALYZE` (or another EXPLAIN option) and turning validation into execution; extended query mode rejects multi-statement input server-side before any tail statement runs. Either guard alone is insufficient. `query_checker_sql` calls `explainQuery` for Postgres validation and never calls `executeQuery` for EXPLAIN; when `explainQuery` is unavailable it skips database validation instead of falling back to simple-mode execution. A server-side validation rejection now makes the overall verdict unsafe.
122
+ - `query_checker_sql` uses a SQL lexer that blanks single-quoted strings (including doubled quotes and E-string backslash escapes), double-quoted identifiers, dollar-quoted strings (`$$...$$`, `$tag$...$tag$`, only at token boundaries), line comments, and nested block comments. The normalized text drives both multi-statement detection and the unqualified-DML check. DML detection looks only at the statement's top-level `UPDATE`/`DELETE` and requires a depth-zero `WHERE` after it, so subquery/CTE `WHERE` clauses, `SELECT ... FOR UPDATE`, `INSERT ... ON CONFLICT DO UPDATE`, and `CREATE TABLE ... ON DELETE/ON UPDATE` do not mask or create a full-table-DML finding.
123
+ - The lexer is advisory/diagnostic rather than a full SQL parser: it does not implement every PostgreSQL literal/identifier form and can misclassify unusual or malformed input. The execution-safety boundary is the server-side parenthesized-options EXPLAIN in extended mode whenever Postgres validation runs; if the adapter lacks `explainQuery`, no server-side validation is performed.
124
+ - `PostgresDatabase.getTableInfo` now lowercases unquoted schema/table parts, preserves quoted identifier case, safely quotes schema-qualified names such as `sales.orders`, filters column and PK/FK metadata by schema (including constraint joins), and reads sample rows from the qualified table.
125
+
126
+ ### fix-wechat-client-request-contract
127
+
128
+ Fix `WeChatClient` request and stream handling:
129
+
130
+ - `makeRequest` dropped per-request headers. It built the merged header map (Content-Type, Authorization, config headers, caller headers, tenant) but passed only the workspace headers to `wechatRequest`, so headers supplied through `request()` / `chat.abort()` (including `x-axiom-affinity`) never reached `wx.request`. It now forwards the fully merged header map with precedence defaults < config < workspace < per-request, so workspace context overrides config headers.
131
+ - `resumeStream` omitted the required `assistant_id` body field, so the gateway rejected resumes with 400. It now includes `assistant_id`, matching the main `Client.resumeStream`.
132
+ - `resumeStream` and `streamRun` omitted workspace/project context. Both now merge `getWorkspaceHeaders()` into their request headers and send `Accept: text/event-stream`.
133
+ - `resumeStream` ignored `ResumeStreamOptions.lastEventId`. A trimmed, non-empty value is now sent as `Last-Event-ID`, matching `Client.resumeStream`.
134
+ - Streaming chunks are now decoded with a per-request `TextDecoder` (`{ stream: true }`) and a pending-line buffer, so JSON frames and multibyte UTF-8 characters split across chunks are no longer dropped or corrupted. Both `data: {...}` and `data:{...}` frames are accepted. On completion the pending final line is flushed, so a last `data:` line without a trailing newline is emitted.
135
+ - `resumeStream` and `streamRun` now inspect the stream response status: 401 surfaces `AuthenticationError` and other non-2xx statuses surface `ApiError` via `onError`, and chunks/completion are suppressed. The error body is parsed from objects, JSON strings, or plain text (`error` / `message`), falling back to `HTTP error! Status: <code>`. A transport `fail` is terminal, so the subsequent `complete` no longer calls `onComplete` or fetches agent state.
136
+ - Aborting through the returned stop function no longer surfaces the WeChat `fail` callback as `onError`, matching the web `Client`; aborts also suppress completion and agent-state fetching. A late completion reported through `success` after abort/terminal is ignored as well.
137
+ - `wechatRequest` now uses the same error-body extractor for 401 and other non-2xx responses, so gateway envelopes like `{ success: false, error: "..." }` surface their `error` (not only `message`).
138
+ - Bodyless `DELETE` requests no longer send `Content-Type: application/json`, matching the web `Client`.
139
+ - Missing `wx` / `wx.request` now raises a descriptive error instead of a raw `TypeError`.
140
+
141
+ ### fix-workspace-client-errors
142
+
143
+ Fix two `WorkspaceClient` error-handling gaps:
144
+
145
+ - `request()` now reads the gateway wire contract's `error` field (`{ success: false, error: "..." }`) before falling back to `message` and the HTTP status, matching `uploadFile`, `downloadFolder`, and `Client`. Previously only `message` was read, so gateway errors surfaced as `HTTP error! Status: 404`.
146
+ - `createWorkspace`, `getWorkspace`, `updateWorkspace`, `createProject`, `getProject`, and `updateProject` now throw a clear `Error` when a successful envelope omits `data`, instead of returning `undefined` through a non-null assertion. `readFile` and `browseFilesystem` get the same treatment (`Failed to read file` / `Failed to browse filesystem`). List methods keep their empty-array fallback.
147
+
148
+ ### harden-menu-item-update-patch
149
+
150
+ Security hardening for menu item updates: PUT `/api/menu-items/:id` now strips server-owned `id` and `tenantId` fields from the patch before calling the registry, so a caller cannot move an item to another tenant or rewrite its id. Normal clients that send a full persisted item back are unaffected; only the mutable fields are applied.
151
+
152
+ ### harden-microsandbox-volume-fs-confinement
153
+
154
+ Harden volume filesystem route confinement. Volume names are now validated against a conservative pattern before host path resolution, guest paths reject lexical traversal, backslashes and NUL bytes, reads/downloads/listings verify the real path stays inside the volume root, and writes/uploads/mkdir verify the nearest existing ancestor before recursive directory creation so symlinked parents cannot create or modify files outside the volume. Uploads also reject malformed base64 instead of silently decoding it.
155
+ This is a deterministic symlink/path hardening, not an atomic guarantee: a concurrent writer with volume access can still race validation and I/O (TOCTOU), and hard links to outside inodes are not detectable by path checks. Guest paths containing any `..` segment (even `a/../b`) are now rejected, and uploads accept only standard base64 (no base64url/whitespace-wrapped input).
156
+
157
+ ### harden-opensandbox-volume-fs-confinement
158
+
159
+ Harden volume filesystem route confinement. Volume names are now validated against a conservative pattern before host path resolution, guest paths reject lexical traversal and backslashes, reads/downloads/listings verify the real path stays inside the volume root, and writes/uploads verify the nearest existing ancestor before recursive directory creation so symlinked parents cannot create or modify files outside the volume. Uploads also reject malformed base64 instead of silently decoding it.
160
+ This is a deterministic symlink/path hardening, not an atomic guarantee: a concurrent writer with volume access can still race validation and I/O (TOCTOU), and hard links to outside inodes are not detectable by path checks. Guest paths containing any `..` segment (even `a/../b`) are now rejected, and uploads accept only standard base64 (no base64url/whitespace-wrapped input).
161
+
162
+ ### remove-processing-agents
163
+
164
+ Remove the deprecated PROCESSING agent type and topology middleware. WORKFLOW agents are the only orchestration type.
165
+
166
+ - Removed `AgentType.PROCESSING`, `ProcessingAgentConfig`, `isProcessingAgentConfig`, the PROCESSING builder/agent, and the disabled `create_processing_agent` / `update_processing_agent` tools.
167
+ - Removed `topologyMiddleware`, the topology middleware editor/default config, the Topology Automation view, and related i18n.
168
+ - Removed `/api/workflows/definitions` and `/api/assistants/:assistantId/workflows/definitions`; workflow run/inbox tracking remains.
169
+ - `CreateWorkflowModal` now creates WORKFLOW agents only.
170
+
171
+ ### tenant-plugin-schema-root
172
+
173
+ Reject tenant sandbox plugin tools whose JSON Schema root is not `type: "object"`. OpenAI-compatible function calling requires an object root; allowing `string`/`array` roots produced runtime `type: null` failures.
174
+
175
+ ### workflow-skill-store-fixes
176
+
177
+ Fix workflow abort detection and filesystem skill resource listing. The input node now lets the "workflow was cancelled before restart" error escape instead of swallowing it in the tracking-store catch, and `FileSystemSkillStore.listSkillResources` reads Node's recursive `Dirent.parentPath` instead of the removed `.path` property. Added workflow, skill-manager, and skill-store lifecycle coverage.
178
+
179
+ - Updated dependencies [3c95be1]
180
+ - @axiom-lattice/core@12.0.1
181
+ - @axiom-lattice/protocols@7.0.1
182
+
3
183
  ## 5.0.0
4
184
 
5
185
  ### Major Changes
package/dist/index.d.mts CHANGED
@@ -581,6 +581,8 @@ declare class LocalModelProviderStore implements ModelProviderStore {
581
581
  declare class LocalWorkflowTrackingStore implements WorkflowTrackingStore {
582
582
  private db;
583
583
  constructor(db: DatabaseWrapper);
584
+ /** Add a column if it does not exist (SQLite version compatible). */
585
+ private ensureColumn;
584
586
  createWorkflowRun(request: CreateWorkflowRunRequest): Promise<WorkflowRun>;
585
587
  getWorkflowRun(runId: string): Promise<WorkflowRun | null>;
586
588
  updateWorkflowRun(runId: string, updates: UpdateWorkflowRunRequest): Promise<WorkflowRun | null>;
package/dist/index.d.ts CHANGED
@@ -581,6 +581,8 @@ declare class LocalModelProviderStore implements ModelProviderStore {
581
581
  declare class LocalWorkflowTrackingStore implements WorkflowTrackingStore {
582
582
  private db;
583
583
  constructor(db: DatabaseWrapper);
584
+ /** Add a column if it does not exist (SQLite version compatible). */
585
+ private ensureColumn;
584
586
  createWorkflowRun(request: CreateWorkflowRunRequest): Promise<WorkflowRun>;
585
587
  getWorkflowRun(runId: string): Promise<WorkflowRun | null>;
586
588
  updateWorkflowRun(runId: string, updates: UpdateWorkflowRunRequest): Promise<WorkflowRun | null>;
package/dist/index.js CHANGED
@@ -2431,6 +2431,7 @@ var LocalConnectionStore = class {
2431
2431
  };
2432
2432
 
2433
2433
  // src/stores/LocalMetricsServerConfigStore.ts
2434
+ var import_core3 = require("@axiom-lattice/core");
2434
2435
  var DDL11 = `
2435
2436
  CREATE TABLE IF NOT EXISTS lt_metrics_configs (
2436
2437
  id TEXT NOT NULL,
@@ -2485,7 +2486,7 @@ var LocalMetricsServerConfigStore = class {
2485
2486
  description = excluded.description,
2486
2487
  config = excluded.config,
2487
2488
  updated_at = excluded.updated_at`
2488
- ).run(id, tenantId, data.key, data.name || null, data.description || null, JSON.stringify(data.config), now, now);
2489
+ ).run(id, tenantId, data.key, data.name || null, data.description || null, JSON.stringify(encryptSecretsInConfig(data.config)), now, now);
2489
2490
  return {
2490
2491
  id,
2491
2492
  tenantId,
@@ -2516,7 +2517,7 @@ var LocalMetricsServerConfigStore = class {
2516
2517
  }
2517
2518
  if (updates.config !== void 0) {
2518
2519
  setClauses.push("config = ?");
2519
- values.push(JSON.stringify(updates.config));
2520
+ values.push(JSON.stringify(encryptSecretsInConfig(updates.config)));
2520
2521
  }
2521
2522
  if (setClauses.length === 0) return existing;
2522
2523
  const now = nowISO();
@@ -2546,16 +2547,31 @@ function mapRowToEntry2(row) {
2546
2547
  id: row.id,
2547
2548
  tenantId: row.tenant_id,
2548
2549
  key: row.key,
2549
- config: JSON.parse(row.config),
2550
+ config: decryptSecretsInConfig(JSON.parse(row.config)),
2550
2551
  name: row.name || void 0,
2551
2552
  description: row.description || void 0,
2552
2553
  createdAt: parseISO(row.created_at),
2553
2554
  updatedAt: parseISO(row.updated_at)
2554
2555
  };
2555
2556
  }
2557
+ function encryptSecretsInConfig(config) {
2558
+ const configCopy = { ...config };
2559
+ if (configCopy.apiKey) configCopy.apiKey = (0, import_core3.encrypt)(configCopy.apiKey);
2560
+ if (configCopy.password) configCopy.password = (0, import_core3.encrypt)(configCopy.password);
2561
+ return configCopy;
2562
+ }
2563
+ function decryptSecretsInConfig(config) {
2564
+ if (config.apiKey && (0, import_core3.isEncryptedValue)(config.apiKey)) {
2565
+ config.apiKey = (0, import_core3.safeDecrypt)(config.apiKey);
2566
+ }
2567
+ if (config.password && (0, import_core3.isEncryptedValue)(config.password)) {
2568
+ config.password = (0, import_core3.safeDecrypt)(config.password);
2569
+ }
2570
+ return config;
2571
+ }
2556
2572
 
2557
2573
  // src/stores/LocalMcpServerConfigStore.ts
2558
- var import_core3 = require("@axiom-lattice/core");
2574
+ var import_core4 = require("@axiom-lattice/core");
2559
2575
  var DDL12 = `
2560
2576
  CREATE TABLE IF NOT EXISTS lt_mcp_configs (
2561
2577
  id TEXT NOT NULL,
@@ -2704,14 +2720,14 @@ function mapRowToEntry3(row) {
2704
2720
  if (config.env && row.is_env_encrypted) {
2705
2721
  const decryptedEnv = {};
2706
2722
  for (const [key, value] of Object.entries(config.env)) {
2707
- decryptedEnv[key] = (0, import_core3.safeDecrypt)(value);
2723
+ decryptedEnv[key] = (0, import_core4.safeDecrypt)(value);
2708
2724
  }
2709
2725
  config.env = decryptedEnv;
2710
2726
  }
2711
2727
  if (config.headers && row.is_env_encrypted) {
2712
2728
  const decryptedHeaders = {};
2713
2729
  for (const [key, value] of Object.entries(config.headers)) {
2714
- decryptedHeaders[key] = (0, import_core3.safeDecrypt)(value);
2730
+ decryptedHeaders[key] = (0, import_core4.safeDecrypt)(value);
2715
2731
  }
2716
2732
  config.headers = decryptedHeaders;
2717
2733
  }
@@ -2735,7 +2751,7 @@ function encryptEnvInConfig(config) {
2735
2751
  if (configCopy.env && Object.keys(configCopy.env).length > 0) {
2736
2752
  const encryptedEnv = {};
2737
2753
  for (const [key, value] of Object.entries(configCopy.env)) {
2738
- encryptedEnv[key] = (0, import_core3.encrypt)(value);
2754
+ encryptedEnv[key] = (0, import_core4.encrypt)(value);
2739
2755
  }
2740
2756
  configCopy.env = encryptedEnv;
2741
2757
  isEnvEncrypted = true;
@@ -2743,7 +2759,7 @@ function encryptEnvInConfig(config) {
2743
2759
  if (configCopy.headers && Object.keys(configCopy.headers).length > 0) {
2744
2760
  const encryptedHeaders = {};
2745
2761
  for (const [key, value] of Object.entries(configCopy.headers)) {
2746
- encryptedHeaders[key] = (0, import_core3.encrypt)(value);
2762
+ encryptedHeaders[key] = (0, import_core4.encrypt)(value);
2747
2763
  }
2748
2764
  configCopy.headers = encryptedHeaders;
2749
2765
  isEnvEncrypted = true;
@@ -2752,7 +2768,7 @@ function encryptEnvInConfig(config) {
2752
2768
  }
2753
2769
 
2754
2770
  // src/stores/LocalModelProviderStore.ts
2755
- var import_core4 = require("@axiom-lattice/core");
2771
+ var import_core5 = require("@axiom-lattice/core");
2756
2772
  var DDL13 = `
2757
2773
  CREATE TABLE IF NOT EXISTS lt_model_providers (
2758
2774
  id TEXT NOT NULL,
@@ -2868,7 +2884,7 @@ var LocalModelProviderStore = class {
2868
2884
  // Phase 1 pins the LLM provider (ADR-138 decision 7b)
2869
2885
  "openai",
2870
2886
  data.baseURL,
2871
- data.apiKey ? (0, import_core4.encrypt)(data.apiKey) : null,
2887
+ data.apiKey ? (0, import_core5.encrypt)(data.apiKey) : null,
2872
2888
  data.apiKey ? data.apiKey.slice(-4) : null,
2873
2889
  data.enabled === false ? 0 : 1,
2874
2890
  now,
@@ -2903,7 +2919,7 @@ var LocalModelProviderStore = class {
2903
2919
  set("api_key_enc", null);
2904
2920
  set("api_key_hint", null);
2905
2921
  } else if (updates.apiKey) {
2906
- set("api_key_enc", (0, import_core4.encrypt)(updates.apiKey));
2922
+ set("api_key_enc", (0, import_core5.encrypt)(updates.apiKey));
2907
2923
  set("api_key_hint", updates.apiKey.slice(-4));
2908
2924
  }
2909
2925
  if (fields.length === 0) {
@@ -3038,7 +3054,7 @@ var LocalModelProviderStore = class {
3038
3054
  function mapRowToEntry4(row) {
3039
3055
  let apiKey;
3040
3056
  if (row.api_key_enc) {
3041
- apiKey = (0, import_core4.safeDecrypt)(row.api_key_enc);
3057
+ apiKey = (0, import_core5.safeDecrypt)(row.api_key_enc);
3042
3058
  }
3043
3059
  return {
3044
3060
  id: row.id,
@@ -3077,6 +3093,7 @@ function mapRowToModel(row) {
3077
3093
  }
3078
3094
 
3079
3095
  // src/stores/LocalWorkflowTrackingStore.ts
3096
+ var import_node_crypto = require("crypto");
3080
3097
  var DDL14 = `
3081
3098
  CREATE TABLE IF NOT EXISTS lt_workflow_runs (
3082
3099
  id TEXT PRIMARY KEY,
@@ -3120,17 +3137,23 @@ CREATE TABLE IF NOT EXISTS lt_workflow_steps (
3120
3137
  PRIMARY KEY (run_id, id)
3121
3138
  );
3122
3139
  CREATE INDEX IF NOT EXISTS idx_lt_ws_type ON lt_workflow_steps(run_id, step_type);
3123
- -- Backfill for existing databases that don't have the column
3124
- ALTER TABLE lt_workflow_steps ADD COLUMN IF NOT EXISTS thread_id TEXT;
3125
3140
  `;
3126
3141
  var LocalWorkflowTrackingStore = class {
3127
3142
  constructor(db) {
3128
3143
  this.db = db;
3129
3144
  ensureTable(db, DDL14);
3145
+ this.ensureColumn("lt_workflow_steps", "thread_id", "thread_id TEXT");
3146
+ }
3147
+ /** Add a column if it does not exist (SQLite version compatible). */
3148
+ ensureColumn(table, column, ddl2) {
3149
+ const cols = this.db.prepare(`PRAGMA table_info(${table})`).all();
3150
+ if (!cols.some((c) => c.name === column)) {
3151
+ this.db.exec(`ALTER TABLE ${table} ADD COLUMN ${ddl2}`);
3152
+ }
3130
3153
  }
3131
3154
  async createWorkflowRun(request) {
3132
3155
  const now = nowISO();
3133
- const id = `${request.threadId}_${Date.now()}`;
3156
+ const id = `${request.threadId}_${Date.now()}_${(0, import_node_crypto.randomUUID)()}`;
3134
3157
  this.db.prepare(
3135
3158
  `INSERT INTO lt_workflow_runs (id, tenant_id, assistant_id, thread_id, status, topology_edges, total_edges, completed_edges, metadata, started_at, created_at, updated_at)
3136
3159
  VALUES (?, ?, ?, ?, 'running', ?, ?, 0, ?, ?, ?, ?)`
@@ -4509,7 +4532,7 @@ function mapRow7(row) {
4509
4532
  }
4510
4533
 
4511
4534
  // src/stores/LocalA2AApiKeyStore.ts
4512
- var import_core5 = require("@axiom-lattice/core");
4535
+ var import_core6 = require("@axiom-lattice/core");
4513
4536
  var import_crypto3 = require("crypto");
4514
4537
  var DDL18 = `
4515
4538
  CREATE TABLE IF NOT EXISTS lt_a2a_api_keys (
@@ -4580,7 +4603,7 @@ var LocalA2AApiKeyStore = class {
4580
4603
  ).all();
4581
4604
  for (const row of rows2) {
4582
4605
  try {
4583
- if ((0, import_core5.decrypt)(row.key_value) === key) return mapRowToRecord(row);
4606
+ if ((0, import_core6.decrypt)(row.key_value) === key) return mapRowToRecord(row);
4584
4607
  } catch {
4585
4608
  }
4586
4609
  }
@@ -4614,7 +4637,7 @@ var LocalA2AApiKeyStore = class {
4614
4637
  this.db.prepare(
4615
4638
  `INSERT INTO lt_a2a_api_keys (id, key_value, tenant_id, project_id, assistant_ids, grants, label, created_at, updated_at)
4616
4639
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`
4617
- ).run(id, (0, import_core5.encrypt)(key), input.tenantId, input.projectId, input.assistantIds ? JSON.stringify(input.assistantIds) : null, input.grants ? JSON.stringify(input.grants) : null, input.label || null, now, now);
4640
+ ).run(id, (0, import_core6.encrypt)(key), input.tenantId, input.projectId, input.assistantIds ? JSON.stringify(input.assistantIds) : null, input.grants ? JSON.stringify(input.grants) : null, input.label || null, now, now);
4618
4641
  const record2 = {
4619
4642
  id,
4620
4643
  key,
@@ -4683,7 +4706,7 @@ var LocalA2AApiKeyStore = class {
4683
4706
  const now = nowISO();
4684
4707
  this.db.prepare(
4685
4708
  `UPDATE lt_a2a_api_keys SET key_value = ?, updated_at = ? WHERE id = ?`
4686
- ).run((0, import_core5.encrypt)(key), now, id);
4709
+ ).run((0, import_core6.encrypt)(key), now, id);
4687
4710
  const row = this.db.prepare(`SELECT * FROM lt_a2a_api_keys WHERE id = ?`).get(id);
4688
4711
  if (!row) throw new Error(`A2A API key not found: ${id}`);
4689
4712
  const record2 = mapRowToRecord(row);
@@ -4700,7 +4723,7 @@ var LocalA2AApiKeyStore = class {
4700
4723
  const map2 = /* @__PURE__ */ new Map();
4701
4724
  for (const row of rows2) {
4702
4725
  try {
4703
- const key = (0, import_core5.decrypt)(row.key_value);
4726
+ const key = (0, import_core6.decrypt)(row.key_value);
4704
4727
  map2.set(key, {
4705
4728
  key,
4706
4729
  tenantId: row.tenant_id,
@@ -4716,7 +4739,7 @@ var LocalA2AApiKeyStore = class {
4716
4739
  function mapRowToRecord(row) {
4717
4740
  return {
4718
4741
  id: row.id,
4719
- key: (0, import_core5.safeDecrypt)(row.key_value),
4742
+ key: (0, import_core6.safeDecrypt)(row.key_value),
4720
4743
  tenantId: row.tenant_id,
4721
4744
  projectId: row.project_id,
4722
4745
  assistantIds: parseAssistantIds(row.assistant_ids),
@@ -5550,6 +5573,8 @@ var LocalScheduleStorage = class {
5550
5573
  if (filters?.limit !== void 0) {
5551
5574
  query += ` LIMIT ?`;
5552
5575
  values.push(filters.limit);
5576
+ } else if (filters?.offset !== void 0) {
5577
+ query += ` LIMIT -1`;
5553
5578
  }
5554
5579
  if (filters?.offset !== void 0) {
5555
5580
  query += ` OFFSET ?`;