owenloop 0.5.9 → 0.5.10

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.
Files changed (83) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +77 -37
  3. package/bin/owenloop.mjs +16 -1
  4. package/dist/packages/work/src/agent/loop.js +7 -0
  5. package/dist/packages/work/src/bundle/pull.d.ts +21 -0
  6. package/dist/packages/work/src/bundle/pull.js +118 -0
  7. package/dist/packages/work/src/exec/instructions.d.ts +4 -1
  8. package/dist/packages/work/src/exec/instructions.js +3 -0
  9. package/dist/packages/work/src/exec/loop.d.ts +1 -1
  10. package/dist/packages/work/src/exec/loop.js +92 -14
  11. package/dist/packages/work/src/harness/claude.js +16 -0
  12. package/dist/packages/work/src/harness/codex.d.ts +8 -0
  13. package/dist/packages/work/src/harness/codex.js +27 -1
  14. package/dist/packages/work/src/harness/contract.d.ts +9 -0
  15. package/dist/packages/work/src/roles/agent-run.js +38 -10
  16. package/dist/packages/work/src/roles/exec.js +25 -8
  17. package/dist/packages/work/src/shift/loop.js +118 -4
  18. package/dist/packages/work/src/shift/runtime.d.ts +3 -0
  19. package/dist/packages/work/src/shift/runtime.js +10 -1
  20. package/dist/packages/work/src/submit-proof.d.ts +11 -8
  21. package/dist/packages/work/src/submit-proof.js +11 -8
  22. package/dist/src/capabilities.d.ts +70 -6
  23. package/dist/src/capabilities.js +49 -6
  24. package/dist/src/capability-mapping-client.d.ts +29 -0
  25. package/dist/src/capability-mapping-client.js +160 -0
  26. package/dist/src/cli.d.ts +2 -2
  27. package/dist/src/cli.js +1196 -164
  28. package/dist/src/defs.d.ts +32 -1
  29. package/dist/src/defs.js +391 -79
  30. package/dist/src/engine.d.ts +62 -19
  31. package/dist/src/engine.js +180 -70
  32. package/dist/src/hub.d.ts +77 -0
  33. package/dist/src/hub.js +162 -0
  34. package/dist/src/implements.d.ts +56 -0
  35. package/dist/src/implements.js +790 -0
  36. package/dist/src/index.d.ts +8 -6
  37. package/dist/src/index.js +4 -3
  38. package/dist/src/mcp/serve.js +254 -45
  39. package/dist/src/mcp/server.d.ts +10 -7
  40. package/dist/src/mcp/server.js +53 -8
  41. package/dist/src/model.d.ts +46 -10
  42. package/dist/src/model.js +220 -74
  43. package/dist/src/store/def-source.d.ts +19 -0
  44. package/dist/src/store/def-source.js +87 -17
  45. package/dist/src/store/gc-recovery.d.ts +46 -0
  46. package/dist/src/store/gc-recovery.js +258 -0
  47. package/dist/src/store/gc.d.ts +94 -0
  48. package/dist/src/store/gc.js +562 -0
  49. package/dist/src/store/index.d.ts +3 -1
  50. package/dist/src/store/index.js +2 -0
  51. package/dist/src/store/install.d.ts +34 -5
  52. package/dist/src/store/install.js +73 -11
  53. package/dist/src/store/pre-commit-verifier.js +42 -2
  54. package/dist/src/store/snapshot-guard.d.ts +18 -0
  55. package/dist/src/store/snapshot-guard.js +94 -0
  56. package/dist/src/store.d.ts +64 -4
  57. package/dist/src/store.js +211 -8
  58. package/dist/src/types.d.ts +61 -17
  59. package/dist/src/util.js +4 -1
  60. package/docs/authoring.md +145 -8
  61. package/docs/bundles.md +19 -0
  62. package/docs/cli.md +270 -30
  63. package/docs/crypto.md +13 -7
  64. package/docs/design.md +107 -46
  65. package/docs/evals/mcp-charter-baseline.json +428 -0
  66. package/docs/mcp-charter-eval.md +124 -0
  67. package/docs/shift-logs.md +18 -0
  68. package/docs/wire-contracts.md +28 -7
  69. package/examples/workflows/compile-dev-playbook.yaml +1 -1
  70. package/examples/workflows/ship.yaml +28 -2
  71. package/package.json +2 -1
  72. package/plugins/claude-code/plugin/.claude-plugin/plugin.json +1 -1
  73. package/plugins/claude-code/plugin/.mcp.json +1 -1
  74. package/plugins/claude-code/plugin/skills/author/SKILL.md +22 -0
  75. package/plugins/claude-code/plugin/skills/ephemeral/SKILL.md +95 -0
  76. package/plugins/claude-code/plugin/skills/graduate/SKILL.md +156 -0
  77. package/plugins/claude-code/plugin/skills/plan/SKILL.md +236 -0
  78. package/plugins/codex/plugins/owenloop/.codex-plugin/plugin.json +1 -1
  79. package/plugins/codex/plugins/owenloop/.mcp.json +1 -1
  80. package/plugins/codex/plugins/owenloop/skills/author/SKILL.md +22 -0
  81. package/plugins/codex/plugins/owenloop/skills/ephemeral/SKILL.md +95 -0
  82. package/plugins/codex/plugins/owenloop/skills/graduate/SKILL.md +156 -0
  83. package/plugins/codex/plugins/owenloop/skills/plan/SKILL.md +236 -0
