@sweny-ai/core 0.1.76 → 0.1.78

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.
Files changed (123) hide show
  1. package/dist/browser.d.ts +11 -5
  2. package/dist/browser.js +11 -11
  3. package/dist/claude.d.ts +20 -0
  4. package/dist/claude.js +139 -9
  5. package/dist/cli/config.d.ts +22 -0
  6. package/dist/cli/config.js +56 -9
  7. package/dist/cli/main.d.ts +1 -1
  8. package/dist/cli/main.js +56 -57
  9. package/dist/cli/marketplace.js +35 -9
  10. package/dist/cli/publish.d.ts +10 -0
  11. package/dist/cli/publish.js +22 -14
  12. package/dist/executor.js +104 -43
  13. package/dist/loader.d.ts +40 -0
  14. package/dist/loader.js +73 -0
  15. package/dist/mcp-catalog.d.ts +47 -0
  16. package/dist/mcp-catalog.js +304 -0
  17. package/dist/mcp.d.ts +6 -9
  18. package/dist/mcp.js +24 -314
  19. package/dist/requires.d.ts +7 -0
  20. package/dist/requires.js +34 -0
  21. package/dist/retry.d.ts +23 -0
  22. package/dist/retry.js +72 -0
  23. package/dist/schema.d.ts +667 -80
  24. package/dist/schema.js +144 -5
  25. package/dist/skills/custom-loader.d.ts +40 -0
  26. package/dist/skills/custom-loader.js +107 -32
  27. package/dist/skills/index.d.ts +13 -1
  28. package/dist/skills/index.js +12 -3
  29. package/dist/studio.js +4 -1
  30. package/dist/templates.d.ts +29 -8
  31. package/dist/templates.js +30 -20
  32. package/dist/testing.d.ts +7 -0
  33. package/dist/testing.js +7 -0
  34. package/dist/types.d.ts +76 -0
  35. package/dist/verify.d.ts +1 -0
  36. package/dist/verify.js +43 -5
  37. package/package.json +8 -4
  38. package/dist/__tests__/cascade.test.d.ts +0 -11
  39. package/dist/__tests__/cascade.test.js +0 -449
  40. package/dist/__tests__/claude.test.d.ts +0 -1
  41. package/dist/__tests__/claude.test.js +0 -427
  42. package/dist/__tests__/custom-loader.test.d.ts +0 -1
  43. package/dist/__tests__/custom-loader.test.js +0 -116
  44. package/dist/__tests__/executor.test.d.ts +0 -1
  45. package/dist/__tests__/executor.test.js +0 -736
  46. package/dist/__tests__/integration/datadog.integration.test.d.ts +0 -1
  47. package/dist/__tests__/integration/datadog.integration.test.js +0 -23
  48. package/dist/__tests__/integration/e2e-workflow.integration.test.d.ts +0 -1
  49. package/dist/__tests__/integration/e2e-workflow.integration.test.js +0 -75
  50. package/dist/__tests__/integration/github.integration.test.d.ts +0 -1
  51. package/dist/__tests__/integration/github.integration.test.js +0 -37
  52. package/dist/__tests__/integration/harness.d.ts +0 -24
  53. package/dist/__tests__/integration/harness.js +0 -34
  54. package/dist/__tests__/integration/linear.integration.test.d.ts +0 -1
  55. package/dist/__tests__/integration/linear.integration.test.js +0 -15
  56. package/dist/__tests__/integration/sentry.integration.test.d.ts +0 -1
  57. package/dist/__tests__/integration/sentry.integration.test.js +0 -20
  58. package/dist/__tests__/integration/slack.integration.test.d.ts +0 -1
  59. package/dist/__tests__/integration/slack.integration.test.js +0 -22
  60. package/dist/__tests__/integration/sources.integration.test.d.ts +0 -1
  61. package/dist/__tests__/integration/sources.integration.test.js +0 -123
  62. package/dist/__tests__/publish.test.d.ts +0 -1
  63. package/dist/__tests__/publish.test.js +0 -180
  64. package/dist/__tests__/schema.test.d.ts +0 -1
  65. package/dist/__tests__/schema.test.js +0 -526
  66. package/dist/__tests__/skill-config-integration.test.d.ts +0 -1
  67. package/dist/__tests__/skill-config-integration.test.js +0 -204
  68. package/dist/__tests__/skills-index.test.d.ts +0 -1
  69. package/dist/__tests__/skills-index.test.js +0 -119
  70. package/dist/__tests__/skills.test.d.ts +0 -1
  71. package/dist/__tests__/skills.test.js +0 -565
  72. package/dist/__tests__/spec-conformance.test.d.ts +0 -18
  73. package/dist/__tests__/spec-conformance.test.js +0 -1074
  74. package/dist/__tests__/studio.test.d.ts +0 -1
  75. package/dist/__tests__/studio.test.js +0 -403
  76. package/dist/__tests__/templates.test.d.ts +0 -1
  77. package/dist/__tests__/templates.test.js +0 -49
  78. package/dist/__tests__/testing.test.d.ts +0 -1
  79. package/dist/__tests__/testing.test.js +0 -224
  80. package/dist/__tests__/verify.test.d.ts +0 -1
  81. package/dist/__tests__/verify.test.js +0 -517
  82. package/dist/__tests__/version-consistency.test.d.ts +0 -1
  83. package/dist/__tests__/version-consistency.test.js +0 -312
  84. package/dist/__tests__/workflow-builder.test.d.ts +0 -1
  85. package/dist/__tests__/workflow-builder.test.js +0 -110
  86. package/dist/__tests__/workflow-yaml.test.d.ts +0 -1
  87. package/dist/__tests__/workflow-yaml.test.js +0 -201
  88. package/dist/cli/__tests__/diagram.test.d.ts +0 -1
  89. package/dist/cli/__tests__/diagram.test.js +0 -225
  90. package/dist/cli/__tests__/report-cloud.test.d.ts +0 -1
  91. package/dist/cli/__tests__/report-cloud.test.js +0 -165
  92. package/dist/cli/__tests__/upgrade.test.d.ts +0 -1
  93. package/dist/cli/__tests__/upgrade.test.js +0 -317
  94. package/dist/cli/__tests__/version-check.test.d.ts +0 -1
  95. package/dist/cli/__tests__/version-check.test.js +0 -209
  96. package/dist/cli/config.test.d.ts +0 -1
  97. package/dist/cli/config.test.js +0 -200
  98. package/dist/cli/credentials.test.d.ts +0 -1
  99. package/dist/cli/credentials.test.js +0 -172
  100. package/dist/cli/e2e.test.d.ts +0 -1
  101. package/dist/cli/e2e.test.js +0 -690
  102. package/dist/cli/marketplace.test.d.ts +0 -1
  103. package/dist/cli/marketplace.test.js +0 -355
  104. package/dist/cli/new.test.d.ts +0 -1
  105. package/dist/cli/new.test.js +0 -1043
  106. package/dist/cli/output.test.d.ts +0 -1
  107. package/dist/cli/output.test.js +0 -180
  108. package/dist/cli/publish.test.d.ts +0 -1
  109. package/dist/cli/publish.test.js +0 -610
  110. package/dist/cli/renderer.test.d.ts +0 -1
  111. package/dist/cli/renderer.test.js +0 -302
  112. package/dist/executor.test.d.ts +0 -1
  113. package/dist/executor.test.js +0 -603
  114. package/dist/mcp.test.d.ts +0 -1
  115. package/dist/mcp.test.js +0 -735
  116. package/dist/mermaid.test.d.ts +0 -1
  117. package/dist/mermaid.test.js +0 -256
  118. package/dist/sources.test.d.ts +0 -1
  119. package/dist/sources.test.js +0 -265
  120. package/dist/sources.validation.test.d.ts +0 -12
  121. package/dist/sources.validation.test.js +0 -380
  122. package/dist/workflow-builder.test.d.ts +0 -1
  123. package/dist/workflow-builder.test.js +0 -117
