0pflow 0.1.0-dev.7aacb27 → 0.1.0-dev.8ac4d9e

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 (240) hide show
  1. package/dist/__tests__/discover.integration.test.d.ts +2 -0
  2. package/dist/__tests__/discover.integration.test.d.ts.map +1 -0
  3. package/dist/__tests__/discover.integration.test.js +137 -0
  4. package/dist/__tests__/discover.integration.test.js.map +1 -0
  5. package/dist/__tests__/factory.test.js +7 -0
  6. package/dist/__tests__/factory.test.js.map +1 -1
  7. package/dist/__tests__/integration.e2e.test.js +2 -1
  8. package/dist/__tests__/integration.e2e.test.js.map +1 -1
  9. package/dist/__tests__/integration.test.js +87 -82
  10. package/dist/__tests__/integration.test.js.map +1 -1
  11. package/dist/agent.d.ts +7 -0
  12. package/dist/agent.d.ts.map +1 -1
  13. package/dist/agent.js +59 -9
  14. package/dist/agent.js.map +1 -1
  15. package/dist/cli/__tests__/discovery.test.js +1 -1
  16. package/dist/cli/__tests__/discovery.test.js.map +1 -1
  17. package/dist/cli/app.d.ts +6 -0
  18. package/dist/cli/app.d.ts.map +1 -1
  19. package/dist/cli/app.js +27 -0
  20. package/dist/cli/app.js.map +1 -1
  21. package/dist/cli/discovery.d.ts +10 -0
  22. package/dist/cli/discovery.d.ts.map +1 -1
  23. package/dist/cli/discovery.js +42 -0
  24. package/dist/cli/discovery.js.map +1 -1
  25. package/dist/cli/env.js +1 -1
  26. package/dist/cli/env.js.map +1 -1
  27. package/dist/cli/index.d.ts +5 -1
  28. package/dist/cli/index.d.ts.map +1 -1
  29. package/dist/cli/index.js +154 -12
  30. package/dist/cli/index.js.map +1 -1
  31. package/dist/cli/install.d.ts.map +1 -1
  32. package/dist/cli/install.js +61 -28
  33. package/dist/cli/install.js.map +1 -1
  34. package/dist/cli/mcp/config.d.ts +0 -1
  35. package/dist/cli/mcp/config.d.ts.map +1 -1
  36. package/dist/cli/mcp/config.js +2 -4
  37. package/dist/cli/mcp/config.js.map +1 -1
  38. package/dist/cli/mcp/lib/scaffolding.d.ts +33 -0
  39. package/dist/cli/mcp/lib/scaffolding.d.ts.map +1 -0
  40. package/dist/cli/mcp/lib/scaffolding.js +219 -0
  41. package/dist/cli/mcp/lib/scaffolding.js.map +1 -0
  42. package/dist/cli/mcp/lib/templates.d.ts +1 -0
  43. package/dist/cli/mcp/lib/templates.d.ts.map +1 -1
  44. package/dist/cli/mcp/lib/templates.js.map +1 -1
  45. package/dist/cli/mcp/tools/createApp.d.ts +1 -0
  46. package/dist/cli/mcp/tools/createApp.d.ts.map +1 -1
  47. package/dist/cli/mcp/tools/createApp.js +12 -55
  48. package/dist/cli/mcp/tools/createApp.js.map +1 -1
  49. package/dist/cli/mcp/tools/createDatabase.d.ts.map +1 -1
  50. package/dist/cli/mcp/tools/createDatabase.js +2 -41
  51. package/dist/cli/mcp/tools/createDatabase.js.map +1 -1
  52. package/dist/cli/mcp/tools/getConnectionInfo.d.ts +19 -0
  53. package/dist/cli/mcp/tools/getConnectionInfo.d.ts.map +1 -0
  54. package/dist/cli/mcp/tools/getConnectionInfo.js +111 -0
  55. package/dist/cli/mcp/tools/getConnectionInfo.js.map +1 -0
  56. package/dist/cli/mcp/tools/getRun.d.ts +22 -0
  57. package/dist/cli/mcp/tools/getRun.d.ts.map +1 -0
  58. package/dist/cli/mcp/tools/getRun.js +80 -0
  59. package/dist/cli/mcp/tools/getRun.js.map +1 -0
  60. package/dist/cli/mcp/tools/getTrace.d.ts +32 -0
  61. package/dist/cli/mcp/tools/getTrace.d.ts.map +1 -0
  62. package/dist/cli/mcp/tools/getTrace.js +104 -0
  63. package/dist/cli/mcp/tools/getTrace.js.map +1 -0
  64. package/dist/cli/mcp/tools/index.d.ts +94 -1
  65. package/dist/cli/mcp/tools/index.d.ts.map +1 -1
  66. package/dist/cli/mcp/tools/index.js +16 -0
  67. package/dist/cli/mcp/tools/index.js.map +1 -1
  68. package/dist/cli/mcp/tools/listIntegrations.d.ts +14 -0
  69. package/dist/cli/mcp/tools/listIntegrations.d.ts.map +1 -0
  70. package/dist/cli/mcp/tools/listIntegrations.js +53 -0
  71. package/dist/cli/mcp/tools/listIntegrations.js.map +1 -0
  72. package/dist/cli/mcp/tools/listRuns.d.ts +21 -0
  73. package/dist/cli/mcp/tools/listRuns.d.ts.map +1 -0
  74. package/dist/cli/mcp/tools/listRuns.js +72 -0
  75. package/dist/cli/mcp/tools/listRuns.js.map +1 -0
  76. package/dist/cli/mcp/tools/listWorkflows.d.ts +15 -0
  77. package/dist/cli/mcp/tools/listWorkflows.d.ts.map +1 -0
  78. package/dist/cli/mcp/tools/listWorkflows.js +45 -0
  79. package/dist/cli/mcp/tools/listWorkflows.js.map +1 -0
  80. package/dist/cli/mcp/tools/runNode.d.ts +17 -0
  81. package/dist/cli/mcp/tools/runNode.d.ts.map +1 -0
  82. package/dist/cli/mcp/tools/runNode.js +74 -0
  83. package/dist/cli/mcp/tools/runNode.js.map +1 -0
  84. package/dist/cli/mcp/tools/runWorkflow.d.ts +16 -0
  85. package/dist/cli/mcp/tools/runWorkflow.d.ts.map +1 -0
  86. package/dist/cli/mcp/tools/runWorkflow.js +66 -0
  87. package/dist/cli/mcp/tools/runWorkflow.js.map +1 -0
  88. package/dist/cli/mcp/tools/setupAppSchema.d.ts +1 -1
  89. package/dist/cli/mcp/tools/setupAppSchema.d.ts.map +1 -1
  90. package/dist/cli/mcp/tools/setupAppSchema.js +11 -129
  91. package/dist/cli/mcp/tools/setupAppSchema.js.map +1 -1
  92. package/dist/cli/mcp/tools/utils.d.ts +7 -0
  93. package/dist/cli/mcp/tools/utils.d.ts.map +1 -0
  94. package/dist/cli/mcp/tools/utils.js +28 -0
  95. package/dist/cli/mcp/tools/utils.js.map +1 -0
  96. package/dist/cli/run.d.ts +2 -0
  97. package/dist/cli/run.d.ts.map +1 -0
  98. package/dist/cli/run.js +545 -0
  99. package/dist/cli/run.js.map +1 -0
  100. package/dist/cli/trace.d.ts +5 -0
  101. package/dist/cli/trace.d.ts.map +1 -1
  102. package/dist/cli/trace.js +1 -1
  103. package/dist/cli/trace.js.map +1 -1
  104. package/dist/connections/cloud-auth.d.ts +46 -0
  105. package/dist/connections/cloud-auth.d.ts.map +1 -0
  106. package/dist/connections/cloud-auth.js +243 -0
  107. package/dist/connections/cloud-auth.js.map +1 -0
  108. package/dist/connections/cloud-client.d.ts +25 -0
  109. package/dist/connections/cloud-client.d.ts.map +1 -0
  110. package/dist/connections/cloud-client.js +59 -0
  111. package/dist/connections/cloud-client.js.map +1 -0
  112. package/dist/connections/cloud-integration-provider.d.ts +21 -0
  113. package/dist/connections/cloud-integration-provider.d.ts.map +1 -0
  114. package/dist/connections/cloud-integration-provider.js +26 -0
  115. package/dist/connections/cloud-integration-provider.js.map +1 -0
  116. package/dist/connections/index.d.ts +11 -0
  117. package/dist/connections/index.d.ts.map +1 -0
  118. package/dist/connections/index.js +9 -0
  119. package/dist/connections/index.js.map +1 -0
  120. package/dist/connections/integration-provider.d.ts +38 -0
  121. package/dist/connections/integration-provider.d.ts.map +1 -0
  122. package/dist/connections/integration-provider.js +20 -0
  123. package/dist/connections/integration-provider.js.map +1 -0
  124. package/dist/connections/local-integration-provider.d.ts +28 -0
  125. package/dist/connections/local-integration-provider.d.ts.map +1 -0
  126. package/dist/connections/local-integration-provider.js +54 -0
  127. package/dist/connections/local-integration-provider.js.map +1 -0
  128. package/dist/connections/nango-client.d.ts +14 -0
  129. package/dist/connections/nango-client.d.ts.map +1 -0
  130. package/dist/connections/nango-client.js +50 -0
  131. package/dist/connections/nango-client.js.map +1 -0
  132. package/dist/connections/resolver.d.ts +26 -0
  133. package/dist/connections/resolver.d.ts.map +1 -0
  134. package/dist/connections/resolver.js +48 -0
  135. package/dist/connections/resolver.js.map +1 -0
  136. package/dist/connections/schema.d.ts +8 -0
  137. package/dist/connections/schema.d.ts.map +1 -0
  138. package/dist/connections/schema.js +31 -0
  139. package/dist/connections/schema.js.map +1 -0
  140. package/dist/context.d.ts.map +1 -1
  141. package/dist/context.js +4 -0
  142. package/dist/context.js.map +1 -1
  143. package/dist/dev-ui/api.d.ts +16 -0
  144. package/dist/dev-ui/api.d.ts.map +1 -0
  145. package/dist/dev-ui/api.js +237 -0
  146. package/dist/dev-ui/api.js.map +1 -0
  147. package/dist/dev-ui/dag/extractor.d.ts +19 -0
  148. package/dist/dev-ui/dag/extractor.d.ts.map +1 -0
  149. package/dist/dev-ui/dag/extractor.js +716 -0
  150. package/dist/dev-ui/dag/extractor.js.map +1 -0
  151. package/dist/dev-ui/dag/types.d.ts +42 -0
  152. package/dist/dev-ui/dag/types.d.ts.map +1 -0
  153. package/dist/dev-ui/dag/types.js +2 -0
  154. package/dist/dev-ui/dag/types.js.map +1 -0
  155. package/dist/dev-ui/dev-server.d.ts +18 -0
  156. package/dist/dev-ui/dev-server.d.ts.map +1 -0
  157. package/dist/dev-ui/dev-server.js +222 -0
  158. package/dist/dev-ui/dev-server.js.map +1 -0
  159. package/dist/dev-ui/index.d.ts +3 -0
  160. package/dist/dev-ui/index.d.ts.map +1 -0
  161. package/dist/dev-ui/index.js +2 -0
  162. package/dist/dev-ui/index.js.map +1 -0
  163. package/dist/dev-ui/pty.d.ts +16 -0
  164. package/dist/dev-ui/pty.d.ts.map +1 -0
  165. package/dist/dev-ui/pty.js +87 -0
  166. package/dist/dev-ui/pty.js.map +1 -0
  167. package/dist/dev-ui/watcher.d.ts +12 -0
  168. package/dist/dev-ui/watcher.d.ts.map +1 -0
  169. package/dist/dev-ui/watcher.js +162 -0
  170. package/dist/dev-ui/watcher.js.map +1 -0
  171. package/dist/dev-ui/ws.d.ts +52 -0
  172. package/dist/dev-ui/ws.d.ts.map +1 -0
  173. package/dist/dev-ui/ws.js +32 -0
  174. package/dist/dev-ui/ws.js.map +1 -0
  175. package/dist/dev-ui-client/assets/index-C-LxzUII.css +32 -0
  176. package/dist/dev-ui-client/assets/index-DAKTQEvj.js +1 -0
  177. package/dist/dev-ui-client/assets/index-aAIwXl4O.js +127 -0
  178. package/dist/dev-ui-client/index.html +13 -0
  179. package/dist/discover.d.ts +15 -0
  180. package/dist/discover.d.ts.map +1 -0
  181. package/dist/discover.js +32 -0
  182. package/dist/discover.js.map +1 -0
  183. package/dist/factory.d.ts.map +1 -1
  184. package/dist/factory.js +25 -12
  185. package/dist/factory.js.map +1 -1
  186. package/dist/index.d.ts +6 -1
  187. package/dist/index.d.ts.map +1 -1
  188. package/dist/index.js +6 -0
  189. package/dist/index.js.map +1 -1
  190. package/dist/node.d.ts +1 -0
  191. package/dist/node.d.ts.map +1 -1
  192. package/dist/node.js +1 -0
  193. package/dist/node.js.map +1 -1
  194. package/dist/nodes/agent/executor.d.ts +2 -0
  195. package/dist/nodes/agent/executor.d.ts.map +1 -1
  196. package/dist/nodes/agent/executor.js +11 -1
  197. package/dist/nodes/agent/executor.js.map +1 -1
  198. package/dist/registry-gen.d.ts +6 -0
  199. package/dist/registry-gen.d.ts.map +1 -0
  200. package/dist/registry-gen.js +126 -0
  201. package/dist/registry-gen.js.map +1 -0
  202. package/dist/types.d.ts +21 -3
  203. package/dist/types.d.ts.map +1 -1
  204. package/dist/workflow.d.ts +22 -0
  205. package/dist/workflow.d.ts.map +1 -1
  206. package/dist/workflow.js +97 -2
  207. package/dist/workflow.js.map +1 -1
  208. package/package.json +28 -6
  209. package/templates/app/.env.example +13 -0
  210. package/templates/app/README.md +29 -0
  211. package/templates/app/biome.jsonc +81 -0
  212. package/templates/app/dbos-config.yaml +6 -0
  213. package/templates/app/drizzle.config.ts +12 -0
  214. package/templates/app/generated/registry.ts +8 -0
  215. package/templates/app/next.config.js +12 -0
  216. package/templates/app/package.json +57 -0
  217. package/templates/app/postcss.config.js +5 -0
  218. package/templates/app/public/favicon.ico +0 -0
  219. package/templates/app/src/app/_components/.gitkeep +0 -0
  220. package/templates/app/src/app/api/trpc/[trpc]/route.ts +34 -0
  221. package/templates/app/src/app/api/workflow/[name]/route.ts +37 -0
  222. package/templates/app/src/app/layout.tsx +29 -0
  223. package/templates/app/src/app/page.tsx +18 -0
  224. package/templates/app/src/env.js +46 -0
  225. package/templates/app/src/instrumentation.ts +6 -0
  226. package/templates/app/src/lib/pflow.ts +28 -0
  227. package/templates/app/src/server/api/root.ts +21 -0
  228. package/templates/app/src/server/api/routers/.gitkeep +0 -0
  229. package/templates/app/src/server/api/trpc.ts +106 -0
  230. package/templates/app/src/server/db/index.ts +18 -0
  231. package/templates/app/src/server/db/schema.ts +14 -0
  232. package/templates/app/src/styles/globals.css +6 -0
  233. package/templates/app/src/styles/globals.css.orange +126 -0
  234. package/templates/app/src/trpc/query-client.ts +25 -0
  235. package/templates/app/src/trpc/react.tsx +78 -0
  236. package/templates/app/src/trpc/server.ts +30 -0
  237. package/templates/app/tsconfig.check.json +23 -0
  238. package/templates/app/tsconfig.json +42 -0
  239. package/templates/app/tsconfig.server.json +5 -0
  240. package/templates/app/tsconfig.test.json +21 -0
