@smithers-orchestrator/components 0.16.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.
Files changed (120) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +47 -0
  3. package/src/SmithersWorkflow.ts +1 -0
  4. package/src/aspects/AspectAccumulator.ts +9 -0
  5. package/src/aspects/AspectContext.js +29 -0
  6. package/src/aspects/AspectContextValue.ts +16 -0
  7. package/src/aspects/CostBudgetConfig.ts +9 -0
  8. package/src/aspects/LatencySloConfig.ts +11 -0
  9. package/src/aspects/TokenBudgetConfig.ts +11 -0
  10. package/src/aspects/TrackingConfig.ts +11 -0
  11. package/src/aspects/index.js +10 -0
  12. package/src/components/Approval.js +211 -0
  13. package/src/components/ApprovalAutoApprove.ts +8 -0
  14. package/src/components/ApprovalDecision.ts +4 -0
  15. package/src/components/ApprovalGate.js +45 -0
  16. package/src/components/ApprovalGateProps.ts +22 -0
  17. package/src/components/ApprovalMode.ts +1 -0
  18. package/src/components/ApprovalOption.ts +6 -0
  19. package/src/components/ApprovalProps.ts +42 -0
  20. package/src/components/ApprovalRanking.ts +4 -0
  21. package/src/components/ApprovalRequest.ts +5 -0
  22. package/src/components/ApprovalSelection.ts +4 -0
  23. package/src/components/Aspects.js +39 -0
  24. package/src/components/AspectsProps.ts +18 -0
  25. package/src/components/Branch.js +12 -0
  26. package/src/components/BranchProps.ts +8 -0
  27. package/src/components/CategoryConfig.ts +10 -0
  28. package/src/components/CheckConfig.ts +8 -0
  29. package/src/components/CheckSuite.js +71 -0
  30. package/src/components/CheckSuiteProps.ts +12 -0
  31. package/src/components/ClassifyAndRoute.js +75 -0
  32. package/src/components/ClassifyAndRouteProps.ts +30 -0
  33. package/src/components/ColumnDef.ts +19 -0
  34. package/src/components/ContentPipeline.js +38 -0
  35. package/src/components/ContentPipelineProps.ts +12 -0
  36. package/src/components/ContentPipelineStage.ts +13 -0
  37. package/src/components/ContinueAsNew.js +27 -0
  38. package/src/components/ContinueAsNewProps.ts +6 -0
  39. package/src/components/Debate.js +63 -0
  40. package/src/components/DebateProps.ts +15 -0
  41. package/src/components/DecisionRule.ts +10 -0
  42. package/src/components/DecisionTable.js +42 -0
  43. package/src/components/DecisionTableProps.ts +14 -0
  44. package/src/components/DepsSpec.ts +3 -0
  45. package/src/components/DriftDetector.js +54 -0
  46. package/src/components/DriftDetectorProps.ts +29 -0
  47. package/src/components/EscalationChain.js +99 -0
  48. package/src/components/EscalationChainProps.ts +20 -0
  49. package/src/components/EscalationLevel.ts +13 -0
  50. package/src/components/GatherAndSynthesize.js +69 -0
  51. package/src/components/GatherAndSynthesizeProps.ts +24 -0
  52. package/src/components/HumanTask.js +94 -0
  53. package/src/components/HumanTaskProps.ts +27 -0
  54. package/src/components/InferDeps.ts +8 -0
  55. package/src/components/Kanban.js +68 -0
  56. package/src/components/KanbanProps.ts +27 -0
  57. package/src/components/Loop.js +6 -0
  58. package/src/components/LoopProps.ts +11 -0
  59. package/src/components/MergeQueue.js +16 -0
  60. package/src/components/MergeQueueProps.ts +12 -0
  61. package/src/components/Optimizer.js +52 -0
  62. package/src/components/OptimizerProps.ts +25 -0
  63. package/src/components/OutputTarget.ts +6 -0
  64. package/src/components/Panel.js +69 -0
  65. package/src/components/PanelProps.ts +17 -0
  66. package/src/components/PanelistConfig.ts +7 -0
  67. package/src/components/Parallel.js +16 -0
  68. package/src/components/ParallelProps.ts +8 -0
  69. package/src/components/Poller.js +69 -0
  70. package/src/components/PollerProps.ts +24 -0
  71. package/src/components/Ralph.js +17 -0
  72. package/src/components/RalphProps.ts +4 -0
  73. package/src/components/ReviewLoop.js +51 -0
  74. package/src/components/ReviewLoopProps.ts +23 -0
  75. package/src/components/Runbook.js +91 -0
  76. package/src/components/RunbookProps.ts +19 -0
  77. package/src/components/RunbookStep.ts +17 -0
  78. package/src/components/Saga.js +77 -0
  79. package/src/components/SagaProps.ts +10 -0
  80. package/src/components/SagaStepDef.ts +8 -0
  81. package/src/components/SagaStepProps.ts +7 -0
  82. package/src/components/Sandbox.js +48 -0
  83. package/src/components/SandboxProps.ts +46 -0
  84. package/src/components/SandboxRuntime.ts +1 -0
  85. package/src/components/SandboxVolumeMount.ts +5 -0
  86. package/src/components/SandboxWorkspaceSpec.ts +6 -0
  87. package/src/components/ScanFixVerify.js +60 -0
  88. package/src/components/ScanFixVerifyProps.ts +30 -0
  89. package/src/components/Sequence.js +11 -0
  90. package/src/components/SequenceProps.ts +6 -0
  91. package/src/components/Signal.js +48 -0
  92. package/src/components/SignalProps.ts +21 -0
  93. package/src/components/SourceDef.ts +12 -0
  94. package/src/components/Subflow.js +32 -0
  95. package/src/components/SubflowProps.ts +33 -0
  96. package/src/components/SuperSmithers.js +102 -0
  97. package/src/components/SuperSmithersProps.ts +20 -0
  98. package/src/components/Supervisor.js +86 -0
  99. package/src/components/SupervisorProps.ts +28 -0
  100. package/src/components/Task.js +319 -0
  101. package/src/components/TaskProps.ts +57 -0
  102. package/src/components/Timer.js +42 -0
  103. package/src/components/TimerProps.ts +21 -0
  104. package/src/components/TryCatchFinally.js +35 -0
  105. package/src/components/TryCatchFinallyProps.ts +12 -0
  106. package/src/components/WaitForEvent.js +37 -0
  107. package/src/components/WaitForEventProps.ts +28 -0
  108. package/src/components/Workflow.js +10 -0
  109. package/src/components/WorkflowProps.ts +7 -0
  110. package/src/components/Worktree.js +17 -0
  111. package/src/components/WorktreeProps.ts +11 -0
  112. package/src/components/control-flow-utils.js +37 -0
  113. package/src/components/index.js +121 -0
  114. package/src/index.d.ts +1579 -0
  115. package/src/index.js +62 -0
  116. package/src/markdownComponents.js +44 -0
  117. package/src/renderMdx.js +26 -0
  118. package/src/types/react-dom-server.d.ts +1 -0
  119. package/src/types.ts +22 -0
  120. package/src/zod-to-example.js +87 -0
