octwin-cli 0.8.5 → 0.8.7

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/dist/index.js CHANGED
@@ -73,7 +73,8 @@ import { loadBuiltinNames, findBuiltinViolations, describeBuiltinFinding } from
73
73
  import { loadTemplateSpecs, findTemplateViolations, describeTemplateFinding } from './lib/template-check.js';
74
74
  import { loadSystemEntities, findEntityViolations, describeEntityFinding } from './lib/entity-check.js';
75
75
  import { loadDeclarationSpecs, findDeclarationViolations, describeDeclarationFinding } from './lib/declaration-check.js';
76
- import { describeKbLookup, findPlatformKbDir } from './lib/kb-path.js';
76
+ import { findPlatformKbDir } from './lib/kb-path.js';
77
+ import { reportChecks } from './lib/outcome.js';
77
78
  import { classifyPackPath, isSkippedDir } from './lib/pack-source.js';
78
79
  import { readPage, morePageHint } from './lib/page.js';
79
80
  import { kbOneLiner, buildKbIndexMarkdown, buildKbOutlineMarkdown, } from './lib/kb-index.js';
@@ -976,158 +977,161 @@ async function cmdValidate(flags) {
976
977
  const yamlDocs = () => parsed;
977
978
  // Checks that need the pulled KB. All of them DEGRADE when it is absent — the KB
978
979
  // is a gitignored cache wiped by every pull, so failing hard would break a fresh
979
- // clone before the author could act. But a skip is ANNOUNCED, and remembered:
980
- // the ✓ used to print above these blocks unconditionally while the per-check ✓s
981
- // lived inside the `if`s, so a KB-less run read as "one check, passed". An entire
982
- // backlog batch reached production that way. The defect is the silence, not the skip.
980
+ // clone before the author could act. But a skip is ANNOUNCED, and remembered.
983
981
  //
984
- // Reasons are COLLECTED rather than printed inline. When the KB is missing, every
985
- // check skips for the identical reason, and six copies of one sentence is how a
986
- // reader learns to scroll past the block which is the same failure as not
987
- // printing it. One line, naming all six.
988
- const skipped = [];
989
- const skipReasons = new Map();
990
- const noteSkip = (label, lookup) => {
991
- skipped.push(label);
992
- // Group by the lookup's IDENTITY, then let `describeKbLookup` phrase the one
993
- // line at print time — so the wording stays in the module that owns it and
994
- // cannot drift into a doubled "SKIPPED — SKIPPED —".
995
- const key = lookup.state === 'ok' ? 'ok'
996
- : `${lookup.state}|${'dir' in lookup ? lookup.dir : ''}|${'reason' in lookup ? lookup.reason : ''}`;
997
- const bucket = skipReasons.get(key) ?? { lookup, labels: [] };
998
- bucket.labels.push(label);
999
- skipReasons.set(key, bucket);
1000
- };
982
+ // Each check RETURNS an `Outcome` and prints nothing; `reportChecks` renders all of
983
+ // them and groups the skips by reason. That is the whole point: a check that returns
984
+ // nothing cannot reach the `passed` branch, so the false-`✓` this file printed twice
985
+ // before once for six checks at a time, once over an unparseable file — is no longer
986
+ // a mistake anyone can make. See [`lib/outcome.ts`](./lib/outcome.ts).
1001
987
  /** Stamp each finding with its source line — the walkers carry the node
1002
988
  * path; `files` holds the raw text the locator needs (E-08). */
1003
989
  const withLines = (fs) => fs.map(f => ({ ...f, line: files[f.file] ? yamlLineOf(files[f.file], f.path) : null }));
1004
- const render = loadAllowedRenderKeys(packDir);
1005
- if (render.keys) {
1006
- const findings = withLines(yamlDocs().flatMap(([p, doc]) => findRenderKeyViolations(doc, p, render.keys, render.nested)));
1007
- if (findings.length) {
1008
- console.error(`✗ ${findings.length} render-intent field error${findings.length === 1 ? '' : 's'}:`);
1009
- for (const f of findings)
1010
- console.error(` ✗ ${describeRenderFinding(f)}`);
1011
- die('fix these before deploying the platform rejects them at load, and before that they rendered as nothing');
1012
- }
1013
- console.log('✓ render intents use only fields the platform renders');
1014
- }
1015
- else {
1016
- noteSkip('render-intent fields', render.lookup);
1017
- }
1018
- // Primitive `args:` keys, same source and same contract. Cannot see inside a
1019
- // `use:` template body (expansion is the platform's job); `--remote` covers that.
1020
- const args = loadPrimitiveArgSpecs(packDir);
1021
- if (args.specs) {
1022
- const findings = withLines(yamlDocs().flatMap(([p, doc]) => findArgViolations(doc, p, args.specs)));
1023
- if (findings.length) {
1024
- console.error(`✗ ${findings.length} primitive-argument error${findings.length === 1 ? '' : 's'}:`);
1025
- for (const f of findings)
1026
- console.error(` ✗ ${describeArgFinding(f)}`);
1027
- die('fix these before deploying — an undeclared argument is dropped with no error at runtime');
1028
- }
1029
- console.log('✓ primitive arguments match their declared inputs');
1030
- }
1031
- else {
1032
- noteSkip('primitive arguments', args.lookup);
1033
- }
1034
- // Expression builtinsthe function set is CLOSED and generated from the
1035
- // runtime, so an invented `$fn(` is checkable here and nowhere else offline.
1036
- const builtins = loadBuiltinNames(packDir);
1037
- if (builtins.names) {
1038
- const findings = withLines(yamlDocs().flatMap(([p, doc]) => findBuiltinViolations(doc, p, builtins.names)));
1039
- if (findings.length) {
1040
- console.error(`✗ ${findings.length} unknown expression function${findings.length === 1 ? '' : 's'}:`);
1041
- for (const f of findings)
1042
- console.error(` ✗ ${describeBuiltinFinding(f)}`);
1043
- die('fix these before deploying — the evaluator cannot resolve them, and it fails mid-conversation');
1044
- }
1045
- console.log('✓ every $function() in an expression exists');
1046
- }
1047
- else {
1048
- noteSkip('expression functions', builtins.lookup);
1049
- }
1050
- // `use:` templates. A pack's OWN templates shadow the platform's, so they are
1051
- // named here and skipped — this check has no schema for them.
1052
- const templates = loadTemplateSpecs(packDir);
1053
- if (templates.specs) {
1054
- // A pack template is `templates/<name>.template.yaml` the `.template`
1055
- // segment is part of the convention the expander scans for, NOT part of the
1056
- // name a `use:` writes. Capturing it would leave every pack that shadows a
1057
- // platform template (kaiian shadows `field_prompt_render`) reported as using
1058
- // one that does not exist.
1059
- const packTemplates = new Set(Object.keys(files)
1060
- .map(p => /^templates\/(.+)\.template\.ya?ml$/i.exec(p.replace(/\\/g, '/'))?.[1])
1061
- .filter((n) => !!n));
1062
- const findings = yamlDocs().flatMap(([p, doc]) => findTemplateViolations(doc, p, templates.specs, packTemplates));
1063
- if (findings.length) {
1064
- console.error(`✗ ${findings.length} template error${findings.length === 1 ? '' : 's'}:`);
1065
- for (const f of findings)
1066
- console.error(` ✗ ${describeTemplateFinding(f)}`);
1067
- die('fix these before deploying — a template param that does not exist arrives as undefined, and renders as a blank');
1068
- }
1069
- console.log('✓ `use:` templates and their params exist');
1070
- }
1071
- else {
1072
- noteSkip('`use:` templates', templates.lookup);
1073
- }
1074
- // Reserved XRM entity keys — a boot error, which means the pack deploys clean
1075
- // and then fails to load on the first inbound message.
1076
- const system = loadSystemEntities(packDir);
1077
- if (system.entities) {
1078
- const findings = yamlDocs()
1079
- .filter(([p]) => /(^|[/\\])xrm\.ya?ml$/i.test(p))
1080
- .flatMap(([p, doc]) => findEntityViolations(doc, p, system.entities, system.rules));
1081
- if (findings.length) {
1082
- console.error(`✗ ${findings.length} reserved-entity error${findings.length === 1 ? '' : 's'}:`);
1083
- for (const f of findings)
1084
- console.error(` ✗ ${describeEntityFinding(f)}`);
1085
- die('fix these before deploying these fail at BOOT, after a deploy that reported success');
1086
- }
1087
- // Name the narrower promise when the catalog-level rules are absent (a KB
1088
- // pulled before they were published) — a ✓ that reads wider than what ran is
1089
- // the failure this file's skip contract exists to prevent.
1090
- console.log(system.rules
1091
- ? '✓ no entity collides with a reserved platform key, and no extension overrides a platform-owned one'
1092
- : '✓ no entity collides with a reserved platform key (re-pull for the `contact`/extension-override rules)');
1093
- }
1094
- else {
1095
- noteSkip('reserved entity keys', system.lookup);
1096
- }
1097
- // The declaration files themselves, against the published JSON Schemas.
1098
- // Deliberately narrow (see declaration-check.ts)it walks away from anything
1099
- // it cannot read rather than guessing.
1100
- const decls = loadDeclarationSpecs(packDir);
1101
- if (decls.specs) {
1102
- const findings = yamlDocs().flatMap(([p, doc]) => {
1103
- const base = p.replace(/\\/g, '/').split('/').pop() ?? p;
1104
- const spec = decls.specs.get(base);
1105
- // Only a file at the PACK ROOT is a declaration — `flows/tools/xrm.yaml`
1106
- // would be a flow that happens to share a name.
1107
- if (!spec || p.replace(/\\/g, '/').includes('/'))
1108
- return [];
1109
- return findDeclarationViolations(doc, spec).map(f => ({ ...f, file: p }));
1110
- });
1111
- if (findings.length) {
1112
- console.error(`✗ ${findings.length} declaration error${findings.length === 1 ? '' : 's'}:`);
1113
- for (const f of findings)
1114
- console.error(` ✗ ${describeDeclarationFinding(f)}`);
1115
- die('fix these before deploying a declaration file is parsed strictly, and an unknown key is rejected');
1116
- }
1117
- // Deliberately narrow wording. Most of `xrm.yaml`'s field shapes are a Zod
1118
- // union, which renders as `anyOf` and which this check walks away from by
1119
- // design — so "matches its schema" would be a promise it does not keep, and
1120
- // an over-claimed is how an author stops reading `--remote` output.
1121
- console.log('✓ declaration files carry no unknown or missing keys (unions are left to --remote)');
1122
- }
1123
- else {
1124
- noteSkip('declaration schemas', decls.lookup);
1125
- }
1126
- // One per distinct reason, naming every check it cost.
1127
- for (const { lookup, labels } of skipReasons.values()) {
1128
- const what = labels.length === 1 ? labels[0] : `${labels.length} checks (${labels.join(', ')})`;
1129
- console.log(`⚠ ${describeKbLookup(lookup, what)}`);
1130
- }
990
+ const checks = [
991
+ {
992
+ label: 'render-intent fields',
993
+ run: () => {
994
+ const render = loadAllowedRenderKeys(packDir);
995
+ if (!render.keys)
996
+ return { kind: 'not-run', lookup: render.lookup };
997
+ const findings = withLines(yamlDocs().flatMap(([p, doc]) => findRenderKeyViolations(doc, p, render.keys, render.nested)));
998
+ return findings.length
999
+ ? {
1000
+ kind: 'findings', noun: 'render-intent field error',
1001
+ lines: findings.map(describeRenderFinding),
1002
+ hint: 'fix these before deploying — the platform rejects them at load, and before that they rendered as nothing',
1003
+ }
1004
+ : { kind: 'passed', line: 'render intents use only fields the platform renders' };
1005
+ },
1006
+ },
1007
+ {
1008
+ // Primitive `args:` keys, same source and same contract. Cannot see inside a
1009
+ // `use:` template body (expansion is the platform's job); `--remote` covers that.
1010
+ label: 'primitive arguments',
1011
+ run: () => {
1012
+ const args = loadPrimitiveArgSpecs(packDir);
1013
+ if (!args.specs)
1014
+ return { kind: 'not-run', lookup: args.lookup };
1015
+ const findings = withLines(yamlDocs().flatMap(([p, doc]) => findArgViolations(doc, p, args.specs)));
1016
+ return findings.length
1017
+ ? {
1018
+ kind: 'findings', noun: 'primitive-argument error',
1019
+ lines: findings.map(describeArgFinding),
1020
+ hint: 'fix these before deploying an undeclared argument is dropped with no error at runtime',
1021
+ }
1022
+ : { kind: 'passed', line: 'primitive arguments match their declared inputs' };
1023
+ },
1024
+ },
1025
+ {
1026
+ // Expression builtins the function set is CLOSED and generated from the
1027
+ // runtime, so an invented `$fn(` is checkable here and nowhere else offline.
1028
+ label: 'expression functions',
1029
+ run: () => {
1030
+ const builtins = loadBuiltinNames(packDir);
1031
+ if (!builtins.names)
1032
+ return { kind: 'not-run', lookup: builtins.lookup };
1033
+ const findings = withLines(yamlDocs().flatMap(([p, doc]) => findBuiltinViolations(doc, p, builtins.names)));
1034
+ return findings.length
1035
+ ? {
1036
+ kind: 'findings', noun: 'unknown expression function',
1037
+ lines: findings.map(describeBuiltinFinding),
1038
+ hint: 'fix these before deploying — the evaluator cannot resolve them, and it fails mid-conversation',
1039
+ }
1040
+ : { kind: 'passed', line: 'every $function() in an expression exists' };
1041
+ },
1042
+ },
1043
+ {
1044
+ // `use:` templates. A pack's OWN templates shadow the platform's, so they are
1045
+ // named here and skipped — this check has no schema for them.
1046
+ label: '`use:` templates',
1047
+ run: () => {
1048
+ const templates = loadTemplateSpecs(packDir);
1049
+ if (!templates.specs)
1050
+ return { kind: 'not-run', lookup: templates.lookup };
1051
+ // A pack template is `templates/<name>.template.yaml` — the `.template`
1052
+ // segment is part of the convention the expander scans for, NOT part of the
1053
+ // name a `use:` writes. Capturing it would leave every pack that shadows a
1054
+ // platform template (kaiian shadows `field_prompt_render`) reported as using
1055
+ // one that does not exist.
1056
+ const packTemplates = new Set(Object.keys(files)
1057
+ .map(p => /^templates\/(.+)\.template\.ya?ml$/i.exec(p.replace(/\\/g, '/'))?.[1])
1058
+ .filter((n) => !!n));
1059
+ const findings = yamlDocs().flatMap(([p, doc]) => findTemplateViolations(doc, p, templates.specs, packTemplates));
1060
+ return findings.length
1061
+ ? {
1062
+ kind: 'findings', noun: 'template error',
1063
+ lines: findings.map(describeTemplateFinding),
1064
+ hint: 'fix these before deploying — a template param that does not exist arrives as undefined, and renders as a blank',
1065
+ }
1066
+ : { kind: 'passed', line: '`use:` templates and their params exist' };
1067
+ },
1068
+ },
1069
+ {
1070
+ // Reserved XRM entity keys — a boot error, which means the pack deploys clean
1071
+ // and then fails to load on the first inbound message.
1072
+ label: 'reserved entity keys',
1073
+ run: () => {
1074
+ const system = loadSystemEntities(packDir);
1075
+ if (!system.entities)
1076
+ return { kind: 'not-run', lookup: system.lookup };
1077
+ const findings = yamlDocs()
1078
+ .filter(([p]) => /(^|[/\\])xrm\.ya?ml$/i.test(p))
1079
+ .flatMap(([p, doc]) => findEntityViolations(doc, p, system.entities, system.rules));
1080
+ return findings.length
1081
+ ? {
1082
+ kind: 'findings', noun: 'reserved-entity error',
1083
+ lines: findings.map(describeEntityFinding),
1084
+ hint: 'fix these before deployingthese fail at BOOT, after a deploy that reported success',
1085
+ }
1086
+ // Name the narrower promise when the catalog-level rules are absent (a KB
1087
+ // pulled before they were published) — a ✓ that reads wider than what ran is
1088
+ // the failure this file's skip contract exists to prevent, and it is why
1089
+ // `passed` carries its own line instead of the printer inventing one.
1090
+ : {
1091
+ kind: 'passed',
1092
+ line: system.rules
1093
+ ? 'no entity collides with a reserved platform key, and no extension overrides a platform-owned one'
1094
+ : 'no entity collides with a reserved platform key (re-pull for the `contact`/extension-override rules)',
1095
+ };
1096
+ },
1097
+ },
1098
+ {
1099
+ // The declaration files themselves, against the published JSON Schemas.
1100
+ // Deliberately narrow (see declaration-check.ts) — it walks away from anything
1101
+ // it cannot read rather than guessing.
1102
+ label: 'declaration schemas',
1103
+ run: () => {
1104
+ const decls = loadDeclarationSpecs(packDir);
1105
+ if (!decls.specs)
1106
+ return { kind: 'not-run', lookup: decls.lookup };
1107
+ const findings = yamlDocs().flatMap(([p, doc]) => {
1108
+ const base = p.replace(/\\/g, '/').split('/').pop() ?? p;
1109
+ const spec = decls.specs.get(base);
1110
+ // Only a file at the PACK ROOT is a declaration `flows/tools/xrm.yaml`
1111
+ // would be a flow that happens to share a name.
1112
+ if (!spec || p.replace(/\\/g, '/').includes('/'))
1113
+ return [];
1114
+ return findDeclarationViolations(doc, spec).map(f => ({ ...f, file: p }));
1115
+ });
1116
+ return findings.length
1117
+ ? {
1118
+ kind: 'findings', noun: 'declaration error',
1119
+ lines: findings.map(describeDeclarationFinding),
1120
+ hint: 'fix these before deploying — a declaration file is parsed strictly, and an unknown key is rejected',
1121
+ }
1122
+ // Deliberately narrow wording. Most of `xrm.yaml`'s field shapes are a Zod
1123
+ // union, which renders as `anyOf` and which this check walks away from by
1124
+ // design — so "matches its schema" would be a promise it does not keep, and
1125
+ // an over-claimed ✓ is how an author stops reading `--remote` output.
1126
+ : { kind: 'passed', line: 'declaration files carry no unknown or missing keys (unions are left to --remote)' };
1127
+ },
1128
+ },
1129
+ ];
1130
+ const skipped = reportChecks(checks, {
1131
+ log: (l) => console.log(l),
1132
+ err: (l) => console.error(l),
1133
+ die,
1134
+ });
1131
1135
  // `--require-kb` is for CI, where a skip nobody reads is worse than a red build.
1132
1136
  if (skipped.length && flags['require-kb'] === true) {
1133
1137
  die(`--require-kb: ${skipped.length} check${skipped.length === 1 ? '' : 's'} could not run (${skipped.join(', ')})`);
@@ -1553,25 +1557,11 @@ function printDeploySuccess(id, version, t, r, listing, problems = 0) {
1553
1557
  : `✓ Deployed ${id}@${version} and installed onto ${targetLabel(t)}`);
1554
1558
  if (r?.warning)
1555
1559
  console.log(` ⚠ ${r.warning}`);
1556
- const s = r?.summary;
1557
- if (s) {
1558
- const parts = [];
1559
- if (s.records != null)
1560
- parts.push(`${s.records} record(s) created`);
1561
- if (s.updated)
1562
- parts.push(`${s.updated} updated`);
1563
- if (s.images)
1564
- parts.push(`${s.images} image(s) generated`);
1565
- if (s.rules)
1566
- parts.push(`${s.rules} availability rule(s)`);
1567
- // A count of rows that threw. The seed keeps going past a bad row now, so a
1568
- // partial seed is a real outcome and has to be said out loud — the alternative
1569
- // reads as a complete one with fewer records than the author wrote.
1570
- if (s.failed)
1571
- parts.push(`${s.failed} row(s) FAILED`);
1572
- if (parts.length)
1573
- console.log(` Seeded: ${parts.join(', ')}`);
1574
- }
1560
+ // This read `r.summary.records` / `.rules` / `.failed` and had been DEAD: the deploy route's
1561
+ // `summary` is a run-log STRING (`"clinic v1.2.0 — {…}"`), so every field was undefined and the
1562
+ // block printed nothing. The counts live on `r.seeded`, keyed by seed kind, and `printSeedCounts`
1563
+ // already renders them — filtering zeros, which is what makes a partial seed legible.
1564
+ printSeedCounts(r?.seeded);
1575
1565
  // A redeploy rebuilds the pack's tools, and suspended flow runs live with them.
1576
1566
  // Say so: otherwise the next tap on a card rendered before the deploy comes back
1577
1567
  // stale and reads like a flow bug.
@@ -1622,7 +1612,7 @@ async function cmdSeed(flags) {
1622
1612
  if (stepErrors.length) {
1623
1613
  // A kind failed but the rest ran — the reconcile softens each step. Say which,
1624
1614
  // and exit non-zero so a scripted `seed && chat` doesn't read as clean.
1625
- console.error(`
1615
+ console.error(`
1626
1616
  ⚠ ${stepErrors.length} step${stepErrors.length === 1 ? '' : 's'} failed — data may be incomplete:`);
1627
1617
  for (const e of stepErrors)
1628
1618
  console.error(` • ${e}`);
@@ -4980,372 +4970,372 @@ async function cmdUsage(flags) {
4980
4970
  console.log('\nThis is MODEL spend. WhatsApp/Meta message billing is operator-only — not reachable by an API token.');
4981
4971
  }
4982
4972
  function help() {
4983
- console.log(`octwin ${VERSION} — Octwin external-pack developer CLI (by CEQUENS)
4984
-
4985
- octwin --version # print the CLI version (+ any upgrade notice)
4986
- octwin init <dir> [--id my-pack] [--description "..."] [--display-name "..."]
4987
- octwin validate [--dir .] [--remote] [--require-kb] # --remote runs the platform's FULL schema check + lint (all errors at once)
4988
- octwin login --url <platformUrl> --token oct_… # a deploy token from the console
4989
- octwin whoami [--url <url>] [--tenant <slug>] # verify the token works
4990
- octwin projects [--archived] [--json] # the --project slugs this token can name
4991
- octwin deploy [--dir .] [--url <url>] [--tenant <slug>] [--project <slug>] [--token <t>] [--seed]
4992
- [--request-listing | --withdraw-listing] # public marketplace — opt-in, see: octwin help deploy
4993
- octwin status [<packId>] [--dir .] [--url <url>] [--tenant <slug>] [--project <slug>] [--token <t>]
4994
- octwin pull <packId> [--dir <out>] [--version <v>] [--force] # write a DEPLOYED pack's source back to disk (the inverse of deploy)
4995
- octwin records [entity] [id] # inspect the pack's XRM data (needs a records:read token)
4996
- octwin work [recordId] [--queues] [--unrouted] [--json] # inspect the work inbox (worked records) + timelines
4997
- # --queues: per-queue open counts + an UNROUTED warning · --unrouted: only the items in no queue
4998
- octwin logs [conversationId] [--as <handle>] [--json] # list conversations / show one's event timeline
4999
- octwin chat "message" [--as <handle>] [--tap <tap-id>] [--media <file|id>] [--json] # drive a turn (+ send media) + print every render
5000
- octwin media generate "<prompt>" [--out <file.png>] [--json] # AI-generate an image → MEDIA- handle (needs media:generate scope)
5001
- octwin agents [packId::agentId] [--prompt] [--json] # effective model/memory + WHICH layer won; --prompt = the resolved system prompt
5002
- octwin orders [reference_id] [--status s] [--payment p] [--json] # the orders a conversation produced + money + payment state
5003
- octwin analytics [entity] [--funnel|--overview|--milestones|--trends|--cost] [--stage <id>] # stage conversion for any pipelined entity
5004
- octwin catalog [--readiness] [--json] # commerce products + stock + the WhatsApp catalog binding
5005
- octwin scheduling [--slots <resourceRecordId>] [--from YYYY-MM-DD] [--days n] # engine state / computed slots
5006
- octwin automation [campaigns] [--json] # the jobs your declarations produced + health, last result each
5007
- octwin integrations [--json] # declared connections BESIDE what is configured (the silent-never-fires check)
5008
- octwin integrations deliveries [<id>] | events # the outbound delivery log / inbound events
5009
- octwin journeys [journeyId] [--funnel|--overview|--goals|--trends|--cost|--definition] [--stage <id>]
5010
- octwin performance [--detail] [--json] # the project's business indicators (value/conversion/duration)
5011
- octwin usage [--json] # model calls, tokens and cost (project if pinned, else workspace)
5012
- octwin platform-kb [pull] [--if-stale|--check] [--dir .] [--url <url>] # no token needed
5013
- octwin test [--dir .] # = validate --remote (the full platform check)
5014
- octwin feedback [--dir .] # submit this pack's FEEDBACK.md to the platform team
5015
- octwin memos [--all] [--json] # read the platform's replies + notices (a reply to your feedback lands here)
5016
-
5017
- Writes — exercise the state your pack creates (each needs the matching :write scope):
5018
- octwin records create <entity> --set field=value … # also: patch <id> --entity <e>, stage <id> --to <s>, note <id> "…"
5019
- octwin records tasks | task complete <taskId> [--outcome done|cancelled]
5020
- octwin work assign <id> --to user:<uuid>|none | note <id> "…" | stage <id> --to <stage>
5021
- octwin work decide <id> --action <a> [--param k=v] [--dry-run] # --dry-run previews, commits nothing
5022
- octwin orders transition <ref> --to <status> | refund <ref> --force
5023
- octwin catalog availability <sku> --to "in stock" | stock <sku> [--set-on-hand n]
5024
- octwin scheduling rules --resource <id> | rule add|rm | exception add|rm
5025
- octwin agents set <packId::agentId> [--model m] [--enable-tool t] [--disable-tool t]
5026
- octwin automation run <jobId> | pause <jobId> | resume <jobId> | send <campaignId>
5027
- octwin integrations test <key> # a LIVE call to the connection's health: operation
5028
- octwin integrations retry|cancel|send-now <deliveryId>
5029
- (octwin integrations preflight <key> needs only integrations:read — it makes no call)
5030
-
5031
- Multi-turn: the platform keeps ONE open conversation per --as handle — consecutive
5032
- \`octwin chat --as <h>\` calls continue the same conversation; press a rendered
5033
- button/row with \`--tap "<tap-id>"\` (chat prints every tap id).
5034
- Get a deploy token: console → your workspace → Settings → API tokens → Generate (tick records:read to inspect data).
5035
- octwin platform-kb pull → writes the platform capability reference into .octwin/platform-kb/ (for the octwin-pack skill).
5036
- Config (deploy): flags > env (PACK_PLATFORM_URL/PACK_TENANT/PACK_PROJECT/PACK_TOKEN) > saved login (\`octwin login\` sets the default target).
4973
+ console.log(`octwin ${VERSION} — Octwin external-pack developer CLI (by CEQUENS)
4974
+
4975
+ octwin --version # print the CLI version (+ any upgrade notice)
4976
+ octwin init <dir> [--id my-pack] [--description "..."] [--display-name "..."]
4977
+ octwin validate [--dir .] [--remote] [--require-kb] # --remote runs the platform's FULL schema check + lint (all errors at once)
4978
+ octwin login --url <platformUrl> --token oct_… # a deploy token from the console
4979
+ octwin whoami [--url <url>] [--tenant <slug>] # verify the token works
4980
+ octwin projects [--archived] [--json] # the --project slugs this token can name
4981
+ octwin deploy [--dir .] [--url <url>] [--tenant <slug>] [--project <slug>] [--token <t>] [--seed]
4982
+ [--request-listing | --withdraw-listing] # public marketplace — opt-in, see: octwin help deploy
4983
+ octwin status [<packId>] [--dir .] [--url <url>] [--tenant <slug>] [--project <slug>] [--token <t>]
4984
+ octwin pull <packId> [--dir <out>] [--version <v>] [--force] # write a DEPLOYED pack's source back to disk (the inverse of deploy)
4985
+ octwin records [entity] [id] # inspect the pack's XRM data (needs a records:read token)
4986
+ octwin work [recordId] [--queues] [--unrouted] [--json] # inspect the work inbox (worked records) + timelines
4987
+ # --queues: per-queue open counts + an UNROUTED warning · --unrouted: only the items in no queue
4988
+ octwin logs [conversationId] [--as <handle>] [--json] # list conversations / show one's event timeline
4989
+ octwin chat "message" [--as <handle>] [--tap <tap-id>] [--media <file|id>] [--json] # drive a turn (+ send media) + print every render
4990
+ octwin media generate "<prompt>" [--out <file.png>] [--json] # AI-generate an image → MEDIA- handle (needs media:generate scope)
4991
+ octwin agents [packId::agentId] [--prompt] [--json] # effective model/memory + WHICH layer won; --prompt = the resolved system prompt
4992
+ octwin orders [reference_id] [--status s] [--payment p] [--json] # the orders a conversation produced + money + payment state
4993
+ octwin analytics [entity] [--funnel|--overview|--milestones|--trends|--cost] [--stage <id>] # stage conversion for any pipelined entity
4994
+ octwin catalog [--readiness] [--json] # commerce products + stock + the WhatsApp catalog binding
4995
+ octwin scheduling [--slots <resourceRecordId>] [--from YYYY-MM-DD] [--days n] # engine state / computed slots
4996
+ octwin automation [campaigns] [--json] # the jobs your declarations produced + health, last result each
4997
+ octwin integrations [--json] # declared connections BESIDE what is configured (the silent-never-fires check)
4998
+ octwin integrations deliveries [<id>] | events # the outbound delivery log / inbound events
4999
+ octwin journeys [journeyId] [--funnel|--overview|--goals|--trends|--cost|--definition] [--stage <id>]
5000
+ octwin performance [--detail] [--json] # the project's business indicators (value/conversion/duration)
5001
+ octwin usage [--json] # model calls, tokens and cost (project if pinned, else workspace)
5002
+ octwin platform-kb [pull] [--if-stale|--check] [--dir .] [--url <url>] # no token needed
5003
+ octwin test [--dir .] # = validate --remote (the full platform check)
5004
+ octwin feedback [--dir .] # submit this pack's FEEDBACK.md to the platform team
5005
+ octwin memos [--all] [--json] # read the platform's replies + notices (a reply to your feedback lands here)
5006
+
5007
+ Writes — exercise the state your pack creates (each needs the matching :write scope):
5008
+ octwin records create <entity> --set field=value … # also: patch <id> --entity <e>, stage <id> --to <s>, note <id> "…"
5009
+ octwin records tasks | task complete <taskId> [--outcome done|cancelled]
5010
+ octwin work assign <id> --to user:<uuid>|none | note <id> "…" | stage <id> --to <stage>
5011
+ octwin work decide <id> --action <a> [--param k=v] [--dry-run] # --dry-run previews, commits nothing
5012
+ octwin orders transition <ref> --to <status> | refund <ref> --force
5013
+ octwin catalog availability <sku> --to "in stock" | stock <sku> [--set-on-hand n]
5014
+ octwin scheduling rules --resource <id> | rule add|rm | exception add|rm
5015
+ octwin agents set <packId::agentId> [--model m] [--enable-tool t] [--disable-tool t]
5016
+ octwin automation run <jobId> | pause <jobId> | resume <jobId> | send <campaignId>
5017
+ octwin integrations test <key> # a LIVE call to the connection's health: operation
5018
+ octwin integrations retry|cancel|send-now <deliveryId>
5019
+ (octwin integrations preflight <key> needs only integrations:read — it makes no call)
5020
+
5021
+ Multi-turn: the platform keeps ONE open conversation per --as handle — consecutive
5022
+ \`octwin chat --as <h>\` calls continue the same conversation; press a rendered
5023
+ button/row with \`--tap "<tap-id>"\` (chat prints every tap id).
5024
+ Get a deploy token: console → your workspace → Settings → API tokens → Generate (tick records:read to inspect data).
5025
+ octwin platform-kb pull → writes the platform capability reference into .octwin/platform-kb/ (for the octwin-pack skill).
5026
+ Config (deploy): flags > env (PACK_PLATFORM_URL/PACK_TENANT/PACK_PROJECT/PACK_TOKEN) > saved login (\`octwin login\` sets the default target).
5037
5027
  Per-command usage: octwin <command> --help`);
5038
5028
  }
5039
5029
  /** Per-subcommand usage — printed for `octwin <cmd> --help|-h` BEFORE any
5040
5030
  * network/auth work (a --help that 401s is worse than no help at all). */
5041
5031
  const COMMAND_HELP = {
5042
- init: `octwin init <dir> [--id my-pack] [--description "..."] [--display-name "..."]
5032
+ init: `octwin init <dir> [--id my-pack] [--description "..."] [--display-name "..."]
5043
5033
  Scaffold a pure-YAML starter pack into <dir>.`,
5044
- validate: `octwin validate [--dir .] [--remote] [--require-kb] [--strict-primitives]
5045
- Offline structural check, plus two checks driven by the pulled capability
5046
- reference (render-intent fields, primitive arguments). Those two SKIP when the
5047
- reference is missing — the run says so, and --require-kb turns the skip into a
5048
- failure for CI. --remote additionally runs the platform's FULL manifest +
5049
- flow-DSL validation and its flow lint (all errors at once) — same check as deploy.
5050
- --strict-primitives (with --remote) additionally type-checks LITERAL args:
5051
- values against each primitive's declared input schema; expression strings
5034
+ validate: `octwin validate [--dir .] [--remote] [--require-kb] [--strict-primitives]
5035
+ Offline structural check, plus two checks driven by the pulled capability
5036
+ reference (render-intent fields, primitive arguments). Those two SKIP when the
5037
+ reference is missing — the run says so, and --require-kb turns the skip into a
5038
+ failure for CI. --remote additionally runs the platform's FULL manifest +
5039
+ flow-DSL validation and its flow lint (all errors at once) — same check as deploy.
5040
+ --strict-primitives (with --remote) additionally type-checks LITERAL args:
5041
+ values against each primitive's declared input schema; expression strings
5052
5042
  ('$found.id', '{$t(…)}') are always exempt.`,
5053
- login: `octwin login --url <platformUrl> --token oct_…
5054
- Save a deploy token (console → Settings → API tokens) for that platform url,
5055
- make that url the DEFAULT deploy target for every later command, and echo the
5043
+ login: `octwin login --url <platformUrl> --token oct_…
5044
+ Save a deploy token (console → Settings → API tokens) for that platform url,
5045
+ make that url the DEFAULT deploy target for every later command, and echo the
5056
5046
  workspace + project pin + scopes the token reaches.`,
5057
- whoami: `octwin whoami [--url <url>] [--tenant <slug>]
5047
+ whoami: `octwin whoami [--url <url>] [--tenant <slug>]
5058
5048
  Verify the resolved token authenticates against the tenant.`,
5059
- projects: `octwin projects [--archived] [--json]
5060
- List the workspace's projects — the slugs every --project flag takes, with the
5061
- plan's project cap. --archived includes archived ones. A pack:deploy token
5062
- reaches this (it names a project in every other command).
5063
-
5064
- octwin projects create "<name>" [--slug <slug>] [--pack <packId>]
5065
- Create a project. The URL slug is derived from the name unless --slug pins one.
5066
- --pack installs an ALREADY-published pack; the usual next step is instead
5067
- \`octwin deploy --project <slug>\`, which publishes this working tree and installs it.
5068
-
5069
- octwin projects rm <slug> [--yes]
5070
- HARD delete — the project and everything cascading from it (conversations,
5071
- contacts, records, installs). No undo, and not the same as archiving.
5072
- WITHOUT --yes it only previews what would be destroyed, so the dry run is the
5073
- default. Together these make a disposable end-to-end environment:
5074
- octwin projects create "Scratch" && octwin deploy --project scratch --seed
5075
- octwin chat "hi" --project scratch
5076
- octwin projects rm scratch --yes
5049
+ projects: `octwin projects [--archived] [--json]
5050
+ List the workspace's projects — the slugs every --project flag takes, with the
5051
+ plan's project cap. --archived includes archived ones. A pack:deploy token
5052
+ reaches this (it names a project in every other command).
5053
+
5054
+ octwin projects create "<name>" [--slug <slug>] [--pack <packId>]
5055
+ Create a project. The URL slug is derived from the name unless --slug pins one.
5056
+ --pack installs an ALREADY-published pack; the usual next step is instead
5057
+ \`octwin deploy --project <slug>\`, which publishes this working tree and installs it.
5058
+
5059
+ octwin projects rm <slug> [--yes]
5060
+ HARD delete — the project and everything cascading from it (conversations,
5061
+ contacts, records, installs). No undo, and not the same as archiving.
5062
+ WITHOUT --yes it only previews what would be destroyed, so the dry run is the
5063
+ default. Together these make a disposable end-to-end environment:
5064
+ octwin projects create "Scratch" && octwin deploy --project scratch --seed
5065
+ octwin chat "hi" --project scratch
5066
+ octwin projects rm scratch --yes
5077
5067
  Both verbs need the \`projects:write\` scope — a pack:deploy token does NOT confer it.`,
5078
- deploy: `octwin deploy [--dir .] [--url <url>] [--tenant <slug>] [--project <slug>] [--token <t>] [--seed]
5079
- [--request-listing | --withdraw-listing]
5080
- Upload the pack bundle, validate server-side, install onto the project.
5081
- --seed additionally applies the pack's demo seed (streams progress).
5082
-
5083
- A plain deploy says NOTHING about the public marketplace — it is a test loop, so it
5084
- neither asks for a listing nor gives one up. The marketplace flags are opt-in:
5085
-
5086
- --request-listing ask an operator to review this pack for the public marketplace
5087
- (the pre-signup storefront at /packs). Requires 'public: true'
5088
- under 'listing:' in manifest.yaml — the manifest states that the
5089
- pack is a product, the flag is you choosing to ask.
5090
- --withdraw-listing retract the request, including an approved listing.
5091
-
5092
- An approval covers the CONTENT it was made against, so a later deploy that changes the
5068
+ deploy: `octwin deploy [--dir .] [--url <url>] [--tenant <slug>] [--project <slug>] [--token <t>] [--seed]
5069
+ [--request-listing | --withdraw-listing]
5070
+ Upload the pack bundle, validate server-side, install onto the project.
5071
+ --seed additionally applies the pack's demo seed (streams progress).
5072
+
5073
+ A plain deploy says NOTHING about the public marketplace — it is a test loop, so it
5074
+ neither asks for a listing nor gives one up. The marketplace flags are opt-in:
5075
+
5076
+ --request-listing ask an operator to review this pack for the public marketplace
5077
+ (the pre-signup storefront at /packs). Requires 'public: true'
5078
+ under 'listing:' in manifest.yaml — the manifest states that the
5079
+ pack is a product, the flag is you choosing to ask.
5080
+ --withdraw-listing retract the request, including an approved listing.
5081
+
5082
+ An approval covers the CONTENT it was made against, so a later deploy that changes the
5093
5083
  pack returns it to the review queue on its own — no flag needed, and the CLI says so.`,
5094
- seed: `octwin seed [--pack <packId>]
5095
- Apply the pack's demo/reference data to the project it is installed on, without
5096
- redeploying: xrm \`demo:\` records + scheduling availability, the commerce catalog,
5097
- and the demo operator topology. Reports what each kind produced.
5098
- Idempotent and safe to re-run — records upsert, and existing media is REUSED rather
5099
- than regenerated, so a second pass costs nothing. --pack is only needed when a
5084
+ seed: `octwin seed [--pack <packId>]
5085
+ Apply the pack's demo/reference data to the project it is installed on, without
5086
+ redeploying: xrm \`demo:\` records + scheduling availability, the commerce catalog,
5087
+ and the demo operator topology. Reports what each kind produced.
5088
+ Idempotent and safe to re-run — records upsert, and existing media is REUSED rather
5089
+ than regenerated, so a second pass costs nothing. --pack is only needed when a
5100
5090
  project somehow runs more than one.`,
5101
- status: `octwin status [<packId>] [--dir .] [--url <url>] [--tenant <slug>] [--project <slug>]
5102
- Show installed vs live version + the flow list for this pack.
5103
- The pack id is read from manifest.yaml and QUALIFIED with your workspace slug
5104
- (a manifest declares a bare name; the owner is attached when you publish). Pass
5105
- <packId> explicitly to skip that lookup — \`octwin agents\` and \`octwin projects\`
5091
+ status: `octwin status [<packId>] [--dir .] [--url <url>] [--tenant <slug>] [--project <slug>]
5092
+ Show installed vs live version + the flow list for this pack.
5093
+ The pack id is read from manifest.yaml and QUALIFIED with your workspace slug
5094
+ (a manifest declares a bare name; the owner is attached when you publish). Pass
5095
+ <packId> explicitly to skip that lookup — \`octwin agents\` and \`octwin projects\`
5106
5096
  both print the qualified form.`,
5107
- records: `octwin records [entity] [id] [--limit 50] [--offset n]
5108
- Inspect the pack's XRM data. No args = list entities. Worked records (cases,
5109
- tickets, anything routed to a queue) read best through \`octwin work\`.
5110
-
5111
- WRITES (need \`records:write\`; every one is re-checked by RBAC on the record):
5112
- octwin records create <entity> --set field=value [--set …] [--stage s] [--contact <id>]
5113
- octwin records patch <recordId> --entity <entity> --set field=value
5114
- octwin records stage <recordId> --to <stage> [--note "..."]
5115
- octwin records note <recordId> "the note text"
5116
- octwin records tasks # open follow-up tasks (\`tasks\` plan feature)
5117
- octwin records task complete <taskId> [--outcome done|cancelled] [--note "..."]
5118
-
5119
- --set coerces JSON scalars: \`--set rating=4.5\` sends a number, \`--set x=null\`
5120
- sends null. Use --fields-json '{"a":{"b":1}}' for anything nested.
5121
- \`patch\` needs --entity even though it has an id: the route resolves the field
5122
- validator from it. A leading \`create/patch/stage/note/tasks/task\` is read as a
5097
+ records: `octwin records [entity] [id] [--limit 50] [--offset n]
5098
+ Inspect the pack's XRM data. No args = list entities. Worked records (cases,
5099
+ tickets, anything routed to a queue) read best through \`octwin work\`.
5100
+
5101
+ WRITES (need \`records:write\`; every one is re-checked by RBAC on the record):
5102
+ octwin records create <entity> --set field=value [--set …] [--stage s] [--contact <id>]
5103
+ octwin records patch <recordId> --entity <entity> --set field=value
5104
+ octwin records stage <recordId> --to <stage> [--note "..."]
5105
+ octwin records note <recordId> "the note text"
5106
+ octwin records tasks # open follow-up tasks (\`tasks\` plan feature)
5107
+ octwin records task complete <taskId> [--outcome done|cancelled] [--note "..."]
5108
+
5109
+ --set coerces JSON scalars: \`--set rating=4.5\` sends a number, \`--set x=null\`
5110
+ sends null. Use --fields-json '{"a":{"b":1}}' for anything nested.
5111
+ \`patch\` needs --entity even though it has an id: the route resolves the field
5112
+ validator from it. A leading \`create/patch/stage/note/tasks/task\` is read as a
5123
5113
  VERB — to list an entity actually named one of those, use \`--entity <name>\`.`,
5124
- work: `octwin work [recordId] [--queues] [--unrouted] [--limit 50] [--offset n] [--json]
5125
- Inspect the work inbox — every entity the pack declares worked (cases, orders
5126
- needing review, applications, …): the inbox, one item + its timeline
5127
- (+ applicable actions), or --queues for queue keys + open counts.
5128
-
5129
- WRITES (need \`work:write\`; \`stage\` needs \`records:write\`):
5130
- octwin work assign <recordId> --to user:<uuid>|team:<uuid>|none
5131
- octwin work note <recordId> "the note text"
5132
- octwin work stage <recordId> --to <stage> [--note "..."]
5133
- octwin work decide <recordId> --action <action> [--param k=v] [--note "..."] [--dry-run]
5134
-
5135
- \`decide\` applies one of the entity's declared operator actions — \`octwin work <id>\`
5136
- lists them with their params. --dry-run previews the customer-facing copy and the
5137
- resulting stage WITHOUT committing (that route needs only \`work:read\`).
5114
+ work: `octwin work [recordId] [--queues] [--unrouted] [--limit 50] [--offset n] [--json]
5115
+ Inspect the work inbox — every entity the pack declares worked (cases, orders
5116
+ needing review, applications, …): the inbox, one item + its timeline
5117
+ (+ applicable actions), or --queues for queue keys + open counts.
5118
+
5119
+ WRITES (need \`work:write\`; \`stage\` needs \`records:write\`):
5120
+ octwin work assign <recordId> --to user:<uuid>|team:<uuid>|none
5121
+ octwin work note <recordId> "the note text"
5122
+ octwin work stage <recordId> --to <stage> [--note "..."]
5123
+ octwin work decide <recordId> --action <action> [--param k=v] [--note "..."] [--dry-run]
5124
+
5125
+ \`decide\` applies one of the entity's declared operator actions — \`octwin work <id>\`
5126
+ lists them with their params. --dry-run previews the customer-facing copy and the
5127
+ resulting stage WITHOUT committing (that route needs only \`work:read\`).
5138
5128
  \`stage\` is the XRM records verb (one transition spelling platform-wide).`,
5139
- logs: `octwin logs [conversationId] [--as <handle>] [--json]
5140
- No id = recent conversations (handle, status, last activity; --as filters).
5141
- With id = the full event timeline including what each turn rendered.
5129
+ logs: `octwin logs [conversationId] [--as <handle>] [--json]
5130
+ No id = recent conversations (handle, status, last activity; --as filters).
5131
+ With id = the full event timeline including what each turn rendered.
5142
5132
  --json = raw events (verbatim payloads).`,
5143
- pull: `octwin pull <packId> [--dir <out>] [--version <v>] [--force]
5144
- Write a DEPLOYED pack's source back to disk — the inverse of deploy.
5145
- A pack pushed with 'octwin deploy' lives on the platform as an artifact the
5146
- runtime serves but nothing hands back, so its only source copy is the machine
5147
- that pushed it. Pull it, fix it, redeploy it.
5148
- Defaults to the version installed on the target project; --version overrides.
5149
- --dir defaults to ./<packId>; a non-empty dir needs --force.
5150
- The pulled dir redeploys where it came from — the target is your saved login.
5133
+ pull: `octwin pull <packId> [--dir <out>] [--version <v>] [--force]
5134
+ Write a DEPLOYED pack's source back to disk — the inverse of deploy.
5135
+ A pack pushed with 'octwin deploy' lives on the platform as an artifact the
5136
+ runtime serves but nothing hands back, so its only source copy is the machine
5137
+ that pushed it. Pull it, fix it, redeploy it.
5138
+ Defaults to the version installed on the target project; --version overrides.
5139
+ --dir defaults to ./<packId>; a non-empty dir needs --force.
5140
+ The pulled dir redeploys where it came from — the target is your saved login.
5151
5141
  You may pull a pack your tenant OWNS (deployed); an operator token pulls any.`,
5152
- chat: `octwin chat "message" [--as <handle>] [--tap <tap-id>] [--media <file|id>] [--json]
5153
- octwin chat --script <file> [--as <handle>] [--json]
5154
- Drive ONE turn through the dev web channel and print every render with its
5155
- tap ids. Same --as handle = same conversation (multi-turn works).
5156
- --tap presses a rendered button/list row instead of sending text.
5157
- --media uploads a local file (or a media id from 'media generate --json') as
5158
- an image/document/audio inbound — any "message" rides as its caption; feeds a
5159
- running media-collect flow (e.g. activate-app).
5160
- --json dumps the raw SSE envelopes for the turn.
5161
-
5162
- --script drives a WHOLE conversation from a file, ONE TURN PER LINE, in one
5163
- process over one connection — waiting for each turn to settle before sending
5164
- the next. Use this for any multi-step flow: chaining shell invocations races
5165
- the agent loop, because a turn ends on a quiet gap that can arrive while the
5166
- server is still working (the symptom is placeholder-filled fields or a second
5167
- workflow run). Blank lines and # comments are skipped:
5168
-
5169
- # book an appointment end to end
5170
- احجز موعد
5171
- tap:t:invoke:book-appointment:doctor_id=D1
5172
- media:./licence.jpg | here is my licence
5142
+ chat: `octwin chat "message" [--as <handle>] [--tap <tap-id>] [--media <file|id>] [--json]
5143
+ octwin chat --script <file> [--as <handle>] [--json]
5144
+ Drive ONE turn through the dev web channel and print every render with its
5145
+ tap ids. Same --as handle = same conversation (multi-turn works).
5146
+ --tap presses a rendered button/list row instead of sending text.
5147
+ --media uploads a local file (or a media id from 'media generate --json') as
5148
+ an image/document/audio inbound — any "message" rides as its caption; feeds a
5149
+ running media-collect flow (e.g. activate-app).
5150
+ --json dumps the raw SSE envelopes for the turn.
5151
+
5152
+ --script drives a WHOLE conversation from a file, ONE TURN PER LINE, in one
5153
+ process over one connection — waiting for each turn to settle before sending
5154
+ the next. Use this for any multi-step flow: chaining shell invocations races
5155
+ the agent loop, because a turn ends on a quiet gap that can arrive while the
5156
+ server is still working (the symptom is placeholder-filled fields or a second
5157
+ workflow run). Blank lines and # comments are skipped:
5158
+
5159
+ # book an appointment end to end
5160
+ احجز موعد
5161
+ tap:t:invoke:book-appointment:doctor_id=D1
5162
+ media:./licence.jpg | here is my licence
5173
5163
  tap:t:resume:book-appointment:run_id=R1;_ctl_approved=true`,
5174
- media: `octwin media generate "<prompt>" [--out <file.png>] [--json]
5175
- AI-generate an image (needs a media:generate-scoped token), store it as a
5176
- public asset, and print its MEDIA- handle + serve URL. --out downloads the
5177
- bytes (WhatsApp renders only .png/.jpg); --json emits { media_id, url, mime,
5164
+ media: `octwin media generate "<prompt>" [--out <file.png>] [--json]
5165
+ AI-generate an image (needs a media:generate-scoped token), store it as a
5166
+ public asset, and print its MEDIA- handle + serve URL. --out downloads the
5167
+ bytes (WhatsApp renders only .png/.jpg); --json emits { media_id, url, mime,
5178
5168
  bytes }. Pair with 'octwin chat --media' to drive media flows.`,
5179
- agents: `octwin agents [packId::agentId] [--prompt] [--json]
5180
- No args = the roster with each agent's EFFECTIVE model and which layer set it.
5181
- With an agent = every governed setting (model / memory.last_messages /
5182
- working_memory) plus the layer that won — an operator PLATFORM default can
5183
- override what your manifest declares, and this is where you see that.
5184
- --prompt = the exact system prompt the LLM sees for this project (pack
5185
- instructions + platform protocol + any project overlay). Needs agents:read.
5186
- The agent ref is the compound \`<packId>::<agentId>\` key or the override-row UUID.
5187
-
5188
- WRITES (need \`agents:write\`):
5189
- octwin agents set <ref> [--model <m>] [--enabled true|false] [--overlay "..."|none]
5190
- [--enable-tool <toolId>] [--disable-tool <toolId>]
5191
-
5192
- Only what you pass is changed. Tool flags read-modify-write \`config_json.tools\`
5193
- so a sibling decision isn't dropped; absent = enabled. A workspace that hides model
5169
+ agents: `octwin agents [packId::agentId] [--prompt] [--json]
5170
+ No args = the roster with each agent's EFFECTIVE model and which layer set it.
5171
+ With an agent = every governed setting (model / memory.last_messages /
5172
+ working_memory) plus the layer that won — an operator PLATFORM default can
5173
+ override what your manifest declares, and this is where you see that.
5174
+ --prompt = the exact system prompt the LLM sees for this project (pack
5175
+ instructions + platform protocol + any project overlay). Needs agents:read.
5176
+ The agent ref is the compound \`<packId>::<agentId>\` key or the override-row UUID.
5177
+
5178
+ WRITES (need \`agents:write\`):
5179
+ octwin agents set <ref> [--model <m>] [--enabled true|false] [--overlay "..."|none]
5180
+ [--enable-tool <toolId>] [--disable-tool <toolId>]
5181
+
5182
+ Only what you pass is changed. Tool flags read-modify-write \`config_json.tools\`
5183
+ so a sibling decision isn't dropped; absent = enabled. A workspace that hides model
5194
5184
  ids refuses --model with a 403 — the platform default governs there.`,
5195
- orders: `octwin orders [reference_id] [--status s] [--payment p] [--limit 50] [--json]
5196
- No args = the order list (#number, status/payment, total, contact). With a
5197
- reference_id = line items, the subtotal/tax/shipping/discount/total breakdown,
5198
- payment_ref, and the allowed status transitions. Needs orders:read + the
5199
- \`orders\` plan feature. Note: the forward payment lifecycle is webhook-owned,
5200
- so \`pending\` on a gateway-less workspace is expected, not a bug.
5201
-
5202
- WRITES (need \`orders:write\`):
5203
- octwin orders transition <reference_id> --to <status>
5204
- octwin orders refund <reference_id> [--reason "..."] [--mark-returned] --force
5205
-
5206
- Refund is irreversible and moves money, hence --force. The route answers 200 even
5207
- when the GATEWAY refuses, so the CLI reads the gateway verdict and exits non-zero
5208
- on a refusal rather than reporting a refund that never happened. Only a payment in
5185
+ orders: `octwin orders [reference_id] [--status s] [--payment p] [--limit 50] [--json]
5186
+ No args = the order list (#number, status/payment, total, contact). With a
5187
+ reference_id = line items, the subtotal/tax/shipping/discount/total breakdown,
5188
+ payment_ref, and the allowed status transitions. Needs orders:read + the
5189
+ \`orders\` plan feature. Note: the forward payment lifecycle is webhook-owned,
5190
+ so \`pending\` on a gateway-less workspace is expected, not a bug.
5191
+
5192
+ WRITES (need \`orders:write\`):
5193
+ octwin orders transition <reference_id> --to <status>
5194
+ octwin orders refund <reference_id> [--reason "..."] [--mark-returned] --force
5195
+
5196
+ Refund is irreversible and moves money, hence --force. The route answers 200 even
5197
+ when the GATEWAY refuses, so the CLI reads the gateway verdict and exits non-zero
5198
+ on a refusal rather than reporting a refund that never happened. Only a payment in
5209
5199
  \`captured\` state can be refunded; \`payment_status\` is never settable directly.`,
5210
- analytics: `octwin analytics [entity] [--funnel|--overview|--milestones|--trends|--cost] [--stage <id>] [--json]
5211
- No args = the entities that carry a \`pipeline:\` (a funnel needs stages).
5212
- With an entity = stage-by-stage conversion (default --funnel) over the last 30
5213
- days. --stage <id> lists the records CURRENTLY at a stage (a live snapshot, not
5200
+ analytics: `octwin analytics [entity] [--funnel|--overview|--milestones|--trends|--cost] [--stage <id>] [--json]
5201
+ No args = the entities that carry a \`pipeline:\` (a funnel needs stages).
5202
+ With an entity = stage-by-stage conversion (default --funnel) over the last 30
5203
+ days. --stage <id> lists the records CURRENTLY at a stage (a live snapshot, not
5214
5204
  range-filtered). Needs records:read + a \`view\` grant on \`record.<entity>\`.`,
5215
- catalog: `octwin catalog [--readiness] [--json]
5216
- The commerce \`product\` records + price, availability, stock (null = not
5217
- inventory-tracked) and the WhatsApp catalog binding. --readiness runs the Meta
5218
- Graph checklist (LIVE Graph calls; needs a bound access token). Needs
5219
- catalog:read + the \`catalog\` plan feature.
5220
-
5221
- WRITES (need \`catalog:write\`):
5222
- octwin catalog availability <retailerId> --to "in stock"|"out of stock"|…
5223
- octwin catalog stock <retailerId> [--set-on-hand <n>]
5224
-
5225
- \`stock\` with no --set-on-hand READS it; \`null\` means the SKU is not
5226
- inventory-tracked (always sellable), which is different from 0. Lowering on_hand
5227
- below the units already reserved for open carts is refused. Creating/deleting
5205
+ catalog: `octwin catalog [--readiness] [--json]
5206
+ The commerce \`product\` records + price, availability, stock (null = not
5207
+ inventory-tracked) and the WhatsApp catalog binding. --readiness runs the Meta
5208
+ Graph checklist (LIVE Graph calls; needs a bound access token). Needs
5209
+ catalog:read + the \`catalog\` plan feature.
5210
+
5211
+ WRITES (need \`catalog:write\`):
5212
+ octwin catalog availability <retailerId> --to "in stock"|"out of stock"|…
5213
+ octwin catalog stock <retailerId> [--set-on-hand <n>]
5214
+
5215
+ \`stock\` with no --set-on-hand READS it; \`null\` means the SKU is not
5216
+ inventory-tracked (always sellable), which is different from 0. Lowering on_hand
5217
+ below the units already reserved for open carts is refused. Creating/deleting
5228
5218
  products and the Meta catalog binding/sync stay in the console.`,
5229
- scheduling: `octwin scheduling [--slots <resourceRecordId>] [--from YYYY-MM-DD] [--days n] [--json]
5230
- No args = the engine state (bookable resource types, upcoming slots, booked
5231
- seats). --slots <recordId> computes the slots for one bookable resource
5232
- (occupancy included; --days is clamped to 1-31 server-side) — the way to verify
5233
- the availability rules a \`deploy --seed\` created. Needs scheduling:read.
5234
-
5235
- RULES (list needs scheduling:read; add/rm need scheduling:write):
5236
- octwin scheduling rules --resource <resourceRecordId>
5237
- octwin scheduling rule add --resource <id> --dow 1 --start 09:00 --end 17:00
5238
- [--slot-minutes 30] [--capacity 1]
5239
- octwin scheduling rule rm <ruleId>
5240
- octwin scheduling exception add --resource <id> --date YYYY-MM-DD --kind closed|extra
5241
- [--start 09:00 --end 13:00]
5242
- octwin scheduling exception rm <exceptionId>
5243
-
5244
- --dow is 0-6, 0 = Sunday. \`rules\` is how you find an id to remove, and
5219
+ scheduling: `octwin scheduling [--slots <resourceRecordId>] [--from YYYY-MM-DD] [--days n] [--json]
5220
+ No args = the engine state (bookable resource types, upcoming slots, booked
5221
+ seats). --slots <recordId> computes the slots for one bookable resource
5222
+ (occupancy included; --days is clamped to 1-31 server-side) — the way to verify
5223
+ the availability rules a \`deploy --seed\` created. Needs scheduling:read.
5224
+
5225
+ RULES (list needs scheduling:read; add/rm need scheduling:write):
5226
+ octwin scheduling rules --resource <resourceRecordId>
5227
+ octwin scheduling rule add --resource <id> --dow 1 --start 09:00 --end 17:00
5228
+ [--slot-minutes 30] [--capacity 1]
5229
+ octwin scheduling rule rm <ruleId>
5230
+ octwin scheduling exception add --resource <id> --date YYYY-MM-DD --kind closed|extra
5231
+ [--start 09:00 --end 13:00]
5232
+ octwin scheduling exception rm <exceptionId>
5233
+
5234
+ --dow is 0-6, 0 = Sunday. \`rules\` is how you find an id to remove, and
5245
5235
  \`--slots\` is how you check what a rule actually produces.`,
5246
- automation: `octwin automation [campaigns] [--limit n] [--offset n] [--json]
5247
- No args = every job the pack's automation declaration produced, with its status,
5248
- interval and LAST RESULT (matched / acted / errors), under a health line whose
5249
- counts come from SQL rather than from filtering the page — the job list is capped
5250
- server-side, so a client-side count would depend on the cap. Needs automation:read.
5251
-
5252
- Jobs are DERIVED from declarations. There is no \`create\`: no automation block in
5253
- the pack means no jobs, and \`octwin deploy\` is what installs them.
5254
-
5255
- WRITES (automation:write):
5256
- octwin automation run <jobId> # run once, now — prints matched/acted/errors
5257
- octwin automation pause|resume <jobId>
5258
- octwin automation send <campaignId> # enqueue a campaign; enqueued != delivered
5259
-
5260
- <jobId> is the \`key\` the list shows (its uuid works too). The routes themselves
5261
- accept only a uuid — the CLI resolves the key for you, and names the keys that do
5262
- exist when it cannot. A 403 on a write can be an RBAC grant gap rather than a
5236
+ automation: `octwin automation [campaigns] [--limit n] [--offset n] [--json]
5237
+ No args = every job the pack's automation declaration produced, with its status,
5238
+ interval and LAST RESULT (matched / acted / errors), under a health line whose
5239
+ counts come from SQL rather than from filtering the page — the job list is capped
5240
+ server-side, so a client-side count would depend on the cap. Needs automation:read.
5241
+
5242
+ Jobs are DERIVED from declarations. There is no \`create\`: no automation block in
5243
+ the pack means no jobs, and \`octwin deploy\` is what installs them.
5244
+
5245
+ WRITES (automation:write):
5246
+ octwin automation run <jobId> # run once, now — prints matched/acted/errors
5247
+ octwin automation pause|resume <jobId>
5248
+ octwin automation send <campaignId> # enqueue a campaign; enqueued != delivered
5249
+
5250
+ <jobId> is the \`key\` the list shows (its uuid works too). The routes themselves
5251
+ accept only a uuid — the CLI resolves the key for you, and names the keys that do
5252
+ exist when it cannot. A 403 on a write can be an RBAC grant gap rather than a
5263
5253
  missing scope: the action is re-checked against the job.`,
5264
- integrations: `octwin integrations [--json]
5265
- What the pack DECLARES beside what is actually CONFIGURED, in one view — because a
5266
- connection that is declared and never configured is the commonest reason an
5267
- integration silently never fires, and neither list alone can show it. Flags the
5268
- gap explicitly. Needs integrations:read.
5269
-
5270
- DIAGNOSE ONE CONNECTION:
5271
- octwin integrations preflight <key> # every check, with a fix hint. Makes NO
5272
- # outbound call — needs only integrations:read
5273
- octwin integrations test <key> # a LIVE call to its health: operation
5274
- # (integrations:write). Exits 1 when it fails.
5275
-
5276
- THE DELIVERY LOG:
5277
- octwin integrations deliveries [--status s] [--operation id] [--limit n]
5278
- octwin integrations deliveries <id> # + the redacted request/response snapshots
5279
- octwin integrations retry|cancel|send-now <id> # integrations:write
5280
- octwin integrations events # INBOUND events (what arrived at your webhook)
5281
-
5282
- retry/cancel answer 409 when the delivery is in the wrong state; the message
5254
+ integrations: `octwin integrations [--json]
5255
+ What the pack DECLARES beside what is actually CONFIGURED, in one view — because a
5256
+ connection that is declared and never configured is the commonest reason an
5257
+ integration silently never fires, and neither list alone can show it. Flags the
5258
+ gap explicitly. Needs integrations:read.
5259
+
5260
+ DIAGNOSE ONE CONNECTION:
5261
+ octwin integrations preflight <key> # every check, with a fix hint. Makes NO
5262
+ # outbound call — needs only integrations:read
5263
+ octwin integrations test <key> # a LIVE call to its health: operation
5264
+ # (integrations:write). Exits 1 when it fails.
5265
+
5266
+ THE DELIVERY LOG:
5267
+ octwin integrations deliveries [--status s] [--operation id] [--limit n]
5268
+ octwin integrations deliveries <id> # + the redacted request/response snapshots
5269
+ octwin integrations retry|cancel|send-now <id> # integrations:write
5270
+ octwin integrations events # INBOUND events (what arrived at your webhook)
5271
+
5272
+ retry/cancel answer 409 when the delivery is in the wrong state; the message
5283
5273
  carries the rule.`,
5284
- journeys: `octwin journeys [journeyId] [--funnel|--overview|--goals|--trends|--cost|--definition]
5285
- [--stage <stageId>] [--limit n] [--json]
5286
- No args = the journeys the pack declares. With an id, one of six views —
5287
- --funnel (default) stage-by-stage reach and drop-off · --overview entered vs
5288
- converted plus the biggest drop-off · --goals completions, contacts, value and
5289
- p50 time · --trends per-bucket activity · --cost tokens and dollars per goal ·
5290
- --definition what was DECLARED, unmeasured (the one view that works with no
5291
- traffic). Needs journeys:read.
5292
-
5293
- --stage <stageId> lists the runs sitting at a stage right now (a live snapshot,
5294
- not the funnel's cumulative reached counts).
5295
-
5296
- Same flag grammar as \`octwin analytics\` on purpose: a journey funnel and an
5297
- entity funnel are the same question about different subjects. Journeys carry RBAC
5298
- on top of the scope, so an empty answer can be a missing \`view\` grant rather
5274
+ journeys: `octwin journeys [journeyId] [--funnel|--overview|--goals|--trends|--cost|--definition]
5275
+ [--stage <stageId>] [--limit n] [--json]
5276
+ No args = the journeys the pack declares. With an id, one of six views —
5277
+ --funnel (default) stage-by-stage reach and drop-off · --overview entered vs
5278
+ converted plus the biggest drop-off · --goals completions, contacts, value and
5279
+ p50 time · --trends per-bucket activity · --cost tokens and dollars per goal ·
5280
+ --definition what was DECLARED, unmeasured (the one view that works with no
5281
+ traffic). Needs journeys:read.
5282
+
5283
+ --stage <stageId> lists the runs sitting at a stage right now (a live snapshot,
5284
+ not the funnel's cumulative reached counts).
5285
+
5286
+ Same flag grammar as \`octwin analytics\` on purpose: a journey funnel and an
5287
+ entity funnel are the same question about different subjects. Journeys carry RBAC
5288
+ on top of the scope, so an empty answer can be a missing \`view\` grant rather
5299
5289
  than missing data — the output says which causes are possible.`,
5300
- performance: `octwin performance [--detail] [--json]
5301
- The project's business indicators — value produced, conversion, duration — each
5302
- with its delta against the previous window and a \`why\` naming the declaration it
5303
- came from. --detail adds the per-indicator breakdown.
5304
-
5305
- Needs records:read, NOT a performance scope (there is none), so a read-only token
5306
- already reaches it. Indicators are DERIVED: a pack that declares no journey goal
5290
+ performance: `octwin performance [--detail] [--json]
5291
+ The project's business indicators — value produced, conversion, duration — each
5292
+ with its delta against the previous window and a \`why\` naming the declaration it
5293
+ came from. --detail adds the per-indicator breakdown.
5294
+
5295
+ Needs records:read, NOT a performance scope (there is none), so a read-only token
5296
+ already reaches it. Indicators are DERIVED: a pack that declares no journey goal
5307
5297
  value and no pipelined entity produces none, which is a different thing from zero.`,
5308
- usage: `octwin usage [--json]
5309
- Model calls, tokens and cost for the resolved scope — project when one is pinned
5310
- or passed with --project, otherwise the whole workspace. Broken down by model,
5311
- kind, agent and channel.
5312
-
5313
- Needs no particular scope: any valid token reaches it.
5314
-
5315
- This is MODEL spend only. WhatsApp/Meta message billing is operator-only and
5298
+ usage: `octwin usage [--json]
5299
+ Model calls, tokens and cost for the resolved scope — project when one is pinned
5300
+ or passed with --project, otherwise the whole workspace. Broken down by model,
5301
+ kind, agent and channel.
5302
+
5303
+ Needs no particular scope: any valid token reaches it.
5304
+
5305
+ This is MODEL spend only. WhatsApp/Meta message billing is operator-only and
5316
5306
  deliberately outside the token scope registry — no API token can read it.`,
5317
- 'platform-kb': `octwin platform-kb [pull] [--if-stale] [--check] [--dir .] [--url <url>] [--token <t>]
5318
- Pull the platform capability reference (markdown + JSON catalogs) into
5319
- .octwin/platform-kb/ for the octwin-pack authoring skill, plus three maps:
5320
- INDEX.md (the corpus) · SYMBOLS.md (every name -> its file; grep this) ·
5321
- OUTLINE.md (every heading with its line number).
5322
-
5323
- NO TOKEN NEEDED — the reference is platform stdlib and is served anonymously,
5324
- and this command never sends one. --token is accepted and ignored, so an older
5325
- script that passes it keeps working.
5326
-
5327
- --if-stale poll the platform's content_hash first and skip the download when
5328
- nothing changed. Cheap enough to run at the start of every session.
5329
- --check report only, write nothing. Exit 0 = current, 2 = stale or never
5330
- pulled, 1 = could not tell (offline / no reference served). For
5307
+ 'platform-kb': `octwin platform-kb [pull] [--if-stale] [--check] [--dir .] [--url <url>] [--token <t>]
5308
+ Pull the platform capability reference (markdown + JSON catalogs) into
5309
+ .octwin/platform-kb/ for the octwin-pack authoring skill, plus three maps:
5310
+ INDEX.md (the corpus) · SYMBOLS.md (every name -> its file; grep this) ·
5311
+ OUTLINE.md (every heading with its line number).
5312
+
5313
+ NO TOKEN NEEDED — the reference is platform stdlib and is served anonymously,
5314
+ and this command never sends one. --token is accepted and ignored, so an older
5315
+ script that passes it keeps working.
5316
+
5317
+ --if-stale poll the platform's content_hash first and skip the download when
5318
+ nothing changed. Cheap enough to run at the start of every session.
5319
+ --check report only, write nothing. Exit 0 = current, 2 = stale or never
5320
+ pulled, 1 = could not tell (offline / no reference served). For
5331
5321
  scripts and agent loops that want to branch without parsing prose.`,
5332
- test: `octwin test [--dir .]
5322
+ test: `octwin test [--dir .]
5333
5323
  Alias for \`octwin validate --remote\` — the full platform check.`,
5334
- memos: `octwin memos [--all] [--json]
5335
- Read what the platform has told you: a REPLY to a report you sent with
5336
- \`octwin feedback\`, or a NOTICE published to every author (a new capability,
5337
- a deprecation, a breaking change). Bodies are printed in full.
5338
- Reading marks them read, so the reminder stops. --all re-reads history and
5339
- acks nothing. --json to branch on \`severity\`
5324
+ memos: `octwin memos [--all] [--json]
5325
+ Read what the platform has told you: a REPLY to a report you sent with
5326
+ \`octwin feedback\`, or a NOTICE published to every author (a new capability,
5327
+ a deprecation, a breaking change). Bodies are printed in full.
5328
+ Reading marks them read, so the reminder stops. --all re-reads history and
5329
+ acks nothing. --json to branch on \`severity\`
5340
5330
  (info | action_required | breaking).`,
5341
- feedback: `octwin feedback [--dir .]
5342
- Submit this pack's FEEDBACK.md to the platform team.
5343
- The octwin-pack skill writes that file in its last step — findings grouped by
5344
- owner (A · CLI, B · Platform, C · Skill/KB). This delivers it instead of asking
5345
- you to paste it into a chat.
5346
- Attaches the pack id + version from manifest.yaml, this CLI's version, and the
5347
- content_hash of the capability reference in .octwin/platform-kb/ — triage needs
5348
- the last two to tell "the platform is wrong" from "that was already fixed" or
5331
+ feedback: `octwin feedback [--dir .]
5332
+ Submit this pack's FEEDBACK.md to the platform team.
5333
+ The octwin-pack skill writes that file in its last step — findings grouped by
5334
+ owner (A · CLI, B · Platform, C · Skill/KB). This delivers it instead of asking
5335
+ you to paste it into a chat.
5336
+ Attaches the pack id + version from manifest.yaml, this CLI's version, and the
5337
+ content_hash of the capability reference in .octwin/platform-kb/ — triage needs
5338
+ the last two to tell "the platform is wrong" from "that was already fixed" or
5349
5339
  "you were reading a stale reference". Needs the \`pack:deploy\` scope.`,
5350
5340
  };
5351
5341
  async function main() {