@elevasis/sdk 1.35.0 → 1.35.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/cli.cjs +23 -13
- package/dist/index.d.ts +80 -150
- package/dist/test-utils/index.d.ts +81 -151
- package/dist/test-utils/index.js +74 -16
- package/dist/types/worker/index.d.ts +1 -1
- package/dist/types/worker/platform.d.ts +1 -0
- package/dist/worker/index.js +74 -16
- package/package.json +2 -2
- package/reference/rules/ui.md +8 -5
- package/reference/sdk/cli-management.mdx +2 -0
package/dist/cli.cjs
CHANGED
|
@@ -24975,6 +24975,8 @@ function ora(options) {
|
|
|
24975
24975
|
var import_path2 = require("path");
|
|
24976
24976
|
var import_promises = require("fs/promises");
|
|
24977
24977
|
var import_fs2 = require("fs");
|
|
24978
|
+
var import_crypto = require("crypto");
|
|
24979
|
+
var import_url = require("url");
|
|
24978
24980
|
init_source();
|
|
24979
24981
|
|
|
24980
24982
|
// ../../node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/external.js
|
|
@@ -45805,7 +45807,7 @@ function wrapAction(commandName, fn) {
|
|
|
45805
45807
|
// package.json
|
|
45806
45808
|
var package_default = {
|
|
45807
45809
|
name: "@elevasis/sdk",
|
|
45808
|
-
version: "1.35.
|
|
45810
|
+
version: "1.35.1",
|
|
45809
45811
|
description: "SDK for building Elevasis organization resources",
|
|
45810
45812
|
type: "module",
|
|
45811
45813
|
bin: {
|
|
@@ -45883,8 +45885,8 @@ var package_default = {
|
|
|
45883
45885
|
var SDK_VERSION = package_default.version;
|
|
45884
45886
|
|
|
45885
45887
|
// src/cli/commands/deploy.ts
|
|
45886
|
-
function getEsbuild() {
|
|
45887
|
-
const consumerRequire = (0, import_module.createRequire)(
|
|
45888
|
+
function getEsbuild(packageRoot = getPackageRoot()) {
|
|
45889
|
+
const consumerRequire = (0, import_module.createRequire)((0, import_path2.resolve)(packageRoot, "package.json"));
|
|
45888
45890
|
return consumerRequire("esbuild");
|
|
45889
45891
|
}
|
|
45890
45892
|
function resolveBareSpecifier(specifier, importer) {
|
|
@@ -45951,10 +45953,11 @@ function createBundleWorkspaceTsPlugin() {
|
|
|
45951
45953
|
}
|
|
45952
45954
|
};
|
|
45953
45955
|
}
|
|
45954
|
-
async function loadTsModule(filePath) {
|
|
45955
|
-
const
|
|
45956
|
-
const
|
|
45957
|
-
const
|
|
45956
|
+
async function loadTsModule(filePath, options = {}) {
|
|
45957
|
+
const packageRoot = options.packageRoot ?? getPackageRoot();
|
|
45958
|
+
const esbuild = getEsbuild(packageRoot);
|
|
45959
|
+
const absPath = (0, import_path2.isAbsolute)(filePath) ? filePath : (0, import_path2.resolve)(packageRoot, filePath);
|
|
45960
|
+
const tmpOut = (0, import_path2.resolve)(packageRoot, `.elevasis-tmp-${process.pid}-${Date.now()}-${(0, import_crypto.randomUUID)()}.mjs`);
|
|
45958
45961
|
try {
|
|
45959
45962
|
await esbuild.build({
|
|
45960
45963
|
entryPoints: [absPath],
|
|
@@ -45967,8 +45970,7 @@ async function loadTsModule(filePath) {
|
|
|
45967
45970
|
plugins: [createBundleWorkspaceTsPlugin()],
|
|
45968
45971
|
logLevel: "silent"
|
|
45969
45972
|
});
|
|
45970
|
-
|
|
45971
|
-
return await import(fileUrl);
|
|
45973
|
+
return await import((0, import_url.pathToFileURL)(tmpOut).href);
|
|
45972
45974
|
} finally {
|
|
45973
45975
|
try {
|
|
45974
45976
|
const { unlinkSync: unlinkSync3 } = await import("fs");
|
|
@@ -49813,13 +49815,13 @@ init_config();
|
|
|
49813
49815
|
var import_path3 = require("path");
|
|
49814
49816
|
var import_fs3 = require("fs");
|
|
49815
49817
|
var ORG_MODEL_REL_PATH = "core/config/organization-model.ts";
|
|
49816
|
-
async function loadOrgModel(projectRoot) {
|
|
49818
|
+
async function loadOrgModel(projectRoot, options = {}) {
|
|
49817
49819
|
const orgModelPath = (0, import_path3.resolve)(projectRoot, ORG_MODEL_REL_PATH);
|
|
49818
49820
|
if (!(0, import_fs3.existsSync)(orgModelPath)) {
|
|
49819
49821
|
return DEFAULT_ORGANIZATION_MODEL;
|
|
49820
49822
|
}
|
|
49821
49823
|
try {
|
|
49822
|
-
const mod = await loadTsModule(orgModelPath);
|
|
49824
|
+
const mod = await loadTsModule(orgModelPath, { packageRoot: options.packageRoot });
|
|
49823
49825
|
const model = mod["organizationModel"] ?? mod["canonicalOrganizationModel"] ?? mod["default"];
|
|
49824
49826
|
if (model && typeof model === "object" && "systems" in model) {
|
|
49825
49827
|
return model;
|
|
@@ -52315,14 +52317,22 @@ var JsonFileArgError = class extends Error {
|
|
|
52315
52317
|
this.name = "JsonFileArgError";
|
|
52316
52318
|
}
|
|
52317
52319
|
};
|
|
52320
|
+
function isWindowsAbsolutePath(path3) {
|
|
52321
|
+
return /^[A-Za-z]:[\\/]/.test(path3) || /^[/\\]{2}[^/\\]+[/\\][^/\\]+/.test(path3);
|
|
52322
|
+
}
|
|
52323
|
+
function resolveCliPath(base, path3) {
|
|
52324
|
+
if (isWindowsAbsolutePath(path3)) return import_node_path16.win32.normalize(path3);
|
|
52325
|
+
if ((0, import_node_path16.isAbsolute)(path3)) return path3;
|
|
52326
|
+
if (isWindowsAbsolutePath(base)) return import_node_path16.win32.resolve(base, path3);
|
|
52327
|
+
return (0, import_node_path16.resolve)(base, path3);
|
|
52328
|
+
}
|
|
52318
52329
|
function resolveJsonFilePath(path3, options) {
|
|
52319
52330
|
if (path3.trim() === "") {
|
|
52320
52331
|
throw new JsonFileArgError("@json: requires a file path", "EMPTY_JSON_FILE_REF");
|
|
52321
52332
|
}
|
|
52322
|
-
if ((0, import_node_path16.isAbsolute)(path3)) return path3;
|
|
52323
52333
|
const cwd = options.cwd ?? process.cwd();
|
|
52324
52334
|
const projectRoot = (options.findProjectRoot ?? tryFindProjectRoot)(cwd);
|
|
52325
|
-
return (
|
|
52335
|
+
return resolveCliPath(projectRoot ?? cwd, path3);
|
|
52326
52336
|
}
|
|
52327
52337
|
function readJsonFileReference(ref, options) {
|
|
52328
52338
|
const relativeOrAbsolutePath = ref.slice(JSON_FILE_PREFIX.length);
|
package/dist/index.d.ts
CHANGED
|
@@ -1428,9 +1428,6 @@ type Json = string | number | boolean | null | {
|
|
|
1428
1428
|
[key: string]: Json | undefined;
|
|
1429
1429
|
} | Json[];
|
|
1430
1430
|
type Database = {
|
|
1431
|
-
__InternalSupabase: {
|
|
1432
|
-
PostgrestVersion: "12.2.3 (519615d)";
|
|
1433
|
-
};
|
|
1434
1431
|
public: {
|
|
1435
1432
|
Tables: {
|
|
1436
1433
|
acq_artifacts: {
|
|
@@ -2630,6 +2627,74 @@ type Database = {
|
|
|
2630
2627
|
}
|
|
2631
2628
|
];
|
|
2632
2629
|
};
|
|
2630
|
+
agent_access_grants: {
|
|
2631
|
+
Row: {
|
|
2632
|
+
allowed_origins: string[];
|
|
2633
|
+
branding: Json;
|
|
2634
|
+
capture_fields: Json;
|
|
2635
|
+
code_hash: string | null;
|
|
2636
|
+
code_salt: string | null;
|
|
2637
|
+
created_at: string;
|
|
2638
|
+
disabled_at: string | null;
|
|
2639
|
+
expires_at: string | null;
|
|
2640
|
+
id: string;
|
|
2641
|
+
max_sessions_per_visitor: number;
|
|
2642
|
+
max_turns_per_session: number;
|
|
2643
|
+
mode: string;
|
|
2644
|
+
organization_id: string;
|
|
2645
|
+
resource_id: string;
|
|
2646
|
+
slug: string;
|
|
2647
|
+
tool_policy: Json;
|
|
2648
|
+
updated_at: string;
|
|
2649
|
+
};
|
|
2650
|
+
Insert: {
|
|
2651
|
+
allowed_origins?: string[];
|
|
2652
|
+
branding?: Json;
|
|
2653
|
+
capture_fields?: Json;
|
|
2654
|
+
code_hash?: string | null;
|
|
2655
|
+
code_salt?: string | null;
|
|
2656
|
+
created_at?: string;
|
|
2657
|
+
disabled_at?: string | null;
|
|
2658
|
+
expires_at?: string | null;
|
|
2659
|
+
id?: string;
|
|
2660
|
+
max_sessions_per_visitor?: number;
|
|
2661
|
+
max_turns_per_session?: number;
|
|
2662
|
+
mode?: string;
|
|
2663
|
+
organization_id: string;
|
|
2664
|
+
resource_id: string;
|
|
2665
|
+
slug: string;
|
|
2666
|
+
tool_policy?: Json;
|
|
2667
|
+
updated_at?: string;
|
|
2668
|
+
};
|
|
2669
|
+
Update: {
|
|
2670
|
+
allowed_origins?: string[];
|
|
2671
|
+
branding?: Json;
|
|
2672
|
+
capture_fields?: Json;
|
|
2673
|
+
code_hash?: string | null;
|
|
2674
|
+
code_salt?: string | null;
|
|
2675
|
+
created_at?: string;
|
|
2676
|
+
disabled_at?: string | null;
|
|
2677
|
+
expires_at?: string | null;
|
|
2678
|
+
id?: string;
|
|
2679
|
+
max_sessions_per_visitor?: number;
|
|
2680
|
+
max_turns_per_session?: number;
|
|
2681
|
+
mode?: string;
|
|
2682
|
+
organization_id?: string;
|
|
2683
|
+
resource_id?: string;
|
|
2684
|
+
slug?: string;
|
|
2685
|
+
tool_policy?: Json;
|
|
2686
|
+
updated_at?: string;
|
|
2687
|
+
};
|
|
2688
|
+
Relationships: [
|
|
2689
|
+
{
|
|
2690
|
+
foreignKeyName: "agent_access_grants_organization_id_fkey";
|
|
2691
|
+
columns: ["organization_id"];
|
|
2692
|
+
isOneToOne: false;
|
|
2693
|
+
referencedRelation: "organizations";
|
|
2694
|
+
referencedColumns: ["id"];
|
|
2695
|
+
}
|
|
2696
|
+
];
|
|
2697
|
+
};
|
|
2633
2698
|
api_keys: {
|
|
2634
2699
|
Row: {
|
|
2635
2700
|
created_at: string | null;
|
|
@@ -3537,138 +3602,6 @@ type Database = {
|
|
|
3537
3602
|
};
|
|
3538
3603
|
Relationships: [];
|
|
3539
3604
|
};
|
|
3540
|
-
agent_access_grants: {
|
|
3541
|
-
Row: {
|
|
3542
|
-
allowed_origins: string[];
|
|
3543
|
-
branding: Json;
|
|
3544
|
-
capture_fields: Json;
|
|
3545
|
-
code_hash: string | null;
|
|
3546
|
-
code_salt: string | null;
|
|
3547
|
-
created_at: string;
|
|
3548
|
-
disabled_at: string | null;
|
|
3549
|
-
expires_at: string | null;
|
|
3550
|
-
id: string;
|
|
3551
|
-
max_sessions_per_visitor: number;
|
|
3552
|
-
max_turns_per_session: number;
|
|
3553
|
-
mode: string;
|
|
3554
|
-
organization_id: string;
|
|
3555
|
-
resource_id: string;
|
|
3556
|
-
slug: string;
|
|
3557
|
-
tool_policy: Json;
|
|
3558
|
-
updated_at: string;
|
|
3559
|
-
};
|
|
3560
|
-
Insert: {
|
|
3561
|
-
allowed_origins?: string[];
|
|
3562
|
-
branding?: Json;
|
|
3563
|
-
capture_fields?: Json;
|
|
3564
|
-
code_hash?: string | null;
|
|
3565
|
-
code_salt?: string | null;
|
|
3566
|
-
created_at?: string;
|
|
3567
|
-
disabled_at?: string | null;
|
|
3568
|
-
expires_at?: string | null;
|
|
3569
|
-
id?: string;
|
|
3570
|
-
max_sessions_per_visitor?: number;
|
|
3571
|
-
max_turns_per_session?: number;
|
|
3572
|
-
mode?: string;
|
|
3573
|
-
organization_id: string;
|
|
3574
|
-
resource_id: string;
|
|
3575
|
-
slug: string;
|
|
3576
|
-
tool_policy?: Json;
|
|
3577
|
-
updated_at?: string;
|
|
3578
|
-
};
|
|
3579
|
-
Update: {
|
|
3580
|
-
allowed_origins?: string[];
|
|
3581
|
-
branding?: Json;
|
|
3582
|
-
capture_fields?: Json;
|
|
3583
|
-
code_hash?: string | null;
|
|
3584
|
-
code_salt?: string | null;
|
|
3585
|
-
created_at?: string;
|
|
3586
|
-
disabled_at?: string | null;
|
|
3587
|
-
expires_at?: string | null;
|
|
3588
|
-
id?: string;
|
|
3589
|
-
max_sessions_per_visitor?: number;
|
|
3590
|
-
max_turns_per_session?: number;
|
|
3591
|
-
mode?: string;
|
|
3592
|
-
organization_id?: string;
|
|
3593
|
-
resource_id?: string;
|
|
3594
|
-
slug?: string;
|
|
3595
|
-
tool_policy?: Json;
|
|
3596
|
-
updated_at?: string;
|
|
3597
|
-
};
|
|
3598
|
-
Relationships: [
|
|
3599
|
-
{
|
|
3600
|
-
foreignKeyName: "agent_access_grants_organization_id_fkey";
|
|
3601
|
-
columns: ["organization_id"];
|
|
3602
|
-
isOneToOne: false;
|
|
3603
|
-
referencedRelation: "organizations";
|
|
3604
|
-
referencedColumns: ["id"];
|
|
3605
|
-
}
|
|
3606
|
-
];
|
|
3607
|
-
};
|
|
3608
|
-
agent_chat_capabilities: {
|
|
3609
|
-
Row: {
|
|
3610
|
-
created_at: string;
|
|
3611
|
-
expires_at: string;
|
|
3612
|
-
grant_id: string;
|
|
3613
|
-
id: string;
|
|
3614
|
-
organization_id: string;
|
|
3615
|
-
origin: string | null;
|
|
3616
|
-
resource_id: string;
|
|
3617
|
-
revoked_at: string | null;
|
|
3618
|
-
session_id: string | null;
|
|
3619
|
-
token_hash: string;
|
|
3620
|
-
visitor_id: string | null;
|
|
3621
|
-
};
|
|
3622
|
-
Insert: {
|
|
3623
|
-
created_at?: string;
|
|
3624
|
-
expires_at: string;
|
|
3625
|
-
grant_id: string;
|
|
3626
|
-
id?: string;
|
|
3627
|
-
organization_id: string;
|
|
3628
|
-
origin?: string | null;
|
|
3629
|
-
resource_id: string;
|
|
3630
|
-
revoked_at?: string | null;
|
|
3631
|
-
session_id?: string | null;
|
|
3632
|
-
token_hash: string;
|
|
3633
|
-
visitor_id?: string | null;
|
|
3634
|
-
};
|
|
3635
|
-
Update: {
|
|
3636
|
-
created_at?: string;
|
|
3637
|
-
expires_at?: string;
|
|
3638
|
-
grant_id?: string;
|
|
3639
|
-
id?: string;
|
|
3640
|
-
organization_id?: string;
|
|
3641
|
-
origin?: string | null;
|
|
3642
|
-
resource_id?: string;
|
|
3643
|
-
revoked_at?: string | null;
|
|
3644
|
-
session_id?: string | null;
|
|
3645
|
-
token_hash?: string;
|
|
3646
|
-
visitor_id?: string | null;
|
|
3647
|
-
};
|
|
3648
|
-
Relationships: [
|
|
3649
|
-
{
|
|
3650
|
-
foreignKeyName: "agent_chat_capabilities_grant_id_fkey";
|
|
3651
|
-
columns: ["grant_id"];
|
|
3652
|
-
isOneToOne: false;
|
|
3653
|
-
referencedRelation: "agent_access_grants";
|
|
3654
|
-
referencedColumns: ["id"];
|
|
3655
|
-
},
|
|
3656
|
-
{
|
|
3657
|
-
foreignKeyName: "agent_chat_capabilities_organization_id_fkey";
|
|
3658
|
-
columns: ["organization_id"];
|
|
3659
|
-
isOneToOne: false;
|
|
3660
|
-
referencedRelation: "organizations";
|
|
3661
|
-
referencedColumns: ["id"];
|
|
3662
|
-
},
|
|
3663
|
-
{
|
|
3664
|
-
foreignKeyName: "agent_chat_capabilities_session_id_fkey";
|
|
3665
|
-
columns: ["session_id"];
|
|
3666
|
-
isOneToOne: false;
|
|
3667
|
-
referencedRelation: "sessions";
|
|
3668
|
-
referencedColumns: ["session_id"];
|
|
3669
|
-
}
|
|
3670
|
-
];
|
|
3671
|
-
};
|
|
3672
3605
|
organizations: {
|
|
3673
3606
|
Row: {
|
|
3674
3607
|
config: Json;
|
|
@@ -4567,11 +4500,11 @@ type Database = {
|
|
|
4567
4500
|
Returns: undefined;
|
|
4568
4501
|
};
|
|
4569
4502
|
auth_jwt_claims: {
|
|
4570
|
-
Args: never
|
|
4503
|
+
Args: Record<PropertyKey, never>;
|
|
4571
4504
|
Returns: Json;
|
|
4572
4505
|
};
|
|
4573
4506
|
auth_uid_safe: {
|
|
4574
|
-
Args: never
|
|
4507
|
+
Args: Record<PropertyKey, never>;
|
|
4575
4508
|
Returns: string;
|
|
4576
4509
|
};
|
|
4577
4510
|
can_assign_role_in_org: {
|
|
@@ -4582,7 +4515,7 @@ type Database = {
|
|
|
4582
4515
|
Returns: boolean;
|
|
4583
4516
|
};
|
|
4584
4517
|
current_user_is_platform_admin: {
|
|
4585
|
-
Args: never
|
|
4518
|
+
Args: Record<PropertyKey, never>;
|
|
4586
4519
|
Returns: boolean;
|
|
4587
4520
|
};
|
|
4588
4521
|
current_user_shares_org_with: {
|
|
@@ -4592,11 +4525,11 @@ type Database = {
|
|
|
4592
4525
|
Returns: boolean;
|
|
4593
4526
|
};
|
|
4594
4527
|
current_user_supabase_id: {
|
|
4595
|
-
Args: never
|
|
4528
|
+
Args: Record<PropertyKey, never>;
|
|
4596
4529
|
Returns: string;
|
|
4597
4530
|
};
|
|
4598
4531
|
detect_stalled_executions: {
|
|
4599
|
-
Args: never
|
|
4532
|
+
Args: Record<PropertyKey, never>;
|
|
4600
4533
|
Returns: undefined;
|
|
4601
4534
|
};
|
|
4602
4535
|
execute_session_turn: {
|
|
@@ -4617,7 +4550,7 @@ type Database = {
|
|
|
4617
4550
|
}[];
|
|
4618
4551
|
};
|
|
4619
4552
|
get_platform_credential_kek: {
|
|
4620
|
-
Args: never
|
|
4553
|
+
Args: Record<PropertyKey, never>;
|
|
4621
4554
|
Returns: string;
|
|
4622
4555
|
};
|
|
4623
4556
|
get_storage_org_id: {
|
|
@@ -4627,7 +4560,7 @@ type Database = {
|
|
|
4627
4560
|
Returns: string;
|
|
4628
4561
|
};
|
|
4629
4562
|
get_workos_user_id: {
|
|
4630
|
-
Args: never
|
|
4563
|
+
Args: Record<PropertyKey, never>;
|
|
4631
4564
|
Returns: string;
|
|
4632
4565
|
};
|
|
4633
4566
|
has_org_access: {
|
|
@@ -4635,10 +4568,7 @@ type Database = {
|
|
|
4635
4568
|
action?: string;
|
|
4636
4569
|
org_id: string;
|
|
4637
4570
|
system_path: string;
|
|
4638
|
-
}
|
|
4639
|
-
Returns: boolean;
|
|
4640
|
-
} | {
|
|
4641
|
-
Args: {
|
|
4571
|
+
} | {
|
|
4642
4572
|
action?: string;
|
|
4643
4573
|
system_path: string;
|
|
4644
4574
|
};
|
|
@@ -4674,15 +4604,15 @@ type Database = {
|
|
|
4674
4604
|
Returns: Json;
|
|
4675
4605
|
};
|
|
4676
4606
|
process_due_schedules: {
|
|
4677
|
-
Args: never
|
|
4607
|
+
Args: Record<PropertyKey, never>;
|
|
4678
4608
|
Returns: Json;
|
|
4679
4609
|
};
|
|
4680
4610
|
recompute_all_memberships: {
|
|
4681
|
-
Args: never
|
|
4611
|
+
Args: Record<PropertyKey, never>;
|
|
4682
4612
|
Returns: undefined;
|
|
4683
4613
|
};
|
|
4684
4614
|
repair_membership_role_assignments: {
|
|
4685
|
-
Args: never
|
|
4615
|
+
Args: Record<PropertyKey, never>;
|
|
4686
4616
|
Returns: {
|
|
4687
4617
|
membership_id: string;
|
|
4688
4618
|
organization_id: string;
|
|
@@ -4712,7 +4642,7 @@ type Database = {
|
|
|
4712
4642
|
Returns: string;
|
|
4713
4643
|
};
|
|
4714
4644
|
upsert_user_profile: {
|
|
4715
|
-
Args: never
|
|
4645
|
+
Args: Record<PropertyKey, never>;
|
|
4716
4646
|
Returns: {
|
|
4717
4647
|
profile_display_name: string;
|
|
4718
4648
|
profile_email: string;
|
|
@@ -1261,9 +1261,6 @@ type Json = string | number | boolean | null | {
|
|
|
1261
1261
|
[key: string]: Json | undefined;
|
|
1262
1262
|
} | Json[];
|
|
1263
1263
|
type Database = {
|
|
1264
|
-
__InternalSupabase: {
|
|
1265
|
-
PostgrestVersion: "12.2.3 (519615d)";
|
|
1266
|
-
};
|
|
1267
1264
|
public: {
|
|
1268
1265
|
Tables: {
|
|
1269
1266
|
acq_artifacts: {
|
|
@@ -2463,6 +2460,74 @@ type Database = {
|
|
|
2463
2460
|
}
|
|
2464
2461
|
];
|
|
2465
2462
|
};
|
|
2463
|
+
agent_access_grants: {
|
|
2464
|
+
Row: {
|
|
2465
|
+
allowed_origins: string[];
|
|
2466
|
+
branding: Json;
|
|
2467
|
+
capture_fields: Json;
|
|
2468
|
+
code_hash: string | null;
|
|
2469
|
+
code_salt: string | null;
|
|
2470
|
+
created_at: string;
|
|
2471
|
+
disabled_at: string | null;
|
|
2472
|
+
expires_at: string | null;
|
|
2473
|
+
id: string;
|
|
2474
|
+
max_sessions_per_visitor: number;
|
|
2475
|
+
max_turns_per_session: number;
|
|
2476
|
+
mode: string;
|
|
2477
|
+
organization_id: string;
|
|
2478
|
+
resource_id: string;
|
|
2479
|
+
slug: string;
|
|
2480
|
+
tool_policy: Json;
|
|
2481
|
+
updated_at: string;
|
|
2482
|
+
};
|
|
2483
|
+
Insert: {
|
|
2484
|
+
allowed_origins?: string[];
|
|
2485
|
+
branding?: Json;
|
|
2486
|
+
capture_fields?: Json;
|
|
2487
|
+
code_hash?: string | null;
|
|
2488
|
+
code_salt?: string | null;
|
|
2489
|
+
created_at?: string;
|
|
2490
|
+
disabled_at?: string | null;
|
|
2491
|
+
expires_at?: string | null;
|
|
2492
|
+
id?: string;
|
|
2493
|
+
max_sessions_per_visitor?: number;
|
|
2494
|
+
max_turns_per_session?: number;
|
|
2495
|
+
mode?: string;
|
|
2496
|
+
organization_id: string;
|
|
2497
|
+
resource_id: string;
|
|
2498
|
+
slug: string;
|
|
2499
|
+
tool_policy?: Json;
|
|
2500
|
+
updated_at?: string;
|
|
2501
|
+
};
|
|
2502
|
+
Update: {
|
|
2503
|
+
allowed_origins?: string[];
|
|
2504
|
+
branding?: Json;
|
|
2505
|
+
capture_fields?: Json;
|
|
2506
|
+
code_hash?: string | null;
|
|
2507
|
+
code_salt?: string | null;
|
|
2508
|
+
created_at?: string;
|
|
2509
|
+
disabled_at?: string | null;
|
|
2510
|
+
expires_at?: string | null;
|
|
2511
|
+
id?: string;
|
|
2512
|
+
max_sessions_per_visitor?: number;
|
|
2513
|
+
max_turns_per_session?: number;
|
|
2514
|
+
mode?: string;
|
|
2515
|
+
organization_id?: string;
|
|
2516
|
+
resource_id?: string;
|
|
2517
|
+
slug?: string;
|
|
2518
|
+
tool_policy?: Json;
|
|
2519
|
+
updated_at?: string;
|
|
2520
|
+
};
|
|
2521
|
+
Relationships: [
|
|
2522
|
+
{
|
|
2523
|
+
foreignKeyName: "agent_access_grants_organization_id_fkey";
|
|
2524
|
+
columns: ["organization_id"];
|
|
2525
|
+
isOneToOne: false;
|
|
2526
|
+
referencedRelation: "organizations";
|
|
2527
|
+
referencedColumns: ["id"];
|
|
2528
|
+
}
|
|
2529
|
+
];
|
|
2530
|
+
};
|
|
2466
2531
|
api_keys: {
|
|
2467
2532
|
Row: {
|
|
2468
2533
|
created_at: string | null;
|
|
@@ -3370,138 +3435,6 @@ type Database = {
|
|
|
3370
3435
|
};
|
|
3371
3436
|
Relationships: [];
|
|
3372
3437
|
};
|
|
3373
|
-
agent_access_grants: {
|
|
3374
|
-
Row: {
|
|
3375
|
-
allowed_origins: string[];
|
|
3376
|
-
branding: Json;
|
|
3377
|
-
capture_fields: Json;
|
|
3378
|
-
code_hash: string | null;
|
|
3379
|
-
code_salt: string | null;
|
|
3380
|
-
created_at: string;
|
|
3381
|
-
disabled_at: string | null;
|
|
3382
|
-
expires_at: string | null;
|
|
3383
|
-
id: string;
|
|
3384
|
-
max_sessions_per_visitor: number;
|
|
3385
|
-
max_turns_per_session: number;
|
|
3386
|
-
mode: string;
|
|
3387
|
-
organization_id: string;
|
|
3388
|
-
resource_id: string;
|
|
3389
|
-
slug: string;
|
|
3390
|
-
tool_policy: Json;
|
|
3391
|
-
updated_at: string;
|
|
3392
|
-
};
|
|
3393
|
-
Insert: {
|
|
3394
|
-
allowed_origins?: string[];
|
|
3395
|
-
branding?: Json;
|
|
3396
|
-
capture_fields?: Json;
|
|
3397
|
-
code_hash?: string | null;
|
|
3398
|
-
code_salt?: string | null;
|
|
3399
|
-
created_at?: string;
|
|
3400
|
-
disabled_at?: string | null;
|
|
3401
|
-
expires_at?: string | null;
|
|
3402
|
-
id?: string;
|
|
3403
|
-
max_sessions_per_visitor?: number;
|
|
3404
|
-
max_turns_per_session?: number;
|
|
3405
|
-
mode?: string;
|
|
3406
|
-
organization_id: string;
|
|
3407
|
-
resource_id: string;
|
|
3408
|
-
slug: string;
|
|
3409
|
-
tool_policy?: Json;
|
|
3410
|
-
updated_at?: string;
|
|
3411
|
-
};
|
|
3412
|
-
Update: {
|
|
3413
|
-
allowed_origins?: string[];
|
|
3414
|
-
branding?: Json;
|
|
3415
|
-
capture_fields?: Json;
|
|
3416
|
-
code_hash?: string | null;
|
|
3417
|
-
code_salt?: string | null;
|
|
3418
|
-
created_at?: string;
|
|
3419
|
-
disabled_at?: string | null;
|
|
3420
|
-
expires_at?: string | null;
|
|
3421
|
-
id?: string;
|
|
3422
|
-
max_sessions_per_visitor?: number;
|
|
3423
|
-
max_turns_per_session?: number;
|
|
3424
|
-
mode?: string;
|
|
3425
|
-
organization_id?: string;
|
|
3426
|
-
resource_id?: string;
|
|
3427
|
-
slug?: string;
|
|
3428
|
-
tool_policy?: Json;
|
|
3429
|
-
updated_at?: string;
|
|
3430
|
-
};
|
|
3431
|
-
Relationships: [
|
|
3432
|
-
{
|
|
3433
|
-
foreignKeyName: "agent_access_grants_organization_id_fkey";
|
|
3434
|
-
columns: ["organization_id"];
|
|
3435
|
-
isOneToOne: false;
|
|
3436
|
-
referencedRelation: "organizations";
|
|
3437
|
-
referencedColumns: ["id"];
|
|
3438
|
-
}
|
|
3439
|
-
];
|
|
3440
|
-
};
|
|
3441
|
-
agent_chat_capabilities: {
|
|
3442
|
-
Row: {
|
|
3443
|
-
created_at: string;
|
|
3444
|
-
expires_at: string;
|
|
3445
|
-
grant_id: string;
|
|
3446
|
-
id: string;
|
|
3447
|
-
organization_id: string;
|
|
3448
|
-
origin: string | null;
|
|
3449
|
-
resource_id: string;
|
|
3450
|
-
revoked_at: string | null;
|
|
3451
|
-
session_id: string | null;
|
|
3452
|
-
token_hash: string;
|
|
3453
|
-
visitor_id: string | null;
|
|
3454
|
-
};
|
|
3455
|
-
Insert: {
|
|
3456
|
-
created_at?: string;
|
|
3457
|
-
expires_at: string;
|
|
3458
|
-
grant_id: string;
|
|
3459
|
-
id?: string;
|
|
3460
|
-
organization_id: string;
|
|
3461
|
-
origin?: string | null;
|
|
3462
|
-
resource_id: string;
|
|
3463
|
-
revoked_at?: string | null;
|
|
3464
|
-
session_id?: string | null;
|
|
3465
|
-
token_hash: string;
|
|
3466
|
-
visitor_id?: string | null;
|
|
3467
|
-
};
|
|
3468
|
-
Update: {
|
|
3469
|
-
created_at?: string;
|
|
3470
|
-
expires_at?: string;
|
|
3471
|
-
grant_id?: string;
|
|
3472
|
-
id?: string;
|
|
3473
|
-
organization_id?: string;
|
|
3474
|
-
origin?: string | null;
|
|
3475
|
-
resource_id?: string;
|
|
3476
|
-
revoked_at?: string | null;
|
|
3477
|
-
session_id?: string | null;
|
|
3478
|
-
token_hash?: string;
|
|
3479
|
-
visitor_id?: string | null;
|
|
3480
|
-
};
|
|
3481
|
-
Relationships: [
|
|
3482
|
-
{
|
|
3483
|
-
foreignKeyName: "agent_chat_capabilities_grant_id_fkey";
|
|
3484
|
-
columns: ["grant_id"];
|
|
3485
|
-
isOneToOne: false;
|
|
3486
|
-
referencedRelation: "agent_access_grants";
|
|
3487
|
-
referencedColumns: ["id"];
|
|
3488
|
-
},
|
|
3489
|
-
{
|
|
3490
|
-
foreignKeyName: "agent_chat_capabilities_organization_id_fkey";
|
|
3491
|
-
columns: ["organization_id"];
|
|
3492
|
-
isOneToOne: false;
|
|
3493
|
-
referencedRelation: "organizations";
|
|
3494
|
-
referencedColumns: ["id"];
|
|
3495
|
-
},
|
|
3496
|
-
{
|
|
3497
|
-
foreignKeyName: "agent_chat_capabilities_session_id_fkey";
|
|
3498
|
-
columns: ["session_id"];
|
|
3499
|
-
isOneToOne: false;
|
|
3500
|
-
referencedRelation: "sessions";
|
|
3501
|
-
referencedColumns: ["session_id"];
|
|
3502
|
-
}
|
|
3503
|
-
];
|
|
3504
|
-
};
|
|
3505
3438
|
organizations: {
|
|
3506
3439
|
Row: {
|
|
3507
3440
|
config: Json;
|
|
@@ -4400,11 +4333,11 @@ type Database = {
|
|
|
4400
4333
|
Returns: undefined;
|
|
4401
4334
|
};
|
|
4402
4335
|
auth_jwt_claims: {
|
|
4403
|
-
Args: never
|
|
4336
|
+
Args: Record<PropertyKey, never>;
|
|
4404
4337
|
Returns: Json;
|
|
4405
4338
|
};
|
|
4406
4339
|
auth_uid_safe: {
|
|
4407
|
-
Args: never
|
|
4340
|
+
Args: Record<PropertyKey, never>;
|
|
4408
4341
|
Returns: string;
|
|
4409
4342
|
};
|
|
4410
4343
|
can_assign_role_in_org: {
|
|
@@ -4415,7 +4348,7 @@ type Database = {
|
|
|
4415
4348
|
Returns: boolean;
|
|
4416
4349
|
};
|
|
4417
4350
|
current_user_is_platform_admin: {
|
|
4418
|
-
Args: never
|
|
4351
|
+
Args: Record<PropertyKey, never>;
|
|
4419
4352
|
Returns: boolean;
|
|
4420
4353
|
};
|
|
4421
4354
|
current_user_shares_org_with: {
|
|
@@ -4425,11 +4358,11 @@ type Database = {
|
|
|
4425
4358
|
Returns: boolean;
|
|
4426
4359
|
};
|
|
4427
4360
|
current_user_supabase_id: {
|
|
4428
|
-
Args: never
|
|
4361
|
+
Args: Record<PropertyKey, never>;
|
|
4429
4362
|
Returns: string;
|
|
4430
4363
|
};
|
|
4431
4364
|
detect_stalled_executions: {
|
|
4432
|
-
Args: never
|
|
4365
|
+
Args: Record<PropertyKey, never>;
|
|
4433
4366
|
Returns: undefined;
|
|
4434
4367
|
};
|
|
4435
4368
|
execute_session_turn: {
|
|
@@ -4450,7 +4383,7 @@ type Database = {
|
|
|
4450
4383
|
}[];
|
|
4451
4384
|
};
|
|
4452
4385
|
get_platform_credential_kek: {
|
|
4453
|
-
Args: never
|
|
4386
|
+
Args: Record<PropertyKey, never>;
|
|
4454
4387
|
Returns: string;
|
|
4455
4388
|
};
|
|
4456
4389
|
get_storage_org_id: {
|
|
@@ -4460,7 +4393,7 @@ type Database = {
|
|
|
4460
4393
|
Returns: string;
|
|
4461
4394
|
};
|
|
4462
4395
|
get_workos_user_id: {
|
|
4463
|
-
Args: never
|
|
4396
|
+
Args: Record<PropertyKey, never>;
|
|
4464
4397
|
Returns: string;
|
|
4465
4398
|
};
|
|
4466
4399
|
has_org_access: {
|
|
@@ -4468,10 +4401,7 @@ type Database = {
|
|
|
4468
4401
|
action?: string;
|
|
4469
4402
|
org_id: string;
|
|
4470
4403
|
system_path: string;
|
|
4471
|
-
}
|
|
4472
|
-
Returns: boolean;
|
|
4473
|
-
} | {
|
|
4474
|
-
Args: {
|
|
4404
|
+
} | {
|
|
4475
4405
|
action?: string;
|
|
4476
4406
|
system_path: string;
|
|
4477
4407
|
};
|
|
@@ -4507,15 +4437,15 @@ type Database = {
|
|
|
4507
4437
|
Returns: Json;
|
|
4508
4438
|
};
|
|
4509
4439
|
process_due_schedules: {
|
|
4510
|
-
Args: never
|
|
4440
|
+
Args: Record<PropertyKey, never>;
|
|
4511
4441
|
Returns: Json;
|
|
4512
4442
|
};
|
|
4513
4443
|
recompute_all_memberships: {
|
|
4514
|
-
Args: never
|
|
4444
|
+
Args: Record<PropertyKey, never>;
|
|
4515
4445
|
Returns: undefined;
|
|
4516
4446
|
};
|
|
4517
4447
|
repair_membership_role_assignments: {
|
|
4518
|
-
Args: never
|
|
4448
|
+
Args: Record<PropertyKey, never>;
|
|
4519
4449
|
Returns: {
|
|
4520
4450
|
membership_id: string;
|
|
4521
4451
|
organization_id: string;
|
|
@@ -4545,7 +4475,7 @@ type Database = {
|
|
|
4545
4475
|
Returns: string;
|
|
4546
4476
|
};
|
|
4547
4477
|
upsert_user_profile: {
|
|
4548
|
-
Args: never
|
|
4478
|
+
Args: Record<PropertyKey, never>;
|
|
4549
4479
|
Returns: {
|
|
4550
4480
|
profile_display_name: string;
|
|
4551
4481
|
profile_email: string;
|
|
@@ -10863,7 +10793,7 @@ type TypedAdapter<TMap extends ToolMethodMap$1> = {
|
|
|
10863
10793
|
*
|
|
10864
10794
|
* Parent -> Worker: { type: 'execute', resourceId, executionId, input, organizationId?, organizationName?,
|
|
10865
10795
|
* sessionId?, sessionTurnNumber?, parentExecutionId?, executionDepth }
|
|
10866
|
-
* Worker -> Parent: { type: 'result', status, output?, error?, logs, metrics: { durationMs } }
|
|
10796
|
+
* Worker -> Parent: { type: 'result', status, output?, memorySnapshot?, error?, logs, metrics: { durationMs } }
|
|
10867
10797
|
*
|
|
10868
10798
|
* Parent -> Worker: { type: 'abort' } (graceful abort before terminate)
|
|
10869
10799
|
*
|
package/dist/test-utils/index.js
CHANGED
|
@@ -4485,8 +4485,10 @@ ${actionsList}
|
|
|
4485
4485
|
|
|
4486
4486
|
- Batch independent tool calls in one iteration (faster execution)
|
|
4487
4487
|
- Dependent operations need separate iterations (tool B needs tool A's result)
|
|
4488
|
-
- "complete" cannot mix with
|
|
4488
|
+
- "complete" cannot mix with navigate-knowledge${includeNavigateKnowledge ? "" : " (when available)"}
|
|
4489
|
+
- "complete" can mix with tool-call when the tool is a fire-and-forget side effect and you do not need its result before ending${includeMessageAction ? `
|
|
4489
4490
|
- Always send at least one message before completing
|
|
4491
|
+
- Send at most one message per iteration. Multiple messages in a session turn are collapsed into one visible assistant message.
|
|
4490
4492
|
- When you have your answer, send message + complete in the SAME iteration. Never send a message alone then complete in a later iteration.
|
|
4491
4493
|
- Never repeat or rephrase the same answer across iterations. One clear answer, then complete.` : ""}
|
|
4492
4494
|
|
|
@@ -4497,6 +4499,7 @@ ${actionsList}
|
|
|
4497
4499
|
|
|
4498
4500
|
**Don't use "complete" when:**
|
|
4499
4501
|
- You just called a tool and need its results
|
|
4502
|
+
- You used navigate-knowledge and need the newly loaded knowledge in the next iteration
|
|
4500
4503
|
- More iterations are needed
|
|
4501
4504
|
|
|
4502
4505
|
## Examples
|
|
@@ -4627,11 +4630,12 @@ function buildToolsPrompt(tools) {
|
|
|
4627
4630
|
section += "To call a tool, return a tool-call action:\n";
|
|
4628
4631
|
section += '{\n "type": "tool-call",\n "id": "unique-id",\n "name": "tool-name",\n "input": { /* tool input matching schema */ }\n}\n\n';
|
|
4629
4632
|
section += "**IMPORTANT RULES:**\n";
|
|
4630
|
-
section += '1. "complete" CANNOT mix with
|
|
4631
|
-
section += '2. "complete" CAN mix with message
|
|
4632
|
-
section +=
|
|
4633
|
-
section += "4.
|
|
4634
|
-
section += "5.
|
|
4633
|
+
section += '1. "complete" CANNOT mix with navigate-knowledge actions in the same response\n';
|
|
4634
|
+
section += '2. "complete" CAN mix with message - always pair your final message with complete in the same iteration\n';
|
|
4635
|
+
section += '3. "complete" CAN mix with fire-and-forget tool-call actions when you do not need their results\n';
|
|
4636
|
+
section += "4. To use tools and inspect their results, return ONLY tool-call actions, then wait for results in the next iteration\n";
|
|
4637
|
+
section += "5. After receiving tool results, you can either call more tools OR complete with final answer\n";
|
|
4638
|
+
section += "6. navigate-knowledge actions load new capabilities - tools become available in the next iteration\n";
|
|
4635
4639
|
return section + "\n";
|
|
4636
4640
|
}
|
|
4637
4641
|
|
|
@@ -5886,12 +5890,35 @@ function validateActionSequence(actions) {
|
|
|
5886
5890
|
}
|
|
5887
5891
|
}
|
|
5888
5892
|
}
|
|
5893
|
+
function normalizeSessionMessages(actions, sessionCapable) {
|
|
5894
|
+
if (!sessionCapable) {
|
|
5895
|
+
return actions;
|
|
5896
|
+
}
|
|
5897
|
+
const messages = actions.filter((action) => action.type === "message");
|
|
5898
|
+
if (messages.length <= 1) {
|
|
5899
|
+
return actions;
|
|
5900
|
+
}
|
|
5901
|
+
const collapsedText = messages.map((message) => message.text).join("\n\n");
|
|
5902
|
+
const collapsedMessage = { type: "message", text: collapsedText };
|
|
5903
|
+
let emittedCollapsedMessage = false;
|
|
5904
|
+
return actions.flatMap((action) => {
|
|
5905
|
+
if (action.type !== "message") {
|
|
5906
|
+
return [action];
|
|
5907
|
+
}
|
|
5908
|
+
if (emittedCollapsedMessage) {
|
|
5909
|
+
return [];
|
|
5910
|
+
}
|
|
5911
|
+
emittedCollapsedMessage = true;
|
|
5912
|
+
return [collapsedMessage];
|
|
5913
|
+
});
|
|
5914
|
+
}
|
|
5889
5915
|
async function processActions(iterationContext, response) {
|
|
5890
5916
|
validateActionSequence(response.nextActions);
|
|
5917
|
+
const normalizedActions = normalizeSessionMessages(response.nextActions, !!iterationContext.config.sessionCapable);
|
|
5891
5918
|
let shouldComplete = false;
|
|
5892
5919
|
const toolCalls = [];
|
|
5893
5920
|
const otherActions = [];
|
|
5894
|
-
for (const action of
|
|
5921
|
+
for (const action of normalizedActions) {
|
|
5895
5922
|
if (action.type === "tool-call") {
|
|
5896
5923
|
toolCalls.push(action);
|
|
5897
5924
|
} else {
|
|
@@ -5918,6 +5945,9 @@ async function processActions(iterationContext, response) {
|
|
|
5918
5945
|
}
|
|
5919
5946
|
}
|
|
5920
5947
|
}
|
|
5948
|
+
if (!shouldComplete && iterationContext.config.sessionCapable && toolCalls.length === 0 && normalizedActions.some((a3) => a3.type === "message") && !normalizedActions.some((a3) => a3.type === "navigate-knowledge")) {
|
|
5949
|
+
shouldComplete = true;
|
|
5950
|
+
}
|
|
5921
5951
|
return { shouldComplete };
|
|
5922
5952
|
}
|
|
5923
5953
|
|
|
@@ -10119,6 +10149,23 @@ function safeZodToJsonSchema(schema) {
|
|
|
10119
10149
|
}
|
|
10120
10150
|
return void 0;
|
|
10121
10151
|
}
|
|
10152
|
+
function serializeWorkerError(err) {
|
|
10153
|
+
const errorRecord = err instanceof Error ? err : void 0;
|
|
10154
|
+
const errorMessage = errorRecord?.message ?? String(err);
|
|
10155
|
+
const errorCode = err !== null && typeof err === "object" && "code" in err ? String(err.code) : "unknown";
|
|
10156
|
+
const errorName = errorRecord?.name ?? (err !== null && typeof err === "object" && err.constructor?.name ? err.constructor.name : "Error");
|
|
10157
|
+
const rawDetails = err !== null && typeof err === "object" && "details" in err ? err.details : void 0;
|
|
10158
|
+
const rawContext = err !== null && typeof err === "object" && "context" in err ? err.context : void 0;
|
|
10159
|
+
const details = rawDetails !== null && typeof rawDetails === "object" ? rawDetails : void 0;
|
|
10160
|
+
const context = rawContext !== null && typeof rawContext === "object" ? rawContext : void 0;
|
|
10161
|
+
return {
|
|
10162
|
+
error: `${errorName}: ${errorMessage}`,
|
|
10163
|
+
errorName,
|
|
10164
|
+
errorCode,
|
|
10165
|
+
...details ? { errorDetails: details } : {},
|
|
10166
|
+
...context ? { errorContext: context } : {}
|
|
10167
|
+
};
|
|
10168
|
+
}
|
|
10122
10169
|
function serializeNext(next) {
|
|
10123
10170
|
if (next === null) return null;
|
|
10124
10171
|
if (next.type === "linear") return { type: "linear", target: next.target };
|
|
@@ -10300,11 +10347,12 @@ function startWorker(org) {
|
|
|
10300
10347
|
parentPort.postMessage({ type: "result", status: "completed", output, logs, metrics: { durationMs } });
|
|
10301
10348
|
} catch (err) {
|
|
10302
10349
|
const durationMs = Date.now() - startTime;
|
|
10303
|
-
|
|
10350
|
+
const serializedError = serializeWorkerError(err);
|
|
10351
|
+
console.error(`[SDK-WORKER] Workflow '${resourceId}' failed (${durationMs}ms): ${serializedError.error}`);
|
|
10304
10352
|
parentPort.postMessage({
|
|
10305
10353
|
type: "result",
|
|
10306
10354
|
status: "failed",
|
|
10307
|
-
|
|
10355
|
+
...serializedError,
|
|
10308
10356
|
logs: [],
|
|
10309
10357
|
metrics: { durationMs }
|
|
10310
10358
|
});
|
|
@@ -10332,20 +10380,28 @@ function startWorker(org) {
|
|
|
10332
10380
|
signal: localAbortController.signal
|
|
10333
10381
|
});
|
|
10334
10382
|
const output = await agentInstance.execute(input, context);
|
|
10383
|
+
const memorySnapshot = agentInstance.getMemorySnapshot();
|
|
10384
|
+
if (!memorySnapshot) {
|
|
10385
|
+
throw new Error("Agent did not produce memory snapshot");
|
|
10386
|
+
}
|
|
10335
10387
|
const durationMs = Date.now() - startTime;
|
|
10336
10388
|
console.log(`[SDK-WORKER] Agent '${resourceId}' completed (${durationMs}ms)`);
|
|
10337
|
-
parentPort.postMessage({
|
|
10389
|
+
parentPort.postMessage({
|
|
10390
|
+
type: "result",
|
|
10391
|
+
status: "completed",
|
|
10392
|
+
output,
|
|
10393
|
+
memorySnapshot,
|
|
10394
|
+
logs,
|
|
10395
|
+
metrics: { durationMs }
|
|
10396
|
+
});
|
|
10338
10397
|
} catch (err) {
|
|
10339
10398
|
const durationMs = Date.now() - startTime;
|
|
10340
|
-
const
|
|
10341
|
-
|
|
10342
|
-
err !== null && typeof err === "object" && "code" in err ? String(err.code) : "unknown";
|
|
10343
|
-
const errorName = errorRecord?.name ?? (err !== null && typeof err === "object" && err.constructor?.name ? err.constructor.name : "Error");
|
|
10344
|
-
console.error(`[SDK-WORKER] Agent '${resourceId}' failed (${durationMs}ms): [${errorName}] ${errorMessage}`);
|
|
10399
|
+
const serializedError = serializeWorkerError(err);
|
|
10400
|
+
console.error(`[SDK-WORKER] Agent '${resourceId}' failed (${durationMs}ms): ${serializedError.error}`);
|
|
10345
10401
|
parentPort.postMessage({
|
|
10346
10402
|
type: "result",
|
|
10347
10403
|
status: "failed",
|
|
10348
|
-
|
|
10404
|
+
...serializedError,
|
|
10349
10405
|
logs,
|
|
10350
10406
|
metrics: { durationMs }
|
|
10351
10407
|
});
|
|
@@ -10359,6 +10415,8 @@ function startWorker(org) {
|
|
|
10359
10415
|
type: "result",
|
|
10360
10416
|
status: "failed",
|
|
10361
10417
|
error: `Resource not found: ${resourceId}`,
|
|
10418
|
+
errorName: "ResourceNotFoundError",
|
|
10419
|
+
errorCode: "resource_not_found",
|
|
10362
10420
|
logs: []
|
|
10363
10421
|
});
|
|
10364
10422
|
}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*
|
|
13
13
|
* Parent -> Worker: { type: 'execute', resourceId, executionId, input, organizationId?, organizationName?,
|
|
14
14
|
* sessionId?, sessionTurnNumber?, parentExecutionId?, executionDepth }
|
|
15
|
-
* Worker -> Parent: { type: 'result', status, output?, error?, logs, metrics: { durationMs } }
|
|
15
|
+
* Worker -> Parent: { type: 'result', status, output?, memorySnapshot?, error?, logs, metrics: { durationMs } }
|
|
16
16
|
*
|
|
17
17
|
* Parent -> Worker: { type: 'abort' } (graceful abort before terminate)
|
|
18
18
|
*
|
package/dist/worker/index.js
CHANGED
|
@@ -2607,8 +2607,10 @@ ${actionsList}
|
|
|
2607
2607
|
|
|
2608
2608
|
- Batch independent tool calls in one iteration (faster execution)
|
|
2609
2609
|
- Dependent operations need separate iterations (tool B needs tool A's result)
|
|
2610
|
-
- "complete" cannot mix with
|
|
2610
|
+
- "complete" cannot mix with navigate-knowledge${includeNavigateKnowledge ? "" : " (when available)"}
|
|
2611
|
+
- "complete" can mix with tool-call when the tool is a fire-and-forget side effect and you do not need its result before ending${includeMessageAction ? `
|
|
2611
2612
|
- Always send at least one message before completing
|
|
2613
|
+
- Send at most one message per iteration. Multiple messages in a session turn are collapsed into one visible assistant message.
|
|
2612
2614
|
- When you have your answer, send message + complete in the SAME iteration. Never send a message alone then complete in a later iteration.
|
|
2613
2615
|
- Never repeat or rephrase the same answer across iterations. One clear answer, then complete.` : ""}
|
|
2614
2616
|
|
|
@@ -2619,6 +2621,7 @@ ${actionsList}
|
|
|
2619
2621
|
|
|
2620
2622
|
**Don't use "complete" when:**
|
|
2621
2623
|
- You just called a tool and need its results
|
|
2624
|
+
- You used navigate-knowledge and need the newly loaded knowledge in the next iteration
|
|
2622
2625
|
- More iterations are needed
|
|
2623
2626
|
|
|
2624
2627
|
## Examples
|
|
@@ -2749,11 +2752,12 @@ function buildToolsPrompt(tools) {
|
|
|
2749
2752
|
section += "To call a tool, return a tool-call action:\n";
|
|
2750
2753
|
section += '{\n "type": "tool-call",\n "id": "unique-id",\n "name": "tool-name",\n "input": { /* tool input matching schema */ }\n}\n\n';
|
|
2751
2754
|
section += "**IMPORTANT RULES:**\n";
|
|
2752
|
-
section += '1. "complete" CANNOT mix with
|
|
2753
|
-
section += '2. "complete" CAN mix with message
|
|
2754
|
-
section +=
|
|
2755
|
-
section += "4.
|
|
2756
|
-
section += "5.
|
|
2755
|
+
section += '1. "complete" CANNOT mix with navigate-knowledge actions in the same response\n';
|
|
2756
|
+
section += '2. "complete" CAN mix with message - always pair your final message with complete in the same iteration\n';
|
|
2757
|
+
section += '3. "complete" CAN mix with fire-and-forget tool-call actions when you do not need their results\n';
|
|
2758
|
+
section += "4. To use tools and inspect their results, return ONLY tool-call actions, then wait for results in the next iteration\n";
|
|
2759
|
+
section += "5. After receiving tool results, you can either call more tools OR complete with final answer\n";
|
|
2760
|
+
section += "6. navigate-knowledge actions load new capabilities - tools become available in the next iteration\n";
|
|
2757
2761
|
return section + "\n";
|
|
2758
2762
|
}
|
|
2759
2763
|
|
|
@@ -3978,12 +3982,35 @@ function validateActionSequence(actions) {
|
|
|
3978
3982
|
}
|
|
3979
3983
|
}
|
|
3980
3984
|
}
|
|
3985
|
+
function normalizeSessionMessages(actions, sessionCapable) {
|
|
3986
|
+
if (!sessionCapable) {
|
|
3987
|
+
return actions;
|
|
3988
|
+
}
|
|
3989
|
+
const messages = actions.filter((action) => action.type === "message");
|
|
3990
|
+
if (messages.length <= 1) {
|
|
3991
|
+
return actions;
|
|
3992
|
+
}
|
|
3993
|
+
const collapsedText = messages.map((message) => message.text).join("\n\n");
|
|
3994
|
+
const collapsedMessage = { type: "message", text: collapsedText };
|
|
3995
|
+
let emittedCollapsedMessage = false;
|
|
3996
|
+
return actions.flatMap((action) => {
|
|
3997
|
+
if (action.type !== "message") {
|
|
3998
|
+
return [action];
|
|
3999
|
+
}
|
|
4000
|
+
if (emittedCollapsedMessage) {
|
|
4001
|
+
return [];
|
|
4002
|
+
}
|
|
4003
|
+
emittedCollapsedMessage = true;
|
|
4004
|
+
return [collapsedMessage];
|
|
4005
|
+
});
|
|
4006
|
+
}
|
|
3981
4007
|
async function processActions(iterationContext, response) {
|
|
3982
4008
|
validateActionSequence(response.nextActions);
|
|
4009
|
+
const normalizedActions = normalizeSessionMessages(response.nextActions, !!iterationContext.config.sessionCapable);
|
|
3983
4010
|
let shouldComplete = false;
|
|
3984
4011
|
const toolCalls = [];
|
|
3985
4012
|
const otherActions = [];
|
|
3986
|
-
for (const action of
|
|
4013
|
+
for (const action of normalizedActions) {
|
|
3987
4014
|
if (action.type === "tool-call") {
|
|
3988
4015
|
toolCalls.push(action);
|
|
3989
4016
|
} else {
|
|
@@ -4010,6 +4037,9 @@ async function processActions(iterationContext, response) {
|
|
|
4010
4037
|
}
|
|
4011
4038
|
}
|
|
4012
4039
|
}
|
|
4040
|
+
if (!shouldComplete && iterationContext.config.sessionCapable && toolCalls.length === 0 && normalizedActions.some((a) => a.type === "message") && !normalizedActions.some((a) => a.type === "navigate-knowledge")) {
|
|
4041
|
+
shouldComplete = true;
|
|
4042
|
+
}
|
|
4013
4043
|
return { shouldComplete };
|
|
4014
4044
|
}
|
|
4015
4045
|
|
|
@@ -6790,6 +6820,23 @@ function safeZodToJsonSchema(schema) {
|
|
|
6790
6820
|
}
|
|
6791
6821
|
return void 0;
|
|
6792
6822
|
}
|
|
6823
|
+
function serializeWorkerError(err) {
|
|
6824
|
+
const errorRecord = err instanceof Error ? err : void 0;
|
|
6825
|
+
const errorMessage = errorRecord?.message ?? String(err);
|
|
6826
|
+
const errorCode = err !== null && typeof err === "object" && "code" in err ? String(err.code) : "unknown";
|
|
6827
|
+
const errorName = errorRecord?.name ?? (err !== null && typeof err === "object" && err.constructor?.name ? err.constructor.name : "Error");
|
|
6828
|
+
const rawDetails = err !== null && typeof err === "object" && "details" in err ? err.details : void 0;
|
|
6829
|
+
const rawContext = err !== null && typeof err === "object" && "context" in err ? err.context : void 0;
|
|
6830
|
+
const details = rawDetails !== null && typeof rawDetails === "object" ? rawDetails : void 0;
|
|
6831
|
+
const context = rawContext !== null && typeof rawContext === "object" ? rawContext : void 0;
|
|
6832
|
+
return {
|
|
6833
|
+
error: `${errorName}: ${errorMessage}`,
|
|
6834
|
+
errorName,
|
|
6835
|
+
errorCode,
|
|
6836
|
+
...details ? { errorDetails: details } : {},
|
|
6837
|
+
...context ? { errorContext: context } : {}
|
|
6838
|
+
};
|
|
6839
|
+
}
|
|
6793
6840
|
function serializeNext(next) {
|
|
6794
6841
|
if (next === null) return null;
|
|
6795
6842
|
if (next.type === "linear") return { type: "linear", target: next.target };
|
|
@@ -6971,11 +7018,12 @@ function startWorker(org) {
|
|
|
6971
7018
|
parentPort.postMessage({ type: "result", status: "completed", output, logs, metrics: { durationMs } });
|
|
6972
7019
|
} catch (err) {
|
|
6973
7020
|
const durationMs = Date.now() - startTime;
|
|
6974
|
-
|
|
7021
|
+
const serializedError = serializeWorkerError(err);
|
|
7022
|
+
console.error(`[SDK-WORKER] Workflow '${resourceId}' failed (${durationMs}ms): ${serializedError.error}`);
|
|
6975
7023
|
parentPort.postMessage({
|
|
6976
7024
|
type: "result",
|
|
6977
7025
|
status: "failed",
|
|
6978
|
-
|
|
7026
|
+
...serializedError,
|
|
6979
7027
|
logs: [],
|
|
6980
7028
|
metrics: { durationMs }
|
|
6981
7029
|
});
|
|
@@ -7003,20 +7051,28 @@ function startWorker(org) {
|
|
|
7003
7051
|
signal: localAbortController.signal
|
|
7004
7052
|
});
|
|
7005
7053
|
const output = await agentInstance.execute(input, context);
|
|
7054
|
+
const memorySnapshot = agentInstance.getMemorySnapshot();
|
|
7055
|
+
if (!memorySnapshot) {
|
|
7056
|
+
throw new Error("Agent did not produce memory snapshot");
|
|
7057
|
+
}
|
|
7006
7058
|
const durationMs = Date.now() - startTime;
|
|
7007
7059
|
console.log(`[SDK-WORKER] Agent '${resourceId}' completed (${durationMs}ms)`);
|
|
7008
|
-
parentPort.postMessage({
|
|
7060
|
+
parentPort.postMessage({
|
|
7061
|
+
type: "result",
|
|
7062
|
+
status: "completed",
|
|
7063
|
+
output,
|
|
7064
|
+
memorySnapshot,
|
|
7065
|
+
logs,
|
|
7066
|
+
metrics: { durationMs }
|
|
7067
|
+
});
|
|
7009
7068
|
} catch (err) {
|
|
7010
7069
|
const durationMs = Date.now() - startTime;
|
|
7011
|
-
const
|
|
7012
|
-
|
|
7013
|
-
err !== null && typeof err === "object" && "code" in err ? String(err.code) : "unknown";
|
|
7014
|
-
const errorName = errorRecord?.name ?? (err !== null && typeof err === "object" && err.constructor?.name ? err.constructor.name : "Error");
|
|
7015
|
-
console.error(`[SDK-WORKER] Agent '${resourceId}' failed (${durationMs}ms): [${errorName}] ${errorMessage}`);
|
|
7070
|
+
const serializedError = serializeWorkerError(err);
|
|
7071
|
+
console.error(`[SDK-WORKER] Agent '${resourceId}' failed (${durationMs}ms): ${serializedError.error}`);
|
|
7016
7072
|
parentPort.postMessage({
|
|
7017
7073
|
type: "result",
|
|
7018
7074
|
status: "failed",
|
|
7019
|
-
|
|
7075
|
+
...serializedError,
|
|
7020
7076
|
logs,
|
|
7021
7077
|
metrics: { durationMs }
|
|
7022
7078
|
});
|
|
@@ -7030,6 +7086,8 @@ function startWorker(org) {
|
|
|
7030
7086
|
type: "result",
|
|
7031
7087
|
status: "failed",
|
|
7032
7088
|
error: `Resource not found: ${resourceId}`,
|
|
7089
|
+
errorName: "ResourceNotFoundError",
|
|
7090
|
+
errorCode: "resource_not_found",
|
|
7033
7091
|
logs: []
|
|
7034
7092
|
});
|
|
7035
7093
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elevasis/sdk",
|
|
3
|
-
"version": "1.35.
|
|
3
|
+
"version": "1.35.1",
|
|
4
4
|
"description": "SDK for building Elevasis organization resources",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"tsup": "^8.0.0",
|
|
59
59
|
"typescript": "5.9.2",
|
|
60
60
|
"zod": "^4.1.0",
|
|
61
|
-
"@repo/core": "0.48.
|
|
61
|
+
"@repo/core": "0.48.1",
|
|
62
62
|
"@repo/eslint-config": "0.0.0",
|
|
63
63
|
"@repo/typescript-config": "0.0.0"
|
|
64
64
|
},
|
package/reference/rules/ui.md
CHANGED
|
@@ -122,16 +122,19 @@ The API URL is centralized in `ui/src/lib/constants/api.ts`. In the current temp
|
|
|
122
122
|
|
|
123
123
|
## Route Structure
|
|
124
124
|
|
|
125
|
-
Current top-level app sections:
|
|
126
|
-
|
|
127
|
-
- `/` -- host-local dashboard entrypoint with quick links derived from `organizationModel.navigation.quickAccessSurfaceIds`
|
|
128
|
-
- `/
|
|
125
|
+
Current top-level app sections:
|
|
126
|
+
|
|
127
|
+
- `/` -- host-local dashboard entrypoint with quick links derived from `organizationModel.navigation.quickAccessSurfaceIds`
|
|
128
|
+
- `/public/agents/$slug` -- public, unauthenticated agent chat route for grant-backed public agents
|
|
129
|
+
- `/lead-gen/*` -- lead generation pages (`lists`, `companies`, `contacts`)
|
|
129
130
|
- `/crm/*` -- CRM overview, pipeline, and deals
|
|
130
131
|
- `/projects/*` -- delivery feature pages (projects, milestones, tasks, notes)
|
|
131
132
|
- `/operations/*` -- operations overview, resources, command queue, command view, sessions, task scheduler
|
|
132
133
|
- `/monitoring/*` -- execution logs, execution health, activity log, cost analytics, notifications
|
|
133
134
|
- `/settings/*` -- account, organization, credentials, API keys, deployments, webhooks, and appearance
|
|
134
|
-
- `/login` and `/auth-redirect` -- auth entry/callback routes
|
|
135
|
+
- `/login` and `/auth-redirect` -- auth entry/callback routes
|
|
136
|
+
|
|
137
|
+
Public routes use the `/public/` prefix and must render outside the authenticated app chrome. Public agent pages should import `PublicAgentChatRoutePage` from `@elevasis/ui/features/public-agent-chat` and mount it at `/public/agents/$slug`. Keep `/chat/$slug` only as a compatibility alias when preserving existing links.
|
|
135
138
|
|
|
136
139
|
Section guards currently follow this pattern:
|
|
137
140
|
|
|
@@ -627,6 +627,8 @@ Knowledge map inspection. The `om:*` (Organization Model) commands expose knowle
|
|
|
627
627
|
|
|
628
628
|
For the full command reference, flag details, and graph architecture, see the [knowledge:\* CLI documentation](/technical/features/knowledge/cli-and-skill).
|
|
629
629
|
|
|
630
|
+
In tenant projects, SDK read commands load `core/config/organization-model.ts` through the SDK's layout-aware TypeScript loader. The temporary bundle and dependency resolution are anchored at the package root that owns SDK dependencies, so hoisted pnpm workspaces resolve `esbuild` and `@elevasis/core` correctly. Missing org-model files still return the default model; malformed files or files with no usable export emit diagnostics. `knowledge:generate` / `om:generate` is the exception because it reads MDX and codegen inputs directly.
|
|
631
|
+
|
|
630
632
|
**Quick reference:**
|
|
631
633
|
|
|
632
634
|
```bash
|