@sellable/mcp 0.1.640 → 0.1.642

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.
@@ -745,9 +745,127 @@ export declare function executeRefillSendsCommand(input?: RefillSendsCommandInpu
745
745
  status: string;
746
746
  workspaceTargetPlan: unknown;
747
747
  selectedTarget?: undefined;
748
+ exactTargetPlan?: undefined;
749
+ note?: undefined;
750
+ completedTarget?: undefined;
751
+ exactRunResult?: undefined;
752
+ };
753
+ continuation: {
754
+ required: boolean;
755
+ userActionRequired: boolean;
756
+ kind?: undefined;
757
+ owner?: undefined;
758
+ tool?: undefined;
759
+ arguments?: undefined;
760
+ stopCondition?: undefined;
761
+ };
762
+ targetDate: string | null;
763
+ untilDate: string | null;
764
+ horizonSendDays: number | null;
765
+ fillWindow: {
766
+ mode: string;
767
+ targetDate: string;
768
+ description: string;
769
+ untilDate?: undefined;
770
+ horizonSendDays?: undefined;
771
+ horizonHours?: undefined;
772
+ } | {
773
+ mode: string;
774
+ untilDate: string;
775
+ description: string;
776
+ targetDate?: undefined;
777
+ horizonSendDays?: undefined;
778
+ horizonHours?: undefined;
779
+ } | {
780
+ mode: string;
781
+ horizonSendDays: number | null;
782
+ horizonHours: number | null;
783
+ description: string;
784
+ targetDate?: undefined;
785
+ untilDate?: undefined;
786
+ };
787
+ approvalMode: RefillSendsApprovalMode;
788
+ campaignId: string | null;
789
+ tableId: string | null;
790
+ targetConfig: RefillTargetConfigV1 | null;
791
+ runHandle: RefillRunHandleV1 | null;
792
+ reportingContext: RefillReportingContextV2 | null;
793
+ messageTemplateRevision: MessageTemplateRevisionV1 | null;
794
+ senderScope: string;
795
+ senderSelectors: {
796
+ senders: string[];
797
+ senderIds: string[];
798
+ senderNames: string[];
799
+ };
800
+ firstOperationalSteps: string[];
801
+ approvalContract: string;
802
+ forbiddenActions: string[];
803
+ hostExamples: {
804
+ claude: string[];
805
+ codex: string[];
806
+ mcpTool: {
807
+ name: string;
808
+ arguments: {
809
+ workspaceCoordinator?: boolean | undefined;
810
+ messageTemplateRevision?: MessageTemplateRevisionV1 | undefined;
811
+ reportingContext?: RefillReportingContextV2 | undefined;
812
+ targetConfig?: RefillTargetConfigV1 | undefined;
813
+ runHandle?: RefillRunHandleV1 | undefined;
814
+ fence?: number | undefined;
815
+ runId?: string | undefined;
816
+ expectedActionKey?: string | undefined;
817
+ expectedTargetShapeRevision?: string | undefined;
818
+ targetDate: string | null;
819
+ untilDate: string | null;
820
+ horizonSendDays: number | null;
821
+ campaignId: string | undefined;
822
+ tableId: string | undefined;
823
+ intent: RefillSendsIntent;
824
+ approvalMode: RefillSendsApprovalMode;
825
+ workspaceId: string | null;
826
+ actionTypes?: ("send_invite" | "send_inmail_closed")[] | undefined;
827
+ yolo: boolean;
828
+ senders: string[];
829
+ senderIds: string[];
830
+ senderNames: string[];
831
+ };
832
+ };
833
+ };
834
+ actionTypes?: ("send_invite" | "send_inmail_closed")[] | undefined;
835
+ command: string;
836
+ tool: string;
837
+ promptName: string;
838
+ workflowPromptName: string;
839
+ workflowAsset: {
840
+ subskillName: string;
841
+ assetPath: string;
842
+ };
843
+ yolo: boolean;
844
+ executionMode: RefillSendsExecutionMode;
845
+ workspaceId: string | null;
846
+ workspaceResolution: string;
847
+ intent: RefillSendsIntent;
848
+ } | {
849
+ status: "terminal";
850
+ doneReason: "loaded_awaiting_scheduler";
851
+ note: string;
852
+ targetPlan: unknown;
853
+ exactTargetPlan: unknown;
854
+ orchestration: {
855
+ mode: string;
856
+ scope: string;
857
+ checkpointedFields: string[];
858
+ transportBudgetMs: number;
859
+ };
860
+ coordinator: {
861
+ scope: string;
862
+ status: string;
863
+ selectedTarget: WorkspaceExactTarget;
864
+ workspaceTargetPlan: unknown;
865
+ exactTargetPlan: unknown;
866
+ note: string;
748
867
  completedTarget?: undefined;
749
868
  exactRunResult?: undefined;
750
- note?: undefined;
751
869
  };
752
870
  continuation: {
753
871
  required: boolean;
@@ -857,9 +975,10 @@ export declare function executeRefillSendsCommand(input?: RefillSendsCommandInpu
857
975
  status: string;
858
976
  selectedTarget: WorkspaceExactTarget | null;
859
977
  workspaceTargetPlan?: undefined;
978
+ exactTargetPlan?: undefined;
979
+ note?: undefined;
860
980
  completedTarget?: undefined;
861
981
  exactRunResult?: undefined;
862
- note?: undefined;
863
982
  };
864
983
  continuation: {
865
984
  required: boolean;
@@ -1079,6 +1198,7 @@ export declare function executeRefillSendsCommand(input?: RefillSendsCommandInpu
1079
1198
  conflicts?: undefined;
1080
1199
  };
1081
1200
  selectedTarget?: undefined;
1201
+ exactTargetPlan?: undefined;
1082
1202
  note?: undefined;
1083
1203
  };
1084
1204
  continuation: {
@@ -1188,6 +1308,149 @@ export declare function executeRefillSendsCommand(input?: RefillSendsCommandInpu
1188
1308
  workspaceId: string | null;
1189
1309
  workspaceResolution: string;
1190
1310
  intent: RefillSendsIntent;
1311
+ } | {
1312
+ status: "terminal";
1313
+ doneReason: "loaded_awaiting_scheduler";
1314
+ note: string;
1315
+ targetPlan: unknown;
1316
+ exactTargetPlan: unknown;
1317
+ orchestration: {
1318
+ mode: string;
1319
+ scope: string;
1320
+ checkpointedFields: string[];
1321
+ transportBudgetMs: number;
1322
+ };
1323
+ coordinator: {
1324
+ scope: string;
1325
+ status: string;
1326
+ completedTarget: WorkspaceExactTarget | null;
1327
+ selectedTarget: WorkspaceExactTarget;
1328
+ workspaceTargetPlan: unknown;
1329
+ exactTargetPlan: unknown;
1330
+ exactRunResult: {
1331
+ runSnapshot: unknown;
1332
+ readOnly: boolean;
1333
+ forbiddenActions: string[];
1334
+ boundedAuthority: string;
1335
+ status: "terminal";
1336
+ doneReason: string;
1337
+ report: Record<string, unknown>;
1338
+ runId: string;
1339
+ guidance?: string;
1340
+ journalPath?: string | null;
1341
+ targetConfig?: RefillTargetConfigV1;
1342
+ runHandle?: RefillRunHandleV1;
1343
+ refillReporting?: Record<string, unknown>;
1344
+ blocker?: undefined;
1345
+ conflicts?: undefined;
1346
+ };
1347
+ note: string;
1348
+ };
1349
+ continuation: {
1350
+ required: boolean;
1351
+ userActionRequired: boolean;
1352
+ kind?: undefined;
1353
+ owner?: undefined;
1354
+ tool?: undefined;
1355
+ arguments?: undefined;
1356
+ stopCondition?: undefined;
1357
+ };
1358
+ runSnapshot: unknown;
1359
+ readOnly: boolean;
1360
+ forbiddenActions: string[];
1361
+ boundedAuthority: string;
1362
+ report: Record<string, unknown>;
1363
+ runId: string;
1364
+ guidance?: string;
1365
+ journalPath?: string | null;
1366
+ targetConfig: RefillTargetConfigV1 | null;
1367
+ runHandle: RefillRunHandleV1 | null;
1368
+ refillReporting?: Record<string, unknown>;
1369
+ blocker?: undefined;
1370
+ conflicts?: undefined;
1371
+ targetDate: string | null;
1372
+ untilDate: string | null;
1373
+ horizonSendDays: number | null;
1374
+ fillWindow: {
1375
+ mode: string;
1376
+ targetDate: string;
1377
+ description: string;
1378
+ untilDate?: undefined;
1379
+ horizonSendDays?: undefined;
1380
+ horizonHours?: undefined;
1381
+ } | {
1382
+ mode: string;
1383
+ untilDate: string;
1384
+ description: string;
1385
+ targetDate?: undefined;
1386
+ horizonSendDays?: undefined;
1387
+ horizonHours?: undefined;
1388
+ } | {
1389
+ mode: string;
1390
+ horizonSendDays: number | null;
1391
+ horizonHours: number | null;
1392
+ description: string;
1393
+ targetDate?: undefined;
1394
+ untilDate?: undefined;
1395
+ };
1396
+ approvalMode: RefillSendsApprovalMode;
1397
+ campaignId: string | null;
1398
+ tableId: string | null;
1399
+ reportingContext: RefillReportingContextV2 | null;
1400
+ messageTemplateRevision: MessageTemplateRevisionV1 | null;
1401
+ senderScope: string;
1402
+ senderSelectors: {
1403
+ senders: string[];
1404
+ senderIds: string[];
1405
+ senderNames: string[];
1406
+ };
1407
+ firstOperationalSteps: string[];
1408
+ approvalContract: string;
1409
+ hostExamples: {
1410
+ claude: string[];
1411
+ codex: string[];
1412
+ mcpTool: {
1413
+ name: string;
1414
+ arguments: {
1415
+ workspaceCoordinator?: boolean | undefined;
1416
+ messageTemplateRevision?: MessageTemplateRevisionV1 | undefined;
1417
+ reportingContext?: RefillReportingContextV2 | undefined;
1418
+ targetConfig?: RefillTargetConfigV1 | undefined;
1419
+ runHandle?: RefillRunHandleV1 | undefined;
1420
+ fence?: number | undefined;
1421
+ runId?: string | undefined;
1422
+ expectedActionKey?: string | undefined;
1423
+ expectedTargetShapeRevision?: string | undefined;
1424
+ targetDate: string | null;
1425
+ untilDate: string | null;
1426
+ horizonSendDays: number | null;
1427
+ campaignId: string | undefined;
1428
+ tableId: string | undefined;
1429
+ intent: RefillSendsIntent;
1430
+ approvalMode: RefillSendsApprovalMode;
1431
+ workspaceId: string | null;
1432
+ actionTypes?: ("send_invite" | "send_inmail_closed")[] | undefined;
1433
+ yolo: boolean;
1434
+ senders: string[];
1435
+ senderIds: string[];
1436
+ senderNames: string[];
1437
+ };
1438
+ };
1439
+ };
1440
+ actionTypes?: ("send_invite" | "send_inmail_closed")[] | undefined;
1441
+ command: string;
1442
+ tool: string;
1443
+ promptName: string;
1444
+ workflowPromptName: string;
1445
+ workflowAsset: {
1446
+ subskillName: string;
1447
+ assetPath: string;
1448
+ };
1449
+ yolo: boolean;
1450
+ executionMode: RefillSendsExecutionMode;
1451
+ workspaceId: string | null;
1452
+ workspaceResolution: string;
1453
+ intent: RefillSendsIntent;
1191
1454
  } | {
1192
1455
  ok: boolean;
1193
1456
  status: "blocked";
@@ -1219,6 +1482,7 @@ export declare function executeRefillSendsCommand(input?: RefillSendsCommandInpu
1219
1482
  conflicts?: undefined;
1220
1483
  };
1221
1484
  workspaceTargetPlan?: undefined;
1485
+ exactTargetPlan?: undefined;
1222
1486
  note?: undefined;
1223
1487
  };
1224
1488
  continuation: {
@@ -1349,6 +1613,7 @@ export declare function executeRefillSendsCommand(input?: RefillSendsCommandInpu
1349
1613
  conflicts?: undefined;
1350
1614
  };
1351
1615
  note: string;
1616
+ exactTargetPlan?: undefined;
1352
1617
  };
1353
1618
  continuation: {
1354
1619
  required: boolean;
@@ -1490,6 +1755,7 @@ export declare function executeRefillSendsCommand(input?: RefillSendsCommandInpu
1490
1755
  conflicts?: undefined;
1491
1756
  };
1492
1757
  workspaceTargetPlan?: undefined;
1758
+ exactTargetPlan?: undefined;
1493
1759
  note?: undefined;
1494
1760
  };
1495
1761
  continuation: {
@@ -1647,9 +1913,9 @@ export declare function executeRefillSendsCommand(input?: RefillSendsCommandInpu
1647
1913
  scope: string;
1648
1914
  status: string | undefined;
1649
1915
  selectedTarget: WorkspaceExactTarget | null;
1916
+ note?: undefined;
1650
1917
  completedTarget?: undefined;
1651
1918
  exactRunResult?: undefined;
1652
- note?: undefined;
1653
1919
  } | undefined;
1654
1920
  orchestration: {
1655
1921
  checkpointedFields: string[];
@@ -1796,9 +2062,9 @@ export declare function executeRefillSendsCommand(input?: RefillSendsCommandInpu
1796
2062
  scope: string;
1797
2063
  status: string | undefined;
1798
2064
  selectedTarget: WorkspaceExactTarget | null;
2065
+ note?: undefined;
1799
2066
  completedTarget?: undefined;
1800
2067
  exactRunResult?: undefined;
1801
- note?: undefined;
1802
2068
  } | undefined;
1803
2069
  orchestration: {
1804
2070
  checkpointedFields: string[];
@@ -1949,9 +2215,9 @@ export declare function executeRefillSendsCommand(input?: RefillSendsCommandInpu
1949
2215
  scope: string;
1950
2216
  status: string | undefined;
1951
2217
  selectedTarget: WorkspaceExactTarget | null;
2218
+ note?: undefined;
1952
2219
  completedTarget?: undefined;
1953
2220
  exactRunResult?: undefined;
1954
- note?: undefined;
1955
2221
  } | undefined;
1956
2222
  orchestration: {
1957
2223
  checkpointedFields: string[];
@@ -2102,9 +2368,9 @@ export declare function executeRefillSendsCommand(input?: RefillSendsCommandInpu
2102
2368
  scope: string;
2103
2369
  status: string | undefined;
2104
2370
  selectedTarget: WorkspaceExactTarget | null;
2371
+ note?: undefined;
2105
2372
  completedTarget?: undefined;
2106
2373
  exactRunResult?: undefined;
2107
- note?: undefined;
2108
2374
  } | undefined;
2109
2375
  orchestration: {
2110
2376
  checkpointedFields: string[];
@@ -2253,9 +2519,9 @@ export declare function executeRefillSendsCommand(input?: RefillSendsCommandInpu
2253
2519
  scope: string;
2254
2520
  status: string | undefined;
2255
2521
  selectedTarget: WorkspaceExactTarget | null;
2522
+ note?: undefined;
2256
2523
  completedTarget?: undefined;
2257
2524
  exactRunResult?: undefined;
2258
- note?: undefined;
2259
2525
  } | undefined;
2260
2526
  orchestration: {
2261
2527
  checkpointedFields: string[];
@@ -2407,9 +2673,9 @@ export declare function executeRefillSendsCommand(input?: RefillSendsCommandInpu
2407
2673
  scope: string;
2408
2674
  status: string | undefined;
2409
2675
  selectedTarget: WorkspaceExactTarget | null;
2676
+ note?: undefined;
2410
2677
  completedTarget?: undefined;
2411
2678
  exactRunResult?: undefined;
2412
- note?: undefined;
2413
2679
  } | undefined;
2414
2680
  orchestration: {
2415
2681
  checkpointedFields: string[];
@@ -2563,9 +2829,9 @@ export declare function executeRefillSendsCommand(input?: RefillSendsCommandInpu
2563
2829
  scope: string;
2564
2830
  status: string | undefined;
2565
2831
  selectedTarget: WorkspaceExactTarget | null;
2832
+ note?: undefined;
2566
2833
  completedTarget?: undefined;
2567
2834
  exactRunResult?: undefined;
2568
- note?: undefined;
2569
2835
  } | undefined;
2570
2836
  orchestration: {
2571
2837
  checkpointedFields: string[];
@@ -520,49 +520,67 @@ function workspaceCoordinatorInput(input) {
520
520
  delete coordinatorInput.agentKeywords;
521
521
  return coordinatorInput;
522
522
  }
523
- function firstRecordWithExactTarget(value) {
523
+ function recordsWithExactTarget(value) {
524
524
  return Array.isArray(value)
525
525
  ? value
526
526
  .map(recordValue)
527
- .find((candidate) => Boolean(stringValue(candidate?.campaignId)) &&
528
- Boolean(stringValue(candidate?.tableId)))
529
- : undefined;
527
+ .filter((candidate) => Boolean(candidate &&
528
+ stringValue(candidate.campaignId) &&
529
+ stringValue(candidate.tableId)))
530
+ : [];
530
531
  }
531
- function workspaceExactTargetFromAction(action) {
532
+ function workspaceExactTargetsFromAction(action) {
532
533
  const toolInput = recordValue(action.toolInput) ?? {};
533
- const exactEdge = firstRecordWithExactTarget(toolInput.expectedTargets) ??
534
- firstRecordWithExactTarget(toolInput.sourceScopes);
534
+ const expectedTargets = recordsWithExactTarget(toolInput.expectedTargets);
535
+ const sourceScopes = recordsWithExactTarget(toolInput.sourceScopes);
536
+ const exactEdges = expectedTargets.length > 0
537
+ ? expectedTargets
538
+ : sourceScopes.length > 0
539
+ ? sourceScopes
540
+ : [null];
535
541
  const campaignIds = normalizeStrings(toolInput.campaignIds);
536
542
  const tableIds = normalizeStrings(toolInput.tableIds);
537
- const campaignId = actionCampaignId(action) ??
538
- stringValue(exactEdge?.campaignId) ??
539
- campaignIds[0];
540
- const tableId = actionTableId(action) ?? stringValue(exactEdge?.tableId) ?? tableIds[0];
541
- if (!campaignId || !tableId)
542
- return null;
543
- const exactEdgeSenderIds = normalizeStrings(exactEdge?.senderIds);
544
- const senderId = actionSenderId(action) ?? stringValue(exactEdge?.senderId) ?? null;
545
- const senderIds = senderId
546
- ? [senderId]
547
- : exactEdgeSenderIds.length > 0
548
- ? exactEdgeSenderIds
549
- : normalizeStrings(toolInput.senderIds);
550
- const directActionType = stringValue(action.actionType) ??
551
- stringValue(exactEdge?.actionType) ??
552
- stringValue(exactEdge?.refillLaneKey);
553
- const exactEdgeActionTypes = normalizeStrings(exactEdge?.branchActionTypes);
554
- const actionTypes = directActionType && REFILL_SEND_ACTION_TYPE_SET.has(directActionType)
555
- ? [directActionType]
556
- : (exactEdgeActionTypes.length > 0
557
- ? exactEdgeActionTypes
558
- : normalizeStrings(toolInput.actionTypes)).filter((actionType) => REFILL_SEND_ACTION_TYPE_SET.has(actionType));
559
- return {
560
- campaignId,
561
- tableId,
562
- senderIds,
563
- actionTypes,
564
- actionKey: stringValue(action.actionKey) ?? null,
565
- };
543
+ return exactEdges.flatMap((exactEdge) => {
544
+ const campaignId = stringValue(exactEdge?.campaignId) ??
545
+ actionCampaignId(action) ??
546
+ campaignIds[0];
547
+ const tableId = stringValue(exactEdge?.tableId) ?? actionTableId(action) ?? tableIds[0];
548
+ if (!campaignId || !tableId)
549
+ return [];
550
+ const exactEdgeSenderIds = normalizeStrings(exactEdge?.senderIds);
551
+ const senderId = stringValue(exactEdge?.senderId) ?? actionSenderId(action) ?? null;
552
+ const senderIds = senderId
553
+ ? [senderId]
554
+ : exactEdgeSenderIds.length > 0
555
+ ? exactEdgeSenderIds
556
+ : normalizeStrings(toolInput.senderIds);
557
+ const directActionType = stringValue(exactEdge?.actionType) ??
558
+ stringValue(exactEdge?.refillLaneKey) ??
559
+ stringValue(action.actionType);
560
+ const exactEdgeActionTypes = normalizeStrings(exactEdge?.branchActionTypes);
561
+ const actionTypes = directActionType && REFILL_SEND_ACTION_TYPE_SET.has(directActionType)
562
+ ? [directActionType]
563
+ : (exactEdgeActionTypes.length > 0
564
+ ? exactEdgeActionTypes
565
+ : normalizeStrings(toolInput.actionTypes)).filter((actionType) => REFILL_SEND_ACTION_TYPE_SET.has(actionType));
566
+ return [
567
+ {
568
+ campaignId,
569
+ tableId,
570
+ senderIds,
571
+ actionTypes,
572
+ actionKey: stringValue(action.actionKey) ?? null,
573
+ },
574
+ ];
575
+ });
576
+ }
577
+ function workspaceExactTargetKey(target) {
578
+ return JSON.stringify([
579
+ target.campaignId,
580
+ target.tableId,
581
+ [...new Set(target.senderIds)].sort(),
582
+ [...new Set(target.actionTypes)].sort(),
583
+ ]);
566
584
  }
567
585
  function evergreenExactTargetCandidates(workspacePlan, options) {
568
586
  const root = recordValue(workspacePlan) ?? {};
@@ -647,16 +665,22 @@ async function selectWorkspaceExactTarget(input, workspacePlanOverride, options
647
665
  .filter((action) => Boolean(action))
648
666
  : [];
649
667
  const workspaceActions = [...globalActions, ...rankedCandidates];
650
- const selectedTarget = [
651
- ...workspaceActions.map(workspaceExactTargetFromAction),
652
- ...evergreenExactTargetCandidates(workspacePlan, {
653
- preferredSenderId: options.preferredSenderId,
654
- actionTypes: input.actionTypes,
655
- }),
656
- ].find((candidate) => Boolean(candidate) &&
657
- !excludedTargets.some((excluded) => excluded.campaignId === candidate?.campaignId &&
658
- excluded.tableId === candidate?.tableId));
659
- if (!selectedTarget) {
668
+ const actionTargets = workspaceActions.flatMap(workspaceExactTargetsFromAction);
669
+ const evergreenTargets = evergreenExactTargetCandidates(workspacePlan, {
670
+ preferredSenderId: options.preferredSenderId,
671
+ actionTypes: input.actionTypes,
672
+ }).filter((candidate) => !actionTargets.some((actionTarget) => actionTarget.campaignId === candidate.campaignId &&
673
+ actionTarget.tableId === candidate.tableId));
674
+ const seenTargetKeys = new Set();
675
+ const targetCandidates = [...actionTargets, ...evergreenTargets].filter((candidate) => {
676
+ const key = workspaceExactTargetKey(candidate);
677
+ if (seenTargetKeys.has(key))
678
+ return false;
679
+ seenTargetKeys.add(key);
680
+ return !excludedTargets.some((excluded) => excluded.campaignId === candidate.campaignId &&
681
+ excluded.tableId === candidate.tableId);
682
+ });
683
+ if (targetCandidates.length === 0) {
660
684
  return {
661
685
  status: "blocked",
662
686
  code: "workspace_exact_target_unavailable",
@@ -666,61 +690,92 @@ async function selectWorkspaceExactTarget(input, workspacePlanOverride, options
666
690
  workspacePlan,
667
691
  };
668
692
  }
669
- const exactInput = {
670
- ...workspaceInput,
671
- campaignId: selectedTarget.campaignId,
672
- tableId: selectedTarget.tableId,
673
- ...(selectedTarget.senderIds.length > 0
674
- ? { senderIds: selectedTarget.senderIds, senders: [], senderNames: [] }
675
- : {}),
676
- ...(selectedTarget.actionTypes.length > 0
677
- ? { actionTypes: selectedTarget.actionTypes }
678
- : {}),
679
- };
680
- const exactTargetPlan = await getRefillTargetPlan(targetPlanInputFor(exactInput));
681
- let targetConfig;
682
- try {
683
- targetConfig = normalizeRefillTargetConfig(recordValue(exactTargetPlan)?.targetConfig);
684
- }
685
- catch {
686
- return {
687
- status: "blocked",
688
- code: "exact_target_config_unavailable",
689
- note: "The exact read-only planner did not issue targetConfig. No refill run or mutation was started.",
690
- workspacePlan,
691
- exactTargetPlan,
692
- selectedTarget,
693
+ let completedExactTargetCount = 0;
694
+ let schedulerLoadedExactTargetCount = 0;
695
+ let lastSchedulerLoadedTarget = null;
696
+ let lastSchedulerLoadedPlan = null;
697
+ for (const selectedTarget of targetCandidates) {
698
+ const exactInput = {
699
+ ...workspaceInput,
700
+ campaignId: selectedTarget.campaignId,
701
+ tableId: selectedTarget.tableId,
702
+ ...(selectedTarget.senderIds.length > 0
703
+ ? { senderIds: selectedTarget.senderIds, senders: [], senderNames: [] }
704
+ : {}),
705
+ ...(selectedTarget.actionTypes.length > 0
706
+ ? { actionTypes: selectedTarget.actionTypes }
707
+ : {}),
693
708
  };
694
- }
695
- if (targetConfig.workspaceId !==
696
- normalizeExplicitWorkspaceId(input.workspaceId) ||
697
- targetConfig.campaignId !== selectedTarget.campaignId ||
698
- targetConfig.tableId !== selectedTarget.tableId) {
709
+ const exactTargetPlan = await getRefillTargetPlan(targetPlanInputFor(exactInput));
710
+ if (yoloPlanIsComplete(exactTargetPlan)) {
711
+ completedExactTargetCount += 1;
712
+ continue;
713
+ }
714
+ if (yoloPlanIsSchedulerLoaded(exactTargetPlan)) {
715
+ schedulerLoadedExactTargetCount += 1;
716
+ lastSchedulerLoadedTarget = selectedTarget;
717
+ lastSchedulerLoadedPlan = exactTargetPlan;
718
+ continue;
719
+ }
720
+ let targetConfig;
721
+ try {
722
+ targetConfig = normalizeRefillTargetConfig(recordValue(exactTargetPlan)?.targetConfig);
723
+ }
724
+ catch {
725
+ return {
726
+ status: "blocked",
727
+ code: "exact_target_config_unavailable",
728
+ note: "The exact read-only planner did not issue targetConfig. No refill run or mutation was started.",
729
+ workspacePlan,
730
+ exactTargetPlan,
731
+ selectedTarget,
732
+ };
733
+ }
734
+ if (targetConfig.workspaceId !==
735
+ normalizeExplicitWorkspaceId(input.workspaceId) ||
736
+ targetConfig.campaignId !== selectedTarget.campaignId ||
737
+ targetConfig.tableId !== selectedTarget.tableId) {
738
+ return {
739
+ status: "blocked",
740
+ code: "exact_target_config_mismatch",
741
+ note: "The server-issued targetConfig did not match the workspace queue's selected campaign/table. No refill run or mutation was started.",
742
+ workspacePlan,
743
+ exactTargetPlan,
744
+ selectedTarget,
745
+ };
746
+ }
747
+ if (!exactCampaignProjectionMatches(exactTargetPlan, selectedTarget.campaignId, selectedTarget.tableId)) {
748
+ return {
749
+ status: "blocked",
750
+ code: "exact_target_projection_mismatch",
751
+ note: "The live exact planner projection did not contain only the workspace queue's selected campaign/table. No refill run or mutation was started.",
752
+ workspacePlan,
753
+ exactTargetPlan,
754
+ selectedTarget,
755
+ };
756
+ }
699
757
  return {
700
- status: "blocked",
701
- code: "exact_target_config_mismatch",
702
- note: "The server-issued targetConfig did not match the workspace queue's selected campaign/table. No refill run or mutation was started.",
758
+ status: "selected",
703
759
  workspacePlan,
704
760
  exactTargetPlan,
705
761
  selectedTarget,
762
+ targetConfig,
706
763
  };
707
764
  }
708
- if (!exactCampaignProjectionMatches(exactTargetPlan, selectedTarget.campaignId, selectedTarget.tableId)) {
765
+ if (lastSchedulerLoadedTarget && lastSchedulerLoadedPlan) {
709
766
  return {
710
- status: "blocked",
711
- code: "exact_target_projection_mismatch",
712
- note: "The live exact planner projection did not contain only the workspace queue's selected campaign/table. No refill run or mutation was started.",
767
+ status: "awaiting_scheduler",
768
+ note: `All exposed exact targets were already complete or scheduler-loaded; ${schedulerLoadedExactTargetCount} exact targets have enough ready inventory to cover their projected gaps. No identical refill fence was reopened.`,
713
769
  workspacePlan,
714
- exactTargetPlan,
715
- selectedTarget,
770
+ exactTargetPlan: lastSchedulerLoadedPlan,
771
+ selectedTarget: lastSchedulerLoadedTarget,
716
772
  };
717
773
  }
718
774
  return {
719
- status: "selected",
775
+ status: "blocked",
776
+ code: "workspace_exact_target_unavailable",
777
+ note: `The fresh workspace queue remained incomplete, but all ${completedExactTargetCount} exposed exact targets were already complete. No identical refill fence was reopened.`,
720
778
  workspacePlan,
721
- exactTargetPlan,
722
- selectedTarget,
723
- targetConfig,
724
779
  };
725
780
  }
726
781
  function yoloCoverage(plan) {
@@ -744,6 +799,16 @@ function yoloPlanIsComplete(plan) {
744
799
  coverage.grossTarget > 0 &&
745
800
  coverage.remainingProjectedGap === 0));
746
801
  }
802
+ function yoloPlanIsSchedulerLoaded(plan) {
803
+ const coverage = yoloCoverage(plan);
804
+ return (coverage.status === "awaiting_scheduler_after_ready_buffer" ||
805
+ (coverage.status !== "blocked" &&
806
+ typeof coverage.grossTarget === "number" &&
807
+ coverage.grossTarget > 0 &&
808
+ typeof coverage.remainingProjectedGap === "number" &&
809
+ coverage.remainingProjectedGap > 0 &&
810
+ coverage.remainingReadyOrProjectedGap === 0));
811
+ }
747
812
  function workspaceConnectivityEmptyState(plan) {
748
813
  const target = yoloTarget(plan);
749
814
  const emptyState = recordValue(target?.emptyState);
@@ -1513,6 +1578,41 @@ export async function executeRefillSendsCommand(input = {}) {
1513
1578
  },
1514
1579
  };
1515
1580
  }
1581
+ if (coordinatorSelection.status === "awaiting_scheduler") {
1582
+ return {
1583
+ ...command,
1584
+ status: "terminal",
1585
+ doneReason: "loaded_awaiting_scheduler",
1586
+ note: coordinatorSelection.note,
1587
+ targetPlan: coordinatorSelection.workspacePlan,
1588
+ exactTargetPlan: coordinatorSelection.exactTargetPlan,
1589
+ orchestration: {
1590
+ mode: "fenced_bounded_yolo",
1591
+ scope: "workspace_exact_target_coordinator",
1592
+ checkpointedFields: [
1593
+ "runId",
1594
+ "fence",
1595
+ "runState",
1596
+ "actionKey",
1597
+ "requestId",
1598
+ "effectId",
1599
+ ],
1600
+ transportBudgetMs: 40_000,
1601
+ },
1602
+ coordinator: {
1603
+ scope: "workspace",
1604
+ status: "loaded_awaiting_scheduler",
1605
+ selectedTarget: coordinatorSelection.selectedTarget,
1606
+ workspaceTargetPlan: coordinatorSelection.workspacePlan,
1607
+ exactTargetPlan: coordinatorSelection.exactTargetPlan,
1608
+ note: coordinatorSelection.note,
1609
+ },
1610
+ continuation: {
1611
+ required: false,
1612
+ userActionRequired: false,
1613
+ },
1614
+ };
1615
+ }
1516
1616
  if (coordinatorSelection.status === "blocked") {
1517
1617
  return {
1518
1618
  ...command,
@@ -1737,6 +1837,44 @@ export async function executeRefillSendsCommand(input = {}) {
1737
1837
  },
1738
1838
  };
1739
1839
  }
1840
+ if (nextSelection.status === "awaiting_scheduler") {
1841
+ return {
1842
+ ...command,
1843
+ ...result,
1844
+ status: "terminal",
1845
+ doneReason: "loaded_awaiting_scheduler",
1846
+ note: nextSelection.note,
1847
+ targetPlan: nextSelection.workspacePlan,
1848
+ exactTargetPlan: nextSelection.exactTargetPlan,
1849
+ orchestration: {
1850
+ mode: "fenced_bounded_yolo",
1851
+ scope: "workspace_exact_target_coordinator",
1852
+ checkpointedFields: [
1853
+ "runId",
1854
+ "fence",
1855
+ "runState",
1856
+ "actionKey",
1857
+ "requestId",
1858
+ "effectId",
1859
+ ],
1860
+ transportBudgetMs: 40_000,
1861
+ },
1862
+ coordinator: {
1863
+ scope: "workspace",
1864
+ status: "loaded_awaiting_scheduler",
1865
+ completedTarget: selectedCoordinatorTarget,
1866
+ selectedTarget: nextSelection.selectedTarget,
1867
+ workspaceTargetPlan: nextSelection.workspacePlan,
1868
+ exactTargetPlan: nextSelection.exactTargetPlan,
1869
+ exactRunResult: result,
1870
+ note: nextSelection.note,
1871
+ },
1872
+ continuation: {
1873
+ required: false,
1874
+ userActionRequired: false,
1875
+ },
1876
+ };
1877
+ }
1740
1878
  if (nextSelection.status === "blocked") {
1741
1879
  return {
1742
1880
  ...command,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sellable/mcp",
3
- "version": "0.1.640",
3
+ "version": "0.1.642",
4
4
  "type": "module",
5
5
  "description": "Sellable MCP server for Claude Code, Codex, and Hermes campaign workflows",
6
6
  "main": "dist/index.js",