package/dist/src/hub.js CHANGED
@@ -853,6 +853,168 @@ export function asCreateWorkflowOk(body, expectedName) {
853
853
  const out = { ok: true, name: b.name, version: b.version, hash: b.hash };
854
854
  if (b.unchanged === true)
855
855
  out.unchanged = true;
856
+ if (b.capabilityReport !== undefined) {
857
+ out.capabilityReport = asCapabilityPublishReport(b.capabilityReport, 'create_workflow: malformed success response');
858
+ }
859
+ return out;
860
+ }
861
+ /**
862
+ * Narrow a `capabilityReport` payload to typed entries, or throw.
863
+ *
864
+ * Called ONLY when the field is present: an ABSENT field is a hub older than
865
+ * the report and must stay `undefined` rather than fail the push (see
866
+ * `CreateWorkflowOk.capabilityReport`). A PRESENT field, on the other hand, is
867
+ * validated strictly (REL-9) — a malformed report is a malformed response, not
868
+ * something to coerce to a default.
869
+ *
870
+ * Unknown extra fields on an entry are IGNORED, not rejected: the hub may add
871
+ * facts to the report and an older CLI must keep pushing.
872
+ *
873
+ * Every message names the offending FIELD and INDEX only, never a body value.
874
+ */
875
+ function asCapabilityPublishReport(value, prefix) {
876
+ if (!Array.isArray(value)) {
877
+ throw new Error(`${prefix} — capabilityReport is not an array`);
878
+ }
879
+ return value.map((raw, i) => {
880
+ const where = `capabilityReport[${i}]`;
881
+ if (typeof raw !== 'object' || raw === null) {
882
+ throw new Error(`${prefix} — ${where} is not an object`);
883
+ }
884
+ const e = raw;
885
+ if (typeof e.capability !== 'string' || e.capability === '') {
886
+ throw new Error(`${prefix} — ${where} missing non-empty string capability`);
887
+ }
888
+ if (e.status !== 'new' && e.status !== 'shared' && e.status !== 'bound') {
889
+ throw new Error(`${prefix} — ${where} status must be one of new, shared, bound`);
890
+ }
891
+ const entry = { capability: e.capability, status: e.status };
892
+ if (e.authored !== undefined) {
893
+ if (typeof e.authored !== 'string' || e.authored === '') {
894
+ throw new Error(`${prefix} — ${where} authored must be a non-empty string when present`);
895
+ }
896
+ entry.authored = e.authored;
897
+ }
898
+ for (const field of ['crews', 'sharedWith']) {
899
+ const list = e[field];
900
+ if (list === undefined)
901
+ continue;
902
+ if (!Array.isArray(list) || list.some((v) => typeof v !== 'string' || v === '')) {
903
+ throw new Error(`${prefix} — ${where} ${field} must be an array of non-empty strings when present`);
904
+ }
905
+ entry[field] = list;
906
+ }
907
+ return entry;
908
+ });
909
+ }
910
+ /**
911
+ * The one human line a pusher reads after `owenloop push` / `owenloop install`.
912
+ *
913
+ * Deliberately a COPY of the hub's `capabilityPublishReportText`, not an import
914
+ * of it: the CLI does not depend on `owenloop-service`, and the wire contract
915
+ * that binds the two is the ENTRY SHAPE above, not the sentence. Empty string
916
+ * for a def that authors no capabilities, so the caller appends nothing rather
917
+ * than a dangling header.
918
+ *
919
+ * `authored → capability` whenever the hub reported an `authored` spelling —
920
+ * that arrow is how an operator sees a mapping took effect.
921
+ *
922
+ * Goes to STDERR. Stdout is the machine JSON.
923
+ */
924
+ export function capabilityPublishReportText(entries) {
925
+ if (entries.length === 0)
926
+ return '';
927
+ const parts = entries.map((entry) => {
928
+ const name = entry.authored === undefined ? entry.capability : `${entry.authored} → ${entry.capability}`;
929
+ if (entry.status === 'bound')
930
+ return `${name}: bound (${(entry.crews ?? []).join(', ')})`;
931
+ if (entry.status === 'shared')
932
+ return `${name}: shared with ${(entry.sharedWith ?? []).join(', ')}`;
933
+ return `${name}: new — nothing serves it yet`;
934
+ });
935
+ return `Capabilities — ${parts.join('; ')}.`;
936
+ }
937
+ /**
938
+ * Narrow `GET /api/capability_mappings`'s 200 body to a plain `authored → org`
939
+ * record. An EMPTY result is valid — that is "this def has no recorded
940
+ * mapping", not an error.
941
+ *
942
+ * TWO BODY SHAPES ARE ACCEPTED, because the shipped hub and this CLI arrived at
943
+ * the endpoint from opposite ends:
944
+ *
945
+ * - `{ mappings: { <authored>: <org>, … } }` — the compact map this module
946
+ * originally proposed. One def, one function from authored name.
947
+ * - `{ mappings: [ { defName, authored, target, … }, … ] }` — the ROW ARRAY
948
+ * `owenloop-service` ships, whose read is a console listing that may span
949
+ * every def and carries provenance columns this caller does not need.
950
+ *
951
+ * Both collapse to the same record. Tolerating both is deliberate and is not
952
+ * temporary compatibility scaffolding: the row array is the hub's answer to a
953
+ * broader question (`what has this org remapped, anywhere`) and will keep its
954
+ * shape, while an older hub that only ever spoke the compact map must not start
955
+ * failing. A caller reading one def passes `defName` so a hub that ignores the
956
+ * `?def=` filter cannot fold another def's rows into the answer — the array
957
+ * carries `defName` precisely so that check is possible.
958
+ *
959
+ * Neither shape's VALUES are ever echoed in an error, only the position.
960
+ */
961
+ export function asCapabilityMappings(body, defName) {
962
+ const prefix = 'capability_mappings: malformed success response';
963
+ if (typeof body !== 'object' || body === null) {
964
+ throw new Error(`${prefix} — not an object`);
965
+ }
966
+ const raw = body.mappings;
967
+ if (Array.isArray(raw))
968
+ return capabilityMappingsFromRows(raw, prefix, defName);
969
+ if (typeof raw !== 'object' || raw === null) {
970
+ throw new Error(`${prefix} — expected a \`mappings\` object or array`);
971
+ }
972
+ const out = {};
973
+ const entries = Object.entries(raw);
974
+ for (let i = 0; i < entries.length; i++) {
975
+ const [authored, target] = entries[i];
976
+ if (authored === '') {
977
+ throw new Error(`${prefix} — mappings[${i}] has an empty authored key`);
978
+ }
979
+ if (typeof target !== 'string' || target === '') {
980
+ throw new Error(`${prefix} — mappings[${i}] must map to a non-empty string`);
981
+ }
982
+ out[authored] = target;
983
+ }
984
+ return out;
985
+ }
986
+ /**
987
+ * The row-array half of `asCapabilityMappings`.
988
+ *
989
+ * A row whose `defName` is a string naming a DIFFERENT def is SKIPPED, not
990
+ * rejected: an unfiltered listing is a well-formed answer to a filtered
991
+ * question, just a broader one, and refusing it would fail a correct hub. A row
992
+ * carrying no `defName` at all is kept — only a positive mismatch excludes.
993
+ *
994
+ * A LATER ROW WINS over an earlier one for the same authored name. The hub keys
995
+ * this table `(def_name, authored)`, so within one def a duplicate cannot
996
+ * happen; across defs the `defName` filter above is what separates them. This
997
+ * rule therefore only ever settles a body that already contradicts itself, and
998
+ * settling it deterministically beats throwing.
999
+ */
1000
+ function capabilityMappingsFromRows(rows, prefix, defName) {
1001
+ const out = {};
1002
+ for (let i = 0; i < rows.length; i++) {
1003
+ const row = rows[i];
1004
+ if (typeof row !== 'object' || row === null || Array.isArray(row)) {
1005
+ throw new Error(`${prefix} — mappings[${i}] is not an object`);
1006
+ }
1007
+ const r = row;
1008
+ if (defName !== undefined && typeof r.defName === 'string' && r.defName !== defName)
1009
+ continue;
1010
+ if (typeof r.authored !== 'string' || r.authored === '') {
1011
+ throw new Error(`${prefix} — mappings[${i}] has no non-empty \`authored\``);
1012
+ }
1013
+ if (typeof r.target !== 'string' || r.target === '') {
1014
+ throw new Error(`${prefix} — mappings[${i}] has no non-empty \`target\``);
1015
+ }
1016
+ out[r.authored] = r.target;
1017
+ }
856
1018
  return out;
857
1019
  }
