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,624 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kernel v3 — Mediator connecting 5 ports.
|
|
3
|
+
*
|
|
4
|
+
* 1:1 parity with Python dna.v3.kernel.__init__.
|
|
5
|
+
*/
|
|
6
|
+
import { Document } from "./document.js";
|
|
7
|
+
import type { CompositionProfile } from "./composition-resolver.js";
|
|
8
|
+
import { HookRegistry, type HookContext, type HookNameArg } from "./hooks.js";
|
|
9
|
+
import { ManifestInstance } from "./instance.js";
|
|
10
|
+
import { type CachePort, type Extension, type KindPort, type ReaderPort, type ResolverPort, type SourcePort, type WriterPort, type StorageDescriptor, type SerializedDocument, type WritableSourcePort, type ToolDefinition } from "./protocols.js";
|
|
11
|
+
import { type Template, type MaterializeOptions } from "./templates.js";
|
|
12
|
+
import { type ResolvedDocument } from "./resolver.js";
|
|
13
|
+
import type { FSLike } from "./fs.js";
|
|
14
|
+
export { kebabKindName, generateAlias, EXPLICIT_ALIAS_ALLOWLIST, KIND_NAME_COLLISION_ALLOWLIST, } from "./kind-registry.js";
|
|
15
|
+
/** Raised when writeDocument/deleteDocument is called but no
|
|
16
|
+
* WritableSourcePort is registered on the Kernel. */
|
|
17
|
+
export declare class NotWritableError extends Error {
|
|
18
|
+
constructor(message?: string);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Return value of Kernel.previewDocument().
|
|
22
|
+
*
|
|
23
|
+
* - `target` — absolute path for filesystem sources, synthetic URL
|
|
24
|
+
* (e.g. "sqlite://<scope>/<kind>/<name>") for others.
|
|
25
|
+
* - `files` — the exact bytes that would be written. Readonly.
|
|
26
|
+
* - `existsAlready` — true iff the target is already present; UIs use
|
|
27
|
+
* this to render "create" vs "overwrite" affordances. Optimistic
|
|
28
|
+
* concurrency (ifMatch) is deferred per
|
|
29
|
+
* docs/superpowers/specs/2026-04-04-kernel-write-path-design.md
|
|
30
|
+
* Out-of-Scope.
|
|
31
|
+
*/
|
|
32
|
+
export interface PreviewResult {
|
|
33
|
+
readonly target: string;
|
|
34
|
+
/** L3 (2026-05-25): files may have `content` (str) or `contentBytes`
|
|
35
|
+
* (Uint8Array). Preview UIs that only render text should fallback
|
|
36
|
+
* to an empty-string display when contentBytes is set. */
|
|
37
|
+
readonly files: readonly import("./protocols.js").SerializedFile[];
|
|
38
|
+
readonly existsAlready: boolean;
|
|
39
|
+
}
|
|
40
|
+
/** i-112 Phase 1 — single source of truth para os special-scope names.
|
|
41
|
+
* Dois papéis distintos (paridade 1:1 com Python protocols.py):
|
|
42
|
+
* DEFAULT_BASE_SCOPE = fallback de herança; SYSTEM_SCOPE = casa dos lookups globais.
|
|
43
|
+
* Ambos "_lib" hoje; nomeados separados pra Fases 2-3 divergirem. */
|
|
44
|
+
export declare const DEFAULT_BASE_SCOPE = "_lib";
|
|
45
|
+
export declare const SYSTEM_SCOPE = "_lib";
|
|
46
|
+
/**
|
|
47
|
+
* The scope that owns the canonical ModelProfile registry.
|
|
48
|
+
* Queried directly by `modelProfile()` — regardless of the caller's scope.
|
|
49
|
+
* 1:1 parity with Python `Kernel._MODEL_REGISTRY_SCOPE`.
|
|
50
|
+
*/
|
|
51
|
+
export declare const MODEL_REGISTRY_SCOPE = "_lib";
|
|
52
|
+
/**
|
|
53
|
+
* The scope that owns the canonical VoicePolicy registry. GLOBAL like
|
|
54
|
+
* ModelProfile — queried directly regardless of the caller's scope.
|
|
55
|
+
* 1:1 parity with Python `Kernel._VOICE_POLICY_SCOPE`.
|
|
56
|
+
*/
|
|
57
|
+
export declare const VOICE_POLICY_SCOPE = "_lib";
|
|
58
|
+
export declare class Kernel {
|
|
59
|
+
private static readonly _BOOTSTRAP_KINDS;
|
|
60
|
+
private static readonly _LEGACY_NON_INHERITABLE;
|
|
61
|
+
static readonly INHERIT_PARENT_SCOPE = "_lib";
|
|
62
|
+
private _classifyKinds;
|
|
63
|
+
/** Kinds structurally never overlayable. Derived from KindPort.isOverlayable
|
|
64
|
+
* (s-kernel-kindport-classification-attrs). 1:1 with Python
|
|
65
|
+
* Kernel._NON_OVERLAYABLE_KINDS. */
|
|
66
|
+
get NON_OVERLAYABLE_KINDS(): ReadonlySet<string>;
|
|
67
|
+
/** Per-scope ledger + structural Kinds that do NOT inherit across scopes.
|
|
68
|
+
* Derived from KindPort.scopeInheritable. 1:1 with Python
|
|
69
|
+
* Kernel._NON_INHERITABLE_KINDS. */
|
|
70
|
+
get NON_INHERITABLE_KINDS(): ReadonlySet<string>;
|
|
71
|
+
/** `k.INHERITABLE_KINDS.has(kind)` — denylist-backed membership (everything
|
|
72
|
+
* inherits EXCEPT NON_INHERITABLE_KINDS). 1:1 with Python _INHERITABLE_KINDS. */
|
|
73
|
+
get INHERITABLE_KINDS(): {
|
|
74
|
+
has(kind: string): boolean;
|
|
75
|
+
};
|
|
76
|
+
private _source;
|
|
77
|
+
private _cache;
|
|
78
|
+
private _resolvers;
|
|
79
|
+
/** @internal — public so the KindRegistry `RegistryHost` slice reaches the
|
|
80
|
+
* rescan gate. Convention `_`-private; not a supported API surface. */
|
|
81
|
+
_readers: ReaderPort[];
|
|
82
|
+
private _writers;
|
|
83
|
+
private _writableSource;
|
|
84
|
+
private _profiles;
|
|
85
|
+
/** Registered-Kind identity map + the registration funnel (Fase 3,
|
|
86
|
+
* s-kernel-decomp-ts-parity). OWNS the `_kinds` Map; the kernel's `_kinds`
|
|
87
|
+
* getter proxies to it, and `kind()`/`kindFromDescriptor()`/
|
|
88
|
+
* `_registerKindDefinitions()`/`_registerCustomKinds()`/`validateDepFilters()`
|
|
89
|
+
* are thin facades. Shared across withTenant copies (Object.assign copies the
|
|
90
|
+
* ref) — Kinds are global, registered once at boot. Py twin:
|
|
91
|
+
* `Kernel._kindreg`. */
|
|
92
|
+
private _kindreg;
|
|
93
|
+
/** The registered-Kind dict — proxied to `this._kindreg` so the ~20 inline
|
|
94
|
+
* `this._kinds` read sites across the kernel keep working after the Fase 3
|
|
95
|
+
* extraction. Key: "apiVersion\0kind". Py twin: `Kernel._kinds` property. */
|
|
96
|
+
get _kinds(): Map<string, KindPort>;
|
|
97
|
+
/** Extensions that successfully registered, in load() order. Used by
|
|
98
|
+
* listTemplates() to aggregate scaffolds from every loaded extension. */
|
|
99
|
+
private _extensions;
|
|
100
|
+
/** Tool-definition registry (s-dna-port-surface-parity — TS twin of the
|
|
101
|
+
* Py `Kernel._toolreg`). Tools are global (not tenant-scoped), so one
|
|
102
|
+
* registry is safely shared across withTenant shallow copies. */
|
|
103
|
+
private _toolreg;
|
|
104
|
+
/** Composition-V2 engine (Phase 17 — s-ts-composition-v2-port). Holds a
|
|
105
|
+
* back-ref to this kernel; the kernel keeps the public methods
|
|
106
|
+
* (resolveDocument / computeResolutionChain / personalizeDocument /
|
|
107
|
+
* compositionSummary) as thin delegators, 1:1 with the Python layout. */
|
|
108
|
+
private readonly _composition;
|
|
109
|
+
/** Document write/delete execution (tenant resolve, layer-policy check,
|
|
110
|
+
* pre_save veto, persist, post_save/post_delete) — extracted collaborator
|
|
111
|
+
* (Fase 2, s-kernel-decomp-f2-writepipeline). The kernel keeps
|
|
112
|
+
* writeDocument/deleteDocument as thin facades. Non-readonly: withTenant
|
|
113
|
+
* re-instantiates it against the copy so a tenant-bound kernel resolves its
|
|
114
|
+
* own tenant. Py twin: `Kernel._write_pipeline`. */
|
|
115
|
+
private _writePipeline;
|
|
116
|
+
readonly hooks: HookRegistry;
|
|
117
|
+
/** @internal — public for the KindRegistry `RegistryHost` slice. */
|
|
118
|
+
_genericsResolved: boolean;
|
|
119
|
+
private _fs;
|
|
120
|
+
/** s-alias-generated-not-typed — owner context for alias generation of
|
|
121
|
+
* the Kinds registered by the Extension currently inside load().
|
|
122
|
+
* @internal — public for the KindRegistry `RegistryHost` slice.
|
|
123
|
+
* Py twin: Kernel._loading_ext_owner. */
|
|
124
|
+
_loadingExtOwner: string | null;
|
|
125
|
+
/** Two-planes F2 — pluggable semantic-search provider (see search()). */
|
|
126
|
+
private _searchProvider;
|
|
127
|
+
/** Damper: warn once per provider-failure episode, then debug. */
|
|
128
|
+
private _searchProviderWarned;
|
|
129
|
+
/**
|
|
130
|
+
* rec-embedding-port — pluggable embedding provider (see embed()). null = no
|
|
131
|
+
* real provider → the deterministic zero-dep FakeEmbeddingProvider (offline/CI
|
|
132
|
+
* floor) is constructed lazily on first use.
|
|
133
|
+
*/
|
|
134
|
+
private _embeddingProvider;
|
|
135
|
+
/**
|
|
136
|
+
* Tenant binding (Phase 1 — tenant-as-first-class).
|
|
137
|
+
*
|
|
138
|
+
* `null` means unbound — only GLOBAL kinds may be written; TENANTED
|
|
139
|
+
* kinds raise `TenantRequired`. Set via the constructor (Sanity
|
|
140
|
+
* `withConfig` pattern) or per-call via `withTenant(other)` (Stripe
|
|
141
|
+
* Connect pattern).
|
|
142
|
+
*/
|
|
143
|
+
tenant: string | null;
|
|
144
|
+
constructor(opts?: {
|
|
145
|
+
tenant?: string | null;
|
|
146
|
+
});
|
|
147
|
+
/**
|
|
148
|
+
* Return a shallow-copy Kernel bound to `tenant`. Original Kernel is
|
|
149
|
+
* unchanged — call sites can hand off the copy to per-request
|
|
150
|
+
* handlers without mutating shared state (Sanity `client.withConfig`
|
|
151
|
+
* pattern).
|
|
152
|
+
*
|
|
153
|
+
* Pass `tenant=null` to obtain an unbound kernel (writes only allowed
|
|
154
|
+
* for GLOBAL kinds).
|
|
155
|
+
*/
|
|
156
|
+
withTenant(tenant: string | null): Kernel;
|
|
157
|
+
/** Return the registered KindPort for a kind name (case-sensitive).
|
|
158
|
+
* With apiVersion the lookup is EXACT on (apiVersion, kind) — bare
|
|
159
|
+
* lookups on a name shared by multiple apiVersions resolve
|
|
160
|
+
* extension-first then registration order (i-195, Py twin:
|
|
161
|
+
* KindRegistry.port_for). */
|
|
162
|
+
private _kindPortFor;
|
|
163
|
+
/** Public lookup for a registered KindPort by kind name. Use from
|
|
164
|
+
* tooling that needs to consult Kind metadata (isRuntimeArtifact,
|
|
165
|
+
* scope, storage, ...) without reaching into Kernel internals. Pass
|
|
166
|
+
* apiVersion for exact resolution on ambiguous names (i-195). */
|
|
167
|
+
kindPortFor(kind: string, apiVersion?: string): KindPort | null;
|
|
168
|
+
/** Validate a Kind-Writer Agent's slot↔schema contract
|
|
169
|
+
* (feat/kind-writer-pilot, Task 2). Called from writeDocument only when
|
|
170
|
+
* spec.writes_kind is set — fail early so a malformed Kind-Writer is
|
|
171
|
+
* rejected before runtime emission. Twin of Python _validate_kind_writer.
|
|
172
|
+
*
|
|
173
|
+
* Contract:
|
|
174
|
+
* - writes_kind must resolve to a registered KindPort whose schema() is an
|
|
175
|
+
* object (schema-bearing); unknown / schema-less → Error (mentions schema).
|
|
176
|
+
* - every creative_slots name must be a property in the schema.
|
|
177
|
+
* - every required schema field must be covered by
|
|
178
|
+
* creative_slots ∪ Object.keys(system_slots); uncovered → "unmapped". */
|
|
179
|
+
/** @internal — called by the Helix extension's Kind-Writer pre_save
|
|
180
|
+
* guard (s-write-path-despecialize). Thin delegator to
|
|
181
|
+
* `WritePipeline.validateKindWriter` (Fase 2,
|
|
182
|
+
* s-kernel-decomp-f2-writepipeline). */
|
|
183
|
+
_validateKindWriter(spec: Record<string, unknown>): void;
|
|
184
|
+
/** All registered KindPorts. Order matches registration. Facade over
|
|
185
|
+
* `this._kindreg.allPorts()` (Fase 3). */
|
|
186
|
+
kindPorts(): KindPort[];
|
|
187
|
+
/** F3 D4 (spec 2026-06-10-kinds-descriptor-f3): kind names whose port
|
|
188
|
+
* declares `embedFields` — via descriptor `embed:` or a class-level
|
|
189
|
+
* `embedFields` (the KindBase parity hook for not-yet-migrated
|
|
190
|
+
* classes). Py twin: `Kernel.embeddable_kinds()` (frozenset). */
|
|
191
|
+
embeddableKinds(): Set<string>;
|
|
192
|
+
/** Return the TenantScope for a registered kind, or null if unset.
|
|
193
|
+
* Phase 1 keeps undeclared kinds permissive (back-compat). @internal —
|
|
194
|
+
* read by WritePipeline.resolveTenantArg via the back-ref. */
|
|
195
|
+
_kindScope(kind: string): string | null;
|
|
196
|
+
use(hook: HookNameArg, fn: (ctx: HookContext) => HookContext): void;
|
|
197
|
+
on(hook: HookNameArg, fn: (ctx: HookContext) => void): void;
|
|
198
|
+
/** Register a veto listener (e.g. 'pre_save') — throwing vetoes the
|
|
199
|
+
* operation. See HookRegistry.onVeto for priority/key semantics. */
|
|
200
|
+
onVeto(hook: HookNameArg, fn: import("./hooks.js").VetoHandler, opts?: {
|
|
201
|
+
priority?: number;
|
|
202
|
+
key?: string;
|
|
203
|
+
}): void;
|
|
204
|
+
source(s: SourcePort): void;
|
|
205
|
+
/** The SourcePort registered via source(), or null. Read-only getter.
|
|
206
|
+
* The setter method is `source(src)`. Named `activeSource` to avoid
|
|
207
|
+
* collision between a method and a property of the same name.
|
|
208
|
+
* Parity: python Kernel.active_source. */
|
|
209
|
+
get activeSource(): SourcePort | null;
|
|
210
|
+
/**
|
|
211
|
+
* Kernel-level record query — push-down delegated to `source.query`
|
|
212
|
+
* (two-planes F2; TS twin of the Py `kernel.query`).
|
|
213
|
+
*
|
|
214
|
+
* Adds on top of the source:
|
|
215
|
+
* - Tenant binding auto-stamp: `opts.tenant` > `Kernel.tenant` > unset
|
|
216
|
+
* (Stripe Connect pattern, same as writeDocument).
|
|
217
|
+
* - Cross-scope `scopes` (F2.4): iterates the scopes with per-scope
|
|
218
|
+
* queries and CONCATENATES without dedup — records from distinct
|
|
219
|
+
* scopes are distinct docs. Mutually exclusive with a diverging
|
|
220
|
+
* positional `scope`: `scopes` wins (the positional is ignored).
|
|
221
|
+
* `limit`/`offset` apply PER scope.
|
|
222
|
+
*
|
|
223
|
+
* Divergence from Py (documented): the TS kernel has NO
|
|
224
|
+
* origin/inheritance machinery (no `origin=` param, no scope-inheritance
|
|
225
|
+
* chain, no catalog pass) — those live in the Py QueryEngine only.
|
|
226
|
+
* Records are per-scope, so the record plane loses nothing.
|
|
227
|
+
*
|
|
228
|
+
* Sources without the optional `query` capability (e.g. PostgresSource
|
|
229
|
+
* TS, no push-down this phase) raise a clear capability error.
|
|
230
|
+
*/
|
|
231
|
+
query(scope: string, kind: string, opts?: {
|
|
232
|
+
filter?: import("./protocols.js").QueryFilter;
|
|
233
|
+
limit?: number;
|
|
234
|
+
offset?: number;
|
|
235
|
+
orderBy?: string[];
|
|
236
|
+
tenant?: string;
|
|
237
|
+
scopes?: string[];
|
|
238
|
+
}): AsyncIterable<Record<string, unknown>>;
|
|
239
|
+
/**
|
|
240
|
+
* F2 D2 — public aggregation count alongside `query` (TS twin of the
|
|
241
|
+
* Py `kernel.count`). Push-down to `source.count` (FS: in-memory core).
|
|
242
|
+
*
|
|
243
|
+
* Returns `CountResult`: `{ total, groups }` — groups by count DESC,
|
|
244
|
+
* key ASC with `null` last; `groups` is `null` without `groupBy`.
|
|
245
|
+
*
|
|
246
|
+
* NO origin/inheritance on purpose — records are per-scope (spec D5:
|
|
247
|
+
* derived views build on top of `kernel.query` in code). Cross-scope
|
|
248
|
+
* via `scopes` (totals SUMMED, groups MERGED by key and re-sorted;
|
|
249
|
+
* `scopes` wins over a diverging positional `scope`).
|
|
250
|
+
*
|
|
251
|
+
* Example (Studio velocity):
|
|
252
|
+
* const res = await kernel.count("dna-development", "Story", {
|
|
253
|
+
* groupBy: "spec.status",
|
|
254
|
+
* });
|
|
255
|
+
* // { total: 950, groups: [{ key: "done", count: 700 }, …] }
|
|
256
|
+
*/
|
|
257
|
+
count(scope: string, kind: string, opts?: {
|
|
258
|
+
filter?: import("./protocols.js").QueryFilter;
|
|
259
|
+
groupBy?: string;
|
|
260
|
+
tenant?: string;
|
|
261
|
+
scopes?: string[];
|
|
262
|
+
}): Promise<import("./protocols.js").CountResult>;
|
|
263
|
+
/**
|
|
264
|
+
* Register the embedding provider (rec-embedding-port). One per kernel; later
|
|
265
|
+
* registration replaces (boot-time wiring). Sibling to
|
|
266
|
+
* `recordSearchProvider` — a real provider (ONNX all-MiniLM-L6-v2) registers
|
|
267
|
+
* itself at app boot; without one, `embed` uses the deterministic
|
|
268
|
+
* `FakeEmbeddingProvider` floor.
|
|
269
|
+
*/
|
|
270
|
+
embeddingProvider(provider: import("./protocols.js").EmbeddingPort): void;
|
|
271
|
+
/** The registered embedding provider, or a lazily-constructed fake (cached).
|
|
272
|
+
* The fake is zero-dep core (js-sha256, already a dependency) so it is a
|
|
273
|
+
* static import — no ML deps enter the graph. */
|
|
274
|
+
private _resolveEmbeddingProvider;
|
|
275
|
+
/**
|
|
276
|
+
* Embed texts into dense vectors (rec-embedding-port; TS twin of the Py
|
|
277
|
+
* `kernel.embed`). Uses the registered `EmbeddingPort` when present, else the
|
|
278
|
+
* deterministic zero-dep fake floor. Returns one `dims`-length vector per
|
|
279
|
+
* input, in order; empty input → empty array. Read the space via
|
|
280
|
+
* `embeddingDims` / `embeddingModelId`.
|
|
281
|
+
*/
|
|
282
|
+
embed(texts: string[]): Promise<number[][]>;
|
|
283
|
+
/** Output dimensionality of the active embedding provider. */
|
|
284
|
+
get embeddingDims(): number;
|
|
285
|
+
/** Identity of the active embedding space (vectors from different `modelId`s
|
|
286
|
+
* are NOT comparable). */
|
|
287
|
+
get embeddingModelId(): string;
|
|
288
|
+
/**
|
|
289
|
+
* Register the semantic-search provider (two-planes F2). One per
|
|
290
|
+
* kernel; later registration replaces (boot-time wiring) and resets
|
|
291
|
+
* the failure-warning damper (new provider → fresh episode).
|
|
292
|
+
*/
|
|
293
|
+
recordSearchProvider(provider: import("./protocols.js").RecordSearchProvider): void;
|
|
294
|
+
/**
|
|
295
|
+
* Public record search (F2 D2; TS twin of the Py `kernel.search`).
|
|
296
|
+
* Provider registered → semantic (degraded=false). No provider OR
|
|
297
|
+
* provider error → lexical token-match fallback over `query()`
|
|
298
|
+
* (degraded=true; requires `kind` — without it returns empty
|
|
299
|
+
* degraded). Tenant binding same as `query()`.
|
|
300
|
+
*/
|
|
301
|
+
search(scope: string, queryText: string, opts?: {
|
|
302
|
+
kind?: string | null;
|
|
303
|
+
k?: number;
|
|
304
|
+
tenant?: string;
|
|
305
|
+
}): Promise<{
|
|
306
|
+
hits: Array<Record<string, unknown>>;
|
|
307
|
+
degraded: boolean;
|
|
308
|
+
}>;
|
|
309
|
+
/**
|
|
310
|
+
* Degraded fallback for `search()` — honest DEV lexical scan, NOT
|
|
311
|
+
* similarity (two-planes F2; 1:1 with the Py `_lexical_search`).
|
|
312
|
+
*
|
|
313
|
+
* Matches by token-set over the STRING VALUES of each doc's spec
|
|
314
|
+
* (recursive walk; never substring over serialized JSON —
|
|
315
|
+
* `json.dumps` Py and `JSON.stringify` TS diverge in separators and
|
|
316
|
+
* would break parity). Requires `kind` (records are scanned per-kind);
|
|
317
|
+
* without it there is nothing safe to scan → empty.
|
|
318
|
+
* Score = query tokens present ÷ total query tokens.
|
|
319
|
+
*/
|
|
320
|
+
private _lexicalSearch;
|
|
321
|
+
/**
|
|
322
|
+
* Internal — one raw doc for a `(scope, kind, name, tenant)` layer key
|
|
323
|
+
* (tenant is "" for the base layer). TS twin of the Py
|
|
324
|
+
* `_granular_doc_cached` MINUS the cache: the TS kernel has no
|
|
325
|
+
* kernel-level doc cache, so this is a direct source read on every
|
|
326
|
+
* call. PERF divergence only — same inputs, same outputs (see
|
|
327
|
+
* composition-resolver.ts module docstring, divergence #1).
|
|
328
|
+
*/
|
|
329
|
+
_granularDoc(key: [string, string, string, string]): Promise<Record<string, unknown> | null>;
|
|
330
|
+
/**
|
|
331
|
+
* Internal — the ordered Catalog scope set for `tenant` (Phase 3b ch1,
|
|
332
|
+
* i-112 on the Py side). The TS kernel has NO catalog machinery yet
|
|
333
|
+
* (Genome scan + tenant lockfile — TS parity tracked as `i-185`), so
|
|
334
|
+
* this hook returns `[]`: the resolver's Catalog splice is fully
|
|
335
|
+
* implemented but contributes no layers on TS today (see
|
|
336
|
+
* composition-resolver.ts module docstring, divergence #3).
|
|
337
|
+
*/
|
|
338
|
+
_catalogScopes(tenant: string | null, opts?: {
|
|
339
|
+
exclude?: Set<string>;
|
|
340
|
+
}): Promise<Array<[string, string | null]>>;
|
|
341
|
+
/**
|
|
342
|
+
* Walk `Genome.spec.parent_scope` transitively → ordered resolution
|
|
343
|
+
* chain of `[scope, tenant]` pairs, HIGHEST priority first:
|
|
344
|
+
* [[scope, tenant], [scope, null], [parent, tenant], [parent, null], …]
|
|
345
|
+
* When `tenant` is null, only base layers are emitted per scope.
|
|
346
|
+
* Cycle detection via visited set; depth capped at MAX_RESOLUTION_DEPTH;
|
|
347
|
+
* missing Genome / missing parent_scope terminates the walk (with the
|
|
348
|
+
* V1 back-compat escalation to `_lib`).
|
|
349
|
+
* Py twin: `Kernel._compute_resolution_chain`.
|
|
350
|
+
*/
|
|
351
|
+
computeResolutionChain(scope: string, tenant?: string | null): Promise<Array<[string, string | null]>>;
|
|
352
|
+
/**
|
|
353
|
+
* Resolve the composition rule `[scope_inheritance, merge_strategy,
|
|
354
|
+
* tenant_overlay]` for (scope, kind) — the scope's
|
|
355
|
+
* `LayerPolicy.composition_rules[kind]`, else the inherit-by-default
|
|
356
|
+
* denylist. Py twin: `Kernel._get_composition_rule`.
|
|
357
|
+
*/
|
|
358
|
+
getCompositionRule(scope: string, kind: string): Promise<[string, string, string]>;
|
|
359
|
+
/**
|
|
360
|
+
* Resolve a doc through the composition chain — Phase 17 primitive.
|
|
361
|
+
* Returns `ResolvedDocument` with merged doc + full provenance.
|
|
362
|
+
* Bootstrap Kinds (Genome, LayerPolicy, KindDefinition) bypass
|
|
363
|
+
* inheritance entirely (local-only, single-layer provenance).
|
|
364
|
+
* Py twin: `Kernel.resolve_document`.
|
|
365
|
+
*/
|
|
366
|
+
resolveDocument(scope: string, kind: string, name: string, opts?: {
|
|
367
|
+
tenant?: string | null;
|
|
368
|
+
}): Promise<ResolvedDocument>;
|
|
369
|
+
/**
|
|
370
|
+
* Clone an inherited doc into `targetScope` as a local override.
|
|
371
|
+
* Throws when the doc isn't inherited or the target already exists
|
|
372
|
+
* (without `overwrite`). Py twin: `Kernel.personalize_document`
|
|
373
|
+
* (bundle-entry payload cloning is Py-only — divergence #4 in
|
|
374
|
+
* composition-resolver.ts).
|
|
375
|
+
*/
|
|
376
|
+
personalizeDocument(targetScope: string, kind: string, name: string, opts?: {
|
|
377
|
+
tenant?: string | null;
|
|
378
|
+
overwrite?: boolean;
|
|
379
|
+
}): Promise<ResolvedDocument>;
|
|
380
|
+
/**
|
|
381
|
+
* Cheap aggregate of the scope's parent chain + per-Kind local /
|
|
382
|
+
* inherited / installed counts (Py twin: `Kernel.composition_summary`;
|
|
383
|
+
* same snake_case wire shape:
|
|
384
|
+
* `{scope, parent_chain, resources: {Kind: {local, inherited, installed,
|
|
385
|
+
* total}}}`). The Py twin rides its QueryEngine origin filters; the TS
|
|
386
|
+
* kernel has no origin machinery, so the three passes are computed here
|
|
387
|
+
* directly with the SAME dedup semantics (local names shadow catalog +
|
|
388
|
+
* parent names; catalog names do NOT shadow inherited — mirroring the
|
|
389
|
+
* three independent origin-filtered queries Python makes). `installed`
|
|
390
|
+
* is always 0 until the TS catalog surface lands (i-185).
|
|
391
|
+
*/
|
|
392
|
+
compositionSummary(scope: string, opts?: {
|
|
393
|
+
tenant?: string | null;
|
|
394
|
+
}): Promise<Record<string, unknown>>;
|
|
395
|
+
/** WriterPorts registered via writer(w). Returns a FROZEN snapshot of
|
|
396
|
+
* the internal writer list — mutating the returned array throws in
|
|
397
|
+
* strict mode and never affects the Kernel's internal state.
|
|
398
|
+
* Parity: python Kernel.active_writers (which returns a tuple). */
|
|
399
|
+
get activeWriters(): readonly WriterPort[];
|
|
400
|
+
/** ReaderPorts registered via reader(r). Frozen snapshot — mirror of
|
|
401
|
+
* activeWriters (s-dna-rw-roundtrip-suite: the round-trip conformance
|
|
402
|
+
* suite enumerates registered pairs through this surface).
|
|
403
|
+
* Parity: python Kernel.active_readers. */
|
|
404
|
+
get activeReaders(): readonly ReaderPort[];
|
|
405
|
+
cache(c: CachePort): void;
|
|
406
|
+
resolver(scheme: string, r: ResolverPort): void;
|
|
407
|
+
reader(r: ReaderPort): void;
|
|
408
|
+
writer(w: WriterPort): void;
|
|
409
|
+
writableSource(ws: WritableSourcePort): void;
|
|
410
|
+
fs(f: FSLike): void;
|
|
411
|
+
/** Register a Kind (H1 validation funnel). Thin facade over
|
|
412
|
+
* `this._kindreg.registerKind()` (Fase 3, s-kernel-decomp-ts-parity —
|
|
413
|
+
* the funnel moved into the KindRegistry; Py twin: `Kernel.kind()`
|
|
414
|
+
* delegating to `self._kindreg.register_kind`). */
|
|
415
|
+
kind(k: KindPort): void;
|
|
416
|
+
/** F3 (spec D3): register a BUILTIN Kind from a KindDefinition
|
|
417
|
+
* descriptor (`kinds/*.kind.yaml` package data). Thin facade over the
|
|
418
|
+
* KindRegistry funnel (Fase 3). Py twin: `Kernel.kind_from_descriptor`. */
|
|
419
|
+
kindFromDescriptor(raw: Record<string, unknown>): KindPort;
|
|
420
|
+
/** Summary dict for a registered kind, including resolved docs. Facade
|
|
421
|
+
* over `this._kindreg.describe()` (Fase 3). */
|
|
422
|
+
describeKind(kindName: string): Record<string, unknown> | null;
|
|
423
|
+
/** Register a composition profile that declares how an orchestrator
|
|
424
|
+
* kind connects to other kinds. Called by extensions (e.g.
|
|
425
|
+
* HelixExtension) during register(). */
|
|
426
|
+
compositionProfile(profile: CompositionProfile): void;
|
|
427
|
+
/** Register a tool definition (delegates to the ToolRegistry;
|
|
428
|
+
* last-write-wins on same name). Py twin: `Kernel.tool`. */
|
|
429
|
+
tool(td: ToolDefinition): void;
|
|
430
|
+
/** Return a tool definition by name, or `null` if unknown.
|
|
431
|
+
* Py twin: `Kernel.get_tool`. */
|
|
432
|
+
getTool(name: string): ToolDefinition | null;
|
|
433
|
+
/** Return registered tool definitions, optionally filtered by group(s)
|
|
434
|
+
* (`groups: ["read"]` expands the umbrella alias).
|
|
435
|
+
* Py twin: `Kernel.get_tools`. */
|
|
436
|
+
getTools(opts?: {
|
|
437
|
+
group?: string | null;
|
|
438
|
+
groups?: Iterable<string> | null;
|
|
439
|
+
}): ToolDefinition[];
|
|
440
|
+
/** Reverse-build `{group: [toolNames…]}` from the registry.
|
|
441
|
+
* Py twin: `Kernel.list_tool_groups`. */
|
|
442
|
+
listToolGroups(): Record<string, string[]>;
|
|
443
|
+
/** Canonical dep_filter target resolution (s-alias-generated-not-typed).
|
|
444
|
+
*
|
|
445
|
+
* The CONTRACT is alias-valued dep_filters (`"soulspec-soul"`). The
|
|
446
|
+
* legacy `"kind=<Name>"` format resolves through a DEPRECATED shim so
|
|
447
|
+
* per-scope KindDefinition docs keep working. Builtin extensions must
|
|
448
|
+
* be alias-pure (validateDepFilters rejects `kind=` there). Delegates
|
|
449
|
+
* to the shared `resolveDepFilterTargetOver` — since
|
|
450
|
+
* s-unify-composition-subsystems the ONE resolver every dep_filter
|
|
451
|
+
* reader (`validateRefs` / `mi.composition` / the Kernel) consumes.
|
|
452
|
+
* Facade over `this._kindreg.resolveDepFilterTarget()` (Fase 3).
|
|
453
|
+
* Py twin: KindRegistry.resolve_dep_filter_target. */
|
|
454
|
+
resolveDepFilterTarget(value: string): KindPort | null;
|
|
455
|
+
/** s-alias-generated-not-typed — every dep_filter target of an
|
|
456
|
+
* EXTENSION-registered Kind must resolve to a registered alias.
|
|
457
|
+
*
|
|
458
|
+
* Aliases are the wire key of dep_filters / Mustache sections /
|
|
459
|
+
* LayerPolicy — a typo used to degrade the prompt SILENTLY (the dep
|
|
460
|
+
* just vanished from the context, warning buried in logs). Called at
|
|
461
|
+
* the end of `loadBuiltins()` (the TS twin of `Kernel.auto()`).
|
|
462
|
+
*
|
|
463
|
+
* - Extension/builtin port with an unknown alias OR the legacy
|
|
464
|
+
* `kind=` format → `KindRegistrationError` (boot fails loud).
|
|
465
|
+
* - Per-scope declarative ports (user KindDefinition docs) only WARN
|
|
466
|
+
* — user docs never take the boot down (same posture as the
|
|
467
|
+
* parse_error / plane-lint funnels).
|
|
468
|
+
* Facade over `this._kindreg.validateDepFilters()` (Fase 3).
|
|
469
|
+
* Py twin: Kernel.validate_dep_filters. */
|
|
470
|
+
validateDepFilters(): void;
|
|
471
|
+
load(ext: Extension): void;
|
|
472
|
+
/**
|
|
473
|
+
* Aggregate `templates()` from every loaded extension.
|
|
474
|
+
*
|
|
475
|
+
* The `templates()` method is feature-tested via
|
|
476
|
+
* `typeof ext.templates === "function"` so extensions that predate
|
|
477
|
+
* Phase 0 (and don't declare the method) still work. A misbehaving
|
|
478
|
+
* extension that throws inside its `templates()` is logged to
|
|
479
|
+
* `console.warn` but never breaks discovery for the other
|
|
480
|
+
* extensions.
|
|
481
|
+
*/
|
|
482
|
+
listTemplates(): Template[];
|
|
483
|
+
/**
|
|
484
|
+
* Materialize a template by id into `opts.targetRoot`.
|
|
485
|
+
*
|
|
486
|
+
* Throws `Error("template not found: <id>")` if no loaded extension
|
|
487
|
+
* advertises a template with the given id (the TS equivalent of
|
|
488
|
+
* Python's `KeyError`). `opts.onConflict` is passed through to
|
|
489
|
+
* {@link materialize}.
|
|
490
|
+
*/
|
|
491
|
+
scaffold(templateId: string, opts: MaterializeOptions): string[];
|
|
492
|
+
/** @internal — public for the KindRegistry `RegistryHost` slice (the
|
|
493
|
+
* 2-phase-load rescan re-resolves generic BUNDLE readers/writers here). */
|
|
494
|
+
_ensureGenericReadersWriters(): void;
|
|
495
|
+
containerForKind(kindName: string): string | null;
|
|
496
|
+
storageForKind(kindName: string): StorageDescriptor | null;
|
|
497
|
+
kindByContainer(container: string): string | null;
|
|
498
|
+
/**
|
|
499
|
+
* Stable human-readable locator for a document.
|
|
500
|
+
*
|
|
501
|
+
* - Filesystem sources (detected by the presence of a `baseDir`
|
|
502
|
+
* property) → "<baseDir>/<scope>/<kindSubdir>/<name>"
|
|
503
|
+
* - Other sources → "<scheme>://<scope>/<kind>/<name>" where scheme
|
|
504
|
+
* comes from source.urlScheme, falling back to the class name with
|
|
505
|
+
* the trailing "source" suffix stripped.
|
|
506
|
+
*
|
|
507
|
+
* Parity: python Kernel._target_locator.
|
|
508
|
+
*/
|
|
509
|
+
_targetLocator(scope: string, kind: string, name: string): string;
|
|
510
|
+
serializeDocument(_scope: string, kind: string, name: string, raw: Record<string, unknown>): SerializedDocument;
|
|
511
|
+
/**
|
|
512
|
+
* Pure preview — returns target, serialized files, existsAlready.
|
|
513
|
+
*
|
|
514
|
+
* Does NOT touch disk. ``existsAlready`` is a UI hint so callers can
|
|
515
|
+
* render "create" vs "overwrite" affordances. Parity: Python
|
|
516
|
+
* Kernel.preview_document.
|
|
517
|
+
*/
|
|
518
|
+
previewDocument(scope: string, kind: string, name: string, raw: Record<string, unknown>): Promise<PreviewResult>;
|
|
519
|
+
/**
|
|
520
|
+
* Best-effort probe: is the target document already present?
|
|
521
|
+
*
|
|
522
|
+
* Uses the writable source's `listVersions` when available (non-empty
|
|
523
|
+
* = exists). Returns false on any adapter failure — this is a UI hint,
|
|
524
|
+
* not a correctness gate. Parity: Python Kernel._target_exists.
|
|
525
|
+
*/
|
|
526
|
+
private _targetExists;
|
|
527
|
+
writeDocument(scope: string, kind: string, name: string, raw: Record<string, unknown>, options?: {
|
|
528
|
+
skipHooks?: boolean;
|
|
529
|
+
author?: string;
|
|
530
|
+
tenant?: string | null;
|
|
531
|
+
layer?: [string, string];
|
|
532
|
+
}): Promise<string>;
|
|
533
|
+
deleteDocument(scope: string, kind: string, name: string, options?: {
|
|
534
|
+
skipHooks?: boolean;
|
|
535
|
+
author?: string;
|
|
536
|
+
tenant?: string | null;
|
|
537
|
+
layer?: [string, string];
|
|
538
|
+
}): Promise<void>;
|
|
539
|
+
/** @internal — resolve the registered writable source or throw
|
|
540
|
+
* NotWritableError. Used by WritePipeline (Py twin:
|
|
541
|
+
* `Kernel._require_writable_source`). */
|
|
542
|
+
_requireWritableSource(): WritableSourcePort;
|
|
543
|
+
/**
|
|
544
|
+
* Per-scope cache of the base (no-layer) ManifestInstance. Used by the
|
|
545
|
+
* layer-policy check so it does not re-resolve layers per call. Mirrors
|
|
546
|
+
* Python KernelCache._base (the kernel's extracted cache collaborator).
|
|
547
|
+
*/
|
|
548
|
+
private _baseInstanceCache;
|
|
549
|
+
/** LRU bound on _baseInstanceCache (scopes). Mirrors Py _BASE_INSTANCE_MAX (i-036). */
|
|
550
|
+
private static readonly BASE_INSTANCE_MAX;
|
|
551
|
+
private _ensureBaseInstance;
|
|
552
|
+
/**
|
|
553
|
+
* Resolve a kind name to its globally-unique alias (`<owner>-<kind>`).
|
|
554
|
+
* Falls back to `kind.toLowerCase()` when no registered port provides one.
|
|
555
|
+
* Facade over `this._kindreg.aliasFor()` (Fase 3). Parity: Python
|
|
556
|
+
* Kernel._alias_for delegating to `self._kindreg.alias_for`.
|
|
557
|
+
*/
|
|
558
|
+
private _aliasFor;
|
|
559
|
+
/**
|
|
560
|
+
* Validate that writing/deleting `kind/name` in `scope` against the given
|
|
561
|
+
* layer overlay satisfies the Module's LayerPolicy (OPEN / RESTRICTED /
|
|
562
|
+
* LOCKED). Parity: Python Kernel._check_layer_policy.
|
|
563
|
+
*
|
|
564
|
+
* Policy modes (resolved via alias `<owner>-<kind>`):
|
|
565
|
+
* - LOCKED — any write throws.
|
|
566
|
+
* - RESTRICTED — adding a new doc (not present in base) throws; adding a
|
|
567
|
+
* *new top-level spec key* on an existing doc throws; overriding
|
|
568
|
+
* existing top-level spec keys is allowed.
|
|
569
|
+
* - OPEN (default) — never throws.
|
|
570
|
+
*
|
|
571
|
+
* When the scope has no Module doc, policy defaults to OPEN (no-op).
|
|
572
|
+
*/
|
|
573
|
+
/** @internal — read by WritePipeline (write/delete policy gate). */
|
|
574
|
+
_checkLayerPolicyAsync(scope: string, kind: string, name: string, raw: unknown, layer: [string, string]): Promise<void>;
|
|
575
|
+
instance(scope: string, layers?: Record<string, string>): Promise<ManifestInstance>;
|
|
576
|
+
resolveLayers(mi: ManifestInstance, layers: Record<string, string>): Promise<ManifestInstance>;
|
|
577
|
+
private _applyLayers;
|
|
578
|
+
/**
|
|
579
|
+
* If a kind declares `descriptionFallbackField` and metadata.description
|
|
580
|
+
* is missing/empty, derive it from the named spec field. Mutates `raw`.
|
|
581
|
+
*/
|
|
582
|
+
static _fillDerivedDescription(raw: Record<string, unknown>, kindPort: unknown): void;
|
|
583
|
+
_parseDoc(raw: Record<string, unknown>, origin?: string): Document;
|
|
584
|
+
/**
|
|
585
|
+
* Phase 1 of 2-phase loading: parse KindDefinition docs + register
|
|
586
|
+
* synthetic DeclarativeKindPorts. Thin facade over the KindRegistry
|
|
587
|
+
* funnel (Fase 3, s-kernel-decomp-ts-parity). Returns true iff new
|
|
588
|
+
* BUNDLE readers were added (the rescan gate). Py twin:
|
|
589
|
+
* `Kernel._register_kind_definitions`.
|
|
590
|
+
*/
|
|
591
|
+
private _registerKindDefinitions;
|
|
592
|
+
/** Register dynamic `Module.spec.custom_kinds`. Thin facade over the
|
|
593
|
+
* KindRegistry funnel (Fase 3). Py twin: `Kernel._register_custom_kinds`. */
|
|
594
|
+
private _registerCustomKinds;
|
|
595
|
+
/** s-realtime-model-single-default — 1:1 parity with the Python kernel:
|
|
596
|
+
* the realtime fallback the prompt-budget guard caps against resolves
|
|
597
|
+
* through ONE env (DNA_VOICE_REALTIME_MODEL), read at ACCESS time so a
|
|
598
|
+
* pin set after construction still applies. */
|
|
599
|
+
readonly _DEFAULT_REALTIME_MODEL_FALLBACK = "gpt-realtime-2";
|
|
600
|
+
get _DEFAULT_REALTIME_MODEL(): string;
|
|
601
|
+
/**
|
|
602
|
+
* Resolve a ModelProfile from the `_lib` scope by `model_id` (pass 1)
|
|
603
|
+
* or `aliases[]` (pass 2). Returns the matching Document or null on miss.
|
|
604
|
+
*
|
|
605
|
+
* Always queries `MODEL_REGISTRY_SCOPE` ("_lib") directly — ModelProfile
|
|
606
|
+
* is GLOBAL and NOT in `INHERITABLE_KINDS`; any caller scope is irrelevant.
|
|
607
|
+
*
|
|
608
|
+
* 1:1 parity with Python `Kernel.model_profile(model_id_or_alias)`.
|
|
609
|
+
*
|
|
610
|
+
* @param modelIdOrAlias - The model_id string or an alias declared in the profile.
|
|
611
|
+
* @returns The matching Document, or null on miss or error.
|
|
612
|
+
*/
|
|
613
|
+
modelProfile(modelIdOrAlias: string): Promise<import("./document.js").Document | null>;
|
|
614
|
+
/**
|
|
615
|
+
* Resolve a VoicePolicy from the `_lib` scope by metadata name.
|
|
616
|
+
* Returns the matching Document, the first policy as a fallback, or null
|
|
617
|
+
* on miss/error. Always queries `VOICE_POLICY_SCOPE` ("_lib")
|
|
618
|
+
* directly — VoicePolicy is GLOBAL and NOT in `INHERITABLE_KINDS`.
|
|
619
|
+
*
|
|
620
|
+
* 1:1 parity with Python `Kernel.voice_policy(name)`.
|
|
621
|
+
*/
|
|
622
|
+
voicePolicy(name?: string): Promise<import("./document.js").Document | null>;
|
|
623
|
+
}
|
|
624
|
+
export { ManifestInstance } from "./instance.js";
|