@kairos-sdk/core 0.5.0 → 0.6.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 +131 -16
- package/dist/{chunk-KIFT5LA7.js → chunk-2ZHNO37N.js} +49 -5
- package/dist/chunk-2ZHNO37N.js.map +1 -0
- package/dist/chunk-GG4B4TYG.js +153 -0
- package/dist/chunk-GG4B4TYG.js.map +1 -0
- package/dist/{chunk-5GAY7CSJ.js → chunk-PCNW5ZUD.js} +2 -2
- package/dist/chunk-SC6CLQZB.js +144 -0
- package/dist/chunk-SC6CLQZB.js.map +1 -0
- package/dist/chunk-SQS4QHDH.js +44 -0
- package/dist/chunk-SQS4QHDH.js.map +1 -0
- package/dist/{chunk-EVOAYH2K.js → chunk-STG7Z2SS.js} +2 -2
- package/dist/{chunk-HBGZTUUZ.js → chunk-YOQTEVDB.js} +5 -7
- package/dist/chunk-YOQTEVDB.js.map +1 -0
- package/dist/cli.cjs +702 -40
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +262 -7
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +417 -39
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +86 -4
- package/dist/index.d.ts +86 -4
- package/dist/index.js +19 -5
- package/dist/mcp-server.cjs +139 -24
- package/dist/mcp-server.cjs.map +1 -1
- package/dist/mcp-server.js +90 -19
- package/dist/mcp-server.js.map +1 -1
- package/dist/pack-builder-RTQWXGIS.js +9 -0
- package/dist/pack-builder-RTQWXGIS.js.map +1 -0
- package/dist/pack-exporter-KFNLSP5V.js +7 -0
- package/dist/pack-exporter-KFNLSP5V.js.map +1 -0
- package/dist/pack-validator-HZPB2XJ3.js +7 -0
- package/dist/pack-validator-HZPB2XJ3.js.map +1 -0
- package/dist/{reader-B5mV20H6.d.ts → reader-CfWGpL4V.d.cts} +2 -1
- package/dist/{reader-B5mV20H6.d.cts → reader-CfWGpL4V.d.ts} +2 -1
- package/dist/standalone.cjs +44 -4
- package/dist/standalone.cjs.map +1 -1
- package/dist/standalone.d.cts +1 -1
- package/dist/standalone.d.ts +1 -1
- package/dist/standalone.js +2 -2
- package/package.json +12 -5
- package/dist/chunk-HBGZTUUZ.js.map +0 -1
- package/dist/chunk-KIFT5LA7.js.map +0 -1
- /package/dist/{chunk-5GAY7CSJ.js.map → chunk-PCNW5ZUD.js.map} +0 -0
- /package/dist/{chunk-EVOAYH2K.js.map → chunk-STG7Z2SS.js.map} +0 -0
package/README.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
# @kairos-sdk/core
|
|
2
2
|
|
|
3
|
-
[](https://github.com/Kruttz/Kairos/actions/workflows/ci.yml)
|
|
4
4
|
[](https://www.npmjs.com/package/@kairos-sdk/core)
|
|
5
5
|
[](https://www.npmjs.com/package/@kairos-sdk/core)
|
|
6
6
|
|
|
7
|
-
**
|
|
7
|
+
**Kairos is an AI workflow delivery engine for n8n. Give it a business context and it generates, validates, deploys, and documents a complete workflow pack — then learns from real executions and repairs over time.**
|
|
8
8
|
|
|
9
9
|

|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Describe your business and Kairos builds a full suite of n8n automations: it plans the workflows, generates each one via Claude, validates every node and connection against **34 structural rules**, deploys to your n8n instance, and hands back a structured document covering credentials needed, data sources, assumptions made, open questions, and a test checklist. Use it as an **MCP server** (connect to Claude Code, Claude Desktop, or any MCP host — no Anthropic API key needed), a **TypeScript SDK**, or a **CLI**. With a seeded template library, Kairos achieves **100% first-try structural validation pass rate** across 20 benchmark prompts.
|
|
12
12
|
|
|
13
13
|
```ts
|
|
14
|
-
import { Kairos } from '@kairos-sdk/core'
|
|
14
|
+
import { Kairos, PackBuilder } from '@kairos-sdk/core'
|
|
15
15
|
|
|
16
16
|
const kairos = new Kairos({
|
|
17
17
|
anthropicApiKey: process.env.ANTHROPIC_API_KEY!,
|
|
@@ -19,12 +19,20 @@ const kairos = new Kairos({
|
|
|
19
19
|
n8nApiKey: process.env.N8N_API_KEY!,
|
|
20
20
|
})
|
|
21
21
|
|
|
22
|
+
// Build a single workflow
|
|
22
23
|
const result = await kairos.build(
|
|
23
|
-
'Every morning at 9am, send a message to #daily-digest on Slack
|
|
24
|
+
'Every morning at 9am, send a message to #daily-digest on Slack'
|
|
24
25
|
)
|
|
25
|
-
|
|
26
|
-
console.log(result.
|
|
27
|
-
|
|
26
|
+
console.log(result.workflowId) // deployed workflow ID
|
|
27
|
+
console.log(result.credentialsNeeded) // what still needs configuring
|
|
28
|
+
|
|
29
|
+
// Build a complete workflow pack from a business context
|
|
30
|
+
const builder = new PackBuilder({ anthropicApiKey: process.env.ANTHROPIC_API_KEY!, kairos })
|
|
31
|
+
const plan = await builder.plan('Homecare DME operations')
|
|
32
|
+
const pack = await builder.build(plan)
|
|
33
|
+
console.log(pack.workflows.map(w => w.name)) // all deployed workflow names
|
|
34
|
+
console.log(pack.openQuestions) // questions to answer before activating
|
|
35
|
+
console.log(pack.testChecklist) // how to verify each workflow
|
|
28
36
|
```
|
|
29
37
|
|
|
30
38
|
### What Kairos does and does not do
|
|
@@ -32,10 +40,12 @@ console.log(result.credentialsNeeded) // what the user still needs to configure
|
|
|
32
40
|
| Kairos does | Kairos does not guarantee (yet) |
|
|
33
41
|
|---|---|
|
|
34
42
|
| Generates valid n8n workflow JSON | Perfect business logic |
|
|
35
|
-
|
|
|
36
|
-
|
|
|
37
|
-
|
|
|
38
|
-
|
|
|
43
|
+
| Builds complete workflow packs from business context | Correct credentials or API configs |
|
|
44
|
+
| Validates structure before deploy (34 rules) | Runtime success for every API |
|
|
45
|
+
| Documents assumptions, open questions, and test steps | That every workflow matches intent perfectly |
|
|
46
|
+
| Syncs node types from your live instance | Full replacement for human review |
|
|
47
|
+
| Learns from prior builds and failures | Monitoring after deployment (coming soon) |
|
|
48
|
+
| Works through MCP, SDK, or CLI | — |
|
|
39
49
|
|
|
40
50
|
---
|
|
41
51
|
|
|
@@ -111,12 +121,14 @@ This means Kairos works with **any LLM** — Claude, GPT, Gemini, Llama, or anyt
|
|
|
111
121
|
| `kairos_validate` | Validates workflow JSON against 34 structural rules — returns errors and warnings |
|
|
112
122
|
| `kairos_search` | Searches the local workflow library for similar past builds |
|
|
113
123
|
| `kairos_sync` | Manually refresh the node catalog from your n8n instance (auto-runs on first `kairos_prompt` call) |
|
|
124
|
+
| `kairos_patterns` | Returns pattern analysis — top failure rules, confidence scores, and improvement suggestions derived from build telemetry |
|
|
114
125
|
|
|
115
126
|
#### Deployment tools
|
|
116
127
|
|
|
117
128
|
| Tool | Description |
|
|
118
129
|
|------|-------------|
|
|
119
130
|
| `kairos_deploy` | Deploys validated workflow JSON to n8n (re-validates before deploying) |
|
|
131
|
+
| `kairos_replace` | Replaces an existing n8n workflow with a new version — validates before updating, preserves workflow ID |
|
|
120
132
|
| `kairos_list` | List all deployed workflows |
|
|
121
133
|
| `kairos_get` | Get full workflow JSON by ID |
|
|
122
134
|
| `kairos_activate` | Activate a workflow |
|
|
@@ -124,6 +136,13 @@ This means Kairos works with **any LLM** — Claude, GPT, Gemini, Llama, or anyt
|
|
|
124
136
|
| `kairos_delete` | Delete a workflow |
|
|
125
137
|
| `kairos_executions` | List recent executions with status |
|
|
126
138
|
|
|
139
|
+
#### Library tools
|
|
140
|
+
|
|
141
|
+
| Tool | Description |
|
|
142
|
+
|------|-------------|
|
|
143
|
+
| `kairos_library` | Browse or search the local Kairos workflow library — returns metadata, node counts, deploy history, and n8n workflow IDs |
|
|
144
|
+
| `kairos_outcome` | Record build outcome against a library entry — feeds the pattern learning system with attempt counts, failed rules, and generation mode |
|
|
145
|
+
|
|
127
146
|
---
|
|
128
147
|
|
|
129
148
|
## Use as SDK
|
|
@@ -314,6 +333,36 @@ const result = await kairos.build(description, {
|
|
|
314
333
|
|
|
315
334
|
---
|
|
316
335
|
|
|
336
|
+
### `new PackBuilder(options)` + `builder.plan()` + `builder.build()`
|
|
337
|
+
|
|
338
|
+
Build a complete workflow pack from a plain-English business context.
|
|
339
|
+
|
|
340
|
+
```ts
|
|
341
|
+
import { Kairos, PackBuilder } from '@kairos-sdk/core'
|
|
342
|
+
|
|
343
|
+
const kairos = new Kairos({ anthropicApiKey, n8nBaseUrl, n8nApiKey })
|
|
344
|
+
const builder = new PackBuilder({ anthropicApiKey, kairos })
|
|
345
|
+
|
|
346
|
+
// Step 1 — plan (LLM generates workflow list, assumptions, open questions)
|
|
347
|
+
const plan = await builder.plan('Homecare DME business operations')
|
|
348
|
+
console.log(plan.workflows) // array of { name, description, purpose }
|
|
349
|
+
console.log(plan.openQuestions) // questions needing human answers before go-live
|
|
350
|
+
|
|
351
|
+
// Step 2 — build (deploys each workflow, aggregates credentials and test steps)
|
|
352
|
+
const pack = await builder.build(plan, {
|
|
353
|
+
dryRun: false,
|
|
354
|
+
activate: false,
|
|
355
|
+
onProgress: (wf, i, total) => console.log(`[${i+1}/${total}] ${wf.name}`),
|
|
356
|
+
})
|
|
357
|
+
|
|
358
|
+
console.log(pack.workflows) // deployed results with workflowId and credentialsNeeded
|
|
359
|
+
console.log(pack.allCredentials) // deduped credential list across all workflows
|
|
360
|
+
console.log(pack.sheetsColumns) // Google Sheets required per sheet
|
|
361
|
+
console.log(pack.testChecklist) // per-workflow test steps
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
---
|
|
365
|
+
|
|
317
366
|
### Workflow management
|
|
318
367
|
|
|
319
368
|
```ts
|
|
@@ -412,11 +461,20 @@ try {
|
|
|
412
461
|
Deploy workflows from the command line — no code required:
|
|
413
462
|
|
|
414
463
|
```bash
|
|
415
|
-
#
|
|
464
|
+
# First-time setup (prompts for credentials, seeds template library, prints Claude Desktop config)
|
|
465
|
+
kairos init
|
|
466
|
+
|
|
467
|
+
# Generate and deploy a single workflow
|
|
416
468
|
kairos build "Every morning at 9am, send a Slack digest to #daily-updates"
|
|
417
469
|
|
|
418
|
-
#
|
|
419
|
-
kairos build "
|
|
470
|
+
# Generate a complete workflow pack from a business context
|
|
471
|
+
kairos build-pack "Homecare DME business — patient onboarding, reorder reminders, social media"
|
|
472
|
+
|
|
473
|
+
# Dry run — plan and validate without deploying
|
|
474
|
+
kairos build-pack "E-commerce store operations" --dry-run
|
|
475
|
+
|
|
476
|
+
# Skip confirmation prompt and build immediately
|
|
477
|
+
kairos build-pack "Real estate agency operations" --yes
|
|
420
478
|
|
|
421
479
|
# Seed library with n8n community templates
|
|
422
480
|
kairos sync-templates --max 200
|
|
@@ -433,7 +491,64 @@ kairos deactivate <workflow-id>
|
|
|
433
491
|
kairos delete <workflow-id> --confirm
|
|
434
492
|
```
|
|
435
493
|
|
|
436
|
-
|
|
494
|
+
### What `build-pack` outputs
|
|
495
|
+
|
|
496
|
+
After building, Kairos prints a structured document and saves a JSON file to `~/.kairos/packs/<name>.json`:
|
|
497
|
+
|
|
498
|
+
```
|
|
499
|
+
Homecare DME business — Workflow Pack
|
|
500
|
+
══════════════════════════════════════
|
|
501
|
+
|
|
502
|
+
Workflows Built (6/6)
|
|
503
|
+
──────────────────────────────────────────────────
|
|
504
|
+
✓ Weekly Social Media Content [360Xba7BEQFQUw3v]
|
|
505
|
+
Generate and email 3 Facebook/Instagram posts for approval each Monday
|
|
506
|
+
✓ Group Home Reorder Reminders [g1Dx5hjTpV4FrkwH]
|
|
507
|
+
Email facility contacts when supplies are due for reorder
|
|
508
|
+
✓ Monthly Newsletter [lO8YxkDiaGkZiq76]
|
|
509
|
+
Send AI-generated newsletter to customer mailing list on the 1st
|
|
510
|
+
✓ New Customer Welcome Sequence [PrMj2DwVGfAo6VXq]
|
|
511
|
+
3-email onboarding sequence triggered by webhook on customer add
|
|
512
|
+
✓ Annual Equipment Check-ins [LZCIedaEnGNsKNRp]
|
|
513
|
+
Daily check for customers whose equipment delivery was ~1 year ago
|
|
514
|
+
✓ Weekly Google Business Post [IfxKaA1MYZ4Xs3eI]
|
|
515
|
+
Auto-post educational content to Google Business Profile each Monday
|
|
516
|
+
|
|
517
|
+
Credentials Needed (connect once in n8n)
|
|
518
|
+
──────────────────────────────────────────────────
|
|
519
|
+
□ Gmail OAuth2
|
|
520
|
+
□ Google Sheets OAuth2
|
|
521
|
+
□ Anthropic Claude API (HTTP Header Auth)
|
|
522
|
+
□ Google My Business OAuth2
|
|
523
|
+
|
|
524
|
+
Google Sheets Required
|
|
525
|
+
──────────────────────────────────────────────────
|
|
526
|
+
□ Facility Contacts: facility_name, contact_name, contact_email, product, reorder_frequency_weeks, last_order_date
|
|
527
|
+
□ Customer Mailing List: name, email
|
|
528
|
+
|
|
529
|
+
Assumptions Made
|
|
530
|
+
──────────────────────────────────────────────────
|
|
531
|
+
- Customer data is maintained in Google Sheets
|
|
532
|
+
- Gmail is the outbound email platform
|
|
533
|
+
- Owner approves social posts before publishing
|
|
534
|
+
|
|
535
|
+
Open Questions (answer before activating)
|
|
536
|
+
──────────────────────────────────────────────────
|
|
537
|
+
? What email address should receive social media approval emails?
|
|
538
|
+
? What is the brand voice / tone for posts and newsletters?
|
|
539
|
+
? Should newsletters require approval before sending to the full list?
|
|
540
|
+
|
|
541
|
+
Test Checklist
|
|
542
|
+
──────────────────────────────────────────────────
|
|
543
|
+
Weekly Social Media Content
|
|
544
|
+
□ Trigger manually — verify approval email arrives with 3 posts
|
|
545
|
+
Group Home Reorder Reminders
|
|
546
|
+
□ Add a test row with last_order_date 30 days ago — verify reminder email
|
|
547
|
+
New Customer Welcome Sequence
|
|
548
|
+
□ POST {"customer_name":"Test","customer_email":"you@test.com","equipment_type":"wheelchair"} to webhook
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
Set your credentials as environment variables or run `kairos init`:
|
|
437
552
|
|
|
438
553
|
```bash
|
|
439
554
|
export ANTHROPIC_API_KEY=sk-ant-...
|
|
@@ -489,6 +489,7 @@ var N8nValidator = class {
|
|
|
489
489
|
this.checkRule32(workflow, issues);
|
|
490
490
|
this.checkRule33(workflow, issues);
|
|
491
491
|
this.checkRule34(workflow, issues);
|
|
492
|
+
this.checkRule35(workflow, issues);
|
|
492
493
|
if (Array.isArray(workflow.nodes)) {
|
|
493
494
|
const nodeById = new Map(workflow.nodes.map((n) => [n.id, n.type]));
|
|
494
495
|
for (const issue of issues) {
|
|
@@ -1061,6 +1062,43 @@ var N8nValidator = class {
|
|
|
1061
1062
|
}
|
|
1062
1063
|
}
|
|
1063
1064
|
}
|
|
1065
|
+
// Rule 35 (WARN): email-sending node with no duplicate-prevention signal
|
|
1066
|
+
checkRule35(w, issues) {
|
|
1067
|
+
if (!Array.isArray(w.nodes)) return;
|
|
1068
|
+
const sendNodes = w.nodes.filter((node) => {
|
|
1069
|
+
if (node.type === "n8n-nodes-base.gmail") {
|
|
1070
|
+
const op = node.parameters?.["operation"];
|
|
1071
|
+
return !op || op === "send" || op === "sendEmail" || op === "reply";
|
|
1072
|
+
}
|
|
1073
|
+
return node.type === "n8n-nodes-base.emailSend" || node.type === "n8n-nodes-base.sendEmail";
|
|
1074
|
+
});
|
|
1075
|
+
if (sendNodes.length === 0) return;
|
|
1076
|
+
const workflowText = JSON.stringify(w).toLowerCase();
|
|
1077
|
+
const IDEMPOTENCY_SIGNALS = [
|
|
1078
|
+
"sent_at",
|
|
1079
|
+
"last_sent",
|
|
1080
|
+
"last_reminder",
|
|
1081
|
+
"processed_at",
|
|
1082
|
+
"already_sent",
|
|
1083
|
+
"email_sent",
|
|
1084
|
+
"notified_at",
|
|
1085
|
+
"reminder_sent",
|
|
1086
|
+
"contacted_at",
|
|
1087
|
+
"dedupe",
|
|
1088
|
+
"idempotent"
|
|
1089
|
+
];
|
|
1090
|
+
const hasIdempotencySignal = IDEMPOTENCY_SIGNALS.some((s) => workflowText.includes(s));
|
|
1091
|
+
if (!hasIdempotencySignal) {
|
|
1092
|
+
for (const node of sendNodes) {
|
|
1093
|
+
this.warn(
|
|
1094
|
+
issues,
|
|
1095
|
+
35,
|
|
1096
|
+
`Node "${node.name}" sends email but no duplicate-prevention signal detected \u2014 add a sent_at timestamp field, a prior-send IF check, or a deduplication key to avoid repeat sends`,
|
|
1097
|
+
node.id
|
|
1098
|
+
);
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1064
1102
|
// Rule 34 (WARN): webhook path contains spaces, starts with slash, or looks like a full URL
|
|
1065
1103
|
checkRule34(w, issues) {
|
|
1066
1104
|
if (!Array.isArray(w.nodes)) return;
|
|
@@ -1242,7 +1280,7 @@ import { join as join4 } from "path";
|
|
|
1242
1280
|
import { homedir as homedir3 } from "os";
|
|
1243
1281
|
|
|
1244
1282
|
// src/validation/rule-metadata.ts
|
|
1245
|
-
var VALIDATOR_RULE_IDS = Array.from({ length:
|
|
1283
|
+
var VALIDATOR_RULE_IDS = Array.from({ length: 35 }, (_, i) => i + 1);
|
|
1246
1284
|
var RULE_PIPELINE_STAGES = {
|
|
1247
1285
|
1: "node_generation",
|
|
1248
1286
|
2: "node_generation",
|
|
@@ -1277,7 +1315,8 @@ var RULE_PIPELINE_STAGES = {
|
|
|
1277
1315
|
31: "node_generation",
|
|
1278
1316
|
32: "node_generation",
|
|
1279
1317
|
33: "node_generation",
|
|
1280
|
-
34: "node_generation"
|
|
1318
|
+
34: "node_generation",
|
|
1319
|
+
35: "node_generation"
|
|
1281
1320
|
};
|
|
1282
1321
|
var RULE_EXAMPLES = {
|
|
1283
1322
|
17: {
|
|
@@ -1327,6 +1366,10 @@ var RULE_EXAMPLES = {
|
|
|
1327
1366
|
34: {
|
|
1328
1367
|
bad: '"path": "/my webhook"',
|
|
1329
1368
|
good: '"path": "my-webhook"'
|
|
1369
|
+
},
|
|
1370
|
+
35: {
|
|
1371
|
+
bad: '"type": "n8n-nodes-base.gmail", "parameters": { "operation": "send" } // no sent_at tracking',
|
|
1372
|
+
good: 'Add a Set node after send that writes "sent_at": "={{ $now }}" back to the sheet, or an IF node that checks sent_at before sending'
|
|
1330
1373
|
}
|
|
1331
1374
|
};
|
|
1332
1375
|
var RULE_MITIGATIONS = {
|
|
@@ -1363,7 +1406,8 @@ var RULE_MITIGATIONS = {
|
|
|
1363
1406
|
31: "Add at least one condition to the if node \u2014 conditions.conditions array must be non-empty",
|
|
1364
1407
|
32: "Add field assignments to the set node \u2014 assignments.assignments array must be non-empty for typeVersion 3.x",
|
|
1365
1408
|
33: "Add at least one schedule rule to scheduleTrigger \u2014 rule.interval array must have at least one entry",
|
|
1366
|
-
34: 'Webhook path must be a relative path without spaces, leading slashes, or protocol prefixes (e.g. "my-hook")'
|
|
1409
|
+
34: 'Webhook path must be a relative path without spaces, leading slashes, or protocol prefixes (e.g. "my-hook")',
|
|
1410
|
+
35: "Add duplicate-prevention to email-sending workflows: a sent_at timestamp field updated after each send, or an IF node that checks prior-send status before sending"
|
|
1367
1411
|
};
|
|
1368
1412
|
|
|
1369
1413
|
// src/telemetry/pattern-analyzer.ts
|
|
@@ -1421,7 +1465,7 @@ var PatternAnalyzer = class _PatternAnalyzer {
|
|
|
1421
1465
|
this._cachedEvents = events;
|
|
1422
1466
|
const starts = events.filter((e) => e.eventType === "build_start");
|
|
1423
1467
|
const attempts = events.filter((e) => e.eventType === "generation_attempt");
|
|
1424
|
-
const
|
|
1468
|
+
const _passed = attempts.filter(
|
|
1425
1469
|
(a) => a.data.validationPassed === true
|
|
1426
1470
|
);
|
|
1427
1471
|
const failed = attempts.filter(
|
|
@@ -2579,4 +2623,4 @@ export {
|
|
|
2579
2623
|
buildSearchCorpus,
|
|
2580
2624
|
FileLibrary
|
|
2581
2625
|
};
|
|
2582
|
-
//# sourceMappingURL=chunk-
|
|
2626
|
+
//# sourceMappingURL=chunk-2ZHNO37N.js.map
|