@synapse-sdk/core 0.3.3 → 0.3.4

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.
@@ -9,7 +9,7 @@
9
9
  "code": "admission_refused",
10
10
  "retryable": true,
11
11
  "source": "broker",
12
- "description": "the runtime refused this connection; retryable: a live session may hold this name, the project may be settling, or the runtime is overloaded \u2014 retry with backoff"
12
+ "description": "the runtime refused this connection; retryable: a live session holds this name (a crashed one is released after the idle timeout) \u2014 the SDK keeps retrying with backoff"
13
13
  },
14
14
  {
15
15
  "code": "invalid_input",
@@ -105,7 +105,7 @@
105
105
  "code": "project_busy",
106
106
  "retryable": false,
107
107
  "source": "broker",
108
- "description": "another project is active and other operators hold grants on it; data.active, data.operators"
108
+ "description": "a project is active; deactivate it first (data: active, operators)"
109
109
  },
110
110
  {
111
111
  "code": "project_inactive",
@@ -117,7 +117,7 @@
117
117
  "code": "project_settling",
118
118
  "retryable": true,
119
119
  "source": "broker",
120
- "description": "the active project just switched; retry when the settle window ends"
120
+ "description": "the store/scene is still catching up with an activation; retry"
121
121
  },
122
122
  {
123
123
  "code": "not_operator",
package/dist/types.d.ts CHANGED
@@ -15,8 +15,8 @@ export interface FecParams {
15
15
  export declare const FEC_DEFAULTS: Readonly<FecParams>;
16
16
  /** `FecParams::repair_for`: repair symbols for K source symbols: `max(2, ceil(K * pct / 100))`; `repair_pct = 0` means none. */
17
17
  export declare function fecRepairFor(params: FecParams, k: number): number;
18
- /** The role ladder (WP §3.2), lowest first. */
19
- export type Role = "observer" | "agent" | "operator" | "admin";
18
+ /** The role ladder (WP §3.2), five rungs, lowest first: a web node starts `observer`, an hmi `hmi` (never promoted or demoted), an agent `agent`. */
19
+ export type Role = "observer" | "agent" | "operator" | "hmi" | "admin";
20
20
  export declare const ROLES: readonly Role[];
21
21
  export declare function roleRank(r: Role): number;
22
22
  export declare function isRole(s: unknown): s is Role;
@@ -220,15 +220,18 @@ export type TimeOffsets = Record<string, TimeOffsetEntry>;
220
220
  export interface ProjectSnapshot {
221
221
  active: ActiveProject | null;
222
222
  operators: OperatorEntry[];
223
- settling_until_us: number | null;
224
223
  }
225
- /** The active project; `scene_id`, `store_id` and `behavior_trees` (slot → `tree:<id>`) are its project document's. */
224
+ /**
225
+ * The active project; `scene_id`, `store_id` and `behavior_trees` (slot → `tree:<id>`) are its project document's.
226
+ * `activated_by_hmi`: an hmi activated it, so only an hmi may deactivate it.
227
+ */
226
228
  export interface ActiveProject {
227
229
  id: string;
228
230
  since_us: number;
229
231
  scene_id: string;
230
232
  store_id: string;
231
233
  behavior_trees: Record<string, string>;
234
+ activated_by_hmi: boolean;
232
235
  }
233
236
  /** The reply of `synapse/tasks/run_robot` and `synapse/tasks/run_project`: how many tasks were started, and how many were declared but have nothing to run. */
234
237
  export interface TasksRun {
package/dist/types.js CHANGED
@@ -11,7 +11,7 @@ export function fecRepairFor(params, k) {
11
11
  return 0;
12
12
  return Math.min(255, Math.max(2, Math.ceil((k * params.repair_pct) / 100)));
13
13
  }
14
- export const ROLES = ["observer", "agent", "operator", "admin"];
14
+ export const ROLES = ["observer", "agent", "operator", "hmi", "admin"];
15
15
  export function roleRank(r) { return ROLES.indexOf(r); }
16
16
  export function isRole(s) { return typeof s === "string" && ROLES.includes(s); }
17
17
  export const CLIENT_TYPES = ["agent", "observer", "web", "hmi"];
@@ -97,7 +97,7 @@ export function normalizeProjectSnapshot(v) {
97
97
  const a = o.active;
98
98
  const trees = a && a.behavior_trees && typeof a.behavior_trees === "object" ? a.behavior_trees : {};
99
99
  const active = a && typeof a === "object" && typeof a.id === "string"
100
- ? { id: a.id, since_us: num(a.since_us) ?? 0, scene_id: str(a.scene_id), store_id: str(a.store_id), behavior_trees: trees }
100
+ ? { id: a.id, since_us: num(a.since_us) ?? 0, scene_id: str(a.scene_id), store_id: str(a.store_id), behavior_trees: trees, activated_by_hmi: a.activated_by_hmi === true }
101
101
  : null;
102
102
  const operators = Array.isArray(o.operators)
103
103
  ? o.operators.filter(e => e && typeof e.name === "string").map(e => ({
@@ -105,7 +105,7 @@ export function normalizeProjectSnapshot(v) {
105
105
  type: isClientType(e.type) ? e.type : "observer", since_us: num(e.since_us) ?? 0,
106
106
  }))
107
107
  : [];
108
- return { active, operators, settling_until_us: num(o.settling_until_us) ?? null };
108
+ return { active, operators };
109
109
  }
110
110
  // ------------------------------------------------------------------------------------ store.rs
111
111
  export const STORE_CONFIG = "config";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synapse-sdk/core",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "Synapse SDK core: message encoding, contracts and error codes shared by the other packages.",
5
5
  "type": "module",
6
6
  "sideEffects": false,