@synap-core/workspace-templates 0.47.0 → 0.49.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/README.md +9 -2
- package/capabilities/postiz.capability.json +8 -4
- package/capabilities/unipile-linkedin.capability.json +39 -3
- package/dist/{define-BAPO0xZf.d.ts → define-Dto5_E47.d.ts} +15 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +244 -158
- package/dist/index.js.map +1 -1
- package/dist/wire.d.ts +1 -1
- package/package.json +1 -1
- package/src/brand-library.yaml +6 -6
- package/src/builder.yaml +17 -12
- package/src/content-os.template.test.ts +38 -22
- package/src/content-os.video-takes.template.test.ts +4 -2
- package/src/content-os.yaml +33 -23
- package/src/crm-absorbs-outreach.template.test.ts +5 -1
- package/src/crm.yaml +19 -11
- package/src/decisions-wave.template.test.ts +99 -5
- package/src/finance.yaml +11 -6
- package/src/lead-becomes-client.template.test.ts +4 -1
- package/src/lifecycle-declarations.test.ts +1 -1
- package/src/marketing.yaml +3 -3
- package/src/operations.yaml +8 -8
- package/src/postiz-contract.test.ts +25 -5
- package/src/process-contract.validate.test.ts +4 -1
- package/src/publish-official-lib.test.ts +8 -7
- package/src/research-base.yaml +2 -2
- package/src/research-decision.yaml +1 -1
- package/src/ship-a-change.template.test.ts +11 -2
- package/src/templates.ts +80 -59
- package/src/types.ts +15 -3
- package/src/unipile-lookups-read-only.test.ts +1 -0
- package/src/validate-flow.ts +15 -1
- package/src/validate.ts +40 -4
package/src/validate-flow.ts
CHANGED
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
* `schema/automations.ts`.
|
|
37
37
|
*/
|
|
38
38
|
import { PLAYBOOK_RUN_MODES } from "@synap-core/types/automations";
|
|
39
|
+
import { needRefProblem } from "@synap-core/types/needs";
|
|
39
40
|
|
|
40
41
|
// ── Contract constants (mirror schema/automations.ts — keep in sync) ──────────
|
|
41
42
|
|
|
@@ -311,11 +312,24 @@ export function validateFlowDefinition(
|
|
|
311
312
|
|
|
312
313
|
switch (type) {
|
|
313
314
|
case "capability": {
|
|
315
|
+
// A node may name a NEED instead of a verb (0426): the verb is the
|
|
316
|
+
// space's bound provider's, resolved at run time.
|
|
317
|
+
if (!nonEmptyString(data.verbId) && nonEmptyString(data.need)) {
|
|
318
|
+
const problem = needRefProblem(data.need);
|
|
319
|
+
if (problem) {
|
|
320
|
+
errors.push({
|
|
321
|
+
nodeId,
|
|
322
|
+
code: "capability_unknown_need",
|
|
323
|
+
message: `Capability node "${nodeId}": ${problem}`,
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
314
328
|
if (!nonEmptyString(data.verbId)) {
|
|
315
329
|
errors.push({
|
|
316
330
|
nodeId,
|
|
317
331
|
code: "capability_missing_verbId",
|
|
318
|
-
message: `Capability node "${nodeId}" has no \`verbId
|
|
332
|
+
message: `Capability node "${nodeId}" has no \`verbId\` (or \`need\`). Pick a verb on the selected tool, or name a need.`,
|
|
319
333
|
});
|
|
320
334
|
} else if (
|
|
321
335
|
resolvers?.verbExists &&
|
package/src/validate.ts
CHANGED
|
@@ -603,8 +603,15 @@ export function knownRelationTypes(
|
|
|
603
603
|
/**
|
|
604
604
|
* The process contract a playbook declares on top of its stages:
|
|
605
605
|
* - it names no `statusProperty`, `onEnd` or `humanOnlyStatuses` (retired);
|
|
606
|
-
* - every `stages[].subjectStatus
|
|
607
|
-
* the subject kind's declared
|
|
606
|
+
* - every `stages[].subjectStatus`, `stages[].onApproved` and
|
|
607
|
+
* `activators[].status` is an option of the subject kind's declared
|
|
608
|
+
* lifecycle;
|
|
609
|
+
* - a stage whose `onApproved` has NO approval signal (it owes no required
|
|
610
|
+
* output and the next stage has no gate, or it is the last stage) names
|
|
611
|
+
* that move in its goal: the engine never writes such a status (never on
|
|
612
|
+
* a session's end, decision 5e377b06), so the agent finishing the stage
|
|
613
|
+
* moves the subject through the status door. It stays declared so the
|
|
614
|
+
* follow and `flow.of` know what the stage reaches (decision D2);
|
|
608
615
|
* - `onFail.toStage` names a stage (key or name) of the same playbook;
|
|
609
616
|
* - every `relationToSubject` (playbook- and stage-level outputs) is a
|
|
610
617
|
* relation the corpus defines, or `none`.
|
|
@@ -630,6 +637,18 @@ export const MAX_SESSION_CRITERIA = 12;
|
|
|
630
637
|
*/
|
|
631
638
|
export const TEMPLATE_ACTIVATOR_ON = ["created", "enters_status", "count", "schedule", "manual"] as const;
|
|
632
639
|
|
|
640
|
+
/**
|
|
641
|
+
* Does a stage's goal NAME the move into `value` — the status value or its
|
|
642
|
+
* lifecycle label, as a whole word, any case? The test for an `onApproved`
|
|
643
|
+
* nothing approves (`stage-on-approved-no-signal`): the goal is what the agent
|
|
644
|
+
* finishing the stage reads, so it is where that move must be written.
|
|
645
|
+
*/
|
|
646
|
+
function goalNamesStatus(goal: unknown, value: unknown, labels: Map<string, string> | null): boolean {
|
|
647
|
+
if (typeof goal !== "string" || typeof value !== "string") return false;
|
|
648
|
+
const names = [value, labels?.get(value)].filter((n): n is string => !!n && n.trim() !== "");
|
|
649
|
+
return names.some((n) => new RegExp(`(^|[^\\p{L}\\p{N}_])${n.trim().replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}($|[^\\p{L}\\p{N}_])`, "iu").test(goal));
|
|
650
|
+
}
|
|
651
|
+
|
|
633
652
|
function checkProcessContract(
|
|
634
653
|
tpl: WorkspaceYaml,
|
|
635
654
|
resolveDep: (slug: string) => WorkspaceYaml | undefined,
|
|
@@ -666,6 +685,7 @@ function checkProcessContract(
|
|
|
666
685
|
// The lifecycle vocabulary: the kind's DECLARED lifecycle (null = none in
|
|
667
686
|
// reach to check against).
|
|
668
687
|
let statuses: Set<string> | null = null;
|
|
688
|
+
let labels: Map<string, string> | null = null;
|
|
669
689
|
let lifecycleProperty: string | undefined;
|
|
670
690
|
// A kind no declaration in reach carries is not judged without a corpus
|
|
671
691
|
// (an unknown kind is reported by playbook-ref-unknown).
|
|
@@ -677,6 +697,7 @@ function checkProcessContract(
|
|
|
677
697
|
if (declared) {
|
|
678
698
|
lifecycleProperty = declared.property;
|
|
679
699
|
statuses = new Set(declared.options.map((o) => o.key));
|
|
700
|
+
labels = new Map(declared.options.map((o) => [o.key, o.label ?? o.key]));
|
|
680
701
|
}
|
|
681
702
|
}
|
|
682
703
|
const checkStatus = (rule: string, path: string, value: unknown) => {
|
|
@@ -710,10 +731,25 @@ function checkProcessContract(
|
|
|
710
731
|
`${at}.criteria`,
|
|
711
732
|
`playbook "${pb.name}" declares ${criterionKeys.size} criteria (playbook-level plus every stage's) — a session keeps ${MAX_SESSION_CRITERIA} and drops the rest silently`
|
|
712
733
|
);
|
|
713
|
-
|
|
734
|
+
stages.forEach((stage, i) => {
|
|
714
735
|
const sp = `${at}.stages.${stage.key}`;
|
|
715
736
|
if (stage.subjectStatus !== undefined)
|
|
716
737
|
checkStatus("stage-subject-status-unknown", `${sp}.subjectStatus`, stage.subjectStatus);
|
|
738
|
+
if (stage.onApproved !== undefined) {
|
|
739
|
+
checkStatus("stage-on-approved-unknown", `${sp}.onApproved`, stage.onApproved);
|
|
740
|
+
// The pod's two approval signals (`stage-subject-status.ts`): a
|
|
741
|
+
// required output of this stage (an optional one never holds it back,
|
|
742
|
+
// so it never approves it either), or the NEXT stage's gate passing.
|
|
743
|
+
// A stage's own gate approves the stage BEFORE it, never itself.
|
|
744
|
+
const owesOutput = (stage.expectedOutputs ?? []).some((o) => o.optional !== true);
|
|
745
|
+
const nextGated = !!stages[i + 1]?.gate;
|
|
746
|
+
if (!owesOutput && !nextGated && !goalNamesStatus(stage.goal, stage.onApproved, labels))
|
|
747
|
+
add(
|
|
748
|
+
"stage-on-approved-no-signal",
|
|
749
|
+
`${sp}.onApproved`,
|
|
750
|
+
`stage "${stage.key}" of playbook "${pb.name}" owes no required output and ${stages[i + 1] ? `the next stage "${stages[i + 1]!.key}" has no gate` : "is the last stage"}: nothing approves it, so the pod never writes onApproved "${String(stage.onApproved)}" (never on the session's end). Keep it declared, and make the goal tell whoever finishes the stage to move the subject to "${String(stage.onApproved)}" through the status door`
|
|
751
|
+
);
|
|
752
|
+
}
|
|
717
753
|
const toStage = stage.onFail?.toStage;
|
|
718
754
|
if (stage.onFail !== undefined && (!toStage || !stageIds.has(toStage)))
|
|
719
755
|
add(
|
|
@@ -721,7 +757,7 @@ function checkProcessContract(
|
|
|
721
757
|
`${sp}.onFail.toStage`,
|
|
722
758
|
`stage "${stage.key}" onFail.toStage "${String(toStage)}" names no stage of playbook "${pb.name}"`
|
|
723
759
|
);
|
|
724
|
-
}
|
|
760
|
+
});
|
|
725
761
|
|
|
726
762
|
(pb.activators ?? []).forEach((a, i) => {
|
|
727
763
|
const ap = `${at}.activators[${i}]`;
|