package/dist/workflow.js CHANGED
@@ -1,12 +1,19 @@
1
1
  import { DBOS } from "@dbos-inc/dbos-sdk";
2
+ import { resolveConnectionId } from "./connections/index.js";
2
3
  /**
3
4
  * Create a WorkflowContext that wraps calls in DBOS steps for durability
4
5
  */
5
- function createDurableContext() {
6
+ function createDurableContext(config) {
7
+ let _currentNodeName = "*";
8
+ let _currentIntegrations;
6
9
  const ctx = {
10
+ workflowName: config?.workflowName ?? "*",
7
11
  run: async (executable, inputs) => {
8
12
  // Validate inputs against schema
9
13
  const validated = executable.inputSchema.parse(inputs);
14
+ // Track current node for connection resolution
15
+ _currentNodeName = executable.name;
16
+ _currentIntegrations = executable.integrations;
10
17
  if (executable.type === "workflow" || executable.type === "agent") {
11
18
  // For workflows and agents, call execute directly (they handle their own DBOS registration)
12
19
  // This allows proper child workflow tracking
@@ -15,12 +22,59 @@ function createDurableContext() {
15
22
  // For nodes, wrap execution in DBOS step for durability
16
23
  return DBOS.runStep(async () => executable.execute(ctx, validated), { name: executable.name });
17
24
  },
25
+ getConnection: async (integrationId) => {
26
+ if (!config?.sql || !config?.integrationProvider) {
27
+ throw new Error("Connection management not configured. Set NANGO_SECRET_KEY and DATABASE_URL.");
28
+ }
29
+ // Validate that the integration was declared on the current node
30
+ if (_currentIntegrations && !_currentIntegrations.includes(integrationId)) {
31
+ const declared = _currentIntegrations.map(i => `"${i}"`).join(", ");
32
+ throw new Error(`Integration "${integrationId}" is not declared on node "${_currentNodeName}". ` +
33
+ `Declared integrations: [${declared}]. ` +
34
+ `Add "${integrationId}" to the node's integrations array.`);
35
+ }
36
+ const connectionId = await resolveConnectionId(config.sql, config.workflowName, _currentNodeName, integrationId, config.appSchema);
37
+ if (!connectionId) {
38
+ throw new Error(`No connection configured for integration "${integrationId}" ` +
39
+ `(workflow="${config.workflowName}", node="${_currentNodeName}"). ` +
40
+ `Configure it in the Dev UI or set a global default.`);
41
+ }
42
+ return config.integrationProvider.fetchCredentials(integrationId, connectionId);
43
+ },
18
44
  log: (message, level = "info") => {
19
45
  DBOS.logger[level](message);
20
46
  },
21
47
  };
22
48
  return ctx;
23
49
  }
50
+ /**
51
+ * Runtime config stored on globalThis so it's shared across module instances.
52
+ * This is necessary because jiti-loaded workflow files may import a different
53
+ * copy of this module than the compiled MCP server code that calls
54
+ * configureWorkflowRuntime().
55
+ * @internal
56
+ */
57
+ const POOL_KEY = Symbol.for("opflow.getWorkflowPool()");
58
+ const PROVIDER_KEY = Symbol.for("opflow.getWorkflowIntegrationProvider()");
59
+ const SCHEMA_KEY = Symbol.for("opflow.getWorkflowAppSchema()");
60
+ function getWorkflowPool() {
61
+ return globalThis[POOL_KEY] ?? null;
62
+ }
63
+ function getWorkflowIntegrationProvider() {
64
+ return globalThis[PROVIDER_KEY] ?? null;
65
+ }
66
+ function getWorkflowAppSchema() {
67
+ return globalThis[SCHEMA_KEY] ?? "public";
68
+ }
69
+ /**
70
+ * Configure the workflow runtime (called by factory)
71
+ * @internal
72
+ */
73
+ export function configureWorkflowRuntime(sql, integrationProvider, appSchema) {
74
+ globalThis[POOL_KEY] = sql;
75
+ globalThis[PROVIDER_KEY] = integrationProvider;
76
+ globalThis[SCHEMA_KEY] = appSchema;
77
+ }
24
78
  /**
25
79
  * Factory for creating workflow executables
26
80
  */
@@ -28,7 +82,12 @@ export const Workflow = {
28
82
  create(definition) {
29
83
  // Create the DBOS-registered workflow function
30
84
  async function workflowImpl(inputs) {
31
- const ctx = createDurableContext();
85
+ const ctx = createDurableContext({
86
+ sql: getWorkflowPool(),
87
+ integrationProvider: getWorkflowIntegrationProvider(),
88
+ workflowName: definition.name,
89
+ appSchema: getWorkflowAppSchema(),
90
+ });
32
91
  return definition.run(ctx, inputs);
33
92
  }
34
93
  // Register with DBOS (returns callable function)
@@ -46,5 +105,41 @@ export const Workflow = {
46
105
  execute: (_ctx, inputs) => durableWorkflow(inputs),
47
106
  };
48
107
  },
108
+ /**
109
+ * Create a wrapper workflow for running a node standalone.
110
+ * Uses the same _parentWorkflowName pattern as Agent.create() so
111
+ * connection resolution uses the real workflow name instead of the
112
+ * synthetic `_node_<name>` wrapper name.
113
+ */
114
+ createNodeWrapper(nodeName, node) {
115
+ const wrapperName = `_node_${nodeName}`;
116
+ // Parent workflow name for connection resolution (same pattern as Agent)
117
+ let _parentWorkflowName;
118
+ async function wrapperImpl(inputs) {
119
+ const ctx = createDurableContext({
120
+ sql: getWorkflowPool(),
121
+ integrationProvider: getWorkflowIntegrationProvider(),
122
+ workflowName: _parentWorkflowName ?? wrapperName,
123
+ appSchema: getWorkflowAppSchema(),
124
+ });
125
+ _parentWorkflowName = undefined;
126
+ return ctx.run(node, inputs);
127
+ }
128
+ const durableWrapper = DBOS.registerWorkflow(wrapperImpl, {
129
+ name: wrapperName,
130
+ });
131
+ return {
132
+ executable: {
133
+ name: wrapperName,
134
+ type: "workflow",
135
+ description: `Wrapper workflow for node ${nodeName}`,
136
+ version: 1,
137
+ inputSchema: node.inputSchema,
138
+ outputSchema: node.outputSchema,
139
+ execute: (_ctx, inputs) => durableWrapper(inputs),
140
+ },
141
+ setParentWorkflowName: (name) => { _parentWorkflowName = name; },
142
+ };
143
+ },
49
144
  };
50
145
  //# sourceMappingURL=workflow.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"workflow.js","sourceRoot":"","sources":["../src/workflow.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAuB1C;;GAEG;AACH,SAAS,oBAAoB;IAC3B,MAAM,GAAG,GAAoB;QAC3B,GAAG,EAAE,KAAK,EACR,UAAuC,EACvC,MAAc,EACI,EAAE;YACpB,iCAAiC;YACjC,MAAM,SAAS,GAAG,UAAU,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAEvD,IAAI,UAAU,CAAC,IAAI,KAAK,UAAU,IAAI,UAAU,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;gBAClE,4FAA4F;gBAC5F,6CAA6C;gBAC7C,OAAO,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;YAC5C,CAAC;YAED,wDAAwD;YACxD,OAAO,IAAI,CAAC,OAAO,CACjB,KAAK,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,SAAS,CAAC,EAC9C,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,CAC1B,CAAC;QACJ,CAAC;QAED,GAAG,EAAE,CAAC,OAAe,EAAE,QAAkB,MAAM,EAAE,EAAE;YACjD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC;QAC9B,CAAC;KACF,CAAC;IAEF,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,MAAM,CACJ,UAA+C;QAE/C,+CAA+C;QAC/C,KAAK,UAAU,YAAY,CAAC,MAAc;YACxC,MAAM,GAAG,GAAG,oBAAoB,EAAE,CAAC;YACnC,OAAO,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CA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H,OAAO;YACL,UAAU,EAAE;gBACV,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,UAAU;gBAChB,WAAW,EAAE,6BAA6B,QAAQ,EAAE;gBACpD,OAAO,EAAE,CAAC;gBACV,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,YAAY,EAAE,IAAI,CAAC,YAAY;gBAC/B,OAAO,EAAE,CAAC,IAAqB,EAAE,MAAc,EAAE,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC;aAC3E;YACD,qBAAqB,EAAE,CAAC,IAAI,EAAE,EAAE,GAAG,mBAAmB,GAAG,IAAI,CAAC,CAAC,CAAC;SACjE,CAAC;IACJ,CAAC;CACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "0pflow",
3
- "version": "0.1.0-dev.7aacb27",
3
+ "version": "0.1.0-dev.8ac4d9e",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,20 +18,24 @@
18
18
  }
19
19
  },
20
20
  "files": [
21
- "dist"
21
+ "dist",
22
+ "templates"
22
23
  ],
23
24
  "scripts": {
24
- "build": "tsc",
25
+ "build": "tsc --build && vite build dev-ui && chmod +x dist/cli/index.js",
25
26
  "test": "vitest run",
26
27
  "test:watch": "vitest"
27
28
  },
28
29
  "dependencies": {
29
30
  "@ai-sdk/anthropic": "^3.0.23",
30
31
  "@ai-sdk/openai": "^3.0.19",
32
+ "@clack/prompts": "^1.0.1",
31
33
  "@dbos-inc/dbos-sdk": "^4.7.9",
32
34
  "@mozilla/readability": "^0.6.0",
33
- "@tigerdata/mcp-boilerplate": "^0.8.0",
35
+ "@nangohq/node": "^0.45.0",
36
+ "@tigerdata/mcp-boilerplate": "^1.1.0",
34
37
  "ai": "^6.0.49",
38
+ "chokidar": "^4.0.0",
35
39
  "cli-table3": "^0.6.5",
36
40
  "commander": "^14.0.2",
37
41
  "dotenv": "^17.2.3",
@@ -39,14 +43,32 @@
39
43
  "handlebars": "^4.7.8",
40
44
  "jiti": "^2.6.1",
41
45
  "linkedom": "^0.18.12",
46
+ "node-pty": "1.2.0-beta.11",
42
47
  "pg": "^8.17.2",
43
48
  "picocolors": "^1.1.1",
44
- "postgres": "^3.4.8",
45
- "zod": "^3.25.76"
49
+ "tree-sitter-typescript": "^0.23.2",
50
+ "web-tree-sitter": "^0.24.7",
51
+ "ws": "^8.18.0",
52
+ "zod": "^4.3.5"
46
53
  },
47
54
  "devDependencies": {
55
+ "@nangohq/frontend": "^0.69.0",
56
+ "@tailwindcss/vite": "^4.0.0",
48
57
  "@types/pg": "^8.16.0",
58
+ "@types/react": "^19.0.0",
59
+ "@types/react-dom": "^19.0.0",
60
+ "@types/ws": "^8.5.0",
61
+ "@vitejs/plugin-react": "^4.3.0",
62
+ "@xterm/addon-fit": "^0.11.0",
63
+ "@xterm/addon-web-links": "^0.12.0",
64
+ "@xterm/xterm": "^6.0.0",
65
+ "@xyflow/react": "^12.0.0",
66
+ "react": "^19.0.0",
67
+ "react-dom": "^19.0.0",
68
+ "tailwindcss": "^4.0.0",
69
+ "tsx": "^4.21.0",
49
70
  "typescript": "^5.9.3",
71
+ "vite": "^6.0.0",
50
72
  "vitest": "^4.0.15"
51
73
  }
52
74
  }
