@exellix/graph-composer 2.0.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.
Files changed (103) hide show
  1. package/.env.example +66 -0
  2. package/LICENSE +21 -0
  3. package/README.md +329 -0
  4. package/dist/aiTaskProfile.d.ts +66 -0
  5. package/dist/aiTaskProfile.d.ts.map +1 -0
  6. package/dist/aiTaskProfile.js +179 -0
  7. package/dist/canonicalGraphDocument.d.ts +8 -0
  8. package/dist/canonicalGraphDocument.d.ts.map +1 -0
  9. package/dist/canonicalGraphDocument.js +344 -0
  10. package/dist/canonicalGraphWarnings.d.ts +6 -0
  11. package/dist/canonicalGraphWarnings.d.ts.map +1 -0
  12. package/dist/canonicalGraphWarnings.js +140 -0
  13. package/dist/catalogMatchAssist.d.ts +20 -0
  14. package/dist/catalogMatchAssist.d.ts.map +1 -0
  15. package/dist/catalogMatchAssist.js +203 -0
  16. package/dist/cataloxCatalogBridge.d.ts +103 -0
  17. package/dist/cataloxCatalogBridge.d.ts.map +1 -0
  18. package/dist/cataloxCatalogBridge.js +222 -0
  19. package/dist/cli.d.ts +3 -0
  20. package/dist/cli.d.ts.map +1 -0
  21. package/dist/cli.js +43 -0
  22. package/dist/composeInstructions.d.ts +11 -0
  23. package/dist/composeInstructions.d.ts.map +1 -0
  24. package/dist/composeInstructions.js +39 -0
  25. package/dist/defaultUtilitySkills.d.ts +4 -0
  26. package/dist/defaultUtilitySkills.d.ts.map +1 -0
  27. package/dist/defaultUtilitySkills.js +5 -0
  28. package/dist/exampleGeneration.d.ts +15 -0
  29. package/dist/exampleGeneration.d.ts.map +1 -0
  30. package/dist/exampleGeneration.js +72 -0
  31. package/dist/exampleInputs.d.ts +12 -0
  32. package/dist/exampleInputs.d.ts.map +1 -0
  33. package/dist/exampleInputs.js +181 -0
  34. package/dist/graphComposerActions.d.ts +22 -0
  35. package/dist/graphComposerActions.d.ts.map +1 -0
  36. package/dist/graphComposerActions.js +168 -0
  37. package/dist/graphComposerAgent.d.ts +26 -0
  38. package/dist/graphComposerAgent.d.ts.map +1 -0
  39. package/dist/graphComposerAgent.js +175 -0
  40. package/dist/graphComposerOutputValidation.d.ts +23 -0
  41. package/dist/graphComposerOutputValidation.d.ts.map +1 -0
  42. package/dist/graphComposerOutputValidation.js +709 -0
  43. package/dist/graphConceptPatchMerge.d.ts +10 -0
  44. package/dist/graphConceptPatchMerge.d.ts.map +1 -0
  45. package/dist/graphConceptPatchMerge.js +40 -0
  46. package/dist/graphEngineBridge.d.ts +7 -0
  47. package/dist/graphEngineBridge.d.ts.map +1 -0
  48. package/dist/graphEngineBridge.js +5 -0
  49. package/dist/index.d.ts +24 -0
  50. package/dist/index.d.ts.map +1 -0
  51. package/dist/index.js +19 -0
  52. package/dist/openRouterConnectTimeout.d.ts +3 -0
  53. package/dist/openRouterConnectTimeout.d.ts.map +1 -0
  54. package/dist/openRouterConnectTimeout.js +48 -0
  55. package/dist/packDir.d.ts +7 -0
  56. package/dist/packDir.d.ts.map +1 -0
  57. package/dist/packDir.js +23 -0
  58. package/dist/parseGraphConceptStory.d.ts +21 -0
  59. package/dist/parseGraphConceptStory.d.ts.map +1 -0
  60. package/dist/parseGraphConceptStory.js +105 -0
  61. package/dist/redactForLog.d.ts +2 -0
  62. package/dist/redactForLog.d.ts.map +1 -0
  63. package/dist/redactForLog.js +37 -0
  64. package/dist/runGraphComposer.d.ts +54 -0
  65. package/dist/runGraphComposer.d.ts.map +1 -0
  66. package/dist/runGraphComposer.js +444 -0
  67. package/dist/scopingCatalogHostTypes.d.ts +28 -0
  68. package/dist/scopingCatalogHostTypes.d.ts.map +1 -0
  69. package/dist/scopingCatalogHostTypes.js +6 -0
  70. package/dist/scopingNeedMatchAssist.d.ts +14 -0
  71. package/dist/scopingNeedMatchAssist.d.ts.map +1 -0
  72. package/dist/scopingNeedMatchAssist.js +58 -0
  73. package/dist/taskNodeTaskVariable.d.ts +44 -0
  74. package/dist/taskNodeTaskVariable.d.ts.map +1 -0
  75. package/dist/taskNodeTaskVariable.js +347 -0
  76. package/dist/types.d.ts +174 -0
  77. package/dist/types.d.ts.map +1 -0
  78. package/dist/types.js +1 -0
  79. package/examples/network-vuln-subnet-triage.v2.json +389 -0
  80. package/functions/graph-composer/meta.json +607 -0
  81. package/functions/graph-composer/prompts/README.md +46 -0
  82. package/functions/graph-composer/prompts/action-create.md +51 -0
  83. package/functions/graph-composer/prompts/action-explain.md +26 -0
  84. package/functions/graph-composer/prompts/action-modify.md +32 -0
  85. package/functions/graph-composer/prompts/action-review-concept.md +97 -0
  86. package/functions/graph-composer/prompts/action-suggest-catalog-creations.md +31 -0
  87. package/functions/graph-composer/prompts/action-suggest-catalog-resolution.md +42 -0
  88. package/functions/graph-composer/prompts/action-suggest-concept-objective.md +38 -0
  89. package/functions/graph-composer/prompts/action-suggest-scoping-map-creation.md +31 -0
  90. package/functions/graph-composer/prompts/action-suggest-scoping-need-match.md +25 -0
  91. package/functions/graph-composer/prompts/default-utility-skills.json +22 -0
  92. package/functions/graph-composer/prompts/judge-rules.md +30 -0
  93. package/functions/graph-composer/prompts/orchestrator-system.md +21 -0
  94. package/functions/graph-composer/prompts/shared/graph-format.md +124 -0
  95. package/functions/graph-composer/prompts/shared/request-context.md +12 -0
  96. package/functions/graph-composer/prompts/shared/skill-selection.md +6 -0
  97. package/functions/graph-composer/prompts/shared/structural-validation.md +19 -0
  98. package/functions/graph-composer/prompts/skill-catalog-ai-header.md +3 -0
  99. package/functions/graph-composer/prompts/skill-catalog-utility-header.md +3 -0
  100. package/functions/graph-composer/prompts/skill-mode-extensible.md +7 -0
  101. package/functions/graph-composer/prompts/skill-mode-locked.md +7 -0
  102. package/functions/graph-composer/test-cases.json +52 -0
  103. package/package.json +86 -0