package/src/index.js ADDED
@@ -0,0 +1,62 @@
1
+ // @smithers-type-exports-begin
2
+ /**
3
+ * @template Ctx
4
+ * @typedef {import("@smithers-orchestrator/scheduler/CachePolicy").CachePolicy<Ctx>} CachePolicy
5
+ */
6
+ /** @typedef {import("@smithers-orchestrator/scheduler").EngineDecision} EngineDecision */
7
+ /** @typedef {import("@smithers-orchestrator/graph").ExtractOptions} ExtractOptions */
8
+ /** @typedef {import("@smithers-orchestrator/graph").HostElement} HostElement */
9
+ /** @typedef {import("@smithers-orchestrator/graph").HostNode} HostNode */
10
+ /** @typedef {import("@smithers-orchestrator/graph").HostText} HostText */
11
+ /**
12
+ * @template T
13
+ * @typedef {import("@smithers-orchestrator/driver/OutputAccessor").InferOutputEntry<T>} InferOutputEntry
14
+ */
15
+ /**
16
+ * @template TTable
17
+ * @typedef {import("@smithers-orchestrator/driver/OutputAccessor").InferRow<TTable>} InferRow
18
+ */
19
+ /**
20
+ * @template Schema
21
+ * @typedef {import("@smithers-orchestrator/driver/OutputAccessor").OutputAccessor<Schema>} OutputAccessor
22
+ */
23
+ /** @typedef {import("@smithers-orchestrator/driver/OutputKey").OutputKey} OutputKey */
24
+ /** @typedef {import("@smithers-orchestrator/scheduler").RenderContext} RenderContext */
25
+ /** @typedef {import("@smithers-orchestrator/scheduler/RetryPolicy").RetryPolicy} RetryPolicy */
26
+ /** @typedef {import("@smithers-orchestrator/driver/RunAuthContext").RunAuthContext} RunAuthContext */
27
+ /** @typedef {import("@smithers-orchestrator/driver").RunOptions} RunOptions */
28
+ /** @typedef {import("@smithers-orchestrator/driver").RunResult} RunResult */
29
+ /** @typedef {import("@smithers-orchestrator/db/SchemaRegistryEntry").SchemaRegistryEntry} SchemaRegistryEntry */
30
+ /** @typedef {import("@smithers-orchestrator/scheduler/SmithersWorkflowOptions").SmithersAlertLabels} SmithersAlertLabels */
31
+ /** @typedef {import("@smithers-orchestrator/scheduler/SmithersWorkflowOptions").SmithersAlertPolicy} SmithersAlertPolicy */
32
+ /** @typedef {import("@smithers-orchestrator/scheduler/SmithersWorkflowOptions").SmithersAlertPolicyDefaults} SmithersAlertPolicyDefaults */
33
+ /** @typedef {import("@smithers-orchestrator/scheduler/SmithersWorkflowOptions").SmithersAlertPolicyRule} SmithersAlertPolicyRule */
34
+ /** @typedef {import("@smithers-orchestrator/scheduler/SmithersWorkflowOptions").SmithersAlertReaction} SmithersAlertReaction */
35
+ /** @typedef {import("@smithers-orchestrator/scheduler/SmithersWorkflowOptions").SmithersAlertReactionKind} SmithersAlertReactionKind */
36
+ /** @typedef {import("@smithers-orchestrator/scheduler/SmithersWorkflowOptions").SmithersAlertReactionRef} SmithersAlertReactionRef */
37
+ /** @typedef {import("@smithers-orchestrator/scheduler/SmithersWorkflowOptions").SmithersAlertSeverity} SmithersAlertSeverity */
38
+ /** @typedef {import("@smithers-orchestrator/driver").SmithersCtx} SmithersCtx */
39
+ /** @typedef {import("@smithers-orchestrator/errors/SmithersErrorCode").SmithersErrorCode} SmithersErrorCode */
40
+ /**
41
+ * @template Schema
42
+ * @typedef {import("@smithers-orchestrator/driver/WorkflowDefinition").WorkflowDefinition<Schema>} SmithersWorkflow
43
+ */
44
+ /**
45
+ * @template Schema
46
+ * @typedef {import("@smithers-orchestrator/driver/WorkflowDriverOptions").WorkflowDriverOptions<Schema>} SmithersWorkflowDriverOptions
47
+ */
48
+ /** @typedef {import("@smithers-orchestrator/scheduler").SmithersWorkflowOptions} SmithersWorkflowOptions */
49
+ /** @typedef {import("@smithers-orchestrator/graph").TaskDescriptor} TaskDescriptor */
50
+ /** @typedef {import("@smithers-orchestrator/scheduler").WaitReason} WaitReason */
51
+ /** @typedef {import("@smithers-orchestrator/graph").WorkflowGraph} WorkflowGraph */
52
+ /** @typedef {import("@smithers-orchestrator/driver/workflow-types").WorkflowRuntime} WorkflowRuntime */
53
+ /** @typedef {import("@smithers-orchestrator/driver/workflow-types").WorkflowSession} WorkflowSession */
54
+ /** @typedef {import("@smithers-orchestrator/graph").XmlElement} XmlElement */
55
+ /** @typedef {import("@smithers-orchestrator/graph").XmlNode} XmlNode */
56
+ /** @typedef {import("@smithers-orchestrator/graph").XmlText} XmlText */
57
+ // @smithers-type-exports-end
58
+
59
+ export * from "./components/index.js";
60
+ export { markdownComponents } from "./markdownComponents.js";
61
+ export { renderMdx } from "./renderMdx.js";
62
+ export { zodSchemaToJsonExample } from "./zod-to-example.js";
@@ -0,0 +1,44 @@
1
+ import React from "react";
2
+ /**
3
+ * @param {any[]} ...parts
4
+ */
5
+ function fragment(...parts) {
6
+ return React.createElement(React.Fragment, null, ...parts);
7
+ }
8
+ /** @type {Record<string, React.FC<any>>} */
9
+ export const markdownComponents = {
10
+ h1: ({ children }) => fragment("# ", children, "\n\n"),
11
+ h2: ({ children }) => fragment("## ", children, "\n\n"),
12
+ h3: ({ children }) => fragment("### ", children, "\n\n"),
13
+ h4: ({ children }) => fragment("#### ", children, "\n\n"),
14
+ h5: ({ children }) => fragment("##### ", children, "\n\n"),
15
+ h6: ({ children }) => fragment("###### ", children, "\n\n"),
16
+ p: ({ children }) => fragment(children, "\n\n"),
17
+ blockquote: ({ children }) => fragment("> ", children, "\n"),
18
+ hr: () => fragment("---\n\n"),
19
+ ul: ({ children }) => fragment(children, "\n"),
20
+ ol: ({ children }) => fragment(children, "\n"),
21
+ li: ({ children }) => fragment("- ", children, "\n"),
22
+ code: ({ children, className }) => {
23
+ if (className) {
24
+ const lang = className.replace("language-", "");
25
+ return fragment("```", lang, "\n", children, "\n```\n\n");
26
+ }
27
+ return fragment("`", children, "`");
28
+ },
29
+ pre: ({ children }) => fragment(children),
30
+ strong: ({ children }) => fragment("**", children, "**"),
31
+ em: ({ children }) => fragment("*", children, "*"),
32
+ a: ({ href, children }) => fragment("[", children, "](", href, ")"),
33
+ br: () => fragment("\n"),
34
+ img: ({ alt, src }) => fragment("![", alt ?? "", "](", src, ")"),
35
+ table: ({ children }) => fragment(children, "\n"),
36
+ thead: ({ children }) => fragment(children),
37
+ tbody: ({ children }) => fragment(children),
38
+ tr: ({ children }) => fragment("| ", children, "\n"),
39
+ th: ({ children }) => fragment(children, " | "),
40
+ td: ({ children }) => fragment(children, " | "),
41
+ div: ({ children }) => fragment(children, "\n"),
42
+ section: ({ children }) => fragment(children, "\n"),
43
+ span: ({ children }) => fragment(children),
44
+ };
@@ -0,0 +1,26 @@
1
+ import React from "react";
2
+ import { renderToStaticMarkup } from "react-dom/server";
3
+ import { markdownComponents } from "./markdownComponents.js";
4
+ /** @typedef {import("mdx/types").MDXContent} MDXContent */
5
+ /**
6
+ * Render an MDX component to plain markdown text.
7
+ *
8
+ * Injects `markdownComponents` so headings, paragraphs, code blocks, etc.
9
+ * render as markdown-formatted text instead of HTML tags.
10
+ *
11
+ * @param {MDXContent} Component
12
+ * @param {Record<string, any>} [props]
13
+ * @returns {string}
14
+ */
15
+ export function renderMdx(Component, props = {}) {
16
+ const element = React.createElement(Component, {
17
+ ...props,
18
+ components: {
19
+ ...markdownComponents,
20
+ ...props.components,
21
+ },
22
+ });
23
+ return renderToStaticMarkup(element)
24
+ .replace(/\n{3,}/g, "\n\n")
25
+ .trim();
26
+ }
@@ -0,0 +1 @@
1
+ declare module "react-dom/server";
package/src/types.ts ADDED
@@ -0,0 +1,22 @@
1
+ export type { WorkflowDefinition as SmithersWorkflow } from "@smithers-orchestrator/driver/WorkflowDefinition";
2
+ export type { WorkflowDriverOptions as SmithersWorkflowDriverOptions } from "@smithers-orchestrator/driver/WorkflowDriverOptions";
3
+
4
+ export type {
5
+ EngineDecision,
6
+ RenderContext,
7
+ WaitReason,
8
+ SmithersWorkflowOptions,
9
+ } from "@smithers-orchestrator/scheduler";
10
+ export type { RunOptions, RunResult, SmithersCtx } from "@smithers-orchestrator/driver";
11
+ export type { WorkflowRuntime, WorkflowSession } from "@smithers-orchestrator/driver/workflow-types";
12
+ export type {
13
+ ExtractOptions,
14
+ HostElement,
15
+ HostNode,
16
+ HostText,
17
+ TaskDescriptor,
18
+ WorkflowGraph,
19
+ XmlElement,
20
+ XmlNode,
21
+ XmlText,
22
+ } from "@smithers-orchestrator/graph";
@@ -0,0 +1,87 @@
1
+
2
+ /** @typedef {import("zod").ZodObject<import("zod").ZodRawShape>} ZodObject */
3
+ /** @typedef {import("zod").ZodTypeAny} ZodTypeAny */
4
+ /**
5
+ * @param {ZodObject} schema
6
+ * @returns {string}
7
+ */
8
+ export function zodSchemaToJsonExample(schema) {
9
+ /** @type {Record<string, unknown>} */
10
+ const example = {};
11
+ for (const [key, field] of Object.entries(schema.shape)) {
12
+ example[key] = zodFieldToExample(/** @type {ZodTypeAny} */ (field));
13
+ }
14
+ return JSON.stringify(example, null, 2);
15
+ }
16
+ /**
17
+ * @param {ZodTypeAny} field
18
+ * @returns {unknown}
19
+ */
20
+ function zodFieldToExample(field) {
21
+ const anyField = /** @type {{
22
+ description?: string;
23
+ _def?: { description?: string };
24
+ _zod?: {
25
+ bag?: { description?: string };
26
+ def?: {
27
+ type?: string;
28
+ description?: string;
29
+ element?: ZodTypeAny;
30
+ values?: unknown[];
31
+ entries?: Record<string, unknown>;
32
+ innerType?: ZodTypeAny;
33
+ };
34
+ };
35
+ shape?: Record<string, ZodTypeAny>;
36
+ }} */ (/** @type {unknown} */ (field));
37
+ const zod = anyField._zod;
38
+ const def = zod?.def;
39
+ if (!def)
40
+ return "value";
41
+ const description = anyField.description ??
42
+ anyField._def?.description ??
43
+ zod?.bag?.description ??
44
+ def.description ??
45
+ "";
46
+ const typeName = def.type;
47
+ switch (typeName) {
48
+ case "string":
49
+ return description || "string";
50
+ case "number":
51
+ return 0;
52
+ case "boolean":
53
+ return false;
54
+ case "array": {
55
+ const inner = def.element;
56
+ if (inner && typeof inner === "object")
57
+ return [zodFieldToExample(inner)];
58
+ return ["value"];
59
+ }
60
+ case "enum": {
61
+ if (Array.isArray(def.values))
62
+ return def.values[0] ?? "enum";
63
+ if (def.entries && typeof def.entries === "object") {
64
+ const keys = Object.keys(def.entries);
65
+ return keys[0] ?? "enum";
66
+ }
67
+ return "enum";
68
+ }
69
+ case "object": {
70
+ const shape = anyField.shape;
71
+ if (!shape)
72
+ return {};
73
+ /** @type {Record<string, unknown>} */
74
+ const obj = {};
75
+ for (const [key, value] of Object.entries(shape)) {
76
+ obj[key] = zodFieldToExample(value);
77
+ }
78
+ return obj;
79
+ }
80
+ case "nullable":
81
+ return def.innerType ? zodFieldToExample(def.innerType) : null;
82
+ case "optional":
83
+ return def.innerType ? zodFieldToExample(def.innerType) : undefined;
84
+ default:
85
+ return description || "value";
86
+ }
87
+ }