@@ -0,0 +1,13 @@
1
+ # Since the ".env" file is gitignored, you can use the ".env.example" file to
2
+ # build a new ".env" file when you clone the repo. Keep this file up-to-date
3
+ # when you add new variables to `.env`.
4
+
5
+ # This file will be committed to version control, so make sure not to have any
6
+ # secrets in it. If you are cloning this repo, create a copy of this file named
7
+ # ".env" and populate it with your secrets.
8
+
9
+ # When adding additional environment variables, the schema in "/src/env.js"
10
+ # should be updated accordingly.
11
+
12
+ # Drizzle
13
+ DATABASE_URL="postgresql://postgres:password@localhost:5432/{{app_name}}"
@@ -0,0 +1,29 @@
1
+ # {{app_name}}
2
+
3
+ Built with [T3 Stack](https://create.t3.gg/).
4
+
5
+ ## What's next? How do I make an app with this?
6
+
7
+ We try to keep this project as simple as possible, so you can start with just the scaffolding we set up for you, and add additional things later when they become necessary.
8
+
9
+ If you are not familiar with the different technologies used in this project, please refer to the respective docs. If you still are in the wind, please join our [Discord](https://t3.gg/discord) and ask for help.
10
+
11
+ - [Next.js](https://nextjs.org)
12
+ - [NextAuth.js](https://next-auth.js.org)
13
+ - [Prisma](https://prisma.io)
14
+ - [Drizzle](https://orm.drizzle.team)
15
+ - [Tailwind CSS](https://tailwindcss.com)
16
+ - [tRPC](https://trpc.io)
17
+
18
+ ## Learn More
19
+
20
+ To learn more about the [T3 Stack](https://create.t3.gg/), take a look at the following resources:
21
+
22
+ - [Documentation](https://create.t3.gg/)
23
+ - [Learn the T3 Stack](https://create.t3.gg/en/faq#what-learning-resources-are-currently-available) — Check out these awesome tutorials
24
+
25
+ You can check out the [create-t3-app GitHub repository](https://github.com/t3-oss/create-t3-app) — your feedback and contributions are welcome!
26
+
27
+ ## How do I deploy this?
28
+
29
+ Follow our deployment guides for [Vercel](https://create.t3.gg/en/deployment/vercel), [Netlify](https://create.t3.gg/en/deployment/netlify) and [Docker](https://create.t3.gg/en/deployment/docker) for more information.
@@ -0,0 +1,81 @@
1
+ {
2
+ "$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
3
+ "root": true,
4
+ "vcs": {
5
+ "enabled": true,
6
+ "useIgnoreFile": true,
7
+ "clientKind": "git"
8
+ },
9
+ "assist": {
10
+ "enabled": true,
11
+ "actions": {
12
+ "recommended": true,
13
+ "source": {
14
+ "recommended": true,
15
+ "organizeImports": "on",
16
+ "useSortedAttributes": "on"
17
+ }
18
+ }
19
+ },
20
+ "formatter": {
21
+ "enabled": true,
22
+ "indentStyle": "space",
23
+ "indentWidth": 2
24
+ },
25
+ "linter": {
26
+ "enabled": true,
27
+ "rules": {
28
+ "recommended": true,
29
+ "correctness": {
30
+ "noUnusedImports": {
31
+ "level": "error",
32
+ "fix": "safe"
33
+ }
34
+ },
35
+ "nursery": {
36
+ "useSortedClasses": {
37
+ "level": "warn",
38
+ "fix": "safe",
39
+ "options": {
40
+ "functions": [
41
+ "clsx",
42
+ "cva",
43
+ "cn"
44
+ ]
45
+ }
46
+ }
47
+ }
48
+ }
49
+ },
50
+ "html": {
51
+ "formatter": {
52
+ "enabled": true
53
+ }
54
+ },
55
+ "javascript": {
56
+ "assist": {
57
+ "enabled": true
58
+ },
59
+ "formatter": {
60
+ "enabled": true
61
+ },
62
+ "linter": {
63
+ "enabled": true
64
+ }
65
+ },
66
+ "css": {
67
+ "assist": {
68
+ "enabled": true
69
+ },
70
+ "formatter": {
71
+ "enabled": true
72
+ },
73
+ "linter": {
74
+ "enabled": true
75
+ },
76
+ "parser": {
77
+ "cssModules": true,
78
+ "tailwindDirectives": true
79
+ }
80
+ }
81
+ }
@@ -0,0 +1,6 @@
1
+ name: {{app_name}}
2
+ language: node
3
+ system_database_url: ${DBOS_SYSTEM_DATABASE_URL}
4
+ runtimeConfig:
5
+ start:
6
+ - npm run start
@@ -0,0 +1,12 @@
1
+ import { type Config } from "drizzle-kit";
2
+
3
+ import { env } from "~/env";
4
+
5
+ export default {
6
+ schema: "./src/server/db/schema.ts",
7
+ dialect: "postgresql",
8
+ dbCredentials: {
9
+ url: env.DATABASE_URL,
10
+ },
11
+ schemaFilter: [env.DATABASE_SCHEMA],
12
+ } satisfies Config;
@@ -0,0 +1,8 @@
1
+ // generated/registry.ts
2
+ // Auto-generated by 0pflow build - do not edit directly
3
+
4
+ export const workflows = {};
5
+
6
+ export const agents = {};
7
+
8
+ export const nodes = {};
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful
3
+ * for Docker builds.
4
+ */
5
+ import "./src/env.js";
6
+
7
+ /** @type {import("next").NextConfig} */
8
+ const config = {
9
+ serverExternalPackages: ["@dbos-inc/dbos-sdk"],
10
+ };
11
+
12
+ export default config;
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "{{app_name}}",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "prebuild": "0pflow build",
8
+ "build": "next build",
9
+ "check": "biome check .",
10
+ "check:unsafe": "biome check --write --unsafe .",
11
+ "check:write": "biome check --write .",
12
+ "db:generate": "drizzle-kit generate",
13
+ "db:migrate": "drizzle-kit migrate",
14
+ "db:push": "drizzle-kit push",
15
+ "db:studio": "drizzle-kit studio",
16
+ "predev": "0pflow build",
17
+ "dev": "next dev --turbo",
18
+ "0pflow": "0pflow",
19
+ "preview": "next build && next start",
20
+ "start": "next start",
21
+ "typecheck": "tsc --noEmit"
22
+ },
23
+ "dependencies": {
24
+ "0pflow": "{{opflow_version}}",
25
+ "@nangohq/node": "^0.45.0",
26
+ "@dbos-inc/otel": "latest",
27
+ "@t3-oss/env-nextjs": "^0.13.10",
28
+ "@tanstack/react-query": "^5.90.19",
29
+ "@trpc/client": "^11.8.1",
30
+ "@trpc/react-query": "^11.8.1",
31
+ "@trpc/server": "^11.8.1",
32
+ "drizzle-orm": "^0.41.0",
33
+ "next": "^16.1.4",
34
+ "postgres": "^3.4.8",
35
+ "react": "^19.2.3",
36
+ "react-dom": "^19.2.3",
37
+ "server-only": "^0.0.1",
38
+ "superjson": "^2.2.6",
39
+ "zod": "^4.3.5"
40
+ },
41
+ "devDependencies": {
42
+ "@biomejs/biome": "^2.3.11",
43
+ "@tailwindcss/postcss": "^4.1.18",
44
+ "@types/node": "^25.0.9",
45
+ "@types/react": "^19.2.9",
46
+ "@types/react-dom": "^19.2.3",
47
+ "drizzle-kit": "^0.31.8",
48
+ "postcss": "^8.5.6",
49
+ "tailwindcss": "^4.1.18",
50
+ "tsx": "^4.21.0",
51
+ "typescript": "^5.9.3"
52
+ },
53
+ "ct3aMetadata": {
54
+ "initVersion": "7.40.0"
55
+ },
56
+ "packageManager": "npm@11.7.0"
57
+ }
@@ -0,0 +1,5 @@
1
+ export default {
2
+ plugins: {
3
+ "@tailwindcss/postcss": {},
4
+ },
5
+ };
Binary file
File without changes
@@ -0,0 +1,34 @@
1
+ import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
2
+ import { type NextRequest } from "next/server";
3
+
4
+ import { env } from "~/env";
5
+ import { appRouter } from "~/server/api/root";
6
+ import { createTRPCContext } from "~/server/api/trpc";
7
+
8
+ /**
9
+ * This wraps the `createTRPCContext` helper and provides the required context for the tRPC API when
10
+ * handling a HTTP request (e.g. when you make requests from Client Components).
11
+ */
12
+ const createContext = async (req: NextRequest) => {
13
+ return createTRPCContext({
14
+ headers: req.headers,
15
+ });
16
+ };
17
+
18
+ const handler = (req: NextRequest) =>
19
+ fetchRequestHandler({
20
+ endpoint: "/api/trpc",
21
+ req,
22
+ router: appRouter,
23
+ createContext: () => createContext(req),
24
+ onError:
25
+ env.NODE_ENV === "development"
26
+ ? ({ path, error }) => {
27
+ console.error(
28
+ `❌ tRPC failed on ${path ?? "<no-path>"}: ${error.message}`
29
+ );
30
+ }
31
+ : undefined,
32
+ });
33
+
34
+ export { handler as GET, handler as POST };
@@ -0,0 +1,37 @@
1
+ import { type NextRequest, NextResponse } from "next/server";
2
+ import { getPflow } from "~/lib/pflow";
3
+
4
+ export async function GET(
5
+ _request: NextRequest,
6
+ { params }: { params: Promise<{ name: string }> },
7
+ ) {
8
+ try {
9
+ const { name } = await params;
10
+ const pflow = await getPflow();
11
+ const result = await pflow.triggerWorkflow(name, {});
12
+ return NextResponse.json({ status: "completed", result });
13
+ } catch (error) {
14
+ return NextResponse.json(
15
+ { error: (error as Error).message },
16
+ { status: 500 },
17
+ );
18
+ }
19
+ }
20
+
21
+ export async function POST(
22
+ request: NextRequest,
23
+ { params }: { params: Promise<{ name: string }> },
24
+ ) {
25
+ try {
26
+ const { name } = await params;
27
+ const pflow = await getPflow();
28
+ const body: unknown = await request.json();
29
+ const result = await pflow.triggerWorkflow(name, body);
30
+ return NextResponse.json({ status: "completed", result });
31
+ } catch (error) {
32
+ return NextResponse.json(
33
+ { error: (error as Error).message },
34
+ { status: 500 },
35
+ );
36
+ }
37
+ }
@@ -0,0 +1,29 @@
1
+ import "~/styles/globals.css";
2
+
3
+ import { type Metadata } from "next";
4
+ import { Geist } from "next/font/google";
5
+
6
+ import { TRPCReactProvider } from "~/trpc/react";
7
+
8
+ export const metadata: Metadata = {
9
+ title: "{{app_name}}",
10
+ description: "{{product_brief}}",
11
+ icons: [{ rel: "icon", url: "/favicon.ico" }],
12
+ };
13
+
14
+ const geist = Geist({
15
+ subsets: ["latin"],
16
+ variable: "--font-geist-sans",
17
+ });
18
+
19
+ export default function RootLayout({
20
+ children,
21
+ }: Readonly<{ children: React.ReactNode }>) {
22
+ return (
23
+ <html lang="en" className={`${geist.variable}`}>
24
+ <body>
25
+ <TRPCReactProvider>{children}</TRPCReactProvider>
26
+ </body>
27
+ </html>
28
+ );
29
+ }
@@ -0,0 +1,18 @@
1
+ import { HydrateClient } from "~/trpc/server";
2
+
3
+ export default async function Home() {
4
+ return (
5
+ <HydrateClient>
6
+ <main className="flex min-h-screen flex-col items-center justify-center bg-gradient-to-b from-[#2e026d] to-[#15162c] text-white">
7
+ <div className="container flex flex-col items-center justify-center gap-12 px-4 py-16">
8
+ <h1 className="text-5xl font-extrabold tracking-tight sm:text-[5rem]">
9
+ {{app_name}}
10
+ </h1>
11
+ <p className="text-2xl text-white/70">
12
+ 0pflow workflow app
13
+ </p>
14
+ </div>
15
+ </main>
16
+ </HydrateClient>
17
+ );
18
+ }
@@ -0,0 +1,46 @@
1
+ import { createEnv } from "@t3-oss/env-nextjs";
2
+ import { z } from "zod";
3
+
4
+ export const env = createEnv({
5
+ /**
6
+ * Specify your server-side environment variables schema here. This way you can ensure the app
7
+ * isn't built with invalid env vars.
8
+ */
9
+ server: {
10
+ DATABASE_URL: z.string().url(),
11
+ DATABASE_SCHEMA: z.string().default("{{app_name}}"),
12
+ NODE_ENV: z
13
+ .enum(["development", "test", "production"])
14
+ .default("development"),
15
+ },
16
+
17
+ /**
18
+ * Specify your client-side environment variables schema here. This way you can ensure the app
19
+ * isn't built with invalid env vars. To expose them to the client, prefix them with
20
+ * `NEXT_PUBLIC_`.
21
+ */
22
+ client: {
23
+ // NEXT_PUBLIC_CLIENTVAR: z.string(),
24
+ },
25
+
26
+ /**
27
+ * You can't destruct `process.env` as a regular object in the Next.js edge runtimes (e.g.
28
+ * middlewares) or client-side so we need to destruct manually.
29
+ */
30
+ runtimeEnv: {
31
+ DATABASE_URL: process.env.DATABASE_URL,
32
+ DATABASE_SCHEMA: process.env.DATABASE_SCHEMA,
33
+ NODE_ENV: process.env.NODE_ENV,
34
+ // NEXT_PUBLIC_CLIENTVAR: process.env.NEXT_PUBLIC_CLIENTVAR,
35
+ },
36
+ /**
37
+ * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially
38
+ * useful for Docker builds.
39
+ */
40
+ skipValidation: !!process.env.SKIP_ENV_VALIDATION,
41
+ /**
42
+ * Makes it so that empty strings are treated as undefined. `SOME_VAR: z.string()` and
43
+ * `SOME_VAR=''` will throw an error.
44
+ */
45
+ emptyStringAsUndefined: true,
46
+ });
@@ -0,0 +1,6 @@
1
+ export async function register() {
2
+ if (process.env.NEXT_RUNTIME === "nodejs") {
3
+ const { getPflow } = await import("~/lib/pflow");
4
+ await getPflow();
5
+ }
6
+ }
@@ -0,0 +1,28 @@
1
+ import { create0pflow } from "0pflow";
2
+ import { workflows, agents, nodes } from "../../generated/registry";
3
+ import "server-only";
4
+
5
+ type PflowInstance = Awaited<ReturnType<typeof create0pflow>>;
6
+
7
+ let pflow: PflowInstance | null = null;
8
+ let initPromise: Promise<PflowInstance> | null = null;
9
+
10
+ export async function getPflow(): Promise<PflowInstance> {
11
+ if (pflow) return pflow;
12
+ if (initPromise) return initPromise;
13
+
14
+ initPromise = (async () => {
15
+ const instance = await create0pflow({
16
+ databaseUrl: process.env.DATABASE_URL!,
17
+ appName: "{{app_name}}",
18
+ workflows,
19
+ agents,
20
+ nodes,
21
+ });
22
+ console.log("0pflow initialized");
23
+ return instance;
24
+ })();
25
+
26
+ pflow = await initPromise;
27
+ return pflow;
28
+ }