@@ -0,0 +1,12 @@
1
+ ## Request payload (always read)
2
+
3
+ - **`intent.description`**: The user’s goal or question for this call. For `explain` and `suggestConceptObjective`, treat it as the angle of emphasis (e.g. “focus on data flow”, “explain branching”) when it adds detail beyond the graph alone. It may contain a **graph concept story** (marker line `# graphConcept story` plus structured `key: value` lines and multiline `|` blocks); the raw text remains authoritative alongside any structured companion field.
4
+ - **`graphConceptFromStory`**: When present on `create`, `modify`, or `reviewConcept` requests (server-parsed from `intent.description`), this object includes **`parsed`**: a JSON object with fields such as `graphType`, `primaryIntentType`, `primaryIntentStatement`, `expectedInput`, `coreTasks` (array of task objects merged from `coreTasks.N.*` keys), `outputDescription`, `persistenceNotes`, etc. Treat **`parsed` plus `intent.description`** together as the product-level spec for the graph (or the expected spec when reviewing). Follow the action-specific instructions when this field appears.
5
+ - **`intent.focusNodeIds`**: When set on `modify` or `explain`, prioritize those nodes (and their edges); still keep the rest consistent or summarized as required by the action.
6
+ - **`constraints`**: Honor `maxNodes`, `requireFinalizer`, `allowConditionalEdges`, and any `executionMemorySchema` hints from the request when building or changing graphs.
7
+ - **`skillMode`**: Governs whether you may introduce new `skillKey` values (see the skill-mode section appended after the catalogs).
8
+ - **`analysisContext`**: When present on `suggestConceptObjective`, treat it as **structured analysis** (execution order, per-node IO, issues, layers, etc.). Prefer it over re-deriving the same facts from scratch when it is consistent with `existingGraph`.
9
+ - **`catalogCandidates`**: When present on `suggestCatalogResolution` / `suggestCatalogCreations`, extra managed-catalog rows from the host (e.g. **Catalox** via `loadCatalogCandidatesFromCatalox`): `aiSkills`, `utilitySkills`, `scopingMaps`, `narrixTemplates`. These extend the inline `aiSkills` / `utilitySkills` arrays for matching.
10
+ - **`catalogMatchHints`**: When present, a server-injected object with optional `skills`, `scoping`, `narrix` entries from `matchLists` pre-pass. Treat as **non-authoritative hints**; reconcile with `existingGraph` and produce your own final recommendations.
11
+ - **`suggestScopingNeedMatch`**: Requires non-empty **`catalogCandidates.scopingMaps`**. **`intent.description`** is the data need. **`existingGraph`** optional.
12
+ - **`scopingNeedMatchHints`**: When present, server-injected `matchLists` result for need → scoping map candidates. **Hints only**; you produce the final `hasSuitableMatch` / `recommended` / `gaps`.
@@ -0,0 +1,6 @@
1
+ ## Skill selection guidelines
2
+ - Prefer local/deterministic skills for rule evaluation, data lookup, payload assembly, and persistence.
3
+ - Use AI-backed skills for inference, classification, summarization, open-ended analysis, and any task requiring judgment.
4
+ - Never use an AI-backed skill for something a local skill can handle deterministically.
5
+ - When writing `taskVariable.question` for an AI skill, be specific: state what data the skill will receive, what it should analyze, and what shape of answer is expected.
6
+ - Each node should do one thing. If a step requires both data reading and inference, use two nodes.
@@ -0,0 +1,19 @@
1
+ ## Structural validation rules
2
+ Before returning any graph (create/modify only), verify:
3
+ 1. Every edge references existing node ids in `from` and `to`.
4
+ 2. Every `executionMemoryPath` in `inputsConfig` or `jobContextMapping` traces to `input.*`, `inputs.*`, or an upstream `executionMapping.path`.
5
+ 3. Dynamic task variables use `taskVariable` only. Put `question`, literals, and `$path` refs (`jobVariables.*`, `taskVariables.*`, or legacy `variables.*`) under `taskVariable`; do not place them under `inputsConfig` or deprecated `inputs`.
6
+ 4. Every conditional edge's `when.path` traces to a written execution-memory path.
7
+ 5. The finalizer's `config.items` reference existing node ids.
8
+ 6. No cycles exist.
9
+ 7. If `requireFinalizer` is true, at least one finalizer node exists.
10
+ 8. If `maxNodes` is set, the total node count does not exceed it.
11
+ 9. All `skillKey` values exist in the provided catalog (unless extensible mode is active).
12
+ 10. For every **AI task** node, include **`taskConfiguration.aiTaskProfile.preStrategyKey`** and **`postStrategyKey`** (non-empty strings matching deployment PRE/POST strategy catalog row ids). Omit only on local/utility skills.
13
+ 11. When **`taskConfiguration.aiTaskProfile.webScoping.enabled`** is `true`, include a non-empty **`webScoping.questions`** array. Do not set `questions` when `enabled` is `false`.
14
+ 12. When **`inputSynthesis.enabled`** is `true`, set non-empty **`inputSynthesis.catalogId`**, **`strategyKey`**, **`outputKey`**, **`sources`** (memory paths), and **`destination`** (`job`, `task`, or `execution`). Do not add manual PRE `synthesized-context` steps when profile synthesis is enabled.
15
+ 13. Do not author deprecated task-node **`inputs`** or **`outputMapping`** — use **`inputsConfig`** and **`executionMapping`**.
16
+ 14. **Narrix** belongs under **`taskConfiguration.narrix`** (`datasetId`, `layer`, `narrativeTypeIds` when needed). Author web questions only under **`taskConfiguration.aiTaskProfile.webScoping`**, not on `narrix`.
17
+ 15. **`metadata`** is for planning fields (`graphReadability`, `catalogBinding`, …) only.
18
+ 16. Optional **`metadata.catalogBinding`** / **`metadata.catalogRequests`** per product catalog planning.
19
+ 17. New graphs should include root **`response`** with `shape` selectors; legacy `metadata.graphResponse` is non-canonical.
@@ -0,0 +1,3 @@
1
+ ## Available AI skills (call ai-tasks; isLocal: false)
2
+
3
+ Use **exactly** the `skillKey` strings below when selecting an AI-backed step. Read each skill’s description and schemas to match intent. Prefer an AI skill only when the work needs judgment, language, or unstructured reasoning—otherwise use a utility skill if one fits.
@@ -0,0 +1,3 @@
1
+ ## Available Utility skills (runtime-local; isLocal: true)
2
+
3
+ Use **exactly** the `skillKey` strings below for deterministic work (rules, reads/writes, assembly, routing). Prefer these over AI skills whenever the job can be specified as a fixed procedure.
@@ -0,0 +1,7 @@
1
+ ## Skill mode: EXTENSIBLE
2
+
3
+ - Use skills from the **Available AI skills** and **Available Utility skills** lists whenever a reasonable match exists (exact `skillKey` strings).
4
+ - If a step **requires** a capability that no listed skill provides, you may introduce a **new** `skillKey` on that node.
5
+ - For **every** new `skillKey` you use anywhere in the graph, you **must** include one **`requiredSkills`** array entry in the output with **all** of:
6
+ - `skillKey`, `description`, `expectedInputSchema`, `expectedOutputSchema`, and `rationale` (why no existing skill sufficed).
7
+ - Keep `expectedInputSchema` / `expectedOutputSchema` as concrete JSON Schema–style objects (at least `type`, `properties`, and `required` where applicable) so operators can implement the skill.
@@ -0,0 +1,7 @@
1
+ ## Skill mode: LOCKED
2
+
3
+ - You may **only** use `skillKey` values that appear in the **Available AI skills** and **Available Utility skills** sections above (exact string match).
4
+ - If a step is needed but **no listed skill** can reasonably perform it, **do not** invent a `skillKey`. Instead:
5
+ - Prefer restructuring the graph to approximate the goal with allowed skills, **or**
6
+ - Omit that step and add a **`warnings`** entry describing the catalog gap and what skill would be needed.
7
+ - Never output a node whose `skillKey` is absent from the provided catalogs.
@@ -0,0 +1,52 @@
1
+ [
2
+ {
3
+ "id": "create-simple-linear",
4
+ "input": {
5
+ "intent": { "action": "create", "description": "Read a record, classify it, write the result." },
6
+ "skillMode": "locked",
7
+ "aiSkills": [
8
+ { "skillKey": "professional-answer", "description": "Answer a question about a record with structured output", "isLocal": false }
9
+ ],
10
+ "utilitySkills": [
11
+ { "skillKey": "scoped-data-reader", "description": "Read scoped data from storage", "isLocal": true },
12
+ { "skillKey": "scoped-answer-writer", "description": "Persist assembled answers", "isLocal": true }
13
+ ],
14
+ "constraints": { "requireFinalizer": true }
15
+ }
16
+ },
17
+ {
18
+ "id": "create-branching",
19
+ "input": {
20
+ "intent": { "action": "create", "description": "Read a record, decide if web enrichment is needed, if yes enrich then classify, if no classify directly, then finalize." },
21
+ "skillMode": "locked",
22
+ "aiSkills": [
23
+ { "skillKey": "professional-answer", "description": "Classify with structured output", "isLocal": false },
24
+ { "skillKey": "web-enrich", "description": "Enrich record with web data", "isLocal": false }
25
+ ],
26
+ "utilitySkills": [
27
+ { "skillKey": "scoped-data-reader", "description": "Read scoped data", "isLocal": true },
28
+ { "skillKey": "deterministic-rule", "description": "Evaluate ordered rules locally", "isLocal": true }
29
+ ],
30
+ "constraints": { "requireFinalizer": true, "allowConditionalEdges": true }
31
+ }
32
+ },
33
+ {
34
+ "id": "modify-add-node",
35
+ "input": {
36
+ "intent": { "action": "modify", "description": "Add an exposure-check step between classification and finalization." },
37
+ "existingGraph": { "id": "test.v1", "nodes": [], "edges": [] },
38
+ "skillMode": "extensible",
39
+ "aiSkills": [{ "skillKey": "professional-answer", "description": "Classify", "isLocal": false }],
40
+ "utilitySkills": []
41
+ }
42
+ },
43
+ {
44
+ "id": "explain-basic",
45
+ "input": {
46
+ "intent": { "action": "explain", "description": "Explain this graph." },
47
+ "existingGraph": { "id": "test.v1", "nodes": [], "edges": [] },
48
+ "aiSkills": [],
49
+ "utilitySkills": []
50
+ }
51
+ }
52
+ ]
package/package.json ADDED
@@ -0,0 +1,86 @@
1
+ {
2
+ "name": "@exellix/graph-composer",
3
+ "version": "2.0.0",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "description": "LLM-backed worox-graph DAG composer: create, modify, explain, suggestConceptObjective, reviewConcept, catalog resolution/creation, scoping need match and scoping map creation plans, plus optional orchestrator — OpenRouter via @x12i/funcx; catalog rows from @x12i/catalox (loadCatalogCandidatesFromCatalox)",
8
+ "type": "module",
9
+ "main": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.js",
15
+ "default": "./dist/index.js"
16
+ }
17
+ },
18
+ "bin": {
19
+ "graph-composer": "./dist/cli.js"
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "functions",
24
+ "examples",
25
+ "README.md",
26
+ "LICENSE",
27
+ ".env.example"
28
+ ],
29
+ "scripts": {
30
+ "postinstall": "node -e \"const fs=require('fs'),p=require('path');const s=p.join('node_modules','nx-config2','bin','nx-config2.js'),d=p.join('node_modules','@x12i','env','bin','nx-config2.js');try{if(fs.existsSync(s)&&!fs.existsSync(d))fs.copyFileSync(s,d);}catch(_){}\"",
31
+ "build": "tsc -p tsconfig.build.json",
32
+ "prepublishOnly": "npm run build",
33
+ "start": "x12i-env run --env-file .env -- node dist/cli.js",
34
+ "run:example": "x12i-env run --env-file .env -- tsx src/cli.ts",
35
+ "typecheck": "tsc --noEmit",
36
+ "verify:local": "tsx src/verify-local.ts",
37
+ "verify:catalog-live": "x12i-env run --env-file .env -- tsx scripts/verify-catalog-live.ts",
38
+ "test": "npm run test:unit && npm run test:live",
39
+ "test:unit": "node --import tsx/esm --test --test-force-exit test/unit/explain-shape.test.ts test/unit/graph-concept-patch.test.ts test/unit/graph-concept-story-parse.test.ts test/unit/review-concept-output-validation.test.ts test/unit/review-concept-catalog-alias.test.ts test/unit/redact-for-log.test.ts test/unit/worker-instructions.test.ts test/unit/catalog-output-validation.test.ts test/unit/catalox-catalog-bridge.test.ts test/unit/ai-task-profile.test.ts test/unit/create-modify-output-validation.test.ts test/unit/task-node-task-variable.test.ts test/unit/canonical-graph-document.test.ts test/unit/graph-engine-bridge.test.ts test/unit/example-generation.test.ts",
40
+ "test:live": "x12i-env run --env-file .env -- node --import tsx/esm --test test/live/all.ts",
41
+ "pack:check": "npm pack --dry-run",
42
+ "suggest-smoke": "x12i-env run --env-file .env -- tsx scripts/run-suggest-concept-smoke.ts"
43
+ },
44
+ "keywords": [
45
+ "worox",
46
+ "worox-graph",
47
+ "dag",
48
+ "graph",
49
+ "llm",
50
+ "openrouter",
51
+ "funcx"
52
+ ],
53
+ "license": "MIT",
54
+ "engines": {
55
+ "node": ">=20"
56
+ },
57
+ "repository": {
58
+ "type": "git",
59
+ "url": "git+https://github.com/woroces/graph-composer.git"
60
+ },
61
+ "bugs": {
62
+ "url": "https://github.com/woroces/graph-composer/issues"
63
+ },
64
+ "homepage": "https://github.com/woroces/graph-composer#readme",
65
+ "peerDependencies": {
66
+ "@exellix/graph-engine": "^6.0.0"
67
+ },
68
+ "peerDependenciesMeta": {
69
+ "@exellix/graph-engine": {
70
+ "optional": true
71
+ }
72
+ },
73
+ "dependencies": {
74
+ "@x12i/catalox": "^5.1.1",
75
+ "@x12i/env": "^4.0.1",
76
+ "@x12i/funcx": "^4.0.2",
77
+ "@x12i/logxer": "^4.3.5"
78
+ },
79
+ "devDependencies": {
80
+ "@exellix/graph-engine": "^6.0.0",
81
+ "@types/node": "^22.10.2",
82
+ "nx-config2": "^3.6.5",
83
+ "tsx": "^4.19.2",
84
+ "typescript": "^5.7.2"
85
+ }
86
+ }