@makinbakin/sdk 0.0.1-rc.22 → 0.0.1-rc.24

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,33 @@
1
+ /**
2
+ * Health observation builders — the ONE construction path for check
3
+ * output, shared by plugins (via `@makinbakin/sdk/utils`, which
4
+ * re-exports these) and adapter packages (which depend only on
5
+ * `@bakin/core`).
6
+ *
7
+ * The builders CLAMP copy to the health contract's bounds instead of
8
+ * letting an overlong or blank string invalidate the whole run: a check
9
+ * that interpolated a long runtime error into its summary used to fail
10
+ * contract validation wholesale, turning real evidence into a useless
11
+ * "could not be verified" card (field-diagnosed 2026-07-22). Truncated
12
+ * copy is honest; discarded evidence is not. Constructing observations
13
+ * as raw object literals bypasses this protection — always build through
14
+ * these helpers.
15
+ */
16
+ import type { ErrorObservationInput, HealthNonEmptyArray, HealthObservationInput, HealthyObservationInput, NotApplicableHealthCheckRunInput, ObservedHealthCheckRunInput, UnknownObservationInput, WarningObservationInput } from '../plugin-types';
17
+ type HealthyObservationFields = Omit<HealthyObservationInput, 'status'>;
18
+ type WarningObservationFields = Omit<WarningObservationInput, 'status'>;
19
+ type ErrorObservationFields = Omit<ErrorObservationInput, 'status'>;
20
+ type UnknownObservationFields = Omit<UnknownObservationInput, 'status'>;
21
+ /** Build a healthy observation. Healthy observations cannot carry incidents. */
22
+ export declare function healthHealthy(input: HealthyObservationFields): HealthyObservationInput;
23
+ /** Build a warning observation with an explicit advisory/watch/action disposition. */
24
+ export declare function healthWarning(input: WarningObservationFields): WarningObservationInput;
25
+ /** Build an error observation. Its incident must require operator action. */
26
+ export declare function healthError(input: ErrorObservationFields): ErrorObservationInput;
27
+ /** Build an Unknown verification observation (watch, or advisory when it self-resolves). */
28
+ export declare function healthUnknown(input: UnknownObservationFields): UnknownObservationInput;
29
+ /** Build a successful observed run. Empty diagnostic output is unrepresentable. */
30
+ export declare function healthObserved(observations: HealthNonEmptyArray<HealthObservationInput>): ObservedHealthCheckRunInput;
31
+ /** Build an explicit successful not-applicable run. */
32
+ export declare function healthNotApplicable(reason: string): NotApplicableHealthCheckRunInput;
33
+ export {};
@@ -231,7 +231,7 @@ export interface NotificationChannelDef extends PluginNotificationChannelInput {
231
231
  /** Set when runtime === 'plugin'; identifies the owning plugin. */
232
232
  pluginId?: string;
233
233
  }
