dna-sdk 0.1.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/LICENSE +21 -0
- package/README.md +58 -0
- package/dist/adapters/embedding/onnx.d.ts +32 -0
- package/dist/adapters/embedding/onnx.js +51 -0
- package/dist/adapters/filesystem/cache.d.ts +16 -0
- package/dist/adapters/filesystem/cache.js +113 -0
- package/dist/adapters/filesystem/index.d.ts +2 -0
- package/dist/adapters/filesystem/index.js +2 -0
- package/dist/adapters/filesystem/source.d.ts +82 -0
- package/dist/adapters/filesystem/source.js +357 -0
- package/dist/adapters/postgres/index.d.ts +2 -0
- package/dist/adapters/postgres/index.js +2 -0
- package/dist/adapters/postgres/migrations.d.ts +14 -0
- package/dist/adapters/postgres/migrations.js +88 -0
- package/dist/adapters/postgres/source.d.ts +172 -0
- package/dist/adapters/postgres/source.js +569 -0
- package/dist/adapters/resolvers/github.d.ts +12 -0
- package/dist/adapters/resolvers/github.js +47 -0
- package/dist/adapters/resolvers/http.d.ts +22 -0
- package/dist/adapters/resolvers/http.js +145 -0
- package/dist/adapters/resolvers/index.d.ts +3 -0
- package/dist/adapters/resolvers/index.js +3 -0
- package/dist/adapters/resolvers/local.d.ts +24 -0
- package/dist/adapters/resolvers/local.js +132 -0
- package/dist/adapters/search/driver.d.ts +45 -0
- package/dist/adapters/search/driver.js +138 -0
- package/dist/adapters/search/migrations.d.ts +26 -0
- package/dist/adapters/search/migrations.js +58 -0
- package/dist/adapters/search/rrf.d.ts +23 -0
- package/dist/adapters/search/rrf.js +42 -0
- package/dist/adapters/search/sqlite-vec.d.ts +66 -0
- package/dist/adapters/search/sqlite-vec.js +294 -0
- package/dist/bootstrap.d.ts +45 -0
- package/dist/bootstrap.js +134 -0
- package/dist/extensions/agentskills/DOCS.md +18 -0
- package/dist/extensions/agentskills.d.ts +28 -0
- package/dist/extensions/agentskills.js +252 -0
- package/dist/extensions/agentsmd/DOCS.md +18 -0
- package/dist/extensions/agentsmd.d.ts +22 -0
- package/dist/extensions/agentsmd.js +170 -0
- package/dist/extensions/audit/kinds/audit-log.kind.yaml +148 -0
- package/dist/extensions/audit.d.ts +25 -0
- package/dist/extensions/audit.js +62 -0
- package/dist/extensions/automation/kinds/automation.kind.yaml +296 -0
- package/dist/extensions/automation/query.d.ts +49 -0
- package/dist/extensions/automation/query.js +77 -0
- package/dist/extensions/automation/write-guards.d.ts +59 -0
- package/dist/extensions/automation/write-guards.js +153 -0
- package/dist/extensions/automation.d.ts +41 -0
- package/dist/extensions/automation.js +54 -0
- package/dist/extensions/collab.d.ts +16 -0
- package/dist/extensions/collab.js +79 -0
- package/dist/extensions/doc/kinds/doc.kind.yaml +118 -0
- package/dist/extensions/doc.d.ts +25 -0
- package/dist/extensions/doc.js +10 -0
- package/dist/extensions/eval/kinds/eval-baseline.kind.yaml +65 -0
- package/dist/extensions/eval/kinds/eval-case.kind.yaml +140 -0
- package/dist/extensions/eval/kinds/eval-run.kind.yaml +134 -0
- package/dist/extensions/eval/kinds/eval-suite.kind.yaml +87 -0
- package/dist/extensions/eval.d.ts +24 -0
- package/dist/extensions/eval.js +31 -0
- package/dist/extensions/evidence/kinds/evidence.kind.yaml +92 -0
- package/dist/extensions/evidence.d.ts +17 -0
- package/dist/extensions/evidence.js +94 -0
- package/dist/extensions/federation.d.ts +22 -0
- package/dist/extensions/federation.js +173 -0
- package/dist/extensions/guardrails/DOCS.md +20 -0
- package/dist/extensions/guardrails.d.ts +31 -0
- package/dist/extensions/guardrails.js +228 -0
- package/dist/extensions/helix/DOCS-Actor.md +20 -0
- package/dist/extensions/helix/DOCS-Agent.md +20 -0
- package/dist/extensions/helix/DOCS-UseCase.md +20 -0
- package/dist/extensions/helix/layers.d.ts +12 -0
- package/dist/extensions/helix/layers.js +18 -0
- package/dist/extensions/helix/write-guards.d.ts +70 -0
- package/dist/extensions/helix/write-guards.js +172 -0
- package/dist/extensions/helix.d.ts +29 -0
- package/dist/extensions/helix.js +963 -0
- package/dist/extensions/helix_extras.d.ts +124 -0
- package/dist/extensions/helix_extras.js +328 -0
- package/dist/extensions/hooks.d.ts +31 -0
- package/dist/extensions/hooks.js +247 -0
- package/dist/extensions/kinddef/DOCS.md +24 -0
- package/dist/extensions/kinddef.d.ts +40 -0
- package/dist/extensions/kinddef.js +171 -0
- package/dist/extensions/lesson.d.ts +6 -0
- package/dist/extensions/lesson.js +194 -0
- package/dist/extensions/modelreg/kinds/model-profile.kind.yaml +155 -0
- package/dist/extensions/modelreg.d.ts +30 -0
- package/dist/extensions/modelreg.js +38 -0
- package/dist/extensions/recognizer.d.ts +34 -0
- package/dist/extensions/recognizer.js +272 -0
- package/dist/extensions/research.d.ts +32 -0
- package/dist/extensions/research.js +292 -0
- package/dist/extensions/safety.d.ts +33 -0
- package/dist/extensions/safety.js +230 -0
- package/dist/extensions/sdlc/kinds/adr.kind.yaml +136 -0
- package/dist/extensions/sdlc/kinds/archive-proposal.kind.yaml +107 -0
- package/dist/extensions/sdlc/kinds/changelog.kind.yaml +108 -0
- package/dist/extensions/sdlc/kinds/cognitive-policy.kind.yaml +470 -0
- package/dist/extensions/sdlc/kinds/forecast.kind.yaml +125 -0
- package/dist/extensions/sdlc/kinds/insight.kind.yaml +87 -0
- package/dist/extensions/sdlc/kinds/kaizen.kind.yaml +106 -0
- package/dist/extensions/sdlc/kinds/lesson-learned.kind.yaml +270 -0
- package/dist/extensions/sdlc/kinds/narrative.kind.yaml +189 -0
- package/dist/extensions/sdlc/kinds/pattern-insight.kind.yaml +204 -0
- package/dist/extensions/sdlc/kinds/postmortem.kind.yaml +168 -0
- package/dist/extensions/sdlc/kinds/pre-mortem.kind.yaml +145 -0
- package/dist/extensions/sdlc/kinds/prompt-template.kind.yaml +109 -0
- package/dist/extensions/sdlc/kinds/retrospective.kind.yaml +186 -0
- package/dist/extensions/sdlc/kinds/risk-register.kind.yaml +178 -0
- package/dist/extensions/sdlc/kinds/saved-view.kind.yaml +127 -0
- package/dist/extensions/sdlc/kinds/status-report.kind.yaml +129 -0
- package/dist/extensions/sdlc/kinds/synthesis-run.kind.yaml +279 -0
- package/dist/extensions/sdlc/kinds/synthesizer-state.kind.yaml +196 -0
- package/dist/extensions/sdlc/kinds/workflow-event.kind.yaml +195 -0
- package/dist/extensions/sdlc.d.ts +32 -0
- package/dist/extensions/sdlc.js +1318 -0
- package/dist/extensions/soulspec/DOCS.md +19 -0
- package/dist/extensions/soulspec.d.ts +22 -0
- package/dist/extensions/soulspec.js +287 -0
- package/dist/extensions/tenant.d.ts +6 -0
- package/dist/extensions/tenant.js +291 -0
- package/dist/extensions/testkit.d.ts +24 -0
- package/dist/extensions/testkit.js +211 -0
- package/dist/index.d.ts +80 -0
- package/dist/index.js +102 -0
- package/dist/kernel/_text.d.ts +28 -0
- package/dist/kernel/_text.js +42 -0
- package/dist/kernel/bundle-handle.d.ts +83 -0
- package/dist/kernel/bundle-handle.js +184 -0
- package/dist/kernel/capabilities.d.ts +157 -0
- package/dist/kernel/capabilities.js +109 -0
- package/dist/kernel/collaborator-ports.d.ts +91 -0
- package/dist/kernel/collaborator-ports.js +1 -0
- package/dist/kernel/composition-resolver.d.ts +215 -0
- package/dist/kernel/composition-resolver.js +558 -0
- package/dist/kernel/composition.d.ts +10 -0
- package/dist/kernel/composition.js +1 -0
- package/dist/kernel/descriptor-loader.d.ts +13 -0
- package/dist/kernel/descriptor-loader.js +48 -0
- package/dist/kernel/document.d.ts +43 -0
- package/dist/kernel/document.js +71 -0
- package/dist/kernel/embedding.d.ts +28 -0
- package/dist/kernel/embedding.js +78 -0
- package/dist/kernel/errors.d.ts +62 -0
- package/dist/kernel/errors.js +82 -0
- package/dist/kernel/events.d.ts +6 -0
- package/dist/kernel/events.js +21 -0
- package/dist/kernel/evidence-capture.d.ts +69 -0
- package/dist/kernel/evidence-capture.js +138 -0
- package/dist/kernel/fs.d.ts +20 -0
- package/dist/kernel/fs.js +128 -0
- package/dist/kernel/generic-rw.d.ts +33 -0
- package/dist/kernel/generic-rw.js +235 -0
- package/dist/kernel/hooks.d.ts +172 -0
- package/dist/kernel/hooks.js +256 -0
- package/dist/kernel/index.d.ts +624 -0
- package/dist/kernel/index.js +1638 -0
- package/dist/kernel/instance.d.ts +211 -0
- package/dist/kernel/instance.js +487 -0
- package/dist/kernel/kind-registry.d.ts +183 -0
- package/dist/kernel/kind-registry.js +710 -0
- package/dist/kernel/kind_base.d.ts +106 -0
- package/dist/kernel/kind_base.js +244 -0
- package/dist/kernel/layer-resolver.d.ts +48 -0
- package/dist/kernel/layer-resolver.js +284 -0
- package/dist/kernel/lock-manager.d.ts +21 -0
- package/dist/kernel/lock-manager.js +43 -0
- package/dist/kernel/lock.d.ts +38 -0
- package/dist/kernel/lock.js +115 -0
- package/dist/kernel/meta.d.ts +135 -0
- package/dist/kernel/meta.js +817 -0
- package/dist/kernel/models.d.ts +3089 -0
- package/dist/kernel/models.js +764 -0
- package/dist/kernel/navigator.d.ts +36 -0
- package/dist/kernel/navigator.js +132 -0
- package/dist/kernel/port-surface.d.ts +33 -0
- package/dist/kernel/port-surface.js +180 -0
- package/dist/kernel/preview.d.ts +60 -0
- package/dist/kernel/preview.js +54 -0
- package/dist/kernel/prompt-budget.d.ts +39 -0
- package/dist/kernel/prompt-budget.js +43 -0
- package/dist/kernel/prompt-builder.d.ts +25 -0
- package/dist/kernel/prompt-builder.js +237 -0
- package/dist/kernel/protocols.d.ts +751 -0
- package/dist/kernel/protocols.js +493 -0
- package/dist/kernel/reports.d.ts +26 -0
- package/dist/kernel/reports.js +215 -0
- package/dist/kernel/resolver.d.ts +146 -0
- package/dist/kernel/resolver.js +232 -0
- package/dist/kernel/resource.d.ts +57 -0
- package/dist/kernel/resource.js +97 -0
- package/dist/kernel/runtime.d.ts +16 -0
- package/dist/kernel/runtime.js +18 -0
- package/dist/kernel/safety-scanner.d.ts +38 -0
- package/dist/kernel/safety-scanner.js +228 -0
- package/dist/kernel/serialize-to-files.d.ts +29 -0
- package/dist/kernel/serialize-to-files.js +23 -0
- package/dist/kernel/spec-access.d.ts +23 -0
- package/dist/kernel/spec-access.js +40 -0
- package/dist/kernel/studio_ui.d.ts +88 -0
- package/dist/kernel/studio_ui.js +135 -0
- package/dist/kernel/templates.d.ts +77 -0
- package/dist/kernel/templates.js +116 -0
- package/dist/kernel/tool-registry.d.ts +52 -0
- package/dist/kernel/tool-registry.js +89 -0
- package/dist/kernel/write-pipeline.d.ts +65 -0
- package/dist/kernel/write-pipeline.js +271 -0
- package/dist/kernel/writer-helpers.d.ts +24 -0
- package/dist/kernel/writer-helpers.js +42 -0
- package/dist/memory/decay.d.ts +31 -0
- package/dist/memory/decay.js +97 -0
- package/dist/memory/ecphory.d.ts +25 -0
- package/dist/memory/ecphory.js +178 -0
- package/dist/memory/encodingContext.d.ts +21 -0
- package/dist/memory/encodingContext.js +62 -0
- package/dist/memory/index.d.ts +23 -0
- package/dist/memory/index.js +23 -0
- package/dist/memory/memoryType.d.ts +7 -0
- package/dist/memory/memoryType.js +24 -0
- package/dist/memory/policy.d.ts +35 -0
- package/dist/memory/policy.js +35 -0
- package/dist/memory/retrieval.d.ts +21 -0
- package/dist/memory/retrieval.js +145 -0
- package/dist/testing/index.d.ts +8 -0
- package/dist/testing/index.js +8 -0
- package/dist/testing/recordSearchConformance.d.ts +43 -0
- package/dist/testing/recordSearchConformance.js +147 -0
- package/dist/viz/ascii.d.ts +7 -0
- package/dist/viz/ascii.js +60 -0
- package/dist/viz/health.d.ts +8 -0
- package/dist/viz/health.js +161 -0
- package/dist/viz/index.d.ts +10 -0
- package/dist/viz/index.js +10 -0
- package/dist/viz/matrix.d.ts +8 -0
- package/dist/viz/matrix.js +84 -0
- package/dist/viz/mermaid.d.ts +38 -0
- package/dist/viz/mermaid.js +706 -0
- package/package.json +82 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { KindBase } from "../kernel/kind_base.js";
|
|
2
|
+
import { SD } from "../kernel/protocols.js";
|
|
3
|
+
import { loadDescriptors } from "../kernel/descriptor-loader.js";
|
|
4
|
+
const API_VERSION = "github.com/ruinosus/dna/audit/v1";
|
|
5
|
+
const ORIGIN = "github.com/ruinosus/dna/audit";
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
// UserRoleAssignmentKind
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
class UserRoleAssignmentKind extends KindBase {
|
|
10
|
+
apiVersion = API_VERSION;
|
|
11
|
+
kind = "UserRoleAssignment";
|
|
12
|
+
alias = "audit-userroleassignment";
|
|
13
|
+
origin = ORIGIN;
|
|
14
|
+
isPromptTarget = false;
|
|
15
|
+
isRuntimeArtifact = false;
|
|
16
|
+
promptTargetPriority = 0;
|
|
17
|
+
flattenInContext = false;
|
|
18
|
+
storage = SD.yaml("user-roles");
|
|
19
|
+
graphStyle = { fill: "#6366f1", stroke: "#4f46e5", textColor: "#fff" };
|
|
20
|
+
asciiIcon = "👥";
|
|
21
|
+
displayLabel = "User Role";
|
|
22
|
+
docs = "Persistent role assignment for a user inside a tenant. The doc name IS the " +
|
|
23
|
+
"user_id. Roles list is the source of truth for require_role decorators when " +
|
|
24
|
+
"Clerk webhook sync is enabled.";
|
|
25
|
+
dependencies() { return null; }
|
|
26
|
+
summary() { return null; }
|
|
27
|
+
schema() {
|
|
28
|
+
return {
|
|
29
|
+
type: "object",
|
|
30
|
+
required: ["user_id", "roles", "updated_at"],
|
|
31
|
+
additionalProperties: true,
|
|
32
|
+
properties: {
|
|
33
|
+
user_id: { type: "string", description: "Identity claim (sub or email)." },
|
|
34
|
+
email: { type: "string" },
|
|
35
|
+
roles: {
|
|
36
|
+
type: "array",
|
|
37
|
+
items: { type: "string" },
|
|
38
|
+
description: "Authoritative role list. Backend require_role reads claims.roles " +
|
|
39
|
+
"which is set by Clerk via JWT — this Kind is the admin-managed " +
|
|
40
|
+
"mirror for Clerk's org membership.",
|
|
41
|
+
},
|
|
42
|
+
note: { type: "string", description: "Free-form admin note (hire date, etc)." },
|
|
43
|
+
updated_at: { type: "string", format: "date-time" },
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// ---------------------------------------------------------------------------
|
|
49
|
+
// Extension
|
|
50
|
+
// ---------------------------------------------------------------------------
|
|
51
|
+
export class AuditExtension {
|
|
52
|
+
name = "audit";
|
|
53
|
+
version = "1.0.0";
|
|
54
|
+
register(kernel) {
|
|
55
|
+
kernel.kind(new UserRoleAssignmentKind());
|
|
56
|
+
// expr batch A: AuditLog as a descriptor — kinds/*.kind.yaml package data
|
|
57
|
+
// registered through the SAME funnel as per-scope KindDefinitions.
|
|
58
|
+
for (const raw of loadDescriptors(import.meta.url, "audit/kinds")) {
|
|
59
|
+
kernel.kindFromDescriptor(raw);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
# Automation — unified declarative background automation (record plane).
|
|
2
|
+
#
|
|
3
|
+
# Tier A port from the internal SDK's automation extension
|
|
4
|
+
# (s-tier-a-automation). Upstream, one Automation doc REPLACED a trio of
|
|
5
|
+
# structurally-identical Kinds (async-tool job / bus-event hook / cron
|
|
6
|
+
# schedule) with a single superset schema discriminated by ``on.type`` —
|
|
7
|
+
# the piece that killed hardcoded dispatch: adding or retargeting an
|
|
8
|
+
# automation is writing one YAML, zero deploy. What travels is the
|
|
9
|
+
# DECLARATION: the Kind, its validation and the query helpers
|
|
10
|
+
# (``dna.extensions.automation.query``). EXECUTION does not travel — the
|
|
11
|
+
# SDK has no scheduler/bus/worker; the host reads Automation docs via the
|
|
12
|
+
# query helpers and runs them (extension point documented in
|
|
13
|
+
# docs/concepts/builtin-kinds.md, same declare-here/execute-in-the-host
|
|
14
|
+
# pattern as the CLI's register_post_transition_hook).
|
|
15
|
+
#
|
|
16
|
+
# Trigger vocabulary (honest evolution of the upstream discriminator):
|
|
17
|
+
# - cron — 5-field cron expression; the write guard
|
|
18
|
+
# (dna/extensions/automation/write_guards.py + TS twin) parses it at
|
|
19
|
+
# write time (zero-dep validator, no name aliases like JAN/MON).
|
|
20
|
+
# - hook — a kernel lifecycle hook name; upstream's free-form bus-event
|
|
21
|
+
# trigger becomes the kernel's OWN typed vocabulary (KNOWN_HOOK_NAMES,
|
|
22
|
+
# s-dna-typed-hook-names) and the write guard vetoes unknown names.
|
|
23
|
+
# - tool — an async dispatch tool the host exposes to the model
|
|
24
|
+
# (tool_name + declared input_schema + primary_input).
|
|
25
|
+
#
|
|
26
|
+
# Deliberately NOT ported (coupled to the upstream product, not the Kind):
|
|
27
|
+
# - ``on.condition: shallow_scope`` + ``on.window_minutes`` — cognitive-
|
|
28
|
+
# autopilot gating with no DNA equivalent;
|
|
29
|
+
# - runner kind ``engine`` — upstream cognitive engines; DNA runners are
|
|
30
|
+
# the real Kinds Agent (kind=agent) and Tool (kind=tool).
|
|
31
|
+
#
|
|
32
|
+
# tenant_scope intentionally NOT declared — permissive (base + per-tenant
|
|
33
|
+
# overlay). Automation is an inheritable `_lib` default (it is already in
|
|
34
|
+
# DEFAULT_INHERITABLE_KINDS_V1); the máxima "inheritable ⇒ never TENANTED"
|
|
35
|
+
# applies (test_inheritable_kinds_tenancy.py).
|
|
36
|
+
#
|
|
37
|
+
# PARITY-CRITICAL package data: byte-identical mirror under both runtimes'
|
|
38
|
+
# automation/kinds/ (tests/test_descriptor_hash_parity.py enforces).
|
|
39
|
+
apiVersion: github.com/ruinosus/dna/core/v1
|
|
40
|
+
kind: KindDefinition
|
|
41
|
+
metadata:
|
|
42
|
+
name: automation
|
|
43
|
+
spec:
|
|
44
|
+
target_api_version: github.com/ruinosus/dna/automation/v1
|
|
45
|
+
target_kind: Automation
|
|
46
|
+
alias: dna-automation
|
|
47
|
+
origin: github.com/ruinosus/dna/automation
|
|
48
|
+
plane: record
|
|
49
|
+
prompt_target: false
|
|
50
|
+
flatten_in_context: false
|
|
51
|
+
prompt_target_priority: 0
|
|
52
|
+
storage:
|
|
53
|
+
type: yaml
|
|
54
|
+
container: automations
|
|
55
|
+
spec_defaults:
|
|
56
|
+
enabled: true
|
|
57
|
+
schema:
|
|
58
|
+
type: object
|
|
59
|
+
required:
|
|
60
|
+
- 'on'
|
|
61
|
+
- runner
|
|
62
|
+
additionalProperties: false
|
|
63
|
+
properties:
|
|
64
|
+
'on':
|
|
65
|
+
type: object
|
|
66
|
+
required:
|
|
67
|
+
- type
|
|
68
|
+
additionalProperties: false
|
|
69
|
+
description: The trigger. type=cron → scheduled (5-field cron
|
|
70
|
+
expression, validated at write); type=hook → a kernel lifecycle
|
|
71
|
+
hook name (KNOWN_HOOK_NAMES vocabulary, validated at write);
|
|
72
|
+
type=tool → an async dispatch tool the host exposes to the model.
|
|
73
|
+
properties:
|
|
74
|
+
type:
|
|
75
|
+
type: string
|
|
76
|
+
enum:
|
|
77
|
+
- cron
|
|
78
|
+
- hook
|
|
79
|
+
- tool
|
|
80
|
+
cron:
|
|
81
|
+
type: string
|
|
82
|
+
description: 5-field cron 'min hour dom mon dow', e.g.
|
|
83
|
+
'0 10 * * 1,3,5'. Parsed at write time by the automation
|
|
84
|
+
write guard (numeric fields, '*', ranges, lists, steps —
|
|
85
|
+
no JAN/MON name aliases).
|
|
86
|
+
hook:
|
|
87
|
+
type: string
|
|
88
|
+
description: Kernel lifecycle hook that fires this automation,
|
|
89
|
+
e.g. 'post_save' or 'post_build_prompt'. Must be one of the
|
|
90
|
+
kernel's KNOWN_HOOK_NAMES — the write guard vetoes unknown
|
|
91
|
+
names.
|
|
92
|
+
tool_name:
|
|
93
|
+
type: string
|
|
94
|
+
description: The dispatch tool the model sees (e.g.
|
|
95
|
+
deep_research_async).
|
|
96
|
+
input_schema:
|
|
97
|
+
type: array
|
|
98
|
+
description: Declared args of the dispatch tool (all strings).
|
|
99
|
+
items:
|
|
100
|
+
type: object
|
|
101
|
+
required:
|
|
102
|
+
- name
|
|
103
|
+
additionalProperties: true
|
|
104
|
+
properties:
|
|
105
|
+
name:
|
|
106
|
+
type: string
|
|
107
|
+
type:
|
|
108
|
+
type: string
|
|
109
|
+
description:
|
|
110
|
+
type: string
|
|
111
|
+
required:
|
|
112
|
+
type: boolean
|
|
113
|
+
default:
|
|
114
|
+
type: string
|
|
115
|
+
primary_input:
|
|
116
|
+
type: string
|
|
117
|
+
description: Which input arg carries the main user content fed
|
|
118
|
+
to an agent runner. Defaults to the first input_schema entry.
|
|
119
|
+
allOf:
|
|
120
|
+
- if:
|
|
121
|
+
properties:
|
|
122
|
+
type:
|
|
123
|
+
const: cron
|
|
124
|
+
required:
|
|
125
|
+
- type
|
|
126
|
+
then:
|
|
127
|
+
required:
|
|
128
|
+
- cron
|
|
129
|
+
- if:
|
|
130
|
+
properties:
|
|
131
|
+
type:
|
|
132
|
+
const: hook
|
|
133
|
+
required:
|
|
134
|
+
- type
|
|
135
|
+
then:
|
|
136
|
+
required:
|
|
137
|
+
- hook
|
|
138
|
+
- if:
|
|
139
|
+
properties:
|
|
140
|
+
type:
|
|
141
|
+
const: tool
|
|
142
|
+
required:
|
|
143
|
+
- type
|
|
144
|
+
then:
|
|
145
|
+
required:
|
|
146
|
+
- tool_name
|
|
147
|
+
runner:
|
|
148
|
+
type: object
|
|
149
|
+
required:
|
|
150
|
+
- kind
|
|
151
|
+
- ref
|
|
152
|
+
additionalProperties: false
|
|
153
|
+
properties:
|
|
154
|
+
kind:
|
|
155
|
+
type: string
|
|
156
|
+
enum:
|
|
157
|
+
- agent
|
|
158
|
+
- tool
|
|
159
|
+
ref:
|
|
160
|
+
type: string
|
|
161
|
+
description: Agent name (kind=agent) or Tool name (kind=tool)
|
|
162
|
+
that executes the automation.
|
|
163
|
+
model:
|
|
164
|
+
type: string
|
|
165
|
+
description: Optional model override for the runner.
|
|
166
|
+
expected_output:
|
|
167
|
+
type: string
|
|
168
|
+
enum:
|
|
169
|
+
- slug
|
|
170
|
+
- json
|
|
171
|
+
- text
|
|
172
|
+
description: For an agent runner, what the agent should
|
|
173
|
+
produce. 'slug' = persist a real domain doc (result_kind) and
|
|
174
|
+
return its slug; 'text'/'json' = return prose/structured
|
|
175
|
+
output inline. Hosts default to 'text'.
|
|
176
|
+
timeout_seconds:
|
|
177
|
+
type: number
|
|
178
|
+
description: Wall-clock budget the host should give one run.
|
|
179
|
+
agent_directive:
|
|
180
|
+
type: string
|
|
181
|
+
description: Dispatch instruction sent to an agent runner (with
|
|
182
|
+
{arg} placeholders). Optional — a tool runner needs none.
|
|
183
|
+
input:
|
|
184
|
+
type: object
|
|
185
|
+
additionalProperties: true
|
|
186
|
+
description: Structured input the host resolves into the runner's
|
|
187
|
+
context. Hosts may support tokens such as {scope}, {now},
|
|
188
|
+
{utc_date}.
|
|
189
|
+
result_kind:
|
|
190
|
+
type: string
|
|
191
|
+
description: Kind the automation output should be persisted as
|
|
192
|
+
(e.g. Research, Doc) when the runner produces a document.
|
|
193
|
+
result_spec_template:
|
|
194
|
+
type: object
|
|
195
|
+
additionalProperties: true
|
|
196
|
+
description: Deterministic persist template — when an agent runner
|
|
197
|
+
synthesizes but does not persist a doc itself, the host creates a
|
|
198
|
+
result_kind doc from this template ({arg} fills from the args,
|
|
199
|
+
{output} from the agent synthesis).
|
|
200
|
+
running_message:
|
|
201
|
+
type: string
|
|
202
|
+
description: Spoken/UI copy returned at dispatch (tool trigger).
|
|
203
|
+
done_message:
|
|
204
|
+
type: string
|
|
205
|
+
description: Spoken/UI copy attached to the finished run. Supports
|
|
206
|
+
{placeholders} from the args.
|
|
207
|
+
enabled:
|
|
208
|
+
type: boolean
|
|
209
|
+
description: Disabled automations stay declared but hosts must not
|
|
210
|
+
fire them (automations_for filters them out by default).
|
|
211
|
+
description:
|
|
212
|
+
type: string
|
|
213
|
+
labels:
|
|
214
|
+
type: array
|
|
215
|
+
items:
|
|
216
|
+
type: string
|
|
217
|
+
safety:
|
|
218
|
+
type: object
|
|
219
|
+
additionalProperties: false
|
|
220
|
+
description: Loop-safety the HOST enforces for this automation. All
|
|
221
|
+
fields optional — an absent field falls back to the host default.
|
|
222
|
+
properties:
|
|
223
|
+
debounce_seconds:
|
|
224
|
+
type: number
|
|
225
|
+
minimum: 0
|
|
226
|
+
description: Coalesce repeated fires within this window into
|
|
227
|
+
one.
|
|
228
|
+
cooldown_minutes:
|
|
229
|
+
type: integer
|
|
230
|
+
minimum: 0
|
|
231
|
+
description: Do not re-fire for the same scope within this
|
|
232
|
+
wall-clock window.
|
|
233
|
+
max_fires_per_minute:
|
|
234
|
+
type: integer
|
|
235
|
+
minimum: 1
|
|
236
|
+
description: Circuit-breaker rate cap per (scope, automation).
|
|
237
|
+
max_fan_out:
|
|
238
|
+
type: integer
|
|
239
|
+
minimum: 1
|
|
240
|
+
description: Cap on documents one fire may produce.
|
|
241
|
+
idempotency_key:
|
|
242
|
+
type: string
|
|
243
|
+
description: Template, e.g. '{scope}:{utc_date}'. A 2nd fire
|
|
244
|
+
with the same resolved key is a no-op.
|
|
245
|
+
describe:
|
|
246
|
+
path: description
|
|
247
|
+
description_fallback_field: description
|
|
248
|
+
summary:
|
|
249
|
+
on_type:
|
|
250
|
+
path: on.type
|
|
251
|
+
trigger:
|
|
252
|
+
paths:
|
|
253
|
+
- on.cron
|
|
254
|
+
- on.hook
|
|
255
|
+
- on.tool_name
|
|
256
|
+
filter_falsy: true
|
|
257
|
+
runner_kind:
|
|
258
|
+
path: runner.kind
|
|
259
|
+
default: ''
|
|
260
|
+
runner_ref:
|
|
261
|
+
path: runner.ref
|
|
262
|
+
default: ''
|
|
263
|
+
enabled: true
|
|
264
|
+
ui:
|
|
265
|
+
mode: build
|
|
266
|
+
label:
|
|
267
|
+
en: Automations
|
|
268
|
+
pt-BR: Automações
|
|
269
|
+
icon: ⚙️
|
|
270
|
+
description:
|
|
271
|
+
en: 'Unified declarative automation: cron/hook/tool trigger + runner.'
|
|
272
|
+
pt-BR: 'Automação declarativa unificada: gatilho cron/hook/tool + runner.'
|
|
273
|
+
routes:
|
|
274
|
+
list: docs/Automation
|
|
275
|
+
detail: docs/Automation/:name
|
|
276
|
+
permissions:
|
|
277
|
+
list: any
|
|
278
|
+
detail: any
|
|
279
|
+
in_sidebar: true
|
|
280
|
+
display_order: 54
|
|
281
|
+
graph_style:
|
|
282
|
+
fill: '#60A5FA'
|
|
283
|
+
stroke: '#2563EB'
|
|
284
|
+
text_color: '#fff'
|
|
285
|
+
ascii_icon: ⚙️
|
|
286
|
+
display_label: Automations
|
|
287
|
+
docs: An Automation declares background work as data — ``on`` picks the
|
|
288
|
+
trigger (cron = 5-field schedule; hook = a kernel lifecycle hook name
|
|
289
|
+
from KNOWN_HOOK_NAMES; tool = an async dispatch tool the host exposes
|
|
290
|
+
to the model), ``runner`` picks what executes (an Agent or a Tool by
|
|
291
|
+
name), plus the shared agent_directive / input / result templating /
|
|
292
|
+
spoken copy / safety block. Adding or retargeting an automation is
|
|
293
|
+
writing one YAML, zero deploy. The SDK validates and lists (see
|
|
294
|
+
``dna.extensions.automation.query.automations_for``); the HOST
|
|
295
|
+
executes — the runner contract is an extension point, documented in
|
|
296
|
+
docs/concepts/builtin-kinds.md.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query helpers a host executor uses to read Automation docs.
|
|
3
|
+
*
|
|
4
|
+
* The SDK declares and validates automations; the HOST executes them (see
|
|
5
|
+
* docs/concepts/builtin-kinds.md — the execution extension point). These
|
|
6
|
+
* helpers are the read side of that contract, built strictly on the
|
|
7
|
+
* blessed instance query surface (`instance.all`): no kernel method is
|
|
8
|
+
* added — listing automations is extension domain knowledge, not
|
|
9
|
+
* microkernel surface.
|
|
10
|
+
*
|
|
11
|
+
* Usage (host executor):
|
|
12
|
+
*
|
|
13
|
+
* const mi = await kernel.instance("my-scope");
|
|
14
|
+
* for (const doc of automationsFor(mi, "cron")) {
|
|
15
|
+
* schedule(triggerKey(doc), doc.spec.runner, doc.spec);
|
|
16
|
+
* }
|
|
17
|
+
*
|
|
18
|
+
* 1:1 parity with Python `dna.extensions.automation.query`.
|
|
19
|
+
*/
|
|
20
|
+
import type { Document } from "../../kernel/document.js";
|
|
21
|
+
/** The `on.type` discriminator vocabulary (mirrors the descriptor enum). */
|
|
22
|
+
export declare const TRIGGER_TYPES: readonly ["cron", "hook", "tool"];
|
|
23
|
+
export type TriggerType = (typeof TRIGGER_TYPES)[number];
|
|
24
|
+
/** The narrow instance surface the helpers read through. */
|
|
25
|
+
interface QueryableInstance {
|
|
26
|
+
all(kind: string): Document[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* List the scope's Automation docs, filtered for a host executor.
|
|
30
|
+
*
|
|
31
|
+
* - `triggerType` — keep only automations whose `on.type` matches
|
|
32
|
+
* (`"cron"` / `"hook"` / `"tool"`); `null`/omitted returns all.
|
|
33
|
+
* - `enabledOnly` (default true) — drop docs with `enabled: false`
|
|
34
|
+
* (declared but paused; hosts must not fire them).
|
|
35
|
+
*
|
|
36
|
+
* `instance` is a `ManifestInstance` — the blessed query surface. Source
|
|
37
|
+
* order is preserved (inherited `_lib` defaults resolve like any other
|
|
38
|
+
* Kind; a tenant overlay wins per the layer policy).
|
|
39
|
+
*/
|
|
40
|
+
export declare function automationsFor(instance: QueryableInstance, triggerType?: TriggerType | null, opts?: {
|
|
41
|
+
enabledOnly?: boolean;
|
|
42
|
+
}): Document[];
|
|
43
|
+
/**
|
|
44
|
+
* The trigger's identifying value: the cron expression (`cron`), the
|
|
45
|
+
* hook name (`hook`) or the dispatch tool name (`tool`). Null when the
|
|
46
|
+
* trigger is missing/unknown.
|
|
47
|
+
*/
|
|
48
|
+
export declare function triggerKey(doc: Document): string | null;
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query helpers a host executor uses to read Automation docs.
|
|
3
|
+
*
|
|
4
|
+
* The SDK declares and validates automations; the HOST executes them (see
|
|
5
|
+
* docs/concepts/builtin-kinds.md — the execution extension point). These
|
|
6
|
+
* helpers are the read side of that contract, built strictly on the
|
|
7
|
+
* blessed instance query surface (`instance.all`): no kernel method is
|
|
8
|
+
* added — listing automations is extension domain knowledge, not
|
|
9
|
+
* microkernel surface.
|
|
10
|
+
*
|
|
11
|
+
* Usage (host executor):
|
|
12
|
+
*
|
|
13
|
+
* const mi = await kernel.instance("my-scope");
|
|
14
|
+
* for (const doc of automationsFor(mi, "cron")) {
|
|
15
|
+
* schedule(triggerKey(doc), doc.spec.runner, doc.spec);
|
|
16
|
+
* }
|
|
17
|
+
*
|
|
18
|
+
* 1:1 parity with Python `dna.extensions.automation.query`.
|
|
19
|
+
*/
|
|
20
|
+
const KIND = "Automation";
|
|
21
|
+
/** The `on.type` discriminator vocabulary (mirrors the descriptor enum). */
|
|
22
|
+
export const TRIGGER_TYPES = ["cron", "hook", "tool"];
|
|
23
|
+
function specOf(doc) {
|
|
24
|
+
const spec = doc.spec;
|
|
25
|
+
return typeof spec === "object" && spec !== null && !Array.isArray(spec)
|
|
26
|
+
? spec
|
|
27
|
+
: {};
|
|
28
|
+
}
|
|
29
|
+
function onOf(spec) {
|
|
30
|
+
const on = spec.on;
|
|
31
|
+
return typeof on === "object" && on !== null && !Array.isArray(on)
|
|
32
|
+
? on
|
|
33
|
+
: {};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* List the scope's Automation docs, filtered for a host executor.
|
|
37
|
+
*
|
|
38
|
+
* - `triggerType` — keep only automations whose `on.type` matches
|
|
39
|
+
* (`"cron"` / `"hook"` / `"tool"`); `null`/omitted returns all.
|
|
40
|
+
* - `enabledOnly` (default true) — drop docs with `enabled: false`
|
|
41
|
+
* (declared but paused; hosts must not fire them).
|
|
42
|
+
*
|
|
43
|
+
* `instance` is a `ManifestInstance` — the blessed query surface. Source
|
|
44
|
+
* order is preserved (inherited `_lib` defaults resolve like any other
|
|
45
|
+
* Kind; a tenant overlay wins per the layer policy).
|
|
46
|
+
*/
|
|
47
|
+
export function automationsFor(instance, triggerType = null, opts = {}) {
|
|
48
|
+
const enabledOnly = opts.enabledOnly ?? true;
|
|
49
|
+
if (triggerType !== null && !TRIGGER_TYPES.includes(triggerType)) {
|
|
50
|
+
throw new Error(`unknown triggerType ${JSON.stringify(triggerType)} — expected one ` +
|
|
51
|
+
`of ${JSON.stringify(TRIGGER_TYPES)}`);
|
|
52
|
+
}
|
|
53
|
+
const out = [];
|
|
54
|
+
for (const doc of instance.all(KIND)) {
|
|
55
|
+
const spec = specOf(doc);
|
|
56
|
+
const on = onOf(spec);
|
|
57
|
+
if (triggerType !== null && on.type !== triggerType)
|
|
58
|
+
continue;
|
|
59
|
+
if (enabledOnly && spec.enabled === false)
|
|
60
|
+
continue;
|
|
61
|
+
out.push(doc);
|
|
62
|
+
}
|
|
63
|
+
return out;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The trigger's identifying value: the cron expression (`cron`), the
|
|
67
|
+
* hook name (`hook`) or the dispatch tool name (`tool`). Null when the
|
|
68
|
+
* trigger is missing/unknown.
|
|
69
|
+
*/
|
|
70
|
+
export function triggerKey(doc) {
|
|
71
|
+
const on = onOf(specOf(doc));
|
|
72
|
+
const pick = on.type === "cron" ? on.cron
|
|
73
|
+
: on.type === "hook" ? on.hook
|
|
74
|
+
: on.type === "tool" ? on.tool_name
|
|
75
|
+
: null;
|
|
76
|
+
return typeof pick === "string" ? pick : null;
|
|
77
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Automation-owned write-path guards (s-tier-a-automation).
|
|
3
|
+
*
|
|
4
|
+
* One `pre_save` VETO hook that makes an Automation write *fully valid or
|
|
5
|
+
* not persisted*, covering what is Automation's OWN:
|
|
6
|
+
*
|
|
7
|
+
* - **Semantics the schema cannot express:**
|
|
8
|
+
*
|
|
9
|
+
* - **cron expression** (`on.type: cron`) — parsed by a zero-dependency
|
|
10
|
+
* 5-field validator (documented decision: a cron lib would be a
|
|
11
|
+
* runtime dep for one field; the grammar below covers the standard
|
|
12
|
+
* crontab core — `*`, numbers, ranges, lists, steps — and rejects the
|
|
13
|
+
* rest loudly. Name aliases like `JAN`/`MON` are NOT supported.)
|
|
14
|
+
* - **hook name** (`on.type: hook`) — must belong to the kernel's typed
|
|
15
|
+
* hook vocabulary `KNOWN_HOOK_NAMES` (s-dna-typed-hook-names). The
|
|
16
|
+
* HookRegistry itself tolerates custom names (warn-once), but an
|
|
17
|
+
* Automation is DATA a host executor dispatches on: a misspelled hook
|
|
18
|
+
* would be declared, listed, and silently never fire — so here the
|
|
19
|
+
* unknown name is a veto, not a warning.
|
|
20
|
+
*
|
|
21
|
+
* The Python twin has one extra FIRST step this side does not need: PyYAML
|
|
22
|
+
* reads a bare `on:` key as boolean `True` (YAML 1.1), so the Py guard
|
|
23
|
+
* heals a top-level `True` spec key back to `"on"` before validating.
|
|
24
|
+
* js-yaml keeps `on` a string — no trap, no step.
|
|
25
|
+
*
|
|
26
|
+
* Schema SHAPE at write time (originally this guard's step 1) is no longer
|
|
27
|
+
* Automation-specific: `s-write-path-validation` (i-008) generalized it —
|
|
28
|
+
* `WritePipeline.write` validates every doc's spec against the Kind's
|
|
29
|
+
* declared `schema()` after the veto hooks run. This guard keeps only the
|
|
30
|
+
* semantics JSON Schema cannot express.
|
|
31
|
+
*
|
|
32
|
+
* A throw from the guard vetoes the write (nothing is persisted). The hook
|
|
33
|
+
* fires for EVERY `kernel.writeDocument` regardless of `skipHooks` — it is
|
|
34
|
+
* an integrity gate, not a notification. 1:1 parity with Python
|
|
35
|
+
* `dna.extensions.automation.write_guards`.
|
|
36
|
+
*/
|
|
37
|
+
import type { PreSaveContext } from "../../kernel/hooks.js";
|
|
38
|
+
export declare const PRIORITY_TRIGGER_GUARD = 50;
|
|
39
|
+
/**
|
|
40
|
+
* Validate a 5-field cron expression. Throws on the first problem
|
|
41
|
+
* (didactic message); returns void when valid.
|
|
42
|
+
*/
|
|
43
|
+
export declare function validateCronExpression(expr: string): void;
|
|
44
|
+
/**
|
|
45
|
+
* Veto an Automation write that is not fully valid.
|
|
46
|
+
*
|
|
47
|
+
* Checks the semantics JSON Schema cannot express (cron grammar,
|
|
48
|
+
* hook-name vocabulary). Schema SHAPE is validated by the kernel's
|
|
49
|
+
* generic write-path step (s-write-path-validation, i-008), which runs
|
|
50
|
+
* after the veto hooks — this guard no longer duplicates it.
|
|
51
|
+
*/
|
|
52
|
+
export declare function automationTriggerGuard(ctx: PreSaveContext): void;
|
|
53
|
+
/**
|
|
54
|
+
* Wire the Automation write guard as a `pre_save` veto hook.
|
|
55
|
+
*
|
|
56
|
+
* The key makes the registration idempotent (re-loading the extension
|
|
57
|
+
* onto a shared HookRegistry replaces instead of stacking duplicates).
|
|
58
|
+
*/
|
|
59
|
+
export declare function registerWriteGuards(kernel: unknown): void;
|