@elevasis/sdk 1.35.0 → 1.36.0
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 +187 -13
- package/dist/index.d.ts +80 -150
- package/dist/test-utils/index.d.ts +82 -152
- package/dist/test-utils/index.js +84 -26
- package/dist/types/worker/index.d.ts +2 -2
- package/dist/types/worker/platform.d.ts +1 -0
- package/dist/worker/index.js +84 -26
- package/package.json +4 -4
- package/reference/claude-config/registries/skill-coverage.json +1 -0
- package/reference/claude-config/sync-notes/2026-06-12-agent-grants-visualizer-operations.md +30 -0
- package/reference/rules/ui.md +8 -5
- package/reference/sdk/cli-management.mdx +2 -0
|
@@ -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,11 +10793,11 @@ 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
|
*
|
|
10870
|
-
* Worker -> Parent: { type: 'log', entry: { level, message, timestamp, executionId } }
|
|
10800
|
+
* Worker -> Parent: { type: 'log', entry: { level, message, timestamp, executionId, context? } }
|
|
10871
10801
|
*
|
|
10872
10802
|
* Worker -> Parent: { type: 'tool-call', id, tool, method, params, credential? }
|
|
10873
10803
|
* Parent -> Worker: { type: 'tool-result', id, result?, error?, code? }
|
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 };
|
|
@@ -10156,10 +10203,10 @@ async function executeWorkflow(workflow, input, context) {
|
|
|
10156
10203
|
}
|
|
10157
10204
|
function buildWorkerExecutionContext(params) {
|
|
10158
10205
|
const { executionId } = params;
|
|
10159
|
-
const postLog = (level, message) => {
|
|
10206
|
+
const postLog = (level, message, logContext) => {
|
|
10160
10207
|
parentPort.postMessage({
|
|
10161
10208
|
type: "log",
|
|
10162
|
-
entry: { level, message, timestamp: (/* @__PURE__ */ new Date()).toISOString(), executionId }
|
|
10209
|
+
entry: { level, message, timestamp: (/* @__PURE__ */ new Date()).toISOString(), executionId, context: logContext }
|
|
10163
10210
|
});
|
|
10164
10211
|
};
|
|
10165
10212
|
return {
|
|
@@ -10174,21 +10221,21 @@ function buildWorkerExecutionContext(params) {
|
|
|
10174
10221
|
signal: params.signal,
|
|
10175
10222
|
store: /* @__PURE__ */ new Map(),
|
|
10176
10223
|
logger: {
|
|
10177
|
-
debug: (msg) => {
|
|
10224
|
+
debug: (msg, logContext) => {
|
|
10178
10225
|
console.log(`[debug] ${msg}`);
|
|
10179
|
-
postLog("info", msg);
|
|
10226
|
+
postLog("info", msg, logContext);
|
|
10180
10227
|
},
|
|
10181
|
-
info: (msg) => {
|
|
10228
|
+
info: (msg, logContext) => {
|
|
10182
10229
|
console.log(`[info] ${msg}`);
|
|
10183
|
-
postLog("info", msg);
|
|
10230
|
+
postLog("info", msg, logContext);
|
|
10184
10231
|
},
|
|
10185
|
-
warn: (msg) => {
|
|
10232
|
+
warn: (msg, logContext) => {
|
|
10186
10233
|
console.warn(`[warn] ${msg}`);
|
|
10187
|
-
postLog("warn", msg);
|
|
10234
|
+
postLog("warn", msg, logContext);
|
|
10188
10235
|
},
|
|
10189
|
-
error: (msg) => {
|
|
10236
|
+
error: (msg, logContext) => {
|
|
10190
10237
|
console.error(`[error] ${msg}`);
|
|
10191
|
-
postLog("error", msg);
|
|
10238
|
+
postLog("error", msg, logContext);
|
|
10192
10239
|
}
|
|
10193
10240
|
},
|
|
10194
10241
|
onMessageEvent: async (event) => {
|
|
@@ -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,11 +12,11 @@
|
|
|
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
|
*
|
|
19
|
-
* Worker -> Parent: { type: 'log', entry: { level, message, timestamp, executionId } }
|
|
19
|
+
* Worker -> Parent: { type: 'log', entry: { level, message, timestamp, executionId, context? } }
|
|
20
20
|
*
|
|
21
21
|
* Worker -> Parent: { type: 'tool-call', id, tool, method, params, credential? }
|
|
22
22
|
* Parent -> Worker: { type: 'tool-result', id, result?, error?, code? }
|