@assemblyline/al-orc 0.7.0 → 0.9.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/CHANGELOG.md CHANGED
@@ -7,6 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.9.0] - 2026-12-03
11
+
12
+ ### Changed
13
+ - **Breaking:** `factory-sessions show --tasks` is now `--runs`. The orchestrator reads a
14
+ session's runs from work records (the step queue is gone): outcomes by station and the
15
+ recent runs, each with its station code.
16
+
17
+ ## [0.8.0] - 2026-12-03
18
+
19
+ ### Changed
20
+ - **Breaking:** `work-records show --steps` is now `--output`: the config the run used (with
21
+ any overrides) and what its handler returned. The orchestrator no longer keeps step outputs.
22
+ - `stations list` drops the STEPS column; `stations show` prints the station's config.
23
+ - `factory-sessions show` groups outcomes and recent tasks by station.
24
+
25
+ ### Removed
26
+ - `stations pull` no longer keeps `steps` in a local file that has them: every factory is on
27
+ lib-factory 0.42, and the orchestrator refuses `steps`.
28
+ - `supporting-docs show` no longer prints a document's step.
29
+
10
30
  ## [0.7.0] - 2026-12-03
11
31
 
12
32
  ### Changed
package/README.md CHANGED
@@ -10,7 +10,7 @@ al-orc login # pick orgs in the browser; one p
10
10
  al-orc status # org and key the profile belongs to
11
11
  al-orc lines push --all && al-orc stations push --all # from a factory repo root
12
12
  al-orc stations run EX0
13
- al-orc stations run EX1 --set dry_run=true # change a step config key for this run
13
+ al-orc stations run EX1 --set dry_run=true # change a config key for this run
14
14
  al-orc work-records list --station EX0