234
- export type { ActionIncidentInput, AdvisoryIncidentInput, CanonicalErrorObservation, CanonicalHealthyObservation, CanonicalUnknownObservation, CanonicalWarningObservation, ErrorObservationInput, HealthCheckExecution, HealthCheckRegistrationInput, HealthCheckRunContext, HealthCheckRunInput, HealthCheckSnapshot, HealthCheckState, HealthDisposition, HealthFullSweep, HealthGroup, HealthIncident, HealthIncidentInput, HealthInstructionsResolution, HealthNavigateResolution, HealthNonEmptyArray, HealthObservation, HealthObservationInput, HealthObservationStatus, HealthOwner, HealthOwnerKind, HealthRepairActionDefinition, HealthRepairApplyRequest, HealthRepairApplyResult, HealthRepairSafety, HealthRepairChange, HealthRepairPlanItem, HealthRepairPlan, HealthRepairPrecondition, HealthRepairResolution, HealthRepairTarget, HealthReport, HealthReportStatus, HealthReportSummary, HealthResolution, HealthResource, HealthResourceKind, HealthRerunResolution, HealthyObservationInput, JsonObject, JsonValue, SearchReadiness, SearchReadinessStage, SearchReadinessStageKey, SearchReadinessStatus, SearchStageStatus, UnknownObservationInput, WarningObservationInput, WatchIncidentInput, } from '@makinbakin/sdk/types';
234
+ export type { ActionIncidentInput, AdvisoryIncidentInput, CanonicalErrorObservation, CanonicalHealthyObservation, CanonicalUnknownObservation, CanonicalWarningObservation, ErrorObservationInput, HealthCheckExecution, HealthCheckRegistrationInput, HealthCheckRunContext, HealthCheckRunInput, HealthCheckSnapshot, HealthCheckState, HealthDisposition, HealthFullSweep, HealthGroup, HealthIncident, HealthIncidentInput, HealthInstructionsResolution, HealthNavigateResolution, HealthNonEmptyArray, HealthObservation, HealthObservationInput, HealthObservationStatus, HealthOwner, HealthOwnerKind, HealthRepairActionDefinition, HealthRepairApplyRequest, HealthRepairApplyResult, HealthRepairSafety, HealthRepairChange, HealthRepairPlanItem, HealthRepairPlan, HealthRepairPrecondition, HealthRepairResolution, HealthRepairTarget, HealthReport, HealthReportStatus, HealthReportSummary, HealthResolution, HealthResource, HealthResourceKind, HealthRerunResolution, HealthyObservationInput, JsonObject, JsonValue, NotApplicableHealthCheckRunInput, ObservedHealthCheckRunInput, SearchReadiness, SearchReadinessStage, SearchReadinessStageKey, SearchReadinessStatus, SearchStageStatus, UnknownObservationInput, WarningObservationInput, WatchIncidentInput, } from '@makinbakin/sdk/types';
235
235
  /** Core-internal canonical registration with its resolved owner and local id. */