858
1020
  /** Narrow a `GET /api/whoami` 200 body to its typed shape. Throws on a malformed body. */
@@ -0,0 +1,56 @@
1
+ import type { JsonSchema, WorkflowDef } from './types.ts';
2
+ /** A versioned external interface coordinate claimed in a workflow's x bag. */
3
+ export interface WorkflowInterfaceClaim {
4
+ name: string;
5
+ version: string;
6
+ }
7
+ /** A named input or public output and the schema that defines its values. */
8
+ export interface WorkflowInterfaceArtifact {
9
+ name: string;
10
+ schema?: JsonSchema;
11
+ }
12
+ /**
13
+ * The typed portion of an external workflow interface. Its catalog coordinate
14
+ * is deliberately separate: this checker compares a supplied signature and
15
+ * does not resolve a hub catalog or decide whether the workflow authored a
16
+ * matching x.implements claim.
17
+ */
18
+ export interface WorkflowInterfaceSignature {
19
+ inputs: WorkflowInterfaceArtifact[];
20
+ outputs: WorkflowInterfaceArtifact[];
21
+ }
22
+ /** One deterministic reason an implementation does not satisfy an interface. */
23
+ export interface InterfaceCompatibilityIssue {
24
+ path: string;
25
+ message: string;
26
+ }
27
+ /** The pure result returned when a signature is checked against a workflow. */
28
+ export interface InterfaceCompatibilityCheck {
29
+ compatible: boolean;
30
+ issues: InterfaceCompatibilityIssue[];
31
+ }
32
+ /**
33
+ * Validate a workflow against a supplied external interface signature without
34
+ * mutating either value. x.discovery.interface remains the definition's
35
+ * self-description and owns local schemaRef pointers; x.implements only names
36
+ * external contracts and carries no copied schemas or second pointer syntax.
37
+ *
38
+ * This is structural JSON Schema compatibility, not a general theorem prover.
39
+ * It supports booleans; type/const/enum; numeric, string, array, and object
40
+ * bounds; array items and uniqueItems; object properties, required, and
41
+ * additionalProperties; and oneOf/anyOf. Union sibling constraints are
42
+ * compared separately from branch coverage. Target oneOf branches are accepted
43
+ * only when non-boolean, object-only schemas with required const/enum
44
+ * discriminators prove every pair disjoint.
45
+ * The checker remains structural and incomplete: coverage requiring multiple
46
+ * target branches fails closed. allOf, if/then/else, not, $ref, prefixItems,
47
+ * and other validation keywords fail closed with a path-specific issue. For a
48
+ * closed interface output, the projection rule permits extra implementation
49
+ * properties only when that implementation is also closed.
50
+ */
51
+ export declare function checkInterfaceCompatibility(signature: WorkflowInterfaceSignature, def: WorkflowDef): InterfaceCompatibilityCheck;
52
+ /**
53
+ * Return advisory, field-qualified authoring issues for x.implements. The
54
+ * extension remains optional so old binaries keep loading existing definitions.
55
+ */
56
+ export declare function implementsIssues(def: WorkflowDef): string[];