15
15
  ```
16
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@assemblyline/al-orc",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "Assembly Line Orchestrator client + al-orc CLI (2-in-1): push lines and stations, run them, read work records.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,10 +25,10 @@ export function buildFactorySessionsSubcommands(yargs) {
25
25
  )
26
26
  .command(
27
27
  'show <id>',
28
- 'Show a factory session and its per-step outcomes (--tasks for the task list)',
28
+ 'Show a factory session and its outcomes by station (--runs for the runs it claimed)',
29
29
  (y) =>
30
30
  localOptions(y.positional('id', { describe: 'Factory session ID', type: 'string' }))
31
- .option('tasks', { describe: 'Include the tasks this session claimed', type: 'boolean' })
31
+ .option('runs', { describe: 'Include the runs this session claimed', type: 'boolean' })
32
32
  .option('json', { describe: 'Output raw JSON', type: 'boolean' }),
33
33
  safe(showFactorySessionHandler),
34
34
  )
@@ -9,7 +9,7 @@ import { formatTable, formatDate, localTzLabel } from '../utils/format.js';
9
9
  * if they run different code or out of different directories they are not
10
10
  * interchangeable — and the orchestrator hands each task to whoever polls
11
11
  * first. That is the 2026-08-11 failure mode: two factory sessions on `dev-laptop1`,
12
- * one without the EM steps, so EM runs failed at random.
12
+ * one without the EM stations, so EM runs failed at random.
13
13
  *
14
14
  * D1 (one active session per org+location) now refuses the second session, so
15
15
  * this should be empty on a healthy fleet. It stays because historical rows
@@ -4,7 +4,7 @@ import { formatTable, formatDate, formatField, formatSection, localTzLabel, trun
4
4
 
5
5
  /** `al-orc factory-sessions show <id>` — one factory session, and what it did. */
6
6
  export async function showFactorySessionHandler(argv) {
7
- const { id, tasks, json } = argv;
7
+ const { id, runs, json } = argv;
8
8
 
9
9
  const orc = clientFor();
10
10
  const session = await orc.factorySessions.get(id);
@@ -32,44 +32,44 @@ export async function showFactorySessionHandler(argv) {
32
32
  if (session.ended_at) {
33
33
  console.log(formatField('Ended', formatDate(session.ended_at), 14));
34
34
  }
35
- console.log(formatField('Tasks', `${session.tasks_completed ?? 0} completed, ${session.tasks_failed ?? 0} failed`, 14));
35
+ console.log(formatField('Runs', `${session.tasks_completed ?? 0} completed, ${session.tasks_failed ?? 0} failed`, 14));
36
36
 
37
- const breakdown = session.slug_breakdown || [];
37
+ const breakdown = session.station_breakdown || [];
38
38
  console.log('');
39
- console.log(formatSection(`Outcomes by step (${breakdown.length})`));
39
+ console.log(formatSection(`Outcomes by station (${breakdown.length})`));
40
40
  if (breakdown.length === 0) {
41
- console.log('This session never claimed a task.');
41
+ console.log('This session never claimed a run.');
42
42
  } else {
43
43
  console.log(formatTable(
44
- ['STEP', 'OK', 'FAILED', 'OTHER'],
45
- breakdown.map((s) => [s.step_slug, String(s.completed), String(s.failed), String(s.other)]),
44
+ ['STATION', 'OK', 'FAILED', 'OTHER'],
45
+ breakdown.map((s) => [s.station, String(s.completed), String(s.failed), String(s.other)]),
46
46
  ));
47
47
 
48
- // The stale-deploy signature: some slugs work, others never do. A factory session
49
- // with bad credentials or a dead upstream fails everything; one whose code
50
- // predates a station fails only that station's slugs.
48
+ // The stale-deploy signature: some stations work, others never do. A factory session
49
+ // with bad credentials or a dead upstream fails everything; one whose code predates a
50
+ // station fails only that station.
51
51
  const all_fail = breakdown.filter((s) => s.completed === 0 && s.failed > 0);
52
52
  const any_ok = breakdown.filter((s) => s.completed > 0);
53
53
  if (all_fail.length > 0 && any_ok.length > 0) {
54
54
  console.log('');
55
- console.log(`! ${all_fail.length} step(s) never succeeded here while ${any_ok.length} did.`);
56
- console.log(` Never succeeded: ${all_fail.map((s) => s.step_slug).join(', ')}`);
57
- console.log(" A factory session that handles some steps and no others usually predates them — check its version and restart it.");
55
+ console.log(`! ${all_fail.length} station(s) never succeeded here while ${any_ok.length} did.`);
56
+ console.log(` Never succeeded: ${all_fail.map((s) => s.station).join(', ')}`);
57
+ console.log(" A factory session that handles some stations and no others usually predates them — check its version and restart it.");
58
58
  }
59
59
  }
60
60
 
61
- if (tasks) {
62
- const recent = session.recent_tasks || [];
61
+ if (runs) {
62
+ const recent = session.recent_runs || [];
63
63
  console.log('');
64
- console.log(formatSection(`Recent tasks (${recent.length})`));
64
+ console.log(formatSection(`Recent runs (${recent.length})`));
65
65
  if (recent.length === 0) {
66
- console.log('No tasks.');
66
+ console.log('No runs.');
67
67
  } else {
68
68
  console.log(formatTable(
69
- ['WORK RECORD', 'STEP', 'STATUS', 'TRIES', `CLAIMED (${localTzLabel()})`, 'ERROR'],
69
+ ['WORK RECORD', 'STATION', 'STATUS', 'TRIES', `CLAIMED (${localTzLabel()})`, 'ERROR'],
70
70
  recent.map((t) => [
71
71
  t.work_record,
72
- t.step_slug,
72
+ t.station,
73
73
  t.status,
74
74
  String(t.retry_count ?? 0),
75
75
  formatDate(t.claimed_at),
@@ -79,6 +79,6 @@ export async function showFactorySessionHandler(argv) {
79
79
  }
80
80
  } else {
81
81
  console.log('');
82
- console.log('Use --tasks to list the tasks this session claimed.');
82
+ console.log('Use --runs to list the runs this session claimed.');
83
83
  }
84
84
  }
@@ -41,7 +41,7 @@ export function buildStationsSubcommands(yargs) {
41
41
  )
42
42
  .command(
43
43
  'run <id>',
44
- 'Trigger an orchestrator run (--set key=value changes a step config key for this run)',
44
+ 'Trigger an orchestrator run (--set key=value changes a config key for this run)',
45
45
  (y) =>
46
46
  localOptions(y.positional('id', { describe: 'Station ID or short_code', type: 'string' }))
47
47
  .option('set', {
@@ -24,10 +24,9 @@ export async function listStationsHandler(argv) {
24
24
  s.short_code || '—',
25
25
  s.id,
26
26
  s.name || '—',
27
- String(s.steps ? s.steps.length : 0),
28
27
  ...(include_archived ? [s.archived || s.archived_at ? 'yes' : '—'] : []),
29
28
  ]);
30
- const headers = ['CODE', 'ID', 'NAME', 'STEPS', ...(include_archived ? ['ARCHIVED'] : [])];
29
+ const headers = ['CODE', 'ID', 'NAME', ...(include_archived ? ['ARCHIVED'] : [])];
31
30
 
32
31
  console.log(formatTable(headers, rows));
33
32
  console.log('');
@@ -5,7 +5,7 @@ import { clientFor } from '../_helpers.js';
5
5
  * Turn `--set key=value` flags into per-run config overrides, shallow-merged into the station's
6
6
  * config by the orchestrator. The value is read as JSON (`true`, `2`, `"x"`, `[1,2]`) and,
7
7
  * when it isn't JSON, kept as text. A later flag for the same key wins. The same spelling as
8
- * lib-factory's `factory steps run --set`.
8
+ * lib-factory's `factory stations run --set`.
9
9
  *
10
10
  * @param {string[]} [sets]
11
11
  * @returns {Record<string, unknown>}
@@ -42,10 +42,8 @@ export async function showStationHandler(argv) {
42
42
  }
43
43
  console.log(formatField('Dependencies', deps, lw));
44
44
 
45
- if (station.steps?.length) {
46
- console.log(`\nSteps (${station.steps.length}):`);
47
- station.steps.forEach((s, i) => console.log(` ${i + 1}. ${s.slug}`));
48
- }
45
+ console.log(formatSection('Config'));
46
+ console.log(JSON.stringify(station.config ?? {}, null, 2));
49
47
 
50
48
  if (workRecords || all) {
51
49
  const records = await orc.workRecords.list({ station: station.id, limit: 10 }).then((r) => r.data || []);
@@ -25,7 +25,6 @@ export async function showSupportingDocHandler(argv) {
25
25
  const lw = 16;
26
26
  console.log(formatField('Title', doc.title ?? doc.name, lw));
27
27
  console.log(formatField('Type', doc.type, lw));
28
- if (doc.step_slug) console.log(formatField('Step', doc.step_slug, lw));
29
28
  if (doc.filename) console.log(formatField('Filename', doc.filename, lw));
30
29
  if (doc.mime_type) console.log(formatField('MIME Type', doc.mime_type, lw));
31
30
  if (doc.size_bytes) console.log(formatField('Size', formatBytes(doc.size_bytes), lw));
@@ -55,20 +55,11 @@ export function findStationFile(identifier) {
55
55
  /**
56
56
  * The station as its local file holds it:
57
57
  * - a station with no conveyor has no `conveyor` key, rather than `"conveyor": null`;
58
- * - its config as `config`, unless the file it replaces still has `steps` (a factory not yet
59
- * on lib-factory 0.41's `defineStation`), which keeps `steps` instead. The orchestrator sends
60
- * both and keeps them in step.
61
58
  *
62
59
  * @param {any} station - As the API returns it
63
- * @param {any} [previous] - The local file it replaces
64
60
  */
65
- function forLocalFile(station, previous) {
61
+ function forLocalFile(station) {
66
62
  if (station.conveyor == null) delete station.conveyor;
67
- if (previous?.steps !== undefined && previous?.config === undefined) {
68
- delete station.config;
69
- } else if (station.config !== undefined) {
70
- delete station.steps;
71
- }
72
63
  return station;
73
64
  }
74
65
 
@@ -81,20 +72,12 @@ export function saveStation(station) {
81
72
  const existingByCode = findStationFile(station.short_code);
82
73
  if (existingByCode) toRemove.add(existingByCode);
83
74
  }
84
- let previous;
85
- for (const f of toRemove) {
86
- try {
87
- previous ??= JSON.parse(fs.readFileSync(f, 'utf8'));
88
- } catch {
89
- // a malformed file is replaced
90
- }
91
- fs.unlinkSync(f);
92
- }
75
+ for (const f of toRemove) fs.unlinkSync(f);
93
76
 
94
77
  if (!fs.existsSync(STATIONS_DIR)) fs.mkdirSync(STATIONS_DIR, { recursive: true });
95
78
 
96
79
  const filepath = path.join(STATIONS_DIR, buildFilename(station));
97
- fs.writeFileSync(filepath, JSON.stringify(forLocalFile(station, previous), null, 2));
80
+ fs.writeFileSync(filepath, JSON.stringify(forLocalFile(station), null, 2));
98
81
  return filepath;
99
82
  }
100
83
 
@@ -29,11 +29,11 @@ export function buildWorkRecordsSubcommands(yargs) {
29
29
  )
30
30
  .command(
31
31
  'show <id>',
32
- 'Show a work record (--report/--steps/--supporting-docs/--activity/--all for detail)',
32
+ 'Show a work record (--report/--output/--supporting-docs/--activity/--all for detail)',
33
33
  (y) =>
34
34
  localOptions(y.positional('id', { describe: 'Work record ID', type: 'string' }))
35
35
  .option('report', { describe: 'Include the report', type: 'boolean' })
36
- .option('steps', { describe: 'Include step outputs', type: 'boolean' })
36
+ .option('output', { describe: 'Include the config the run used and its output', type: 'boolean' })
37
37
  .option('supporting-docs', { describe: 'Include supporting documents', type: 'boolean' })
38
38
  .option('activity', { describe: 'Include activity events', type: 'boolean' })
39
39
  .option('all', { describe: 'Include every detail section', type: 'boolean' })
@@ -5,13 +5,12 @@ import { buildStationLabelMap, stationLabel } from '../utils/station-labels.js';
5
5
 
6
6
  /** `al-orc work-records show <id>` — one work record, with optional detail sections. */
7
7
  export async function showWorkRecordHandler(argv) {
8
- const { id, report, steps, supportingDocs, activity, all, json } = argv;
8
+ const { id, report, output, supportingDocs, activity, all, json } = argv;
9
9
 
10
10
  const orc = clientFor();
11
11
 
12
12
  const include = [];
13
13
  if (report || all) include.push('report');
14
- if (steps || all) include.push('step_outputs');
15
14
  if (supportingDocs || all) include.push('supporting_docs');
16
15
 
17
16
  const record = await orc.workRecords.get(id, { include: include.length ? include : undefined });
@@ -49,19 +48,13 @@ export async function showWorkRecordHandler(argv) {
49
48
  console.log(record.report ? (typeof record.report === 'string' ? record.report : JSON.stringify(record.report, null, 2)) : 'No report available.');
50
49
  }
51
50
 
52
- if (steps || all) {
53
- console.log(formatSection('Step Outputs'));
54
- const outputs = record.step_outputs || {};
55
- const slugs = Object.keys(outputs);
56
- if (slugs.length) {
57
- for (const slug of slugs) {
58
- console.log(`\n[${slug}]`);
59
- const output = outputs[slug];
60
- console.log(typeof output === 'object' ? JSON.stringify(output, null, 2) : String(output));
61
- }
62
- } else {
63
- console.log('No step outputs.');
64
- }
51
+ if (output || all) {
52
+ const show = (/** @type {any} */ v) => (v === null || v === undefined ? '—' : JSON.stringify(v, null, 2));
53
+ console.log(formatSection('Config'));
54
+ console.log(show(record.config_snapshot));
55
+ if (record.config_overrides) console.log(`\nOverrides: ${JSON.stringify(record.config_overrides)}`);
56
+ console.log(formatSection('Output'));
57
+ console.log(show(record.output));
65
58
  }
66
59
 
67
60
  if (supportingDocs || all) {
@@ -98,7 +91,7 @@ export async function showWorkRecordHandler(argv) {
98
91
  }
99
92
  }
100
93
 
101
- if (!report && !steps && !supportingDocs && !activity && !all) {
102
- console.log('\nUse --report, --steps, --supporting-docs, --activity, or --all for details.');
94
+ if (!report && !output && !supportingDocs && !activity && !all) {
95
+ console.log('\nUse --report, --output, --supporting-docs, --activity, or --all for details.');
103
96
  }
104
97
  }
@@ -33,8 +33,8 @@
33
33
  */
34
34
 
35
35
  /**
36
- * @typedef {Object} SlugOutcome
37
- * @property {string} step_slug
36
+ * @typedef {Object} StationOutcome
37
+ * @property {string} station The station's code
38
38
  * @property {number} completed
39
39
  * @property {number} failed
40
40
  * @property {number} other
@@ -42,10 +42,10 @@
42
42
 
43
43
  /**
44
44
  * @typedef {FactorySession & {
45
- * slug_breakdown: SlugOutcome[],
46
- * recent_tasks: Array<{ id: string, work_record: string, step_slug: string, status: string,
47
- * retry_count: number, error: string|null,
48
- * claimed_at: string|null, completed_at: string|null }>
45
+ * station_breakdown: StationOutcome[],
46
+ * recent_runs: Array<{ work_record: string, station: string, status: string,
47
+ * retry_count: number, error: string|null,
48
+ * claimed_at: string|null, completed_at: string|null }>
49
49
  * }} FactorySessionDetail
50
50
  */
51
51
 
@@ -57,7 +57,7 @@ export function buildWorkRecords(ctx) {
57
57
  getAll: async (params = {}) =>
58
58
  (await ctx.getAll('/api/v1/work-records', { searchParams: toSearchParams(params) })).data,
59
59
 
60
- /** One work record. `include` pulls optional blocks: 'report', 'step_outputs', 'supporting_docs'. */
60
+ /** One work record. `include` pulls optional blocks: 'report', 'supporting_docs'. */
61
61
  get: (id, { include } = {}) =>
62
62
  ctx
63
63
  .get(`/api/v1/work-records/${enc(id)}`, include?.length ? { searchParams: { include: include.join(',') } } : undefined)
@@ -7,7 +7,7 @@
7
7
  * @property {string} [short_code]
8
8
  * @property {string} line Line code. The line owns the location; a station has none of its own.
9
9
  * @property {string} [description]
10
- * @property {StationStep[]} [steps]
10
+ * @property {Record<string, any>} [config] The station's config, passed to its handler.
11
11
  * @property {{ from: string | string[] } | null} [conveyor] Bins the factory session moves workpieces from into input/
12
12
  * @property {(string|{ id: string, short_code?: string })[]} [dependencies] Station ids or short_codes this one depends on (or station objects).
13
13
  * @property {(string|Tag)[]} [tags]
@@ -17,13 +17,6 @@
17
17
  * @property {string} [created_at]
18
18
  */
19
19
 
20
- /**
21
- * One step within a station definition.
22
- * @typedef {Object} StationStep
23
- * @property {string} slug
24
- * @property {Record<string, any>} [config]
25
- */
26
-
27
20
  /**
28
21
  * The result of triggering a station run.
29
22
  * @typedef {Object} StationRunResult
@@ -12,7 +12,6 @@
12
12
  * @property {string} [title]
13
13
  * @property {string} [filename]
14
14
  * @property {number} [size_bytes]
15
- * @property {string} [step_slug] The step that produced it.
16
15
  * @property {string} [work_record_id]
17
16
  * @property {string} [created_at]
18
17
  */
@@ -8,7 +8,9 @@
8
8
  * @property {string} [status]
9
9
  * @property {(string|Tag)[]} [tags]
10
10
  * @property {Record<string, any>} [report]
11
- * @property {Record<string, any>[]} [step_outputs]
11
+ * @property {Record<string, any>|null} [config_snapshot] The config the run used, overrides applied.
12
+ * @property {Record<string, any>|null} [config_overrides] Per-run overrides, if any.
13
+ * @property {any} [output] What the station's handler returned.
12
14
  * @property {string} [created_at]
13
15
  * @property {string} [updated_at]
14
16
  * @property {string|null} [started_at]