236
236
  export interface HealthCheckDef extends HealthCheckRegistrationInput {
237
237
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makinbakin/sdk",
3
- "version": "0.0.1-rc.22",
3
+ "version": "0.0.1-rc.24",
4
4
  "description": "SDK for building Bakin plugins — UI components, slot types, hooks, and the runtime registerPlugin helper.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
package/utils/index.d.ts CHANGED
@@ -5,23 +5,7 @@
5
5
  * needs. The `format*` helpers are re-exported from `@bakin/core/format`
6
6
  * so plugins have a single import path instead of reaching into `@/lib/*`.
7
7
  */
8
- import type { ErrorObservationInput, HealthNonEmptyArray, HealthObservationInput, HealthyObservationInput, NotApplicableHealthCheckRunInput, ObservedHealthCheckRunInput, UnknownObservationInput, WarningObservationInput } from '../types/index';
9
- type HealthyObservationFields = Omit<HealthyObservationInput, 'status'>;
10
- type WarningObservationFields = Omit<WarningObservationInput, 'status'>;
11
- type ErrorObservationFields = Omit<ErrorObservationInput, 'status'>;
12
- type UnknownObservationFields = Omit<UnknownObservationInput, 'status'>;
13
- /** Build a healthy observation. Healthy observations cannot carry incidents. */
14
- export declare function healthHealthy(input: HealthyObservationFields): HealthyObservationInput;
15
- /** Build a warning observation with an explicit advisory/watch/action disposition. */
16
- export declare function healthWarning(input: WarningObservationFields): WarningObservationInput;
17
- /** Build an error observation. Its incident must require operator action. */
18
- export declare function healthError(input: ErrorObservationFields): ErrorObservationInput;
19
- /** Build an Unknown verification observation with a watch disposition. */
20
- export declare function healthUnknown(input: UnknownObservationFields): UnknownObservationInput;
21
- /** Build a successful observed run. Empty diagnostic output is unrepresentable. */
22
- export declare function healthObserved(observations: HealthNonEmptyArray<HealthObservationInput>): ObservedHealthCheckRunInput;
23
- /** Build an explicit successful not-applicable run. */
24
- export declare function healthNotApplicable(reason: string): NotApplicableHealthCheckRunInput;
8
+ export { healthError, healthHealthy, healthNotApplicable, healthObserved, healthUnknown, healthWarning, } from '../_internal/core/health/observation-builders';
25
9
  /** Tailwind class merger (clsx + tailwind-merge). */
26
10
  export { cn } from '../_internal/app/lib/utils';
27
11
  /** Semantic tone for an outline status badge. */
package/utils/index.js CHANGED
@@ -1,4 +1,52 @@
1
1
  // @bun
2
+ // packages/core/src/health/observation-builders.ts
3
+ var SUMMARY_MAX = 500;
4
+ var DETAIL_MAX = 4000;
5
+ var IMPACT_MAX = 500;
6
+ function truncate(value, max) {
7
+ if (value.length <= max)
8
+ return value;
9
+ let end = max - 1;
10
+ const last = value.charCodeAt(end - 1);
11
+ if (last >= 55296 && last <= 56319)
12
+ end -= 1;
13
+ return `${value.slice(0, end)}\u2026`;
14
+ }
15
+ function clampCopy(input) {
16
+ const clamped = { ...input };
17
+ const summary = clamped.summary.trim();
18
+ clamped.summary = truncate(summary.length > 0 ? summary : "(no summary provided)", SUMMARY_MAX);
19
+ if (clamped.detail !== undefined) {
20
+ const detail = clamped.detail.trim();
21
+ if (detail.length === 0) {
22
+ delete clamped.detail;
23
+ } else {
24
+ clamped.detail = truncate(detail, DETAIL_MAX);
25
+ }
26
+ }
27
+ if (clamped.incident && clamped.incident.impact.length > IMPACT_MAX) {
28
+ clamped.incident = { ...clamped.incident, impact: truncate(clamped.incident.impact, IMPACT_MAX) };
29
+ }
30
+ return clamped;
31
+ }
32
+ function healthHealthy(input) {
33
+ return { ...clampCopy(input), status: "healthy" };
34
+ }
35
+ function healthWarning(input) {
36
+ return { ...clampCopy(input), status: "warning" };
37
+ }
38
+ function healthError(input) {
39
+ return { ...clampCopy(input), status: "error" };
40
+ }
41
+ function healthUnknown(input) {
42
+ return { ...clampCopy(input), status: "unknown" };
43
+ }
44
+ function healthObserved(observations) {
45
+ return { outcome: "observed", observations };
46
+ }
47
+ function healthNotApplicable(reason) {
48
+ return { outcome: "not_applicable", reason };
49
+ }
2
50
  // node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs
3
51
  function r(e) {
4
52
  var t, f, n = "";
@@ -2116,24 +2164,6 @@ function pluginFetch(pluginId, path, init) {
2116
2164
  }
2117
2165
 
2118
2166
  // packages/sdk/src/utils/index.ts
2119
- function healthHealthy(input) {
2120
- return { ...input, status: "healthy" };
2121
- }
2122
- function healthWarning(input) {
2123
- return { ...input, status: "warning" };
2124
- }
2125
- function healthError(input) {
2126
- return { ...input, status: "error" };
2127
- }
2128
- function healthUnknown(input) {
2129
- return { ...input, status: "unknown" };
2130
- }
2131
- function healthObserved(observations) {
2132
- return { outcome: "observed", observations };
2133
- }
2134
- function healthNotApplicable(reason) {
2135
- return { outcome: "not_applicable", reason };
2136
- }
2137
2167
  var TONE_BADGE_CLASS = {
2138
2168
  success: "bg-green-500/10 text-green-400 border-green-500/20",
2139
2169
  pending: "bg-amber-500/10 text-amber-400 border-amber-500/20",