@elevasis/sdk 1.11.0 → 1.12.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 +31 -8
- package/dist/index.d.ts +345 -48
- package/dist/index.js +210 -8
- package/dist/test-utils/index.d.ts +216 -40
- package/dist/test-utils/index.js +4756 -125
- package/dist/types/worker/adapters/llm.d.ts +1 -1
- package/dist/worker/index.js +10 -4
- package/package.json +2 -2
- package/reference/claude-config/rules/agent-start-here.md +14 -14
- package/reference/claude-config/skills/configure/SKILL.md +3 -3
- package/reference/claude-config/skills/setup/SKILL.md +6 -6
- package/reference/claude-config/sync-notes/2026-04-25-auth-role-system-and-settings-roles.md +55 -0
- package/reference/claude-config/sync-notes/2026-04-27-crm-hitl-action-layer-cutover.md +101 -0
- package/reference/cli.mdx +57 -0
- package/reference/examples/organization-model.ts +3 -0
- package/reference/packages/core/src/organization-model/README.md +1 -0
- package/reference/scaffold/core/organization-graph.mdx +5 -2
- package/reference/scaffold/core/organization-model.mdx +6 -0
- package/reference/scaffold/index.mdx +3 -0
- package/reference/scaffold/operations/propagation-pipeline.md +4 -1
- package/reference/scaffold/operations/scaffold-maintenance.md +3 -0
- package/reference/scaffold/operations/workflow-recipes.md +13 -10
- package/reference/scaffold/recipes/add-a-feature.md +3 -0
- package/reference/scaffold/recipes/add-a-resource.md +3 -0
- package/reference/scaffold/recipes/customize-organization-model.md +3 -0
- package/reference/scaffold/recipes/extend-a-base-entity.md +11 -8
- package/reference/scaffold/recipes/gate-by-feature-or-admin.md +3 -0
- package/reference/scaffold/recipes/index.md +3 -0
- package/reference/scaffold/reference/contracts.md +62 -304
- package/reference/scaffold/reference/feature-registry.md +5 -2
- package/reference/scaffold/reference/glossary.md +3 -0
- package/reference/scaffold/ui/composition-extensibility.mdx +3 -0
- package/reference/scaffold/ui/customization.md +3 -0
- package/reference/scaffold/ui/feature-flags-and-gating.md +3 -0
- package/reference/scaffold/ui/feature-shell.mdx +3 -0
- package/reference/scaffold/ui/recipes.md +3 -0
- package/reference/claude-config/logs/pre-edit-vibe-gate.log +0 -40
- package/reference/claude-config/logs/scaffold-registry-reminder.log +0 -38
package/dist/index.js
CHANGED
|
@@ -3052,6 +3052,12 @@ var ResourceRegistry = class {
|
|
|
3052
3052
|
* Static and remote resources coexist in the same org.
|
|
3053
3053
|
*/
|
|
3054
3054
|
remoteResources = /* @__PURE__ */ new Map();
|
|
3055
|
+
/**
|
|
3056
|
+
* System configs for first-class platform resources.
|
|
3057
|
+
* Key: "orgName/resourceId", Value: SystemConfig.
|
|
3058
|
+
* Registered at startup alongside registerStaticResources().
|
|
3059
|
+
*/
|
|
3060
|
+
systemConfigs = /* @__PURE__ */ new Map();
|
|
3055
3061
|
/**
|
|
3056
3062
|
* Validates registry on construction
|
|
3057
3063
|
* - Checks for duplicate resourceIds within organizations
|
|
@@ -3099,7 +3105,9 @@ var ResourceRegistry = class {
|
|
|
3099
3105
|
if (!existingOrg) return void 0;
|
|
3100
3106
|
const remoteIds = this.getRemoteResourceIds(orgName);
|
|
3101
3107
|
if (remoteIds.size === 0) return existingOrg;
|
|
3102
|
-
const relationships = existingOrg.relationships ? Object.fromEntries(
|
|
3108
|
+
const relationships = existingOrg.relationships ? Object.fromEntries(
|
|
3109
|
+
Object.entries(existingOrg.relationships).filter(([resourceId]) => !remoteIds.has(resourceId))
|
|
3110
|
+
) : void 0;
|
|
3103
3111
|
return {
|
|
3104
3112
|
...existingOrg,
|
|
3105
3113
|
version: existingOrg.version ?? "0.0.0",
|
|
@@ -3409,18 +3417,33 @@ var ResourceRegistry = class {
|
|
|
3409
3417
|
}
|
|
3410
3418
|
}
|
|
3411
3419
|
/**
|
|
3412
|
-
* Get remote configuration for a specific resource
|
|
3420
|
+
* Get remote configuration for a specific resource.
|
|
3413
3421
|
*
|
|
3414
|
-
* Returns
|
|
3415
|
-
* or null
|
|
3416
|
-
* Used by the execution coordinator to
|
|
3422
|
+
* Returns RemoteOrgConfig for externally-deployed resources, SystemConfig for
|
|
3423
|
+
* first-class platform resources, or null for static in-process resources.
|
|
3424
|
+
* Used by the execution coordinator to determine the execution path.
|
|
3417
3425
|
*
|
|
3418
3426
|
* @param orgName - Organization name
|
|
3419
3427
|
* @param resourceId - Resource ID
|
|
3420
|
-
* @returns Remote config or null
|
|
3428
|
+
* @returns Remote or System config, or null
|
|
3421
3429
|
*/
|
|
3422
3430
|
getRemoteConfig(orgName, resourceId) {
|
|
3423
|
-
|
|
3431
|
+
const key = `${orgName}/${resourceId}`;
|
|
3432
|
+
return this.remoteResources.get(key) ?? this.systemConfigs.get(key) ?? null;
|
|
3433
|
+
}
|
|
3434
|
+
/**
|
|
3435
|
+
* Register a System config for a first-class platform resource.
|
|
3436
|
+
*
|
|
3437
|
+
* Called at startup alongside registerStaticResources() so that
|
|
3438
|
+
* getRemoteConfig('system', resourceId) returns truthy and the execution
|
|
3439
|
+
* coordinator routes the resource through the worker-thread path.
|
|
3440
|
+
*
|
|
3441
|
+
* @param orgName - Organization name (typically 'system')
|
|
3442
|
+
* @param resourceId - Resource ID
|
|
3443
|
+
* @param config - SystemConfig with kind:'static' and moduleId
|
|
3444
|
+
*/
|
|
3445
|
+
registerSystemConfig(orgName, resourceId, config) {
|
|
3446
|
+
this.systemConfigs.set(`${orgName}/${resourceId}`, config);
|
|
3424
3447
|
}
|
|
3425
3448
|
/**
|
|
3426
3449
|
* Check if an organization has any remote (externally deployed) resources
|
|
@@ -3643,5 +3666,184 @@ var ResourceRegistry = class {
|
|
|
3643
3666
|
return results;
|
|
3644
3667
|
}
|
|
3645
3668
|
};
|
|
3669
|
+
var StageChangeEventSchema = z.object({
|
|
3670
|
+
type: z.literal("stage_change"),
|
|
3671
|
+
timestamp: z.string().datetime(),
|
|
3672
|
+
stageBefore: z.string(),
|
|
3673
|
+
stageAfter: z.string(),
|
|
3674
|
+
reason: z.string().optional()
|
|
3675
|
+
});
|
|
3676
|
+
var StateChangeEventSchema = z.object({
|
|
3677
|
+
type: z.literal("state_change"),
|
|
3678
|
+
timestamp: z.string().datetime(),
|
|
3679
|
+
stateBefore: z.string().nullable(),
|
|
3680
|
+
stateAfter: z.string().nullable(),
|
|
3681
|
+
reason: z.string().optional()
|
|
3682
|
+
});
|
|
3683
|
+
var ActionTakenEventSchema = z.object({
|
|
3684
|
+
type: z.literal("action_taken"),
|
|
3685
|
+
timestamp: z.string().datetime(),
|
|
3686
|
+
actionKey: z.string(),
|
|
3687
|
+
payload: z.record(z.string(), z.unknown()).optional()
|
|
3688
|
+
});
|
|
3689
|
+
var ApprovalCreatedEventSchema = z.object({
|
|
3690
|
+
type: z.literal("approval_created"),
|
|
3691
|
+
timestamp: z.string().datetime(),
|
|
3692
|
+
commandId: z.string(),
|
|
3693
|
+
dealStageBefore: z.string().optional(),
|
|
3694
|
+
dealStageAfter: z.string().optional()
|
|
3695
|
+
});
|
|
3696
|
+
var ApprovalResolvedEventSchema = z.object({
|
|
3697
|
+
type: z.literal("approval_resolved"),
|
|
3698
|
+
timestamp: z.string().datetime(),
|
|
3699
|
+
commandId: z.string(),
|
|
3700
|
+
resolution: z.enum(["superseded"]),
|
|
3701
|
+
originResourceType: z.string().optional()
|
|
3702
|
+
});
|
|
3703
|
+
var ApprovalStaleEventSchema = z.object({
|
|
3704
|
+
type: z.literal("approval_stale"),
|
|
3705
|
+
timestamp: z.string().datetime(),
|
|
3706
|
+
commandId: z.string(),
|
|
3707
|
+
dealStageBefore: z.string().optional(),
|
|
3708
|
+
dealStageAfter: z.string().optional()
|
|
3709
|
+
});
|
|
3710
|
+
var TaskCreatedEventSchema = z.object({
|
|
3711
|
+
type: z.literal("task_created"),
|
|
3712
|
+
timestamp: z.string().datetime(),
|
|
3713
|
+
taskId: z.string()
|
|
3714
|
+
});
|
|
3715
|
+
var DealCreatedEventSchema = z.object({
|
|
3716
|
+
type: z.literal("deal_created"),
|
|
3717
|
+
timestamp: z.string().datetime()
|
|
3718
|
+
});
|
|
3719
|
+
var ReplyReceivedEventSchema = z.object({
|
|
3720
|
+
type: z.literal("reply_received"),
|
|
3721
|
+
timestamp: z.string().datetime(),
|
|
3722
|
+
messageId: z.string().optional(),
|
|
3723
|
+
source: z.string().optional()
|
|
3724
|
+
});
|
|
3725
|
+
var ReplySentToLeadEventSchema = z.object({
|
|
3726
|
+
type: z.literal("reply_sent_to_lead"),
|
|
3727
|
+
timestamp: z.string().datetime(),
|
|
3728
|
+
messageId: z.string().optional(),
|
|
3729
|
+
source: z.string().optional()
|
|
3730
|
+
});
|
|
3731
|
+
var BookingNudgeSentEventSchema = z.object({
|
|
3732
|
+
type: z.literal("booking_nudge_sent"),
|
|
3733
|
+
timestamp: z.string().datetime(),
|
|
3734
|
+
followupDay: z.number()
|
|
3735
|
+
});
|
|
3736
|
+
var ReminderSentEventSchema = z.object({
|
|
3737
|
+
type: z.literal("reminder_sent"),
|
|
3738
|
+
timestamp: z.string().datetime(),
|
|
3739
|
+
followupDay: z.number().optional()
|
|
3740
|
+
});
|
|
3741
|
+
var BookingCancelledEventSchema = z.object({
|
|
3742
|
+
type: z.literal("booking_cancelled"),
|
|
3743
|
+
timestamp: z.string().datetime(),
|
|
3744
|
+
reason: z.string().optional()
|
|
3745
|
+
});
|
|
3746
|
+
var DiscoverySubmittedEventSchema = z.object({
|
|
3747
|
+
type: z.literal("discovery_submitted"),
|
|
3748
|
+
timestamp: z.string().datetime()
|
|
3749
|
+
});
|
|
3750
|
+
var MovedToNurturingEventSchema = z.object({
|
|
3751
|
+
type: z.literal("moved_to_nurturing"),
|
|
3752
|
+
timestamp: z.string().datetime()
|
|
3753
|
+
});
|
|
3754
|
+
var NoShowEventSchema = z.object({
|
|
3755
|
+
type: z.literal("no_show"),
|
|
3756
|
+
timestamp: z.string().datetime()
|
|
3757
|
+
});
|
|
3758
|
+
var FollowupEmailSentEventSchema = z.object({
|
|
3759
|
+
type: z.literal("followup_email_sent"),
|
|
3760
|
+
timestamp: z.string().datetime(),
|
|
3761
|
+
followupDay: z.number().optional()
|
|
3762
|
+
});
|
|
3763
|
+
var ActivityEventSchema = z.discriminatedUnion("type", [
|
|
3764
|
+
StageChangeEventSchema,
|
|
3765
|
+
StateChangeEventSchema,
|
|
3766
|
+
ActionTakenEventSchema,
|
|
3767
|
+
ApprovalCreatedEventSchema,
|
|
3768
|
+
ApprovalResolvedEventSchema,
|
|
3769
|
+
ApprovalStaleEventSchema,
|
|
3770
|
+
TaskCreatedEventSchema,
|
|
3771
|
+
DealCreatedEventSchema,
|
|
3772
|
+
ReplyReceivedEventSchema,
|
|
3773
|
+
ReplySentToLeadEventSchema,
|
|
3774
|
+
BookingNudgeSentEventSchema,
|
|
3775
|
+
ReminderSentEventSchema,
|
|
3776
|
+
BookingCancelledEventSchema,
|
|
3777
|
+
DiscoverySubmittedEventSchema,
|
|
3778
|
+
MovedToNurturingEventSchema,
|
|
3779
|
+
NoShowEventSchema,
|
|
3780
|
+
FollowupEmailSentEventSchema
|
|
3781
|
+
]);
|
|
3782
|
+
|
|
3783
|
+
// ../core/src/business/acquisition/derive-actions.ts
|
|
3784
|
+
var STAGE_ORDER = ["interested", "proposal", "closing", "closed_won", "closed_lost", "nurturing"];
|
|
3785
|
+
function isDefaultStage(key) {
|
|
3786
|
+
return STAGE_ORDER.includes(key);
|
|
3787
|
+
}
|
|
3788
|
+
function transitionAction(stageKey) {
|
|
3789
|
+
const labels = {
|
|
3790
|
+
interested: "Move to Interested",
|
|
3791
|
+
proposal: "Move to Proposal",
|
|
3792
|
+
closing: "Move to Closing",
|
|
3793
|
+
closed_won: "Close Won",
|
|
3794
|
+
closed_lost: "Close Lost",
|
|
3795
|
+
nurturing: "Move to Nurturing"
|
|
3796
|
+
};
|
|
3797
|
+
return {
|
|
3798
|
+
key: `move_to_${stageKey}`,
|
|
3799
|
+
label: labels[stageKey],
|
|
3800
|
+
kind: "transition",
|
|
3801
|
+
payload: { stageKey }
|
|
3802
|
+
};
|
|
3803
|
+
}
|
|
3804
|
+
function interestedActions(stateKey) {
|
|
3805
|
+
const base = [transitionAction("proposal"), transitionAction("closed_lost"), transitionAction("nurturing")];
|
|
3806
|
+
if (stateKey === "discovery_replied") {
|
|
3807
|
+
return [...base, { key: "send_link", label: "Send Booking Link", kind: "modal" }];
|
|
3808
|
+
}
|
|
3809
|
+
if (stateKey === "discovery_link_sent") {
|
|
3810
|
+
return [...base, { key: "send_nudge", label: "Send Nudge", kind: "modal" }];
|
|
3811
|
+
}
|
|
3812
|
+
if (stateKey === "discovery_nudging") {
|
|
3813
|
+
return [
|
|
3814
|
+
...base,
|
|
3815
|
+
{ key: "send_nudge", label: "Send Nudge", kind: "modal" },
|
|
3816
|
+
{ key: "mark_no_show", label: "Mark No-Show", kind: "transition" }
|
|
3817
|
+
];
|
|
3818
|
+
}
|
|
3819
|
+
if (stateKey === "discovery_booking_cancelled") {
|
|
3820
|
+
return [...base, { key: "rebook", label: "Rebook", kind: "modal" }];
|
|
3821
|
+
}
|
|
3822
|
+
return base;
|
|
3823
|
+
}
|
|
3824
|
+
function proposalActions() {
|
|
3825
|
+
return [transitionAction("closing"), transitionAction("closed_lost"), transitionAction("nurturing")];
|
|
3826
|
+
}
|
|
3827
|
+
function closingActions() {
|
|
3828
|
+
return [transitionAction("closed_won"), transitionAction("closed_lost"), transitionAction("nurturing")];
|
|
3829
|
+
}
|
|
3830
|
+
function deriveActions(deal) {
|
|
3831
|
+
const stage = deal.stage_key;
|
|
3832
|
+
if (!isDefaultStage(stage)) {
|
|
3833
|
+
return [];
|
|
3834
|
+
}
|
|
3835
|
+
switch (stage) {
|
|
3836
|
+
case "interested":
|
|
3837
|
+
return interestedActions(deal.state_key);
|
|
3838
|
+
case "proposal":
|
|
3839
|
+
return proposalActions();
|
|
3840
|
+
case "closing":
|
|
3841
|
+
return closingActions();
|
|
3842
|
+
case "closed_won":
|
|
3843
|
+
case "closed_lost":
|
|
3844
|
+
case "nurturing":
|
|
3845
|
+
return [];
|
|
3846
|
+
}
|
|
3847
|
+
}
|
|
3646
3848
|
|
|
3647
|
-
export { ExecutionError, RegistryValidationError, ResourceRegistry, StepType, ToolingError };
|
|
3849
|
+
export { ActivityEventSchema, ExecutionError, RegistryValidationError, ResourceRegistry, StepType, ToolingError, deriveActions };
|