@axiom-lattice/core 13.2.0 → 13.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +40 -12
- package/dist/index.d.ts +40 -12
- package/dist/index.js +119 -73
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +119 -73
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -948,6 +948,8 @@ interface DatabaseConfig {
|
|
|
948
948
|
password?: string;
|
|
949
949
|
connectionString?: string;
|
|
950
950
|
ssl?: boolean;
|
|
951
|
+
/** Verify the database server certificate when SSL is enabled (default: true). */
|
|
952
|
+
sslRejectUnauthorized?: boolean;
|
|
951
953
|
}
|
|
952
954
|
/**
|
|
953
955
|
* Table information
|
|
@@ -9834,7 +9836,7 @@ declare const getSandBoxManager: (key?: string) => SandboxManagerProtocol;
|
|
|
9834
9836
|
* Every consumer that reads or writes tenant-level sandbox data (skills,
|
|
9835
9837
|
* plugins, knowledge, SDK bundles, the plugin host) derives its path from
|
|
9836
9838
|
* these values instead of hardcoding `/root/.agents`. New deployments default
|
|
9837
|
-
* to the non-root runtime (`/home/appuser`, image `0.2.
|
|
9839
|
+
* to the non-root runtime (`/home/appuser`, image `0.2.2`). Old root deployments
|
|
9838
9840
|
* opt out with `SANDBOX_RUNTIME_PROFILE=legacy-root` (or a legacy
|
|
9839
9841
|
* `SANDBOX_HOME=/root` / `0.1.0` image for backward compatibility).
|
|
9840
9842
|
*
|
|
@@ -9845,7 +9847,7 @@ declare const getSandBoxManager: (key?: string) => SandboxManagerProtocol;
|
|
|
9845
9847
|
* process user's home, not the sandbox user's home.
|
|
9846
9848
|
*/
|
|
9847
9849
|
/** Non-root default sandbox image. */
|
|
9848
|
-
declare const NONROOT_SANDBOX_IMAGE = "kioko12520/sandbox:0.2.
|
|
9850
|
+
declare const NONROOT_SANDBOX_IMAGE = "kioko12520/sandbox:0.2.2";
|
|
9849
9851
|
/** Legacy root sandbox image. */
|
|
9850
9852
|
declare const LEGACY_ROOT_SANDBOX_IMAGE = "kioko12520/sandbox:0.1.0";
|
|
9851
9853
|
/** Supported sandbox runtime profiles. */
|
|
@@ -9864,7 +9866,7 @@ interface ResolvedSandboxRuntime {
|
|
|
9864
9866
|
*
|
|
9865
9867
|
* `SANDBOX_RUNTIME_PROFILE` is the single recommended switch:
|
|
9866
9868
|
*
|
|
9867
|
-
* - omitted or `nonroot`: `/home/appuser`, image `0.2.
|
|
9869
|
+
* - omitted or `nonroot`: `/home/appuser`, image `0.2.2`
|
|
9868
9870
|
* - `legacy-root`: `/root`, image `0.1.0`
|
|
9869
9871
|
*
|
|
9870
9872
|
* For backward compatibility, an explicit `SANDBOX_HOME=/root` or pinning the
|
|
@@ -12172,6 +12174,8 @@ declare class Agent {
|
|
|
12172
12174
|
private directInvokeAbort;
|
|
12173
12175
|
private abortPromise?;
|
|
12174
12176
|
private activeExecutionPromise?;
|
|
12177
|
+
/** Scope requested while a run is in flight; applied before the next run. */
|
|
12178
|
+
private pendingExecutionScope?;
|
|
12175
12179
|
/**
|
|
12176
12180
|
* Run signals stopped by the destructive {@link abort}.
|
|
12177
12181
|
*
|
|
@@ -12238,6 +12242,19 @@ declare class Agent {
|
|
|
12238
12242
|
workspace_id?: string | null;
|
|
12239
12243
|
project_id?: string | null;
|
|
12240
12244
|
}): void;
|
|
12245
|
+
/**
|
|
12246
|
+
* Re-pins scope for a dispatch without racing an in-flight run.
|
|
12247
|
+
*
|
|
12248
|
+
* Legacy entry points reuse one Agent per thread; when they carry a project
|
|
12249
|
+
* scope they must make it authoritative before the next sandbox is created.
|
|
12250
|
+
* If a run is already active, defer the update until it settles.
|
|
12251
|
+
*/
|
|
12252
|
+
applyExecutionScopeIfIdle(params: {
|
|
12253
|
+
workspace_id?: string | null;
|
|
12254
|
+
project_id?: string | null;
|
|
12255
|
+
}): void;
|
|
12256
|
+
/** Applies a scope requested during the previous active execution. */
|
|
12257
|
+
private applyPendingExecutionScope;
|
|
12241
12258
|
/**
|
|
12242
12259
|
* Accepts host-authenticated queue metadata through the package-private symbol capability.
|
|
12243
12260
|
*
|
|
@@ -13439,10 +13456,24 @@ declare class AgentInstanceManager {
|
|
|
13439
13456
|
*/
|
|
13440
13457
|
setRunLedger(ledger: IAgentRunLedger, idFactory?: () => string): void;
|
|
13441
13458
|
/**
|
|
13442
|
-
* Get or create Agent instance for a thread
|
|
13443
|
-
*
|
|
13459
|
+
* Get or create Agent instance for a thread.
|
|
13460
|
+
*
|
|
13461
|
+
* Ensures only one instance per thread exists. Read-only callers should use
|
|
13462
|
+
* {@link getAgentForRead}; dispatch callers use {@link getAgentForDispatch}
|
|
13463
|
+
* so the run's project scope is applied before a sandbox is created.
|
|
13444
13464
|
*/
|
|
13445
13465
|
getAgent(params: AgentThreadInterface): Agent;
|
|
13466
|
+
/**
|
|
13467
|
+
* Resolve the managed Agent for a dispatch and apply its explicit project.
|
|
13468
|
+
*
|
|
13469
|
+
* Legacy execution paths (channels, commands, cron, scheduler, Web App,
|
|
13470
|
+
* Open API, task comments, queue recovery) reuse the same per-thread Agent
|
|
13471
|
+
* instance. An explicit project must become authoritative before the next
|
|
13472
|
+
* sandbox is created; while a run is active it is deferred by
|
|
13473
|
+
* {@link Agent.applyExecutionScopeIfIdle}. Calls without a project do not
|
|
13474
|
+
* clear an already-established scope.
|
|
13475
|
+
*/
|
|
13476
|
+
getAgentForDispatch(params: AgentThreadInterface): Agent;
|
|
13446
13477
|
/**
|
|
13447
13478
|
* Get the managed Agent for an exclusive execution and re-pin its scope.
|
|
13448
13479
|
*
|
|
@@ -13458,14 +13489,11 @@ declare class AgentInstanceManager {
|
|
|
13458
13489
|
/**
|
|
13459
13490
|
* Get the managed Agent for a thread WITHOUT creating or registering one.
|
|
13460
13491
|
*
|
|
13461
|
-
* Read-only control-plane callers (state, memory, inbox) must not
|
|
13462
|
-
*
|
|
13463
|
-
* `(tenant_id, assistant_id, thread_id)`, whichever caller reaches
|
|
13464
|
-
* {@link getAgent} first fixes the instance's workspace/project for its whole
|
|
13465
|
-
* lifetime, and a later trusted dispatch on that thread would then fail
|
|
13466
|
-
* trusted-scope validation. This returns the existing managed instance when
|
|
13492
|
+
* Read-only control-plane callers (state, memory, inbox) must not mutate a
|
|
13493
|
+
* thread's execution scope. This returns the existing managed instance when
|
|
13467
13494
|
* present, otherwise a transient unregistered Agent that is sufficient for
|
|
13468
|
-
* state reads and disappears with the request.
|
|
13495
|
+
* state reads and disappears with the request. Dispatch callers use
|
|
13496
|
+
* {@link getAgentForDispatch}.
|
|
13469
13497
|
*
|
|
13470
13498
|
* @param params - Thread identity; scope is only used for the transient Agent.
|
|
13471
13499
|
* @returns The managed instance if any, else an unregistered read-only Agent.
|
package/dist/index.d.ts
CHANGED
|
@@ -948,6 +948,8 @@ interface DatabaseConfig {
|
|
|
948
948
|
password?: string;
|
|
949
949
|
connectionString?: string;
|
|
950
950
|
ssl?: boolean;
|
|
951
|
+
/** Verify the database server certificate when SSL is enabled (default: true). */
|
|
952
|
+
sslRejectUnauthorized?: boolean;
|
|
951
953
|
}
|
|
952
954
|
/**
|
|
953
955
|
* Table information
|
|
@@ -9834,7 +9836,7 @@ declare const getSandBoxManager: (key?: string) => SandboxManagerProtocol;
|
|
|
9834
9836
|
* Every consumer that reads or writes tenant-level sandbox data (skills,
|
|
9835
9837
|
* plugins, knowledge, SDK bundles, the plugin host) derives its path from
|
|
9836
9838
|
* these values instead of hardcoding `/root/.agents`. New deployments default
|
|
9837
|
-
* to the non-root runtime (`/home/appuser`, image `0.2.
|
|
9839
|
+
* to the non-root runtime (`/home/appuser`, image `0.2.2`). Old root deployments
|
|
9838
9840
|
* opt out with `SANDBOX_RUNTIME_PROFILE=legacy-root` (or a legacy
|
|
9839
9841
|
* `SANDBOX_HOME=/root` / `0.1.0` image for backward compatibility).
|
|
9840
9842
|
*
|
|
@@ -9845,7 +9847,7 @@ declare const getSandBoxManager: (key?: string) => SandboxManagerProtocol;
|
|
|
9845
9847
|
* process user's home, not the sandbox user's home.
|
|
9846
9848
|
*/
|
|
9847
9849
|
/** Non-root default sandbox image. */
|
|
9848
|
-
declare const NONROOT_SANDBOX_IMAGE = "kioko12520/sandbox:0.2.
|
|
9850
|
+
declare const NONROOT_SANDBOX_IMAGE = "kioko12520/sandbox:0.2.2";
|
|
9849
9851
|
/** Legacy root sandbox image. */
|
|
9850
9852
|
declare const LEGACY_ROOT_SANDBOX_IMAGE = "kioko12520/sandbox:0.1.0";
|
|
9851
9853
|
/** Supported sandbox runtime profiles. */
|
|
@@ -9864,7 +9866,7 @@ interface ResolvedSandboxRuntime {
|
|
|
9864
9866
|
*
|
|
9865
9867
|
* `SANDBOX_RUNTIME_PROFILE` is the single recommended switch:
|
|
9866
9868
|
*
|
|
9867
|
-
* - omitted or `nonroot`: `/home/appuser`, image `0.2.
|
|
9869
|
+
* - omitted or `nonroot`: `/home/appuser`, image `0.2.2`
|
|
9868
9870
|
* - `legacy-root`: `/root`, image `0.1.0`
|
|
9869
9871
|
*
|
|
9870
9872
|
* For backward compatibility, an explicit `SANDBOX_HOME=/root` or pinning the
|
|
@@ -12172,6 +12174,8 @@ declare class Agent {
|
|
|
12172
12174
|
private directInvokeAbort;
|
|
12173
12175
|
private abortPromise?;
|
|
12174
12176
|
private activeExecutionPromise?;
|
|
12177
|
+
/** Scope requested while a run is in flight; applied before the next run. */
|
|
12178
|
+
private pendingExecutionScope?;
|
|
12175
12179
|
/**
|
|
12176
12180
|
* Run signals stopped by the destructive {@link abort}.
|
|
12177
12181
|
*
|
|
@@ -12238,6 +12242,19 @@ declare class Agent {
|
|
|
12238
12242
|
workspace_id?: string | null;
|
|
12239
12243
|
project_id?: string | null;
|
|
12240
12244
|
}): void;
|
|
12245
|
+
/**
|
|
12246
|
+
* Re-pins scope for a dispatch without racing an in-flight run.
|
|
12247
|
+
*
|
|
12248
|
+
* Legacy entry points reuse one Agent per thread; when they carry a project
|
|
12249
|
+
* scope they must make it authoritative before the next sandbox is created.
|
|
12250
|
+
* If a run is already active, defer the update until it settles.
|
|
12251
|
+
*/
|
|
12252
|
+
applyExecutionScopeIfIdle(params: {
|
|
12253
|
+
workspace_id?: string | null;
|
|
12254
|
+
project_id?: string | null;
|
|
12255
|
+
}): void;
|
|
12256
|
+
/** Applies a scope requested during the previous active execution. */
|
|
12257
|
+
private applyPendingExecutionScope;
|
|
12241
12258
|
/**
|
|
12242
12259
|
* Accepts host-authenticated queue metadata through the package-private symbol capability.
|
|
12243
12260
|
*
|
|
@@ -13439,10 +13456,24 @@ declare class AgentInstanceManager {
|
|
|
13439
13456
|
*/
|
|
13440
13457
|
setRunLedger(ledger: IAgentRunLedger, idFactory?: () => string): void;
|
|
13441
13458
|
/**
|
|
13442
|
-
* Get or create Agent instance for a thread
|
|
13443
|
-
*
|
|
13459
|
+
* Get or create Agent instance for a thread.
|
|
13460
|
+
*
|
|
13461
|
+
* Ensures only one instance per thread exists. Read-only callers should use
|
|
13462
|
+
* {@link getAgentForRead}; dispatch callers use {@link getAgentForDispatch}
|
|
13463
|
+
* so the run's project scope is applied before a sandbox is created.
|
|
13444
13464
|
*/
|
|
13445
13465
|
getAgent(params: AgentThreadInterface): Agent;
|
|
13466
|
+
/**
|
|
13467
|
+
* Resolve the managed Agent for a dispatch and apply its explicit project.
|
|
13468
|
+
*
|
|
13469
|
+
* Legacy execution paths (channels, commands, cron, scheduler, Web App,
|
|
13470
|
+
* Open API, task comments, queue recovery) reuse the same per-thread Agent
|
|
13471
|
+
* instance. An explicit project must become authoritative before the next
|
|
13472
|
+
* sandbox is created; while a run is active it is deferred by
|
|
13473
|
+
* {@link Agent.applyExecutionScopeIfIdle}. Calls without a project do not
|
|
13474
|
+
* clear an already-established scope.
|
|
13475
|
+
*/
|
|
13476
|
+
getAgentForDispatch(params: AgentThreadInterface): Agent;
|
|
13446
13477
|
/**
|
|
13447
13478
|
* Get the managed Agent for an exclusive execution and re-pin its scope.
|
|
13448
13479
|
*
|
|
@@ -13458,14 +13489,11 @@ declare class AgentInstanceManager {
|
|
|
13458
13489
|
/**
|
|
13459
13490
|
* Get the managed Agent for a thread WITHOUT creating or registering one.
|
|
13460
13491
|
*
|
|
13461
|
-
* Read-only control-plane callers (state, memory, inbox) must not
|
|
13462
|
-
*
|
|
13463
|
-
* `(tenant_id, assistant_id, thread_id)`, whichever caller reaches
|
|
13464
|
-
* {@link getAgent} first fixes the instance's workspace/project for its whole
|
|
13465
|
-
* lifetime, and a later trusted dispatch on that thread would then fail
|
|
13466
|
-
* trusted-scope validation. This returns the existing managed instance when
|
|
13492
|
+
* Read-only control-plane callers (state, memory, inbox) must not mutate a
|
|
13493
|
+
* thread's execution scope. This returns the existing managed instance when
|
|
13467
13494
|
* present, otherwise a transient unregistered Agent that is sufficient for
|
|
13468
|
-
* state reads and disappears with the request.
|
|
13495
|
+
* state reads and disappears with the request. Dispatch callers use
|
|
13496
|
+
* {@link getAgentForDispatch}.
|
|
13469
13497
|
*
|
|
13470
13498
|
* @param params - Thread identity; scope is only used for the transient Agent.
|
|
13471
13499
|
* @returns The managed instance if any, else an unregistered read-only Agent.
|
package/dist/index.js
CHANGED
|
@@ -5686,6 +5686,7 @@ var import_crypto4 = require("crypto");
|
|
|
5686
5686
|
var ALGORITHM = "aes-256-gcm";
|
|
5687
5687
|
var IV_LENGTH = 16;
|
|
5688
5688
|
var SALT_LENGTH = 32;
|
|
5689
|
+
var AUTH_TAG_LENGTH = 16;
|
|
5689
5690
|
var ITERATIONS = 1e5;
|
|
5690
5691
|
var DEFAULT_ENCRYPTION_KEY = "lattice-default-encryption-key-dev-only-32b!";
|
|
5691
5692
|
var cachedKey = null;
|
|
@@ -5707,7 +5708,7 @@ function encrypt(plaintext, key6) {
|
|
|
5707
5708
|
const salt = (0, import_crypto4.randomBytes)(SALT_LENGTH);
|
|
5708
5709
|
const iv = (0, import_crypto4.randomBytes)(IV_LENGTH);
|
|
5709
5710
|
const derivedKey = (0, import_crypto4.pbkdf2Sync)(actualKey, salt, ITERATIONS, 32, "sha256");
|
|
5710
|
-
const cipher = (0, import_crypto4.createCipheriv)(ALGORITHM, derivedKey, iv);
|
|
5711
|
+
const cipher = (0, import_crypto4.createCipheriv)(ALGORITHM, derivedKey, iv, { authTagLength: AUTH_TAG_LENGTH });
|
|
5711
5712
|
const encrypted = Buffer.concat([cipher.update(plaintext, "utf8"), cipher.final()]);
|
|
5712
5713
|
const authTag = cipher.getAuthTag();
|
|
5713
5714
|
return Buffer.concat([salt, iv, encrypted, authTag]).toString("base64");
|
|
@@ -5717,10 +5718,10 @@ function decrypt(encrypted, key6) {
|
|
|
5717
5718
|
const data = Buffer.from(encrypted, "base64");
|
|
5718
5719
|
const salt = data.subarray(0, SALT_LENGTH);
|
|
5719
5720
|
const iv = data.subarray(SALT_LENGTH, SALT_LENGTH + IV_LENGTH);
|
|
5720
|
-
const authTag = data.subarray(-
|
|
5721
|
-
const ciphertext = data.subarray(SALT_LENGTH + IV_LENGTH, -
|
|
5721
|
+
const authTag = data.subarray(-AUTH_TAG_LENGTH);
|
|
5722
|
+
const ciphertext = data.subarray(SALT_LENGTH + IV_LENGTH, -AUTH_TAG_LENGTH);
|
|
5722
5723
|
const derivedKey = (0, import_crypto4.pbkdf2Sync)(actualKey, salt, ITERATIONS, 32, "sha256");
|
|
5723
|
-
const decipher = (0, import_crypto4.createDecipheriv)(ALGORITHM, derivedKey, iv);
|
|
5724
|
+
const decipher = (0, import_crypto4.createDecipheriv)(ALGORITHM, derivedKey, iv, { authTagLength: AUTH_TAG_LENGTH });
|
|
5724
5725
|
decipher.setAuthTag(authTag);
|
|
5725
5726
|
return Buffer.concat([decipher.update(ciphertext), decipher.final()]).toString("utf8");
|
|
5726
5727
|
}
|
|
@@ -9821,7 +9822,7 @@ function serializePluginMeta(plugin) {
|
|
|
9821
9822
|
}
|
|
9822
9823
|
|
|
9823
9824
|
// src/sandbox_lattice/sandboxPaths.ts
|
|
9824
|
-
var NONROOT_SANDBOX_IMAGE = "kioko12520/sandbox:0.2.
|
|
9825
|
+
var NONROOT_SANDBOX_IMAGE = "kioko12520/sandbox:0.2.2";
|
|
9825
9826
|
var LEGACY_ROOT_SANDBOX_IMAGE = "kioko12520/sandbox:0.1.0";
|
|
9826
9827
|
function normalizeSandboxHome(value) {
|
|
9827
9828
|
const trimmed = value.trim();
|
|
@@ -17126,6 +17127,60 @@ function failure(error) {
|
|
|
17126
17127
|
return JSON.stringify({ success: false, error });
|
|
17127
17128
|
}
|
|
17128
17129
|
|
|
17130
|
+
// src/capability/CapabilityRuntimeAccessor.ts
|
|
17131
|
+
function getRuntimeCapabilityConfig(executionConfig, capabilityType) {
|
|
17132
|
+
return readRecordProperty(getRuntimeCapabilityPolicy(executionConfig, capabilityType), "config");
|
|
17133
|
+
}
|
|
17134
|
+
function hasRuntimeCapabilityPolicy(executionConfig, capabilityType) {
|
|
17135
|
+
return getRuntimeCapabilityPolicy(executionConfig, capabilityType) !== void 0;
|
|
17136
|
+
}
|
|
17137
|
+
function getRuntimeCapabilityPolicy(executionConfig, capabilityType) {
|
|
17138
|
+
const configurable = readRecordProperty(executionConfig, "configurable");
|
|
17139
|
+
const context = readRecordProperty(executionConfig, "context");
|
|
17140
|
+
const runConfig = readRecordProperty(configurable, "runConfig") ?? readRecordProperty(context, "runConfig");
|
|
17141
|
+
const runtime = readRecordProperty(runConfig, "capabilityRuntime");
|
|
17142
|
+
const middleware = readRecordProperty(runtime, "middleware");
|
|
17143
|
+
return readRecordProperty(middleware, capabilityType);
|
|
17144
|
+
}
|
|
17145
|
+
function getRuntimeSkillSelection(executionConfig) {
|
|
17146
|
+
const policy = getRuntimeCapabilityPolicy(executionConfig, "skill");
|
|
17147
|
+
if (!policy) return { hasPolicy: false, enabled: true, readAll: false };
|
|
17148
|
+
const config = readRecordProperty(policy, "config") ?? {};
|
|
17149
|
+
const skills = config.skills;
|
|
17150
|
+
return {
|
|
17151
|
+
hasPolicy: true,
|
|
17152
|
+
enabled: policy.enabled !== false,
|
|
17153
|
+
...Array.isArray(skills) && skills.every((skill) => typeof skill === "string") ? { skills: [...skills] } : {},
|
|
17154
|
+
readAll: config.readAll === true
|
|
17155
|
+
};
|
|
17156
|
+
}
|
|
17157
|
+
function readRecordProperty(value, property) {
|
|
17158
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
|
|
17159
|
+
const propertyValue = value[property];
|
|
17160
|
+
return typeof propertyValue === "object" && propertyValue !== null && !Array.isArray(propertyValue) ? propertyValue : void 0;
|
|
17161
|
+
}
|
|
17162
|
+
|
|
17163
|
+
// src/tool_lattice/sql/utils.ts
|
|
17164
|
+
function getEffectiveDatabaseKeys(exeConfig, staticDatabaseKeys) {
|
|
17165
|
+
const runtimeConfig = getRuntimeCapabilityConfig(exeConfig, "sql");
|
|
17166
|
+
if (runtimeConfig && Object.prototype.hasOwnProperty.call(runtimeConfig, "databaseKeys")) {
|
|
17167
|
+
const databaseKeys = runtimeConfig.databaseKeys;
|
|
17168
|
+
if (Array.isArray(databaseKeys) && databaseKeys.every((key6) => typeof key6 === "string")) {
|
|
17169
|
+
return databaseKeys;
|
|
17170
|
+
}
|
|
17171
|
+
return [];
|
|
17172
|
+
}
|
|
17173
|
+
return staticDatabaseKeys;
|
|
17174
|
+
}
|
|
17175
|
+
function getTenantIdFromConfig(exeConfig, getTenantId3) {
|
|
17176
|
+
const runConfig = exeConfig?.configurable?.runConfig || {};
|
|
17177
|
+
return runConfig.tenantId || (getTenantId3 ? getTenantId3() : "default");
|
|
17178
|
+
}
|
|
17179
|
+
function buildSslConfig(ssl, rejectUnauthorized) {
|
|
17180
|
+
if (!ssl) return void 0;
|
|
17181
|
+
return { rejectUnauthorized: rejectUnauthorized !== false };
|
|
17182
|
+
}
|
|
17183
|
+
|
|
17129
17184
|
// src/tool_lattice/sql/SqlDatabaseManager.ts
|
|
17130
17185
|
function splitQualifiedTableName(qualifiedName) {
|
|
17131
17186
|
const parts = [];
|
|
@@ -17179,7 +17234,7 @@ var PostgresDatabase = class {
|
|
|
17179
17234
|
database: this.config.database,
|
|
17180
17235
|
user: this.config.user,
|
|
17181
17236
|
password: this.config.password,
|
|
17182
|
-
ssl: this.config.ssl
|
|
17237
|
+
ssl: buildSslConfig(this.config.ssl, this.config.sslRejectUnauthorized)
|
|
17183
17238
|
};
|
|
17184
17239
|
this.pool = new Pool(poolConfig);
|
|
17185
17240
|
const client = await this.pool.connect();
|
|
@@ -17339,7 +17394,7 @@ var MysqlDatabase = class {
|
|
|
17339
17394
|
database: this.config.database,
|
|
17340
17395
|
user: this.config.user,
|
|
17341
17396
|
password: this.config.password,
|
|
17342
|
-
ssl: this.config.ssl
|
|
17397
|
+
ssl: buildSslConfig(this.config.ssl, this.config.sslRejectUnauthorized)
|
|
17343
17398
|
};
|
|
17344
17399
|
this.pool = mysql.createPool({
|
|
17345
17400
|
...poolConfig,
|
|
@@ -17703,58 +17758,6 @@ var sqlDatabaseManager = SqlDatabaseManager.getInstance();
|
|
|
17703
17758
|
// src/tool_lattice/sql/list_tables_sql.ts
|
|
17704
17759
|
var import_zod4 = __toESM(require("zod"));
|
|
17705
17760
|
var import_langchain = require("langchain");
|
|
17706
|
-
|
|
17707
|
-
// src/capability/CapabilityRuntimeAccessor.ts
|
|
17708
|
-
function getRuntimeCapabilityConfig(executionConfig, capabilityType) {
|
|
17709
|
-
return readRecordProperty(getRuntimeCapabilityPolicy(executionConfig, capabilityType), "config");
|
|
17710
|
-
}
|
|
17711
|
-
function hasRuntimeCapabilityPolicy(executionConfig, capabilityType) {
|
|
17712
|
-
return getRuntimeCapabilityPolicy(executionConfig, capabilityType) !== void 0;
|
|
17713
|
-
}
|
|
17714
|
-
function getRuntimeCapabilityPolicy(executionConfig, capabilityType) {
|
|
17715
|
-
const configurable = readRecordProperty(executionConfig, "configurable");
|
|
17716
|
-
const context = readRecordProperty(executionConfig, "context");
|
|
17717
|
-
const runConfig = readRecordProperty(configurable, "runConfig") ?? readRecordProperty(context, "runConfig");
|
|
17718
|
-
const runtime = readRecordProperty(runConfig, "capabilityRuntime");
|
|
17719
|
-
const middleware = readRecordProperty(runtime, "middleware");
|
|
17720
|
-
return readRecordProperty(middleware, capabilityType);
|
|
17721
|
-
}
|
|
17722
|
-
function getRuntimeSkillSelection(executionConfig) {
|
|
17723
|
-
const policy = getRuntimeCapabilityPolicy(executionConfig, "skill");
|
|
17724
|
-
if (!policy) return { hasPolicy: false, enabled: true, readAll: false };
|
|
17725
|
-
const config = readRecordProperty(policy, "config") ?? {};
|
|
17726
|
-
const skills = config.skills;
|
|
17727
|
-
return {
|
|
17728
|
-
hasPolicy: true,
|
|
17729
|
-
enabled: policy.enabled !== false,
|
|
17730
|
-
...Array.isArray(skills) && skills.every((skill) => typeof skill === "string") ? { skills: [...skills] } : {},
|
|
17731
|
-
readAll: config.readAll === true
|
|
17732
|
-
};
|
|
17733
|
-
}
|
|
17734
|
-
function readRecordProperty(value, property) {
|
|
17735
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
|
|
17736
|
-
const propertyValue = value[property];
|
|
17737
|
-
return typeof propertyValue === "object" && propertyValue !== null && !Array.isArray(propertyValue) ? propertyValue : void 0;
|
|
17738
|
-
}
|
|
17739
|
-
|
|
17740
|
-
// src/tool_lattice/sql/utils.ts
|
|
17741
|
-
function getEffectiveDatabaseKeys(exeConfig, staticDatabaseKeys) {
|
|
17742
|
-
const runtimeConfig = getRuntimeCapabilityConfig(exeConfig, "sql");
|
|
17743
|
-
if (runtimeConfig && Object.prototype.hasOwnProperty.call(runtimeConfig, "databaseKeys")) {
|
|
17744
|
-
const databaseKeys = runtimeConfig.databaseKeys;
|
|
17745
|
-
if (Array.isArray(databaseKeys) && databaseKeys.every((key6) => typeof key6 === "string")) {
|
|
17746
|
-
return databaseKeys;
|
|
17747
|
-
}
|
|
17748
|
-
return [];
|
|
17749
|
-
}
|
|
17750
|
-
return staticDatabaseKeys;
|
|
17751
|
-
}
|
|
17752
|
-
function getTenantIdFromConfig(exeConfig, getTenantId3) {
|
|
17753
|
-
const runConfig = exeConfig?.configurable?.runConfig || {};
|
|
17754
|
-
return runConfig.tenantId || (getTenantId3 ? getTenantId3() : "default");
|
|
17755
|
-
}
|
|
17756
|
-
|
|
17757
|
-
// src/tool_lattice/sql/list_tables_sql.ts
|
|
17758
17761
|
var LIST_TABLES_SQL_DESCRIPTION = `List all tables in the connected SQL database. Returns a comma-separated list of table names. Use this tool first to understand what tables are available before querying the database.`;
|
|
17759
17762
|
var SIMPLE_IDENTIFIER = /^[a-z_][a-z0-9_]*$/;
|
|
17760
17763
|
function formatIdentifier(identifier) {
|
|
@@ -31972,6 +31975,27 @@ var Agent = class {
|
|
|
31972
31975
|
this.queue_workspace_id = params.workspace_id === null ? null : this.workspace_id;
|
|
31973
31976
|
this.queue_project_id = params.project_id == null || params.project_id === "" ? null : this.project_id;
|
|
31974
31977
|
}
|
|
31978
|
+
/**
|
|
31979
|
+
* Re-pins scope for a dispatch without racing an in-flight run.
|
|
31980
|
+
*
|
|
31981
|
+
* Legacy entry points reuse one Agent per thread; when they carry a project
|
|
31982
|
+
* scope they must make it authoritative before the next sandbox is created.
|
|
31983
|
+
* If a run is already active, defer the update until it settles.
|
|
31984
|
+
*/
|
|
31985
|
+
applyExecutionScopeIfIdle(params) {
|
|
31986
|
+
if (this.activeExecutionPromise !== void 0) {
|
|
31987
|
+
this.pendingExecutionScope = params;
|
|
31988
|
+
return;
|
|
31989
|
+
}
|
|
31990
|
+
this.applyExecutionScope(params);
|
|
31991
|
+
}
|
|
31992
|
+
/** Applies a scope requested during the previous active execution. */
|
|
31993
|
+
applyPendingExecutionScope() {
|
|
31994
|
+
const pending = this.pendingExecutionScope;
|
|
31995
|
+
if (pending === void 0) return;
|
|
31996
|
+
this.pendingExecutionScope = void 0;
|
|
31997
|
+
this.applyExecutionScope(pending);
|
|
31998
|
+
}
|
|
31975
31999
|
/**
|
|
31976
32000
|
* Accepts host-authenticated queue metadata through the package-private symbol capability.
|
|
31977
32001
|
*
|
|
@@ -33959,7 +33983,9 @@ var Agent = class {
|
|
|
33959
33983
|
trackActiveExecution(execution) {
|
|
33960
33984
|
this.activeExecutionPromise = execution;
|
|
33961
33985
|
const clear = () => {
|
|
33962
|
-
if (this.activeExecutionPromise
|
|
33986
|
+
if (this.activeExecutionPromise !== execution) return;
|
|
33987
|
+
this.activeExecutionPromise = void 0;
|
|
33988
|
+
this.applyPendingExecutionScope();
|
|
33963
33989
|
};
|
|
33964
33990
|
void execution.then(clear, clear);
|
|
33965
33991
|
return execution;
|
|
@@ -34171,8 +34197,11 @@ var AgentInstanceManager = class _AgentInstanceManager {
|
|
|
34171
34197
|
});
|
|
34172
34198
|
}
|
|
34173
34199
|
/**
|
|
34174
|
-
* Get or create Agent instance for a thread
|
|
34175
|
-
*
|
|
34200
|
+
* Get or create Agent instance for a thread.
|
|
34201
|
+
*
|
|
34202
|
+
* Ensures only one instance per thread exists. Read-only callers should use
|
|
34203
|
+
* {@link getAgentForRead}; dispatch callers use {@link getAgentForDispatch}
|
|
34204
|
+
* so the run's project scope is applied before a sandbox is created.
|
|
34176
34205
|
*/
|
|
34177
34206
|
getAgent(params) {
|
|
34178
34207
|
const key6 = this.getKey(params);
|
|
@@ -34183,6 +34212,26 @@ var AgentInstanceManager = class _AgentInstanceManager {
|
|
|
34183
34212
|
}
|
|
34184
34213
|
return this.agents.get(key6);
|
|
34185
34214
|
}
|
|
34215
|
+
/**
|
|
34216
|
+
* Resolve the managed Agent for a dispatch and apply its explicit project.
|
|
34217
|
+
*
|
|
34218
|
+
* Legacy execution paths (channels, commands, cron, scheduler, Web App,
|
|
34219
|
+
* Open API, task comments, queue recovery) reuse the same per-thread Agent
|
|
34220
|
+
* instance. An explicit project must become authoritative before the next
|
|
34221
|
+
* sandbox is created; while a run is active it is deferred by
|
|
34222
|
+
* {@link Agent.applyExecutionScopeIfIdle}. Calls without a project do not
|
|
34223
|
+
* clear an already-established scope.
|
|
34224
|
+
*/
|
|
34225
|
+
getAgentForDispatch(params) {
|
|
34226
|
+
const agent = this.getAgent(params);
|
|
34227
|
+
if (typeof params.project_id === "string" && params.project_id.length > 0) {
|
|
34228
|
+
agent.applyExecutionScopeIfIdle({
|
|
34229
|
+
workspace_id: params.workspace_id,
|
|
34230
|
+
project_id: params.project_id
|
|
34231
|
+
});
|
|
34232
|
+
}
|
|
34233
|
+
return agent;
|
|
34234
|
+
}
|
|
34186
34235
|
/**
|
|
34187
34236
|
* Get the managed Agent for an exclusive execution and re-pin its scope.
|
|
34188
34237
|
*
|
|
@@ -34205,14 +34254,11 @@ var AgentInstanceManager = class _AgentInstanceManager {
|
|
|
34205
34254
|
/**
|
|
34206
34255
|
* Get the managed Agent for a thread WITHOUT creating or registering one.
|
|
34207
34256
|
*
|
|
34208
|
-
* Read-only control-plane callers (state, memory, inbox) must not
|
|
34209
|
-
*
|
|
34210
|
-
* `(tenant_id, assistant_id, thread_id)`, whichever caller reaches
|
|
34211
|
-
* {@link getAgent} first fixes the instance's workspace/project for its whole
|
|
34212
|
-
* lifetime, and a later trusted dispatch on that thread would then fail
|
|
34213
|
-
* trusted-scope validation. This returns the existing managed instance when
|
|
34257
|
+
* Read-only control-plane callers (state, memory, inbox) must not mutate a
|
|
34258
|
+
* thread's execution scope. This returns the existing managed instance when
|
|
34214
34259
|
* present, otherwise a transient unregistered Agent that is sufficient for
|
|
34215
|
-
* state reads and disappears with the request.
|
|
34260
|
+
* state reads and disappears with the request. Dispatch callers use
|
|
34261
|
+
* {@link getAgentForDispatch}.
|
|
34216
34262
|
*
|
|
34217
34263
|
* @param params - Thread identity; scope is only used for the transient Agent.
|
|
34218
34264
|
* @returns The managed instance if any, else an unregistered read-only Agent.
|
|
@@ -34325,7 +34371,7 @@ var DelegationService = class {
|
|
|
34325
34371
|
throw new DelegatedThreadBusyError(request.thread_id);
|
|
34326
34372
|
}
|
|
34327
34373
|
try {
|
|
34328
|
-
const agent = agentInstanceManager.
|
|
34374
|
+
const agent = agentInstanceManager.getAgentForDispatch({
|
|
34329
34375
|
assistant_id: request.assistant_id,
|
|
34330
34376
|
thread_id: request.thread_id,
|
|
34331
34377
|
tenant_id: request.tenantId,
|
|
@@ -35170,7 +35216,7 @@ function registerAgentAddMessageHandler() {
|
|
|
35170
35216
|
workspace_id: runConfigFromMetadata?.workspaceId ?? "",
|
|
35171
35217
|
project_id: runConfigFromMetadata?.projectId ?? ""
|
|
35172
35218
|
}));
|
|
35173
|
-
const agent = agentInstanceManager.
|
|
35219
|
+
const agent = agentInstanceManager.getAgentForDispatch({
|
|
35174
35220
|
tenant_id: taskInfo.tenantId,
|
|
35175
35221
|
assistant_id: taskInfo.assistantId ?? "",
|
|
35176
35222
|
thread_id: taskInfo.threadId ?? "",
|
|
@@ -44800,7 +44846,7 @@ var _LatticeEval = class _LatticeEval {
|
|
|
44800
44846
|
workspace_id: this.config.workspace_id || "default",
|
|
44801
44847
|
project_id: this.config.project_id || "default"
|
|
44802
44848
|
};
|
|
44803
|
-
const agent = agentInstanceManager.
|
|
44849
|
+
const agent = agentInstanceManager.getAgentForDispatch(agentParams);
|
|
44804
44850
|
try {
|
|
44805
44851
|
const stepInput = {
|
|
44806
44852
|
message: step.override_message || inputMessage,
|
|
@@ -46787,7 +46833,7 @@ var ThreadExecutionSupervisor = class {
|
|
|
46787
46833
|
this.probeCooldownMs = positiveOr(options.probeCooldownMs, this.cooldownMs);
|
|
46788
46834
|
this.reapEveryNTicks = positiveIntegerOr(options.reapEveryNTicks, 10);
|
|
46789
46835
|
this.maxInFlightAgeMs = positiveOr(options.maxInFlightAgeMs, 30 * 60 * 1e3);
|
|
46790
|
-
this.getAgent = options.getAgent ?? ((params) => agentInstanceManager.
|
|
46836
|
+
this.getAgent = options.getAgent ?? ((params) => agentInstanceManager.getAgentForDispatch(params));
|
|
46791
46837
|
this.probeThreadRunOwner = options.probeThreadRunOwner ?? probeThreadRunOwner;
|
|
46792
46838
|
this.log = options.log;
|
|
46793
46839
|
}
|