@telorun/sdk 0.60.0 → 0.62.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.
@@ -0,0 +1,31 @@
1
+ /**
2
+ * The ambient kernel error union: codes any dispatch can raise because the
3
+ * kernel — not the kind's controller — enforces the invocation contract.
4
+ *
5
+ * They are **catchable**: a `catches:` entry may name one and its `when:` is
6
+ * validated against this set, so a typo is caught statically like any declared
7
+ * code. They are **excluded from coverage counting**: the completeness rule
8
+ * keeps counting only a kind's own `throws:` codes. Folding them into every
9
+ * union instead would make every bounded `catches:` block in the standard
10
+ * library incomplete overnight; making them uncatchable would leave an author no
11
+ * way to handle a contract violation they can legitimately recover from.
12
+ *
13
+ * Shared by the kernel (which raises them), the analyzer (which type-checks
14
+ * `catches:` against them) and module authors (who name them in a catch).
15
+ */
16
+ /** Inputs did not satisfy the target's declared `inputType`. */
17
+ export declare const ERR_INPUT_INVALID = "ERR_INPUT_INVALID";
18
+ /** A result did not satisfy the target's declared `outputType`. */
19
+ export declare const ERR_OUTPUT_INVALID = "ERR_OUTPUT_INVALID";
20
+ /** A declared contract could not be resolved to a schema — a named type that
21
+ * never registered. Distinct from a value violation: nothing is wrong with the
22
+ * data, the contract itself is unusable, and enforcement must fail rather than
23
+ * quietly switch itself off. */
24
+ export declare const ERR_CONTRACT_UNRESOLVABLE = "ERR_CONTRACT_UNRESOLVABLE";
25
+ export declare const AMBIENT_CONTRACT_ERROR_CODES: readonly ["ERR_INPUT_INVALID", "ERR_OUTPUT_INVALID", "ERR_CONTRACT_UNRESOLVABLE"];
26
+ export type AmbientContractErrorCode = (typeof AMBIENT_CONTRACT_ERROR_CODES)[number];
27
+ /** True when a code is raised by the kernel's contract enforcement rather than
28
+ * declared by a kind. Callers use it to accept the code in a `catches:` entry
29
+ * without counting it toward that kind's declared union. */
30
+ export declare function isAmbientContractErrorCode(code: string): boolean;
31
+ //# sourceMappingURL=contract-errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract-errors.d.ts","sourceRoot":"","sources":["../src/contract-errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,gEAAgE;AAChE,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AAErD,mEAAmE;AACnE,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AAEvD;;;iCAGiC;AACjC,eAAO,MAAM,yBAAyB,8BAA8B,CAAC;AAErE,eAAO,MAAM,4BAA4B,mFAI/B,CAAC;AAEX,MAAM,MAAM,wBAAwB,GAAG,CAAC,OAAO,4BAA4B,CAAC,CAAC,MAAM,CAAC,CAAC;AAIrF;;6DAE6D;AAC7D,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEhE"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * The ambient kernel error union: codes any dispatch can raise because the
3
+ * kernel — not the kind's controller — enforces the invocation contract.
4
+ *
5
+ * They are **catchable**: a `catches:` entry may name one and its `when:` is
6
+ * validated against this set, so a typo is caught statically like any declared
7
+ * code. They are **excluded from coverage counting**: the completeness rule
8
+ * keeps counting only a kind's own `throws:` codes. Folding them into every
9
+ * union instead would make every bounded `catches:` block in the standard
10
+ * library incomplete overnight; making them uncatchable would leave an author no
11
+ * way to handle a contract violation they can legitimately recover from.
12
+ *
13
+ * Shared by the kernel (which raises them), the analyzer (which type-checks
14
+ * `catches:` against them) and module authors (who name them in a catch).
15
+ */
16
+ /** Inputs did not satisfy the target's declared `inputType`. */
17
+ export const ERR_INPUT_INVALID = "ERR_INPUT_INVALID";
18
+ /** A result did not satisfy the target's declared `outputType`. */
19
+ export const ERR_OUTPUT_INVALID = "ERR_OUTPUT_INVALID";
20
+ /** A declared contract could not be resolved to a schema — a named type that
21
+ * never registered. Distinct from a value violation: nothing is wrong with the
22
+ * data, the contract itself is unusable, and enforcement must fail rather than
23
+ * quietly switch itself off. */
24
+ export const ERR_CONTRACT_UNRESOLVABLE = "ERR_CONTRACT_UNRESOLVABLE";
25
+ export const AMBIENT_CONTRACT_ERROR_CODES = [
26
+ ERR_INPUT_INVALID,
27
+ ERR_OUTPUT_INVALID,
28
+ ERR_CONTRACT_UNRESOLVABLE,
29
+ ];
30
+ const AMBIENT = new Set(AMBIENT_CONTRACT_ERROR_CODES);
31
+ /** True when a code is raised by the kernel's contract enforcement rather than
32
+ * declared by a kind. Callers use it to accept the code in a `catches:` entry
33
+ * without counting it toward that kind's declared union. */
34
+ export function isAmbientContractErrorCode(code) {
35
+ return AMBIENT.has(code);
36
+ }
@@ -50,8 +50,14 @@ export type InstanceFactory = (context: EvaluationContext, resource: ResourceMan
50
50
  * registered in this context but not yet initialized. Injection uses it
51
51
  * to defer a resource whose dependency exists but hasn't inited yet —
52
52
  * rather than leaving the slot unresolved — so the init loop retries it.
53
+ * @param owner The context that OWNS this resource — the module context for a top-level
54
+ * resource, the per-run scope child for a `with:`-scoped one. Anything the
55
+ * hook builds on the resource's behalf (notably a scope handle for an
56
+ * `x-telo-scope` field) must hang off this, not off the root: the inline
57
+ * declarations inside a scope name kinds through the import aliases of the
58
+ * module that DECLARED them, which the root context has never heard of.
53
59
  */
