@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.
- package/dist/browser.d.ts +11 -5
- package/dist/browser.js +11 -11
- package/dist/claude.d.ts +20 -0
- package/dist/claude.js +139 -9
- package/dist/cli/config.d.ts +22 -0
- package/dist/cli/config.js +56 -9
- package/dist/cli/main.d.ts +1 -1
- package/dist/cli/main.js +56 -57
- package/dist/cli/marketplace.js +35 -9
- package/dist/cli/publish.d.ts +10 -0
- package/dist/cli/publish.js +22 -14
- package/dist/executor.js +104 -43
- package/dist/loader.d.ts +40 -0
- package/dist/loader.js +73 -0
- package/dist/mcp-catalog.d.ts +47 -0
- package/dist/mcp-catalog.js +304 -0
- package/dist/mcp.d.ts +6 -9
- package/dist/mcp.js +24 -314
- package/dist/requires.d.ts +7 -0
- package/dist/requires.js +34 -0
- package/dist/retry.d.ts +23 -0
- package/dist/retry.js +72 -0
- package/dist/schema.d.ts +667 -80
- package/dist/schema.js +144 -5
- package/dist/skills/custom-loader.d.ts +40 -0
- package/dist/skills/custom-loader.js +107 -32
- package/dist/skills/index.d.ts +13 -1
- package/dist/skills/index.js +12 -3
- package/dist/studio.js +4 -1
- package/dist/templates.d.ts +29 -8
- package/dist/templates.js +30 -20
- package/dist/testing.d.ts +7 -0
- package/dist/testing.js +7 -0
- package/dist/types.d.ts +76 -0
- package/dist/verify.d.ts +1 -0
- package/dist/verify.js +43 -5
- package/package.json +8 -4
- package/dist/__tests__/cascade.test.d.ts +0 -11
- package/dist/__tests__/cascade.test.js +0 -449
- package/dist/__tests__/claude.test.d.ts +0 -1
- package/dist/__tests__/claude.test.js +0 -427
- package/dist/__tests__/custom-loader.test.d.ts +0 -1
- package/dist/__tests__/custom-loader.test.js +0 -116
- package/dist/__tests__/executor.test.d.ts +0 -1
- package/dist/__tests__/executor.test.js +0 -736
- package/dist/__tests__/integration/datadog.integration.test.d.ts +0 -1
- package/dist/__tests__/integration/datadog.integration.test.js +0 -23
- package/dist/__tests__/integration/e2e-workflow.integration.test.d.ts +0 -1
- package/dist/__tests__/integration/e2e-workflow.integration.test.js +0 -75
- package/dist/__tests__/integration/github.integration.test.d.ts +0 -1
- package/dist/__tests__/integration/github.integration.test.js +0 -37
- package/dist/__tests__/integration/harness.d.ts +0 -24
- package/dist/__tests__/integration/harness.js +0 -34
- package/dist/__tests__/integration/linear.integration.test.d.ts +0 -1
- package/dist/__tests__/integration/linear.integration.test.js +0 -15
- package/dist/__tests__/integration/sentry.integration.test.d.ts +0 -1
- package/dist/__tests__/integration/sentry.integration.test.js +0 -20
- package/dist/__tests__/integration/slack.integration.test.d.ts +0 -1
- package/dist/__tests__/integration/slack.integration.test.js +0 -22
- package/dist/__tests__/integration/sources.integration.test.d.ts +0 -1
- package/dist/__tests__/integration/sources.integration.test.js +0 -123
- package/dist/__tests__/publish.test.d.ts +0 -1
- package/dist/__tests__/publish.test.js +0 -180
- package/dist/__tests__/schema.test.d.ts +0 -1
- package/dist/__tests__/schema.test.js +0 -526
- package/dist/__tests__/skill-config-integration.test.d.ts +0 -1
- package/dist/__tests__/skill-config-integration.test.js +0 -204
- package/dist/__tests__/skills-index.test.d.ts +0 -1
- package/dist/__tests__/skills-index.test.js +0 -119
- package/dist/__tests__/skills.test.d.ts +0 -1
- package/dist/__tests__/skills.test.js +0 -565
- package/dist/__tests__/spec-conformance.test.d.ts +0 -18
- package/dist/__tests__/spec-conformance.test.js +0 -1074
- package/dist/__tests__/studio.test.d.ts +0 -1
- package/dist/__tests__/studio.test.js +0 -403
- package/dist/__tests__/templates.test.d.ts +0 -1
- package/dist/__tests__/templates.test.js +0 -49
- package/dist/__tests__/testing.test.d.ts +0 -1
- package/dist/__tests__/testing.test.js +0 -224
- package/dist/__tests__/verify.test.d.ts +0 -1
- package/dist/__tests__/verify.test.js +0 -517
- package/dist/__tests__/version-consistency.test.d.ts +0 -1
- package/dist/__tests__/version-consistency.test.js +0 -312
- package/dist/__tests__/workflow-builder.test.d.ts +0 -1
- package/dist/__tests__/workflow-builder.test.js +0 -110
- package/dist/__tests__/workflow-yaml.test.d.ts +0 -1
- package/dist/__tests__/workflow-yaml.test.js +0 -201
- package/dist/cli/__tests__/diagram.test.d.ts +0 -1
- package/dist/cli/__tests__/diagram.test.js +0 -225
- package/dist/cli/__tests__/report-cloud.test.d.ts +0 -1
- package/dist/cli/__tests__/report-cloud.test.js +0 -165
- package/dist/cli/__tests__/upgrade.test.d.ts +0 -1
- package/dist/cli/__tests__/upgrade.test.js +0 -317
- package/dist/cli/__tests__/version-check.test.d.ts +0 -1
- package/dist/cli/__tests__/version-check.test.js +0 -209
- package/dist/cli/config.test.d.ts +0 -1
- package/dist/cli/config.test.js +0 -200
- package/dist/cli/credentials.test.d.ts +0 -1
- package/dist/cli/credentials.test.js +0 -172
- package/dist/cli/e2e.test.d.ts +0 -1
- package/dist/cli/e2e.test.js +0 -690
- package/dist/cli/marketplace.test.d.ts +0 -1
- package/dist/cli/marketplace.test.js +0 -355
- package/dist/cli/new.test.d.ts +0 -1
- package/dist/cli/new.test.js +0 -1043
- package/dist/cli/output.test.d.ts +0 -1
- package/dist/cli/output.test.js +0 -180
- package/dist/cli/publish.test.d.ts +0 -1
- package/dist/cli/publish.test.js +0 -610
- package/dist/cli/renderer.test.d.ts +0 -1
- package/dist/cli/renderer.test.js +0 -302
- package/dist/executor.test.d.ts +0 -1
- package/dist/executor.test.js +0 -603
- package/dist/mcp.test.d.ts +0 -1
- package/dist/mcp.test.js +0 -735
- package/dist/mermaid.test.d.ts +0 -1
- package/dist/mermaid.test.js +0 -256
- package/dist/sources.test.d.ts +0 -1
- package/dist/sources.test.js +0 -265
- package/dist/sources.validation.test.d.ts +0 -12
- package/dist/sources.validation.test.js +0 -380
- package/dist/workflow-builder.test.d.ts +0 -1
- 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;
|
package/dist/requires.js
ADDED
|
@@ -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
|
+
}
|
package/dist/retry.d.ts
ADDED
|
@@ -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
|
+
}
|