@milaboratories/pl-model-middle-layer 1.40.0 → 1.41.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"block_status.cjs","names":[],"sources":["../src/block_status.ts"],"sourcesContent":["/**\n * The status of a running block, as the middle layer hands it to the Desktop App.\n *\n * The backend keeps a tree of status contexts, one per render, and writes each reporter's\n * transitions into the context of the render it belongs to. The middle layer folds that tree into\n * a {@link BlockStatusSummary}.\n */\n\n/**\n * The node states this build knows, spelled as the backend and the workflow SDK write them into a\n * transition value. The names match `plapi.ActionState` on the backend and `STATES` in\n * workflow-tengo's action-context library.\n *\n * The backend owns the list: a reporter may write a state added after this release, and the middle\n * layer passes it on as written. Only the lifecycle (`Completed`, `Terminated`, and `Running`\n * reported by a command) carries meaning in the fold; the rest exists for the user.\n */\nexport const blockStatusStatesRecord = {\n WaitingForInputs: \"WaitingForInputs\",\n Running: \"Running\",\n WaitingWorkdirGate: \"WaitingWorkdirGate\",\n WaitingSubmissionGate: \"WaitingSubmissionGate\",\n PopulatingWorkdir: \"PopulatingWorkdir\",\n CollectingOutputs: \"CollectingOutputs\",\n WaitingForScheduler: \"WaitingForScheduler\",\n WaitingForMachine: \"WaitingForMachine\",\n Terminated: \"Terminated\",\n Completed: \"Completed\",\n} as const;\n\n/** Every state, in the order above. */\nexport const blockStatusStates = Object.values(blockStatusStatesRecord);\n\n/** A node state name this build knows, e.g. `\"PopulatingWorkdir\"`. */\nexport type BlockStatusState = (typeof blockStatusStates)[number];\n\n/** True for a state a node cannot leave. */\nexport function isTerminalBlockStatusState(state: string): boolean {\n return (\n state === blockStatusStatesRecord.Terminated || state === blockStatusStatesRecord.Completed\n );\n}\n\n/** Jobs held by one state: the transition holding each of them has this namespace and state. */\nexport type BlockStatusJobGroup = {\n /** Who reported the state: `exec` for a command, `workdir` for its work folder, `render`. */\n readonly namespace: string;\n /** As the reporter wrote it, which can be a state this build does not know. */\n readonly state: string;\n readonly count: number;\n /** When the earliest of them entered the state, ms since the epoch. */\n readonly since?: number;\n /** Files done and all, summed over the jobs whose work folders report their progress. */\n readonly files?: { readonly done: number; readonly total: number };\n};\n\n/**\n * The block's jobs: the commands it runs on a machine, each counted once by where it is now.\n *\n * A job is a context that a command or its work folder reports in. Jobs the run has not created yet\n * are not counted, so `total` grows while the run fans out.\n */\nexport type BlockStatusJobs = {\n readonly total: number;\n readonly done: number;\n /**\n * Jobs that failed, and renders that failed on their own (not by passing up a failure under\n * them), e.g. one whose command could not start.\n */\n readonly failed: number;\n /** The jobs not ended, by the state holding each, largest group first. */\n readonly byState: readonly BlockStatusJobGroup[];\n};\n\n/** Why a summary carries no counters. */\nexport type BlockStatusAvailability =\n /** The tree was read and the run has reported what the summary holds. */\n | \"read\"\n /** The context could not be read: it is gone, or reading it raised. The counters are unknown,\n * which is not the same as a run that has reported nothing. */\n | \"unreadable\"\n /** The backend cannot take the `actionContext` link, so no context is created and nothing is\n * ever reported. */\n | \"unsupported\";\n\n/** The status of one block run, folded from its status-context tree. */\nexport type BlockStatusSummary = {\n /** Whether the counters below describe the run, or could not be read at all. */\n readonly availability: BlockStatusAvailability;\n /** The block's own `run-id`: two clicks of Run give two different values. */\n readonly runId?: string;\n /** Action contexts that have not ended. */\n readonly activeContexts: number;\n /** Every action context of the run, active or ended. */\n readonly totalContexts: number;\n /** The run's jobs, counted apart from the template renders that only prepare them. */\n readonly jobs: BlockStatusJobs;\n /** The first transition anywhere in the tree, ms since the epoch. */\n readonly startedAt?: number;\n /** The most recent transition anywhere in the tree, ms since the epoch. */\n readonly lastChangeAt?: number;\n /**\n * True once the root render has ended and nothing in the tree is still running, or once a render\n * failed and no job is still working.\n */\n readonly done: boolean;\n /**\n * Set when any render of the run terminated: the innermost message of the earliest one's reason,\n * one line, empty when it gave none. The full reason stays on the node's transitions. Commands\n * that fail are counted in {@link BlockStatusJobs.failed} instead.\n */\n readonly failure?: string;\n /**\n * True when the user stopped the run. The tree is kept as it was when it stopped, so the counters\n * say where each node was, but nothing in it runs any more.\n */\n readonly cancelled?: boolean;\n};\n\n/** No jobs yet. */\nexport const EmptyBlockStatusJobs: BlockStatusJobs = {\n total: 0,\n done: 0,\n failed: 0,\n byState: [],\n};\n\n/** A summary for a block whose run has not reported anything yet. */\nexport const EmptyBlockStatusSummary: BlockStatusSummary = {\n availability: \"read\",\n activeContexts: 0,\n totalContexts: 0,\n jobs: EmptyBlockStatusJobs,\n done: false,\n};\n\n/** A summary for a context that could not be read; its counters are unknown, not zero. */\nexport const UnreadableBlockStatusSummary: BlockStatusSummary = {\n ...EmptyBlockStatusSummary,\n availability: \"unreadable\",\n};\n\n/** A summary for a backend that does not accept status reports. */\nexport const UnsupportedBlockStatusSummary: BlockStatusSummary = {\n ...EmptyBlockStatusSummary,\n availability: \"unsupported\",\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAa,0BAA0B;CACrC,kBAAkB;CAClB,SAAS;CACT,oBAAoB;CACpB,uBAAuB;CACvB,mBAAmB;CACnB,mBAAmB;CACnB,qBAAqB;CACrB,mBAAmB;CACnB,YAAY;CACZ,WAAW;AACb;;AAGA,MAAa,oBAAoB,OAAO,OAAO,uBAAuB;;AAMtE,SAAgB,2BAA2B,OAAwB;CACjE,OACE,UAAU,wBAAwB,cAAc,UAAU,wBAAwB;AAEtF;;AA+EA,MAAa,uBAAwC;CACnD,OAAO;CACP,MAAM;CACN,QAAQ;CACR,SAAS,CAAC;AACZ;;AAGA,MAAa,0BAA8C;CACzD,cAAc;CACd,gBAAgB;CAChB,eAAe;CACf,MAAM;CACN,MAAM;AACR;;AAGA,MAAa,+BAAmD;CAC9D,GAAG;CACH,cAAc;AAChB;;AAGA,MAAa,gCAAoD;CAC/D,GAAG;CACH,cAAc;AAChB"}
1
+ {"version":3,"file":"block_status.cjs","names":[],"sources":["../src/block_status.ts"],"sourcesContent":["/**\n * The status of a running block, as the middle layer hands it to the Desktop App.\n *\n * The backend keeps a tree of status contexts, one per render, and writes each reporter's\n * transitions into the context of the render it belongs to. The middle layer folds that tree into\n * a {@link BlockStatusSummary}.\n */\n\n/**\n * The node states this build knows, spelled as the backend and the workflow SDK write them into a\n * transition value. The names match `plapi.ActionState` on the backend and `STATES` in\n * workflow-tengo's action-context library.\n *\n * The backend owns the list: a reporter may write a state added after this release, and the middle\n * layer passes it on as written. Only the lifecycle (`Completed`, `Terminated`, and `Running`\n * reported by a command) carries meaning in the fold; the rest exists for the user.\n */\nexport const blockStatusStatesRecord = {\n WaitingForInputs: \"WaitingForInputs\",\n Running: \"Running\",\n WaitingWorkdirGate: \"WaitingWorkdirGate\",\n WaitingSubmissionGate: \"WaitingSubmissionGate\",\n PopulatingWorkdir: \"PopulatingWorkdir\",\n CollectingOutputs: \"CollectingOutputs\",\n WaitingForScheduler: \"WaitingForScheduler\",\n WaitingForMachine: \"WaitingForMachine\",\n Terminated: \"Terminated\",\n Completed: \"Completed\",\n} as const;\n\n/** Every state, in the order above. */\nexport const blockStatusStates = Object.values(blockStatusStatesRecord);\n\n/** A node state name this build knows, e.g. `\"PopulatingWorkdir\"`. */\nexport type BlockStatusState = (typeof blockStatusStates)[number];\n\n/** True for a state a node cannot leave. */\nexport function isTerminalBlockStatusState(state: string): boolean {\n return (\n state === blockStatusStatesRecord.Terminated || state === blockStatusStatesRecord.Completed\n );\n}\n\n/** Jobs held by one state: the transition holding each of them has this namespace and state. */\nexport type BlockStatusJobGroup = {\n /** Who reported the state: `exec` for a command, `workdir` for its work folder, `render`. */\n readonly namespace: string;\n /** As the reporter wrote it, which can be a state this build does not know. */\n readonly state: string;\n readonly count: number;\n /** When the earliest of them entered the state, ms since the epoch. */\n readonly since?: number;\n /** Files done and all, summed over the jobs whose work folders report their progress. */\n readonly files?: { readonly done: number; readonly total: number };\n};\n\n/**\n * The block's jobs: the commands it runs on a machine, each counted once by where it is now.\n *\n * A job is a context that a command or its work folder reports in. Jobs the run has not created yet\n * are not counted, so `total` grows while the run fans out.\n */\nexport type BlockStatusJobs = {\n readonly total: number;\n readonly done: number;\n /**\n * Jobs that failed, and renders that failed on their own (not by passing up a failure under\n * them), e.g. one whose command could not start.\n */\n readonly failed: number;\n /** The jobs not ended, by the state holding each, largest group first. */\n readonly byState: readonly BlockStatusJobGroup[];\n};\n\n/** One resource of the block's jobs: each job's peak use and its grant, summed over the jobs. */\nexport type BlockStatusResource = {\n readonly used: number;\n readonly granted: number;\n};\n\n/** CPU and RAM of the jobs whose commands report telemetry (only the k8s runner does). */\nexport type BlockStatusUsage = {\n /** Jobs that reported. */\n readonly jobs: number;\n /** Millicores. */\n readonly cpu: BlockStatusResource;\n /** Bytes. */\n readonly ram: BlockStatusResource;\n};\n\n/** Why a summary carries no counters. */\nexport type BlockStatusAvailability =\n /** The tree was read and the run has reported what the summary holds. */\n | \"read\"\n /** The context could not be read: it is gone, or reading it raised. The counters are unknown,\n * which is not the same as a run that has reported nothing. */\n | \"unreadable\"\n /** The backend cannot take the `actionContext` link, so no context is created and nothing is\n * ever reported. */\n | \"unsupported\";\n\n/** The status of one block run, folded from its status-context tree. */\nexport type BlockStatusSummary = {\n /** Whether the counters below describe the run, or could not be read at all. */\n readonly availability: BlockStatusAvailability;\n /** The block's own `run-id`: two clicks of Run give two different values. */\n readonly runId?: string;\n /** Action contexts that have not ended. */\n readonly activeContexts: number;\n /** Every action context of the run, active or ended. */\n readonly totalContexts: number;\n /** The run's jobs, counted apart from the template renders that only prepare them. */\n readonly jobs: BlockStatusJobs;\n /** CPU and RAM of the jobs, absent until one of them reports. */\n readonly usage?: BlockStatusUsage;\n /** The first transition anywhere in the tree, ms since the epoch. */\n readonly startedAt?: number;\n /** The most recent transition anywhere in the tree, ms since the epoch. */\n readonly lastChangeAt?: number;\n /**\n * True once the root render has ended and nothing in the tree is still running, or once a render\n * failed and no job is still working.\n */\n readonly done: boolean;\n /**\n * Set when any render of the run terminated: the innermost message of the earliest one's reason,\n * one line, empty when it gave none. The full reason stays on the node's transitions. Commands\n * that fail are counted in {@link BlockStatusJobs.failed} instead.\n */\n readonly failure?: string;\n /**\n * True when the user stopped the run. The tree is kept as it was when it stopped, so the counters\n * say where each node was, but nothing in it runs any more.\n */\n readonly cancelled?: boolean;\n};\n\n/** No jobs yet. */\nexport const EmptyBlockStatusJobs: BlockStatusJobs = {\n total: 0,\n done: 0,\n failed: 0,\n byState: [],\n};\n\n/** A summary for a block whose run has not reported anything yet. */\nexport const EmptyBlockStatusSummary: BlockStatusSummary = {\n availability: \"read\",\n activeContexts: 0,\n totalContexts: 0,\n jobs: EmptyBlockStatusJobs,\n done: false,\n};\n\n/** A summary for a context that could not be read; its counters are unknown, not zero. */\nexport const UnreadableBlockStatusSummary: BlockStatusSummary = {\n ...EmptyBlockStatusSummary,\n availability: \"unreadable\",\n};\n\n/** A summary for a backend that does not accept status reports. */\nexport const UnsupportedBlockStatusSummary: BlockStatusSummary = {\n ...EmptyBlockStatusSummary,\n availability: \"unsupported\",\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAa,0BAA0B;CACrC,kBAAkB;CAClB,SAAS;CACT,oBAAoB;CACpB,uBAAuB;CACvB,mBAAmB;CACnB,mBAAmB;CACnB,qBAAqB;CACrB,mBAAmB;CACnB,YAAY;CACZ,WAAW;AACb;;AAGA,MAAa,oBAAoB,OAAO,OAAO,uBAAuB;;AAMtE,SAAgB,2BAA2B,OAAwB;CACjE,OACE,UAAU,wBAAwB,cAAc,UAAU,wBAAwB;AAEtF;;AAiGA,MAAa,uBAAwC;CACnD,OAAO;CACP,MAAM;CACN,QAAQ;CACR,SAAS,CAAC;AACZ;;AAGA,MAAa,0BAA8C;CACzD,cAAc;CACd,gBAAgB;CAChB,eAAe;CACf,MAAM;CACN,MAAM;AACR;;AAGA,MAAa,+BAAmD;CAC9D,GAAG;CACH,cAAc;AAChB;;AAGA,MAAa,gCAAoD;CAC/D,GAAG;CACH,cAAc;AAChB"}
@@ -64,6 +64,20 @@ export type BlockStatusJobs = {
64
64
  /** The jobs not ended, by the state holding each, largest group first. */
65
65
  readonly byState: readonly BlockStatusJobGroup[];
66
66
  };
67
+ /** One resource of the block's jobs: each job's peak use and its grant, summed over the jobs. */
68
+ export type BlockStatusResource = {
69
+ readonly used: number;
70
+ readonly granted: number;
71
+ };
72
+ /** CPU and RAM of the jobs whose commands report telemetry (only the k8s runner does). */
73
+ export type BlockStatusUsage = {
74
+ /** Jobs that reported. */
75
+ readonly jobs: number;
76
+ /** Millicores. */
77
+ readonly cpu: BlockStatusResource;
78
+ /** Bytes. */
79
+ readonly ram: BlockStatusResource;
80
+ };
67
81
  /** Why a summary carries no counters. */
68
82
  export type BlockStatusAvailability =
69
83
  /** The tree was read and the run has reported what the summary holds. */
@@ -86,6 +100,8 @@ export type BlockStatusSummary = {
86
100
  readonly totalContexts: number;
87
101
  /** The run's jobs, counted apart from the template renders that only prepare them. */
88
102
  readonly jobs: BlockStatusJobs;
103
+ /** CPU and RAM of the jobs, absent until one of them reports. */
104
+ readonly usage?: BlockStatusUsage;
89
105
  /** The first transition anywhere in the tree, ms since the epoch. */
90
106
  readonly startedAt?: number;
91
107
  /** The most recent transition anywhere in the tree, ms since the epoch. */
@@ -1 +1 @@
1
- {"version":3,"file":"block_status.d.ts","names":[],"sources":["../src/block_status.ts"],"mappings":";;;;;;;;;;;;;;;;qBAiBa;WACX;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;qBAIW;;YAGD,2BAA2B;;wBAGvB,2BAA2B;;YAO/B;;WAED;;WAEA;WACA;;WAEA;;WAEA;aAAmB;aAAuB;;;;;;;;;YASzC;WACD;WACA;;;;;WAKA;;WAEA,kBAAkB;;;YAIjB;;;;;;;;;;YAWA;;WAED,cAAc;;WAEd;;WAEA;;WAEA;;WAEA,MAAM;;WAEN;;WAEA;;;;;WAKA;;;;;;WAMA;;;;;WAKA;;;qBAIE,sBAAsB;;qBAQtB,yBAAyB;;qBASzB,8BAA8B;;qBAM9B,+BAA+B"}
1
+ {"version":3,"file":"block_status.d.ts","names":[],"sources":["../src/block_status.ts"],"mappings":";;;;;;;;;;;;;;;;qBAiBa;WACX;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;qBAIW;;YAGD,2BAA2B;;wBAGvB,2BAA2B;;YAO/B;;WAED;;WAEA;WACA;;WAEA;;WAEA;aAAmB;aAAuB;;;;;;;;;YASzC;WACD;WACA;;;;;WAKA;;WAEA,kBAAkB;;;YAIjB;WACD;WACA;;;YAIC;;WAED;;WAEA,KAAK;;WAEL,KAAK;;;YAIJ;;;;;;;;;;YAWA;;WAED,cAAc;;WAEd;;WAEA;;WAEA;;WAEA,MAAM;;WAEN,QAAQ;;WAER;;WAEA;;;;;WAKA;;;;;;WAMA;;;;;WAKA;;;qBAIE,sBAAsB;;qBAQtB,yBAAyB;;qBASzB,8BAA8B;;qBAM9B,+BAA+B"}
@@ -1 +1 @@
1
- {"version":3,"file":"block_status.js","names":[],"sources":["../src/block_status.ts"],"sourcesContent":["/**\n * The status of a running block, as the middle layer hands it to the Desktop App.\n *\n * The backend keeps a tree of status contexts, one per render, and writes each reporter's\n * transitions into the context of the render it belongs to. The middle layer folds that tree into\n * a {@link BlockStatusSummary}.\n */\n\n/**\n * The node states this build knows, spelled as the backend and the workflow SDK write them into a\n * transition value. The names match `plapi.ActionState` on the backend and `STATES` in\n * workflow-tengo's action-context library.\n *\n * The backend owns the list: a reporter may write a state added after this release, and the middle\n * layer passes it on as written. Only the lifecycle (`Completed`, `Terminated`, and `Running`\n * reported by a command) carries meaning in the fold; the rest exists for the user.\n */\nexport const blockStatusStatesRecord = {\n WaitingForInputs: \"WaitingForInputs\",\n Running: \"Running\",\n WaitingWorkdirGate: \"WaitingWorkdirGate\",\n WaitingSubmissionGate: \"WaitingSubmissionGate\",\n PopulatingWorkdir: \"PopulatingWorkdir\",\n CollectingOutputs: \"CollectingOutputs\",\n WaitingForScheduler: \"WaitingForScheduler\",\n WaitingForMachine: \"WaitingForMachine\",\n Terminated: \"Terminated\",\n Completed: \"Completed\",\n} as const;\n\n/** Every state, in the order above. */\nexport const blockStatusStates = Object.values(blockStatusStatesRecord);\n\n/** A node state name this build knows, e.g. `\"PopulatingWorkdir\"`. */\nexport type BlockStatusState = (typeof blockStatusStates)[number];\n\n/** True for a state a node cannot leave. */\nexport function isTerminalBlockStatusState(state: string): boolean {\n return (\n state === blockStatusStatesRecord.Terminated || state === blockStatusStatesRecord.Completed\n );\n}\n\n/** Jobs held by one state: the transition holding each of them has this namespace and state. */\nexport type BlockStatusJobGroup = {\n /** Who reported the state: `exec` for a command, `workdir` for its work folder, `render`. */\n readonly namespace: string;\n /** As the reporter wrote it, which can be a state this build does not know. */\n readonly state: string;\n readonly count: number;\n /** When the earliest of them entered the state, ms since the epoch. */\n readonly since?: number;\n /** Files done and all, summed over the jobs whose work folders report their progress. */\n readonly files?: { readonly done: number; readonly total: number };\n};\n\n/**\n * The block's jobs: the commands it runs on a machine, each counted once by where it is now.\n *\n * A job is a context that a command or its work folder reports in. Jobs the run has not created yet\n * are not counted, so `total` grows while the run fans out.\n */\nexport type BlockStatusJobs = {\n readonly total: number;\n readonly done: number;\n /**\n * Jobs that failed, and renders that failed on their own (not by passing up a failure under\n * them), e.g. one whose command could not start.\n */\n readonly failed: number;\n /** The jobs not ended, by the state holding each, largest group first. */\n readonly byState: readonly BlockStatusJobGroup[];\n};\n\n/** Why a summary carries no counters. */\nexport type BlockStatusAvailability =\n /** The tree was read and the run has reported what the summary holds. */\n | \"read\"\n /** The context could not be read: it is gone, or reading it raised. The counters are unknown,\n * which is not the same as a run that has reported nothing. */\n | \"unreadable\"\n /** The backend cannot take the `actionContext` link, so no context is created and nothing is\n * ever reported. */\n | \"unsupported\";\n\n/** The status of one block run, folded from its status-context tree. */\nexport type BlockStatusSummary = {\n /** Whether the counters below describe the run, or could not be read at all. */\n readonly availability: BlockStatusAvailability;\n /** The block's own `run-id`: two clicks of Run give two different values. */\n readonly runId?: string;\n /** Action contexts that have not ended. */\n readonly activeContexts: number;\n /** Every action context of the run, active or ended. */\n readonly totalContexts: number;\n /** The run's jobs, counted apart from the template renders that only prepare them. */\n readonly jobs: BlockStatusJobs;\n /** The first transition anywhere in the tree, ms since the epoch. */\n readonly startedAt?: number;\n /** The most recent transition anywhere in the tree, ms since the epoch. */\n readonly lastChangeAt?: number;\n /**\n * True once the root render has ended and nothing in the tree is still running, or once a render\n * failed and no job is still working.\n */\n readonly done: boolean;\n /**\n * Set when any render of the run terminated: the innermost message of the earliest one's reason,\n * one line, empty when it gave none. The full reason stays on the node's transitions. Commands\n * that fail are counted in {@link BlockStatusJobs.failed} instead.\n */\n readonly failure?: string;\n /**\n * True when the user stopped the run. The tree is kept as it was when it stopped, so the counters\n * say where each node was, but nothing in it runs any more.\n */\n readonly cancelled?: boolean;\n};\n\n/** No jobs yet. */\nexport const EmptyBlockStatusJobs: BlockStatusJobs = {\n total: 0,\n done: 0,\n failed: 0,\n byState: [],\n};\n\n/** A summary for a block whose run has not reported anything yet. */\nexport const EmptyBlockStatusSummary: BlockStatusSummary = {\n availability: \"read\",\n activeContexts: 0,\n totalContexts: 0,\n jobs: EmptyBlockStatusJobs,\n done: false,\n};\n\n/** A summary for a context that could not be read; its counters are unknown, not zero. */\nexport const UnreadableBlockStatusSummary: BlockStatusSummary = {\n ...EmptyBlockStatusSummary,\n availability: \"unreadable\",\n};\n\n/** A summary for a backend that does not accept status reports. */\nexport const UnsupportedBlockStatusSummary: BlockStatusSummary = {\n ...EmptyBlockStatusSummary,\n availability: \"unsupported\",\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAa,0BAA0B;CACrC,kBAAkB;CAClB,SAAS;CACT,oBAAoB;CACpB,uBAAuB;CACvB,mBAAmB;CACnB,mBAAmB;CACnB,qBAAqB;CACrB,mBAAmB;CACnB,YAAY;CACZ,WAAW;AACb;;AAGA,MAAa,oBAAoB,OAAO,OAAO,uBAAuB;;AAMtE,SAAgB,2BAA2B,OAAwB;CACjE,OACE,UAAU,wBAAwB,cAAc,UAAU,wBAAwB;AAEtF;;AA+EA,MAAa,uBAAwC;CACnD,OAAO;CACP,MAAM;CACN,QAAQ;CACR,SAAS,CAAC;AACZ;;AAGA,MAAa,0BAA8C;CACzD,cAAc;CACd,gBAAgB;CAChB,eAAe;CACf,MAAM;CACN,MAAM;AACR;;AAGA,MAAa,+BAAmD;CAC9D,GAAG;CACH,cAAc;AAChB;;AAGA,MAAa,gCAAoD;CAC/D,GAAG;CACH,cAAc;AAChB"}
1
+ {"version":3,"file":"block_status.js","names":[],"sources":["../src/block_status.ts"],"sourcesContent":["/**\n * The status of a running block, as the middle layer hands it to the Desktop App.\n *\n * The backend keeps a tree of status contexts, one per render, and writes each reporter's\n * transitions into the context of the render it belongs to. The middle layer folds that tree into\n * a {@link BlockStatusSummary}.\n */\n\n/**\n * The node states this build knows, spelled as the backend and the workflow SDK write them into a\n * transition value. The names match `plapi.ActionState` on the backend and `STATES` in\n * workflow-tengo's action-context library.\n *\n * The backend owns the list: a reporter may write a state added after this release, and the middle\n * layer passes it on as written. Only the lifecycle (`Completed`, `Terminated`, and `Running`\n * reported by a command) carries meaning in the fold; the rest exists for the user.\n */\nexport const blockStatusStatesRecord = {\n WaitingForInputs: \"WaitingForInputs\",\n Running: \"Running\",\n WaitingWorkdirGate: \"WaitingWorkdirGate\",\n WaitingSubmissionGate: \"WaitingSubmissionGate\",\n PopulatingWorkdir: \"PopulatingWorkdir\",\n CollectingOutputs: \"CollectingOutputs\",\n WaitingForScheduler: \"WaitingForScheduler\",\n WaitingForMachine: \"WaitingForMachine\",\n Terminated: \"Terminated\",\n Completed: \"Completed\",\n} as const;\n\n/** Every state, in the order above. */\nexport const blockStatusStates = Object.values(blockStatusStatesRecord);\n\n/** A node state name this build knows, e.g. `\"PopulatingWorkdir\"`. */\nexport type BlockStatusState = (typeof blockStatusStates)[number];\n\n/** True for a state a node cannot leave. */\nexport function isTerminalBlockStatusState(state: string): boolean {\n return (\n state === blockStatusStatesRecord.Terminated || state === blockStatusStatesRecord.Completed\n );\n}\n\n/** Jobs held by one state: the transition holding each of them has this namespace and state. */\nexport type BlockStatusJobGroup = {\n /** Who reported the state: `exec` for a command, `workdir` for its work folder, `render`. */\n readonly namespace: string;\n /** As the reporter wrote it, which can be a state this build does not know. */\n readonly state: string;\n readonly count: number;\n /** When the earliest of them entered the state, ms since the epoch. */\n readonly since?: number;\n /** Files done and all, summed over the jobs whose work folders report their progress. */\n readonly files?: { readonly done: number; readonly total: number };\n};\n\n/**\n * The block's jobs: the commands it runs on a machine, each counted once by where it is now.\n *\n * A job is a context that a command or its work folder reports in. Jobs the run has not created yet\n * are not counted, so `total` grows while the run fans out.\n */\nexport type BlockStatusJobs = {\n readonly total: number;\n readonly done: number;\n /**\n * Jobs that failed, and renders that failed on their own (not by passing up a failure under\n * them), e.g. one whose command could not start.\n */\n readonly failed: number;\n /** The jobs not ended, by the state holding each, largest group first. */\n readonly byState: readonly BlockStatusJobGroup[];\n};\n\n/** One resource of the block's jobs: each job's peak use and its grant, summed over the jobs. */\nexport type BlockStatusResource = {\n readonly used: number;\n readonly granted: number;\n};\n\n/** CPU and RAM of the jobs whose commands report telemetry (only the k8s runner does). */\nexport type BlockStatusUsage = {\n /** Jobs that reported. */\n readonly jobs: number;\n /** Millicores. */\n readonly cpu: BlockStatusResource;\n /** Bytes. */\n readonly ram: BlockStatusResource;\n};\n\n/** Why a summary carries no counters. */\nexport type BlockStatusAvailability =\n /** The tree was read and the run has reported what the summary holds. */\n | \"read\"\n /** The context could not be read: it is gone, or reading it raised. The counters are unknown,\n * which is not the same as a run that has reported nothing. */\n | \"unreadable\"\n /** The backend cannot take the `actionContext` link, so no context is created and nothing is\n * ever reported. */\n | \"unsupported\";\n\n/** The status of one block run, folded from its status-context tree. */\nexport type BlockStatusSummary = {\n /** Whether the counters below describe the run, or could not be read at all. */\n readonly availability: BlockStatusAvailability;\n /** The block's own `run-id`: two clicks of Run give two different values. */\n readonly runId?: string;\n /** Action contexts that have not ended. */\n readonly activeContexts: number;\n /** Every action context of the run, active or ended. */\n readonly totalContexts: number;\n /** The run's jobs, counted apart from the template renders that only prepare them. */\n readonly jobs: BlockStatusJobs;\n /** CPU and RAM of the jobs, absent until one of them reports. */\n readonly usage?: BlockStatusUsage;\n /** The first transition anywhere in the tree, ms since the epoch. */\n readonly startedAt?: number;\n /** The most recent transition anywhere in the tree, ms since the epoch. */\n readonly lastChangeAt?: number;\n /**\n * True once the root render has ended and nothing in the tree is still running, or once a render\n * failed and no job is still working.\n */\n readonly done: boolean;\n /**\n * Set when any render of the run terminated: the innermost message of the earliest one's reason,\n * one line, empty when it gave none. The full reason stays on the node's transitions. Commands\n * that fail are counted in {@link BlockStatusJobs.failed} instead.\n */\n readonly failure?: string;\n /**\n * True when the user stopped the run. The tree is kept as it was when it stopped, so the counters\n * say where each node was, but nothing in it runs any more.\n */\n readonly cancelled?: boolean;\n};\n\n/** No jobs yet. */\nexport const EmptyBlockStatusJobs: BlockStatusJobs = {\n total: 0,\n done: 0,\n failed: 0,\n byState: [],\n};\n\n/** A summary for a block whose run has not reported anything yet. */\nexport const EmptyBlockStatusSummary: BlockStatusSummary = {\n availability: \"read\",\n activeContexts: 0,\n totalContexts: 0,\n jobs: EmptyBlockStatusJobs,\n done: false,\n};\n\n/** A summary for a context that could not be read; its counters are unknown, not zero. */\nexport const UnreadableBlockStatusSummary: BlockStatusSummary = {\n ...EmptyBlockStatusSummary,\n availability: \"unreadable\",\n};\n\n/** A summary for a backend that does not accept status reports. */\nexport const UnsupportedBlockStatusSummary: BlockStatusSummary = {\n ...EmptyBlockStatusSummary,\n availability: \"unsupported\",\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAa,0BAA0B;CACrC,kBAAkB;CAClB,SAAS;CACT,oBAAoB;CACpB,uBAAuB;CACvB,mBAAmB;CACnB,mBAAmB;CACnB,qBAAqB;CACrB,mBAAmB;CACnB,YAAY;CACZ,WAAW;AACb;;AAGA,MAAa,oBAAoB,OAAO,OAAO,uBAAuB;;AAMtE,SAAgB,2BAA2B,OAAwB;CACjE,OACE,UAAU,wBAAwB,cAAc,UAAU,wBAAwB;AAEtF;;AAiGA,MAAa,uBAAwC;CACnD,OAAO;CACP,MAAM;CACN,QAAQ;CACR,SAAS,CAAC;AACZ;;AAGA,MAAa,0BAA8C;CACzD,cAAc;CACd,gBAAgB;CAChB,eAAe;CACf,MAAM;CACN,MAAM;AACR;;AAGA,MAAa,+BAAmD;CAC9D,GAAG;CACH,cAAc;AAChB;;AAGA,MAAa,gCAAoD;CAC/D,GAAG;CACH,cAAc;AAChB"}
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import { BlockSettings, InitialBlockSettings, VersionLock } from "./block_settin
3
3
  import { StorageDebugView } from "./storage_debug_view.js";
4
4
  import { BlockStateInternal, BlockStateInternalV3 } from "./block_state.js";
5
5
  import { InstanceStats, InstanceStatsCapacity, InstanceStatsStatus, UnsupportedInstanceStats } from "./instance_stats.js";
6
- import { BlockStatusAvailability, BlockStatusJobGroup, BlockStatusJobs, BlockStatusState, BlockStatusSummary, EmptyBlockStatusJobs, EmptyBlockStatusSummary, UnreadableBlockStatusSummary, UnsupportedBlockStatusSummary, blockStatusStates, blockStatusStatesRecord, isTerminalBlockStatusState } from "./block_status.js";
6
+ import { BlockStatusAvailability, BlockStatusJobGroup, BlockStatusJobs, BlockStatusResource, BlockStatusState, BlockStatusSummary, BlockStatusUsage, EmptyBlockStatusJobs, EmptyBlockStatusSummary, UnreadableBlockStatusSummary, UnsupportedBlockStatusSummary, blockStatusStates, blockStatusStatesRecord, isTerminalBlockStatusState } from "./block_status.js";
7
7
  import { BlockStatusTree, BlockStatusTreeBranch, BlockStatusTreeHeaviest, BlockStatusTreeHeaviestCount, BlockStatusTreeNode, BlockStatusTreeReading, BlockStatusTreeTransition } from "./block_status_tree.js";
8
8
  import { ProjectMeta, normalizeDescription, normalizeProjectMeta } from "./project.js";
9
9
  import { ProjectListEntry } from "./project_list.js";
@@ -36,4 +36,4 @@ import "./block_meta/index.js";
36
36
  import { index_d_exports } from "./pframe/internal_api/index.js";
37
37
  import "./pframe/index.js";
38
38
  import { HashedJson, hashJson, readJson, readJsonSync } from "./json.js";
39
- export { AnyChannel, type AuthorMarker, BlockCalculationStatus, BlockComponents, BlockComponentsDescriptionRaw, BlockComponentsManifest, BlockKindRef, BlockPackDescription, BlockPackDescriptionFromPackageJsonRaw, BlockPackDescriptionManifest, BlockPackDescriptionRaw, BlockPackDevV1, BlockPackDevV2, BlockPackFromPackV2, BlockPackFromRegistryV1, BlockPackFromRegistryV2, BlockPackId, BlockPackIdNoVersion, BlockPackListing, BlockPackManifest, BlockPackManifestFile, BlockPackMeta, BlockPackMetaDescriptionRaw, BlockPackMetaEmbeddedBase64, BlockPackMetaEmbeddedBytes, BlockPackMetaManifest, BlockPackOverview, BlockPackOverviewLegacy, BlockPackOverviewNoRegistryId, BlockPackOverviewRaw, BlockPackSpec, BlockPlatform, BlockSettings, BlockStateInternal, BlockStateInternalV3, BlockStateOverview, BlockStatusAvailability, BlockStatusJobGroup, BlockStatusJobs, BlockStatusState, BlockStatusSummary, BlockStatusTree, BlockStatusTreeBranch, BlockStatusTreeHeaviest, BlockStatusTreeHeaviestCount, BlockStatusTreeNode, BlockStatusTreeReading, BlockStatusTreeTransition, Content, ContentAbsoluteBinaryLocal, ContentAbsoluteFile, ContentAbsoluteFolder, ContentAbsoluteTextLocal, ContentAbsoluteUrl, ContentAnyBinaryLocal, ContentAnyLocal, ContentAnyTextLocal, ContentExplicitBase64, ContentExplicitBytes, ContentExplicitOrRelative, ContentExplicitString, ContentRelative, ContentRelativeBinary, ContentRelativeText, ContentType, ContextType, CreateBlockPackDescriptionSchema, DescriptionContentBinary, DescriptionContentText, EmptyBlockStatusJobs, EmptyBlockStatusSummary, FOLDERS_SCHEMA_VERSION, FeatureFlags, FolderEntry, FolderId, FolderView, FoldersDecoded, FoldersDocument, FoldersDocumentProblem, FoldersEdit, FoldersItem, FoldersItemInput, FoldersItemView, FoldersLabelRename, FoldersLeafItem, FoldersMoveApplication, FoldersMoveEntry, FoldersMoveIssue, FoldersMoveOutcome, FoldersMovePlan, FoldersMovePlanResult, FoldersPlacement, FoldersProjectInput, FoldersProjectView, FoldersRemoval, FoldersRemovalIssue, FoldersRemovalOutcome, FoldersRemovalPlanResult, FoldersStoredDocument, FoldersTemplateInput, FoldersTemplateView, FoldersView, FoldersViolation, HashedJson, InitialBlockSettings, InstanceStats, InstanceStatsCapacity, InstanceStatsStatus, LocalDevFolder, ManifestFileInfo, index_d_exports as PFrameInternal, ProjectListEntry, ProjectMeta, ProjectOverview, RegistryEntry, RegistryList, RegistrySpec, RegistryStatus, RemoteRegistryV1Spec, RemoteRegistryV2Spec, SemVer, Sha256Schema, SingleBlockPackOverview, StableChannel, StorageDebugView, UnreadableBlockStatusSummary, UnsupportedBlockStatusSummary, UnsupportedInstanceStats, UpdateSuggestion, UpdateSuggestions, VersionLock, VersionWithChannels, Workflow, WorkflowSchemaV1, WorkflowV1, addPrefixToRelative, applyFoldersMove, applyFoldersRemoval, asFolderId, blockPackIdEquals, blockPackIdNoVersionEquals, blockPackIdNoVersionToString, blockPackIdToString, blockPackOverviewToLegacy, blockStatusStates, blockStatusStatesRecord, commitFoldersMove, commitFoldersRemoval, decodeFoldersDocument, decodeStoredFoldersDocument, emptyFoldersDocument, encodeFoldersDocument, foldersChildren, foldersDocumentFromView, foldersMovePlansEqual, foldersNameBlank, foldersNameTaken, foldersRemovalsEqual, foldersSiblingNames, foldersSubtree, foldersUniqueName, foldersViewFromDocument, formatFoldersViolation, hashJson, healFolders, inheritedFolder, isTerminalBlockStatusState, mapRemoteToAbsolute, normalizeDescription, normalizeProjectMeta, overrideDescriptionVersion, overrideManifestVersion, planFoldersMove, planFoldersRemoval, readJson, readJsonSync, validateFoldersDocument };
39
+ export { AnyChannel, type AuthorMarker, BlockCalculationStatus, BlockComponents, BlockComponentsDescriptionRaw, BlockComponentsManifest, BlockKindRef, BlockPackDescription, BlockPackDescriptionFromPackageJsonRaw, BlockPackDescriptionManifest, BlockPackDescriptionRaw, BlockPackDevV1, BlockPackDevV2, BlockPackFromPackV2, BlockPackFromRegistryV1, BlockPackFromRegistryV2, BlockPackId, BlockPackIdNoVersion, BlockPackListing, BlockPackManifest, BlockPackManifestFile, BlockPackMeta, BlockPackMetaDescriptionRaw, BlockPackMetaEmbeddedBase64, BlockPackMetaEmbeddedBytes, BlockPackMetaManifest, BlockPackOverview, BlockPackOverviewLegacy, BlockPackOverviewNoRegistryId, BlockPackOverviewRaw, BlockPackSpec, BlockPlatform, BlockSettings, BlockStateInternal, BlockStateInternalV3, BlockStateOverview, BlockStatusAvailability, BlockStatusJobGroup, BlockStatusJobs, BlockStatusResource, BlockStatusState, BlockStatusSummary, BlockStatusTree, BlockStatusTreeBranch, BlockStatusTreeHeaviest, BlockStatusTreeHeaviestCount, BlockStatusTreeNode, BlockStatusTreeReading, BlockStatusTreeTransition, BlockStatusUsage, Content, ContentAbsoluteBinaryLocal, ContentAbsoluteFile, ContentAbsoluteFolder, ContentAbsoluteTextLocal, ContentAbsoluteUrl, ContentAnyBinaryLocal, ContentAnyLocal, ContentAnyTextLocal, ContentExplicitBase64, ContentExplicitBytes, ContentExplicitOrRelative, ContentExplicitString, ContentRelative, ContentRelativeBinary, ContentRelativeText, ContentType, ContextType, CreateBlockPackDescriptionSchema, DescriptionContentBinary, DescriptionContentText, EmptyBlockStatusJobs, EmptyBlockStatusSummary, FOLDERS_SCHEMA_VERSION, FeatureFlags, FolderEntry, FolderId, FolderView, FoldersDecoded, FoldersDocument, FoldersDocumentProblem, FoldersEdit, FoldersItem, FoldersItemInput, FoldersItemView, FoldersLabelRename, FoldersLeafItem, FoldersMoveApplication, FoldersMoveEntry, FoldersMoveIssue, FoldersMoveOutcome, FoldersMovePlan, FoldersMovePlanResult, FoldersPlacement, FoldersProjectInput, FoldersProjectView, FoldersRemoval, FoldersRemovalIssue, FoldersRemovalOutcome, FoldersRemovalPlanResult, FoldersStoredDocument, FoldersTemplateInput, FoldersTemplateView, FoldersView, FoldersViolation, HashedJson, InitialBlockSettings, InstanceStats, InstanceStatsCapacity, InstanceStatsStatus, LocalDevFolder, ManifestFileInfo, index_d_exports as PFrameInternal, ProjectListEntry, ProjectMeta, ProjectOverview, RegistryEntry, RegistryList, RegistrySpec, RegistryStatus, RemoteRegistryV1Spec, RemoteRegistryV2Spec, SemVer, Sha256Schema, SingleBlockPackOverview, StableChannel, StorageDebugView, UnreadableBlockStatusSummary, UnsupportedBlockStatusSummary, UnsupportedInstanceStats, UpdateSuggestion, UpdateSuggestions, VersionLock, VersionWithChannels, Workflow, WorkflowSchemaV1, WorkflowV1, addPrefixToRelative, applyFoldersMove, applyFoldersRemoval, asFolderId, blockPackIdEquals, blockPackIdNoVersionEquals, blockPackIdNoVersionToString, blockPackIdToString, blockPackOverviewToLegacy, blockStatusStates, blockStatusStatesRecord, commitFoldersMove, commitFoldersRemoval, decodeFoldersDocument, decodeStoredFoldersDocument, emptyFoldersDocument, encodeFoldersDocument, foldersChildren, foldersDocumentFromView, foldersMovePlansEqual, foldersNameBlank, foldersNameTaken, foldersRemovalsEqual, foldersSiblingNames, foldersSubtree, foldersUniqueName, foldersViewFromDocument, formatFoldersViolation, hashJson, healFolders, inheritedFolder, isTerminalBlockStatusState, mapRemoteToAbsolute, normalizeDescription, normalizeProjectMeta, overrideDescriptionVersion, overrideManifestVersion, planFoldersMove, planFoldersRemoval, readJson, readJsonSync, validateFoldersDocument };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milaboratories/pl-model-middle-layer",
3
- "version": "1.40.0",
3
+ "version": "1.41.1",
4
4
  "description": "Common model between middle layer and non-block UI code",
5
5
  "files": [
6
6
  "./dist/**/*",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@milaboratories/helpers": "1.14.7",
21
- "@milaboratories/pl-model-common": "1.56.0",
21
+ "@milaboratories/pl-model-common": "1.57.0",
22
22
  "es-toolkit": "^1.39.10",
23
23
  "utility-types": "^3.11.0",
24
24
  "zod": "~3.25.76"
@@ -72,6 +72,22 @@ export type BlockStatusJobs = {
72
72
  readonly byState: readonly BlockStatusJobGroup[];
73
73
  };
74
74
 
75
+ /** One resource of the block's jobs: each job's peak use and its grant, summed over the jobs. */
76
+ export type BlockStatusResource = {
77
+ readonly used: number;
78
+ readonly granted: number;
79
+ };
80
+
81
+ /** CPU and RAM of the jobs whose commands report telemetry (only the k8s runner does). */
82
+ export type BlockStatusUsage = {
83
+ /** Jobs that reported. */
84
+ readonly jobs: number;
85
+ /** Millicores. */
86
+ readonly cpu: BlockStatusResource;
87
+ /** Bytes. */
88
+ readonly ram: BlockStatusResource;
89
+ };
90
+
75
91
  /** Why a summary carries no counters. */
76
92
  export type BlockStatusAvailability =
77
93
  /** The tree was read and the run has reported what the summary holds. */
@@ -95,6 +111,8 @@ export type BlockStatusSummary = {
95
111
  readonly totalContexts: number;
96
112
  /** The run's jobs, counted apart from the template renders that only prepare them. */
97
113
  readonly jobs: BlockStatusJobs;
114
+ /** CPU and RAM of the jobs, absent until one of them reports. */
115
+ readonly usage?: BlockStatusUsage;
98
116
  /** The first transition anywhere in the tree, ms since the epoch. */
99
117
  readonly startedAt?: number;
100
118
  /** The most recent transition anywhere in the tree, ms since the epoch. */