54
- export type PreInitHook = (resource: ResourceManifest, getInstance: (name: string, alias?: string) => ResourceInstance | undefined, isPending?: (name: string) => boolean) => void;
60
+ export type PreInitHook = (resource: ResourceManifest, getInstance: (name: string, alias?: string) => ResourceInstance | undefined, isPending: ((name: string) => boolean) | undefined, owner: EvaluationContext) => void;
55
61
  /** Canonical key for a resource instance: "<module>.<kind>.<name>" */
56
62
  export declare function resourceKey(r: ResourceManifest): string;
57
63
  /** The resource that owns a spawned child context — the parent in the resource
@@ -1 +1 @@
1
- {"version":3,"file":"evaluation-context.d.ts","sourceRoot":"","sources":["../src/evaluation-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAClF,OAAO,KAAK,EAAE,WAAW,EAAE,M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O,GAAG,OAAO,CAAC;IAChC,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC;IAC3E,WAAW,CACT,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,KAAK,EAAE,MAAM,EAAE,EACf,YAAY,CAAC,EAAE,MAAM,EAAE,GACtB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC5B"}
package/dist/index.d.ts CHANGED
@@ -18,6 +18,7 @@ export * from "./module-context.js";
18
18
  export * from "./resource-context.js";
19
19
  export * from "./resource-instance.js";
20
20
  export * from "./resource-manifest.js";
21
+ export * from "./contract-errors.js";
21
22
  export * from "./invoke-error.js";
22
23
  export * from "./log-record.js";
23
24
  export * from "./log-sink.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,UAAU,CAAC;AACzB,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,UAAU,CAAC;AACzB,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -18,6 +18,7 @@ export * from "./module-context.js";
18
18
  export * from "./resource-context.js";
19
19
  export * from "./resource-instance.js";
20
20
  export * from "./resource-manifest.js";
21
+ export * from "./contract-errors.js";
21
22
  export * from "./invoke-error.js";
22
23
  export * from "./log-record.js";
23
24
  export * from "./log-sink.js";
@@ -1,3 +1,30 @@
1
+ /** The manifest site a statically-raised diagnostic was reported at, carried
2
+ * through verbatim from the analyzer's `data` so a renderer resolves
3
+ * `file:line:col` against the `LoadedGraph` exactly as `telo check` does —
4
+ * never by re-parsing the rendered message. */
5
+ export interface DiagnosticOrigin {
6
+ filePath?: string;
7
+ /** Field path within the manifest doc, as keyed by its position index. */
8
+ path?: string;
9
+ resource?: {
10
+ kind?: string;
11
+ name?: string;
12
+ };
13
+ /** The diagnostic's own position, for one that has no field path to look up:
14
+ * a YAML parse failure knows where the syntax broke but has no parsed tree
15
+ * to index. Structurally the analyzer's LSP `Range` (0-based), so a renderer
16
+ * can hand it back to the shared range resolver unchanged. */
17
+ range?: {
18
+ start: {
19
+ line: number;
20
+ character: number;
21
+ };
22
+ end: {
23
+ line: number;
24
+ character: number;
25
+ };
26
+ };
27
+ }
1
28
  export interface RuntimeDiagnostic {
2
29
  severity?: "error" | "warning";
3
30
  message: string;
@@ -5,7 +32,21 @@ export interface RuntimeDiagnostic {
5
32
  kind?: string;
6
33
  details?: string;
7
34
  code?: string;
35
+ /** Set when the failure came from static analysis rather than a running
36
+ * resource; lets the renderer point at the offending line. */
37
+ origin?: DiagnosticOrigin;
38
+ /** Set when this entry failed ONLY because another resource in the same
39
+ * failure set did — it carries no independent cause. Renderers collapse
40
+ * these into one line rather than repeating one failure per dependent. */
41
+ derived?: boolean;
42
+ /** When `derived`, the ROOT of the dependency chain — the resource a reader
43
+ * has to fix. Absent when the blocker could not be named. */
44
+ blockedBy?: string;
45
+ /** Diagnostics from a nested context (an import's own resource init), kept
46
+ * structured instead of flattened into `message` so the classification and
47
+ * the error count see the real leaves. */
48
+ children?: RuntimeDiagnostic[];
8
49
  }
9
50
  /** Well-known kernel error codes. User-defined codes (e.g. from Type.JsonSchema rules) are also valid. */
10
- export type RuntimeErrorCode = "ERR_RESOURCE_NOT_FOUND" | "ERR_RESOURCE_NOT_RUNNABLE" | "ERR_CONTROLLER_NOT_FOUND" | "ERR_CONTROLLER_INVALID" | "ERR_RESOURCE_INITIALIZATION_FAILED" | "ERR_RESOURCE_NOT_INVOKABLE" | "ERR_RESOURCE_SCHEMA_VALIDATION_FAILED" | "ERR_DUPLICATE_RESOURCE" | "ERR_EXECUTION_FAILED" | "ERR_INVALID_VALUE" | "ERR_VISIBILITY_DENIED" | "ERR_MANIFEST_VALIDATION_FAILED" | "ERR_CIRCULAR_DEPENDENCY" | "ERR_SCOPE_RESOURCE_NOT_FOUND" | "ERR_TYPE_NOT_FOUND" | "ERR_TYPE_VALIDATION_FAILED" | "ERR_KERNEL_STATE_INVALID" | (string & {});
51
+ export type RuntimeErrorCode = "ERR_RESOURCE_NOT_FOUND" | "ERR_RESOURCE_NOT_RUNNABLE" | "ERR_CONTROLLER_NOT_FOUND" | "ERR_CONTROLLER_INVALID" | "ERR_RESOURCE_INITIALIZATION_FAILED" | "ERR_RESOURCE_NOT_INVOKABLE" | "ERR_RESOURCE_SCHEMA_VALIDATION_FAILED" | "ERR_DUPLICATE_RESOURCE" | "ERR_EXECUTION_FAILED" | "ERR_INVALID_VALUE" | "ERR_VISIBILITY_DENIED" | "ERR_MANIFEST_VALIDATION_FAILED" | "ERR_CIRCULAR_DEPENDENCY" | "ERR_SCOPE_RESOURCE_NOT_FOUND" | "ERR_TYPE_NOT_FOUND" | "ERR_TYPE_VALIDATION_FAILED" | "ERR_KERNEL_STATE_INVALID" | "ERR_LOCAL_REF_PENDING" | "ERR_CROSS_MODULE_REF_PENDING" | (string & {});
11
52
  //# sourceMappingURL=runtime-error.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-error.d.ts","sourceRoot":"","sources":["../src/runtime-error.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,OA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AM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;mEAC+D;IAC/D,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B;;+EAE2E;IAC3E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;kEAC8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;+CAE2C;IAC3C,QAAQ,CAAC,EAAE,iBAAiB,EAAE,CAAC;CAChC;AAED,0GAA0G;AAC1G,MAAM,MAAM,gBAAgB,GACxB,wBAAwB,GACxB,2BAA2B,GAC3B,0BAA0B,GAC1B,wBAAwB,GACxB,oCAAoC,GACpC,4BAA4B,GAC5B,uCAAuC,GACvC,wBAAwB,GACxB,sBAAsB,GACtB,mBAAmB,GACnB,uBAAuB,GACvB,gCAAgC,GAChC,yBAAyB,GACzB,8BAA8B,GAC9B,oBAAoB,GACpB,4BAA4B,GAC5B,0BAA0B,GAC1B,uBAAuB,GACvB,8BAA8B,GAC9B,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC"}
@@ -11,7 +11,22 @@
11
11
  * pinned version is ever loaded, so the canonical id stays version-free.
12
12
  */
13
13
  export declare const TELO_TYPE_SCHEME = "telo://";
14
- /** The canonical, alias-resolved `$id` a named type schema is registered under. */
14
+ /**
15
+ * The canonical, alias-resolved id a named type schema is registered under.
16
+ *
17
+ * Authority-free (`telo:<module>/<type>`, not `telo://<module>/<type>`) because
18
+ * a JSON Schema validator has to RESOLVE it: AJV parses a `$ref` as a
19
+ * URI-reference against the document base, and a non-standard scheme carrying an
20
+ * authority resolves to nothing — a schema registered under `telo://M/T` cannot
21
+ * be referenced by `$ref: "telo://M/T"` no matter how it is registered, while the
22
+ * authority-free form resolves natively. Nothing enforced this before because no
23
+ * runtime path ever compiled a `$ref`-bearing contract; the invocation contract
24
+ * does, on every declaring kind.
25
+ *
26
+ * This is the INTERNAL id only. Authors keep writing the readable authority form
27
+ * (`telo://Self/<type>`, `telo://<Alias>/<type>`) — see {@link parseTeloTypeRef} —
28
+ * and the loader rewrites it to this. Published manifests are unaffected.
29
+ */
15
30
  export declare function canonicalTypeSchemaId(moduleName: string, typeName: string): string;
16
31
  /**
17
32
  * Resolve `extends` into a single self-contained object schema by deep-merging an
@@ -1 +1 @@
1
- {"version":3,"file":"type-schema-ref.d.ts","sourceRoot":"","sources":["../src/type-schema-ref.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAE1C,mFAAmF;AACnF,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAElF;AAiBD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GACjC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAqCzB;AAED,0EAA0E;AAC1E,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,CAKjE"}
1
+ {"version":3,"file":"type-schema-ref.d.ts","sourceRoot":"","sources":["../src/type-schema-ref.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAE1C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAElF;AAiBD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GACjC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAqCzB;AAED,0EAA0E;AAC1E,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,CAKjE"}
@@ -11,9 +11,24 @@
11
11
  * pinned version is ever loaded, so the canonical id stays version-free.
12
12
  */
13
13
  export const TELO_TYPE_SCHEME = "telo://";
14
- /** The canonical, alias-resolved `$id` a named type schema is registered under. */
14
+ /**
15
+ * The canonical, alias-resolved id a named type schema is registered under.
16
+ *
17
+ * Authority-free (`telo:<module>/<type>`, not `telo://<module>/<type>`) because
18
+ * a JSON Schema validator has to RESOLVE it: AJV parses a `$ref` as a
19
+ * URI-reference against the document base, and a non-standard scheme carrying an
20
+ * authority resolves to nothing — a schema registered under `telo://M/T` cannot
21
+ * be referenced by `$ref: "telo://M/T"` no matter how it is registered, while the
22
+ * authority-free form resolves natively. Nothing enforced this before because no
23
+ * runtime path ever compiled a `$ref`-bearing contract; the invocation contract
24
+ * does, on every declaring kind.
25
+ *
26
+ * This is the INTERNAL id only. Authors keep writing the readable authority form
27
+ * (`telo://Self/<type>`, `telo://<Alias>/<type>`) — see {@link parseTeloTypeRef} —
28
+ * and the loader rewrites it to this. Published manifests are unaffected.
29
+ */
15
30
  export function canonicalTypeSchemaId(moduleName, typeName) {
16
- return `${TELO_TYPE_SCHEME}${moduleName}/${typeName}`;
31
+ return `telo:${moduleName}/${typeName}`;
17
32
  }
18
33
  /** Top-level keywords merged structurally rather than copied wholesale when
19
34
  * resolving `extends`: object shape (`properties` / `required` /
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telorun/sdk",
3
- "version": "0.60.0",
3
+ "version": "0.62.0",
4
4
  "description": "Telo SDK - Public API for Telo module authors.",
5
5
  "keywords": [
6
6
  "telo",
@@ -0,0 +1,44 @@
1
+ /**
2
+ * The ambient kernel error union: codes any dispatch can raise because the
3
+ * kernel — not the kind's controller — enforces the invocation contract.
4
+ *
5
+ * They are **catchable**: a `catches:` entry may name one and its `when:` is
6
+ * validated against this set, so a typo is caught statically like any declared
7
+ * code. They are **excluded from coverage counting**: the completeness rule
8
+ * keeps counting only a kind's own `throws:` codes. Folding them into every
9
+ * union instead would make every bounded `catches:` block in the standard
10
+ * library incomplete overnight; making them uncatchable would leave an author no
11
+ * way to handle a contract violation they can legitimately recover from.
12
+ *
13
+ * Shared by the kernel (which raises them), the analyzer (which type-checks
14
+ * `catches:` against them) and module authors (who name them in a catch).
15
+ */
16
+
17
+ /** Inputs did not satisfy the target's declared `inputType`. */
18
+ export const ERR_INPUT_INVALID = "ERR_INPUT_INVALID";
19
+
20
+ /** A result did not satisfy the target's declared `outputType`. */
21
+ export const ERR_OUTPUT_INVALID = "ERR_OUTPUT_INVALID";
22
+
23
+ /** A declared contract could not be resolved to a schema — a named type that
24
+ * never registered. Distinct from a value violation: nothing is wrong with the
25
+ * data, the contract itself is unusable, and enforcement must fail rather than
26
+ * quietly switch itself off. */
27
+ export const ERR_CONTRACT_UNRESOLVABLE = "ERR_CONTRACT_UNRESOLVABLE";
28
+
29
+ export const AMBIENT_CONTRACT_ERROR_CODES = [
30
+ ERR_INPUT_INVALID,
31
+ ERR_OUTPUT_INVALID,
32
+ ERR_CONTRACT_UNRESOLVABLE,
33
+ ] as const;
34
+
35
+ export type AmbientContractErrorCode = (typeof AMBIENT_CONTRACT_ERROR_CODES)[number];
36
+
37
+ const AMBIENT = new Set<string>(AMBIENT_CONTRACT_ERROR_CODES);
38
+
39
+ /** True when a code is raised by the kernel's contract enforcement rather than
40
+ * declared by a kind. Callers use it to accept the code in a `catches:` entry
41
+ * without counting it toward that kind's declared union. */
42
+ export function isAmbientContractErrorCode(code: string): boolean {
43
+ return AMBIENT.has(code);
44
+ }
@@ -67,11 +67,18 @@ export type InstanceFactory = (
67
67
  * registered in this context but not yet initialized. Injection uses it
68
68
  * to defer a resource whose dependency exists but hasn't inited yet —
69
69
  * rather than leaving the slot unresolved — so the init loop retries it.
70
+ * @param owner The context that OWNS this resource — the module context for a top-level
71
+ * resource, the per-run scope child for a `with:`-scoped one. Anything the
72
+ * hook builds on the resource's behalf (notably a scope handle for an
73
+ * `x-telo-scope` field) must hang off this, not off the root: the inline
74
+ * declarations inside a scope name kinds through the import aliases of the
75
+ * module that DECLARED them, which the root context has never heard of.
70
76
  */
71
77
  export type PreInitHook = (
72
78
  resource: ResourceManifest,
73
79
  getInstance: (name: string, alias?: string) => ResourceInstance | undefined,
74
- isPending?: (name: string) => boolean,
80
+ isPending: ((name: string) => boolean) | undefined,
81
+ owner: EvaluationContext,
75
82
  ) => void;
76
83
 
77
84
  /** Canonical key for a resource instance: "<module>.<kind>.<name>" */
package/src/index.ts CHANGED
@@ -18,6 +18,7 @@ export * from "./module-context.js";
18
18
  export * from "./resource-context.js";
19
19
  export * from "./resource-instance.js";
20
20
  export * from "./resource-manifest.js";
21
+ export * from "./contract-errors.js";
21
22
  export * from "./invoke-error.js";
22
23
  export * from "./log-record.js";
23
24
  export * from "./log-sink.js";
@@ -1,3 +1,22 @@
1
+ /** The manifest site a statically-raised diagnostic was reported at, carried
2
+ * through verbatim from the analyzer's `data` so a renderer resolves
3
+ * `file:line:col` against the `LoadedGraph` exactly as `telo check` does —
4
+ * never by re-parsing the rendered message. */
5
+ export interface DiagnosticOrigin {
6
+ filePath?: string;
7
+ /** Field path within the manifest doc, as keyed by its position index. */
8
+ path?: string;
9
+ resource?: { kind?: string; name?: string };
10
+ /** The diagnostic's own position, for one that has no field path to look up:
11
+ * a YAML parse failure knows where the syntax broke but has no parsed tree
12
+ * to index. Structurally the analyzer's LSP `Range` (0-based), so a renderer
13
+ * can hand it back to the shared range resolver unchanged. */
14
+ range?: {
15
+ start: { line: number; character: number };
16
+ end: { line: number; character: number };
17
+ };
18
+ }
19
+
1
20
  export interface RuntimeDiagnostic {
2
21
  severity?: "error" | "warning";
3
22
  message: string;
@@ -5,6 +24,20 @@ export interface RuntimeDiagnostic {
5
24
  kind?: string;
6
25
  details?: string;
7
26
  code?: string;
27
+ /** Set when the failure came from static analysis rather than a running
28
+ * resource; lets the renderer point at the offending line. */
29
+ origin?: DiagnosticOrigin;
30
+ /** Set when this entry failed ONLY because another resource in the same
31
+ * failure set did — it carries no independent cause. Renderers collapse
32
+ * these into one line rather than repeating one failure per dependent. */
33
+ derived?: boolean;
34
+ /** When `derived`, the ROOT of the dependency chain — the resource a reader
35
+ * has to fix. Absent when the blocker could not be named. */
36
+ blockedBy?: string;
37
+ /** Diagnostics from a nested context (an import's own resource init), kept
38
+ * structured instead of flattened into `message` so the classification and
39
+ * the error count see the real leaves. */
40
+ children?: RuntimeDiagnostic[];
8
41
  }
9
42
 
10
43
  /** Well-known kernel error codes. User-defined codes (e.g. from Type.JsonSchema rules) are also valid. */
@@ -26,4 +59,6 @@ export type RuntimeErrorCode =
26
59
  | "ERR_TYPE_NOT_FOUND"
27
60
  | "ERR_TYPE_VALIDATION_FAILED"
28
61
  | "ERR_KERNEL_STATE_INVALID"
62
+ | "ERR_LOCAL_REF_PENDING"
63
+ | "ERR_CROSS_MODULE_REF_PENDING"
29
64
  | (string & {});
@@ -13,9 +13,24 @@
13
13
 
14
14
  export const TELO_TYPE_SCHEME = "telo://";
15
15
 
16
- /** The canonical, alias-resolved `$id` a named type schema is registered under. */
16
+ /**
17
+ * The canonical, alias-resolved id a named type schema is registered under.
18
+ *
19
+ * Authority-free (`telo:<module>/<type>`, not `telo://<module>/<type>`) because
20
+ * a JSON Schema validator has to RESOLVE it: AJV parses a `$ref` as a
21
+ * URI-reference against the document base, and a non-standard scheme carrying an
22
+ * authority resolves to nothing — a schema registered under `telo://M/T` cannot
23
+ * be referenced by `$ref: "telo://M/T"` no matter how it is registered, while the
24
+ * authority-free form resolves natively. Nothing enforced this before because no
25
+ * runtime path ever compiled a `$ref`-bearing contract; the invocation contract
26
+ * does, on every declaring kind.
27
+ *
28
+ * This is the INTERNAL id only. Authors keep writing the readable authority form
29
+ * (`telo://Self/<type>`, `telo://<Alias>/<type>`) — see {@link parseTeloTypeRef} —
30
+ * and the loader rewrites it to this. Published manifests are unaffected.
31
+ */
17
32
  export function canonicalTypeSchemaId(moduleName: string, typeName: string): string {
18
- return `${TELO_TYPE_SCHEME}${moduleName}/${typeName}`;
33
+ return `telo:${moduleName}/${typeName}`;
19
34
  }
20
35
 
21
36
  /** Top-level keywords merged structurally rather than copied wholesale when