@@ -0,0 +1,7 @@
1
+ import type { NodeRequires } from "./types.js";
2
+ /**
3
+ * Evaluate a node's `requires` block against the cross-node context map.
4
+ * Returns null when all checks pass (or when `requires` is undefined),
5
+ * otherwise a single concatenated failure string.
6
+ */
7
+ export declare function evaluateRequires(requires: NodeRequires | undefined, context: Record<string, unknown>): string | null;
@@ -0,0 +1,34 @@
1
+ // ─── Requires: pre-condition gate ───────────────────────────────────
2
+ //
3
+ // Evaluates `node.requires` BEFORE the LLM runs. Same path grammar and
4
+ // resolver as verify — the only differences are the data root (cross-node
5
+ // context map instead of result.data) and the error prefix.
6
+ import { checkOutputRequired, checkOutputMatches } from "./verify.js";
7
+ /**
8
+ * Evaluate a node's `requires` block against the cross-node context map.
9
+ * Returns null when all checks pass (or when `requires` is undefined),
10
+ * otherwise a single concatenated failure string.
11
+ */
12
+ export function evaluateRequires(requires, context) {
13
+ if (!requires)
14
+ return null;
15
+ const hasRequiredChecks = requires.output_required && requires.output_required.length > 0;
16
+ const hasMatchChecks = requires.output_matches && requires.output_matches.length > 0;
17
+ if (!hasRequiredChecks && !hasMatchChecks) {
18
+ return `requires failed:\n - Requires block present but no checks declared`;
19
+ }
20
+ const failures = [];
21
+ if (hasRequiredChecks) {
22
+ const e = checkOutputRequired(requires.output_required, context);
23
+ if (e)
24
+ failures.push(e);
25
+ }
26
+ if (hasMatchChecks) {
27
+ const e = checkOutputMatches(requires.output_matches, context);
28
+ if (e)
29
+ failures.push(e);
30
+ }
31
+ if (failures.length === 0)
32
+ return null;
33
+ return `requires failed:\n - ${failures.join("\n - ")}`;
34
+ }
@@ -0,0 +1,23 @@
1
+ import type { Claude, NodeRetry, ToolCall, Logger } from "./types.js";
2
+ export interface BuildRetryPreambleOptions {
3
+ retry: NodeRetry;
4
+ verifyError: string;
5
+ toolCalls: ToolCall[];
6
+ nodeInstruction: string;
7
+ claude: Claude;
8
+ logger: Logger;
9
+ context: Record<string, unknown>;
10
+ }
11
+ /**
12
+ * Build the retry preamble for a single retry attempt.
13
+ *
14
+ * Resolution order:
15
+ * 1. retry.instruction is a string → static preamble + verify error
16
+ * 2. retry.instruction is { auto: true } → claude.ask(default prompt)
17
+ * 3. retry.instruction is { reflect: "..." } → claude.ask(author prompt)
18
+ * 4. Otherwise (omitted) → default preamble
19
+ *
20
+ * Reflection failure (throw or empty response) silently falls back to the
21
+ * default static preamble and logs a warning.
22
+ */
23
+ export declare function buildRetryPreamble(opts: BuildRetryPreambleOptions): Promise<string>;
package/dist/retry.js ADDED
@@ -0,0 +1,72 @@
1
+ // ─── Retry: preamble construction for verify-failure self-healing ──
2
+ //
3
+ // Builds the preamble that gets prepended to the node instruction on retry.
4
+ // In autonomous modes ({ auto: true } or { reflect: ... }), this calls
5
+ // claude.ask to generate a diagnosis. If reflection fails or returns empty,
6
+ // falls back to the default static preamble — reflection failure never
7
+ // escalates to a workflow failure.
8
+ import { isErrorOutput } from "./verify.js";
9
+ const DEFAULT_REFLECTION_PROMPT = "Briefly diagnose the failure and state your strategy for the retry. Keep your response to 2-4 sentences.";
10
+ const DEFAULT_PREAMBLE_HEADER = "## Previous attempt failed verification";
11
+ /**
12
+ * Build the retry preamble for a single retry attempt.
13
+ *
14
+ * Resolution order:
15
+ * 1. retry.instruction is a string → static preamble + verify error
16
+ * 2. retry.instruction is { auto: true } → claude.ask(default prompt)
17
+ * 3. retry.instruction is { reflect: "..." } → claude.ask(author prompt)
18
+ * 4. Otherwise (omitted) → default preamble
19
+ *
20
+ * Reflection failure (throw or empty response) silently falls back to the
21
+ * default static preamble and logs a warning.
22
+ */
23
+ export async function buildRetryPreamble(opts) {
24
+ const { retry, verifyError, toolCalls, nodeInstruction, claude, logger, context } = opts;
25
+ const inst = retry.instruction;
26
+ if (typeof inst === "string") {
27
+ return `## Retry guidance\n\n${inst}\n\n${DEFAULT_PREAMBLE_HEADER}\n\n${verifyError}`;
28
+ }
29
+ if (inst && typeof inst === "object") {
30
+ const reflectPrompt = "reflect" in inst && typeof inst.reflect === "string" ? inst.reflect : DEFAULT_REFLECTION_PROMPT;
31
+ const askInstruction = buildReflectionPrompt(reflectPrompt, nodeInstruction, verifyError, toolCalls);
32
+ try {
33
+ const diagnosis = await claude.ask({ instruction: askInstruction, context });
34
+ const trimmed = diagnosis.trim();
35
+ if (trimmed.length > 0) {
36
+ return `## Reflection on previous attempt\n\n${trimmed}\n\n${DEFAULT_PREAMBLE_HEADER}\n\n${verifyError}`;
37
+ }
38
+ logger.warn("Retry reflection returned empty response; falling back to default preamble.");
39
+ }
40
+ catch (err) {
41
+ const msg = err instanceof Error ? err.message : String(err);
42
+ logger.warn(`Retry reflection threw: ${msg}; falling back to default preamble.`);
43
+ }
44
+ }
45
+ return defaultPreamble(verifyError);
46
+ }
47
+ function defaultPreamble(verifyError) {
48
+ return `${DEFAULT_PREAMBLE_HEADER}\n\n${verifyError}\n\nFix the issue and try again.`;
49
+ }
50
+ function buildReflectionPrompt(reflectPrompt, nodeInstruction, verifyError, toolCalls) {
51
+ const summary = summarizeToolCalls(toolCalls);
52
+ return [
53
+ `You attempted to: ${nodeInstruction}`,
54
+ "",
55
+ `Verification failed with: ${verifyError}`,
56
+ "",
57
+ `You called these tools during the failed attempt:`,
58
+ summary,
59
+ "",
60
+ reflectPrompt,
61
+ ].join("\n");
62
+ }
63
+ function summarizeToolCalls(toolCalls) {
64
+ if (toolCalls.length === 0)
65
+ return "(no tools were called)";
66
+ return toolCalls
67
+ .map((c) => {
68
+ const status = isErrorOutput(c.output) ? "error" : "ok";
69
+ return ` - ${c.tool} (${status})`;
70
+ })
71
+ .join("\n");
72
+ }