@lmzhen/dsh-evolution-io 0.26.15 → 0.27.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/lib/index.js CHANGED
@@ -58,28 +58,39 @@ var EvolutionIoRegistry = class extends Service {
58
58
  return first;
59
59
  }
60
60
  };
61
+ const mediumObservations = /* @__PURE__ */ new WeakMap();
61
62
  /**
62
- * Resolve the seam implementation for a consumer, preferring a backend the deployment mounted.
63
- *
64
- * Contract C2 (declared gaps) has no other shape: a consumer that can work on either medium asks for
65
- * its preference and the DEPLOYMENT decides which backends exist. The lookup is contained here because
66
- * the registry deliberately has no presence probe (v20 A-3 removed `hasProvider`; a presence probe goes
67
- * through `provider(name)`, which fails loud) — so this function is the ONE sanctioned place that turns
68
- * that failure into a fallback. A caller that needs a SPECIFIC backend must call `provider(name)` and
69
- * take the error.
70
- * @param registry - the seam registry (`ctx.evolutionIo`).
71
- * @param names - preferred provider names, most preferred first.
72
- * @returns the first registered preference, else the registry default.
73
- */
74
- /**
75
- * @typeParam T - the seam implementation type the caller works with (`EvolutionIo` or the wider
76
- * `EvolutionIoLike`), so the same helper serves every consumer shape.
63
+ * The read-only face of the marker: what served THIS registry, without resolving anything.
64
+ * @param registry - the seam registry the caller already holds.
65
+ * @returns `known` with the observation, or `unknown` when nothing resolved through this registry yet.
77
66
  */
67
+ function describeMedium(registry) {
68
+ const observation = mediumObservations.get(registry);
69
+ if (observation === void 0) return { state: "unknown" };
70
+ return {
71
+ state: "known",
72
+ requested: observation.requested,
73
+ resolved: observation.resolved,
74
+ via: observation.via
75
+ };
76
+ }
78
77
  function preferProvider(registry, names) {
79
78
  for (const name of names) try {
80
- return registry.provider(name);
79
+ const resolved = registry.provider(name);
80
+ mediumObservations.set(registry, {
81
+ requested: names,
82
+ resolved: name,
83
+ via: "preference"
84
+ });
85
+ return resolved;
81
86
  } catch {}
82
- return registry.provider();
87
+ const fallback = registry.provider();
88
+ mediumObservations.set(registry, {
89
+ requested: names,
90
+ resolved: void 0,
91
+ via: "default"
92
+ });
93
+ return fallback;
83
94
  }
84
95
  //#endregion
85
- export { EvolutionIoRegistry, EvolutionIoRegistry as default, preferProvider };
96
+ export { EvolutionIoRegistry, EvolutionIoRegistry as default, describeMedium, preferProvider };
@@ -52,22 +52,18 @@ export declare class EvolutionIoRegistry extends Service {
52
52
  provider(name?: string): EvolutionIo;
53
53
  }
54
54
  /**
55
- * Resolve the seam implementation for a consumer, preferring a backend the deployment mounted.
56
- *
57
- * Contract C2 (declared gaps) has no other shape: a consumer that can work on either medium asks for
58
- * its preference and the DEPLOYMENT decides which backends exist. The lookup is contained here because
59
- * the registry deliberately has no presence probe (v20 A-3 removed `hasProvider`; a presence probe goes
60
- * through `provider(name)`, which fails loud) — so this function is the ONE sanctioned place that turns
61
- * that failure into a fallback. A caller that needs a SPECIFIC backend must call `provider(name)` and
62
- * take the error.
63
- * @param registry - the seam registry (`ctx.evolutionIo`).
64
- * @param names - preferred provider names, most preferred first.
65
- * @returns the first registered preference, else the registry default.
66
- */
67
- /**
68
- * @typeParam T - the seam implementation type the caller works with (`EvolutionIo` or the wider
69
- * `EvolutionIoLike`), so the same helper serves every consumer shape.
55
+ * The read-only face of the marker: what served THIS registry, without resolving anything.
56
+ * @param registry - the seam registry the caller already holds.
57
+ * @returns `known` with the observation, or `unknown` when nothing resolved through this registry yet.
70
58
  */
59
+ export declare function describeMedium(registry: object): {
60
+ readonly state: 'known';
61
+ readonly requested: readonly string[];
62
+ readonly resolved: string | undefined;
63
+ readonly via: string;
64
+ } | {
65
+ readonly state: 'unknown';
66
+ };
71
67
  export declare function preferProvider<T>(registry: {
72
68
  provider(name?: string): T;
73
69
  }, names: readonly string[]): T;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lmzhen/dsh-evolution-io",
3
3
  "description": "IO seam for evolution providers (community build)",
4
- "version": "0.26.15",
4
+ "version": "0.27.0",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -26,9 +26,12 @@
26
26
  ],
27
27
  "license": "MIT",
28
28
  "dependencies": {
29
- "@lmzhen/dsh-evolution-core": "^0.26.15"
29
+ "@lmzhen/dsh-evolution-core": "^0.27.0"
30
30
  },
31
31
  "peerDependencies": {
32
- "@deepseek-ai/cordis": "^4.0.1"
32
+ "@deepseek-ai/cordis": "^4.0.5"
33
+ },
34
+ "engines": {
35
+ "dsh": ">=0.2.1-rc.1 <0.2.2-0"
33
36
  }
34
37
  }