@ebay-dt/bonfire-next 0.1.0 → 0.2.0-alpha.3

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 (41) hide show
  1. package/README.md +24 -10
  2. package/dist/client/index.d.ts +1 -1
  3. package/dist/client/index.d.ts.map +1 -1
  4. package/dist/client/index.js +1 -1
  5. package/dist/client/index.js.map +1 -1
  6. package/dist/client/lifecycle-provider.d.ts +5 -2
  7. package/dist/client/lifecycle-provider.d.ts.map +1 -1
  8. package/dist/client/lifecycle-provider.js +6 -5
  9. package/dist/client/lifecycle-provider.js.map +1 -1
  10. package/dist/server/agent-actions.d.ts +2 -1
  11. package/dist/server/agent-actions.d.ts.map +1 -1
  12. package/dist/server/agent-actions.js +27 -1
  13. package/dist/server/agent-actions.js.map +1 -1
  14. package/dist/server/auth-routes.d.ts +1 -2
  15. package/dist/server/auth-routes.d.ts.map +1 -1
  16. package/dist/server/auth-routes.js +0 -28
  17. package/dist/server/auth-routes.js.map +1 -1
  18. package/dist/server/create-bonfire-next.d.ts +17 -2
  19. package/dist/server/create-bonfire-next.d.ts.map +1 -1
  20. package/dist/server/create-bonfire-next.js +67 -10
  21. package/dist/server/create-bonfire-next.js.map +1 -1
  22. package/dist/server/entry-coordinator.d.ts +29 -0
  23. package/dist/server/entry-coordinator.d.ts.map +1 -0
  24. package/dist/server/entry-coordinator.js +84 -0
  25. package/dist/server/entry-coordinator.js.map +1 -0
  26. package/dist/server/index.d.ts +2 -0
  27. package/dist/server/index.d.ts.map +1 -1
  28. package/dist/server/index.js.map +1 -1
  29. package/dist/server/prototype-actions.d.ts +2 -1
  30. package/dist/server/prototype-actions.d.ts.map +1 -1
  31. package/dist/server/prototype-actions.js +23 -7
  32. package/dist/server/prototype-actions.js.map +1 -1
  33. package/dist/server/repository-actions.d.ts +24 -0
  34. package/dist/server/repository-actions.d.ts.map +1 -0
  35. package/dist/server/repository-actions.js +166 -0
  36. package/dist/server/repository-actions.js.map +1 -0
  37. package/dist/server/repository-routes.d.ts +12 -0
  38. package/dist/server/repository-routes.d.ts.map +1 -0
  39. package/dist/server/repository-routes.js +43 -0
  40. package/dist/server/repository-routes.js.map +1 -0
  41. package/package.json +5 -5
package/README.md CHANGED
@@ -302,6 +302,10 @@ export async function openInCursor(input: OpenInAgentInput) {
302
302
  export async function openInClaudeCode(input: OpenInClaudeCodeInput) {
303
303
  return bonfire.prototypes.agents.openInClaudeCode(input);
304
304
  }
305
+
306
+ export async function copyPrototypePath(input: OpenInAgentInput) {
307
+ return bonfire.prototypes.agents.copyPrototypePath(input);
308
+ }
305
309
  ```
306
310
 
307
311
  Pass these Server Action references to both packaged surfaces. The dashboard
@@ -310,7 +314,7 @@ page can provide them to owner cards:
310
314
  ```tsx
311
315
  <PrototypeDashboard
312
316
  {...model}
313
- agentActions={{ openInClaudeCode, openInCursor }}
317
+ agentActions={{ copyPrototypePath, openInClaudeCode, openInCursor }}
314
318
  user={user}
315
319
  />
316
320
  ```
@@ -318,7 +322,10 @@ page can provide them to owner cards:
318
322
  The root header accepts the same bindings:
319
323
 
320
324
  ```tsx
321
- <AppHeader {...headerProps} agentActions={{ openInClaudeCode, openInCursor }} />
325
+ <AppHeader
326
+ {...headerProps}
327
+ agentActions={{ copyPrototypePath, openInClaudeCode, openInCursor }}
328
+ />
322
329
  ```
323
330
 
324
331
  The card controls are owner-only icon buttons with tooltips. A successful card
@@ -326,13 +333,19 @@ launch navigates into the selected prototype; preflight and launch failures
326
333
  remain on the current page so their dialogs can be shown. The header controls
327
334
  are text menu rows and close the account popover when clicked. Both surfaces
328
335
  use the validated prototype reference on the server; browser props contain no
329
- absolute filesystem path or shell command.
336
+ absolute filesystem path or shell command. The optional path-copy action
337
+ resolves the path only after authorization and returns it solely for the
338
+ requested clipboard operation.
330
339
 
331
340
  Cursor requires `cursor` and Claude Code requires `claude` on the `PATH` inherited
332
- by the Bonfire server process. On macOS, Claude Code also requires
333
- `osascript`. A GUI-launched Node process may have a different `PATH` from an
334
- interactive shell, so restart Bonfire after changing a shell profile. Claude
335
- Code terminal preferences support Terminal.app, iTerm2, and Warp. The first
341
+ by the Bonfire server process. On macOS, terminal-based Claude Code launching
342
+ also requires `osascript`. Ghostty requires a version with macOS AppleScript
343
+ support. VS Code launching uses the `code` CLI when available and, on macOS,
344
+ falls back to the CLI bundled inside a standard VS Code or VS Code Insiders app
345
+ installation. It opens the prototype in a new window. A GUI-launched Node
346
+ process may have a different `PATH` from an interactive shell, so restart
347
+ Bonfire after changing a shell profile. Claude Code terminal
348
+ preferences support Terminal.app, iTerm2, Warp, Ghostty, and VS Code. The first
336
349
  launch without a preference presents the packaged terminal-selection dialog;
337
350
  the selected value is written server-side and then used for the launch.
338
351
 
@@ -499,9 +512,10 @@ export async function deployPrototype(input: PrototypeCommandInput) {
499
512
  ```
500
513
 
501
514
  Keep these wrappers thin: form validation, session lookup, lifecycle errors,
502
- and filesystem/Git operations remain in Bonfire. Save creates a local,
503
- path-scoped commit and discard restores/removes content only inside that path;
504
- neither operation pushes. The host should pass the Server Action references to
515
+ and filesystem/Git operations remain in Bonfire. In managed mode, Save creates
516
+ and pushes a path-scoped commit on the identity branch; a push failure preserves
517
+ the local commit. Discard restores/removes content only inside that path and
518
+ does not push. The host should pass the Server Action references to
505
519
  `NextLifecycleProvider` from `@ebay-dt/bonfire-next/client`. In development, the
506
520
  provider protects dirty internal navigation and reload/close attempts; in
507
521
  production it is disabled and the application remains public/read-only.
@@ -1,2 +1,2 @@
1
- export { NextLifecycleProvider, type NextLifecycleProviderProps, } from "./lifecycle-provider.js";
1
+ export { NextLifecycleProvider, useRepositoryActions, type NextLifecycleProviderProps, type RepositoryActionBindings, } from "./lifecycle-provider.js";
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,KAAK,0BAA0B,GAChC,MAAM,yBAAyB,CAAC","sourcesContent":["export {\n NextLifecycleProvider,\n type NextLifecycleProviderProps,\n} from \"./lifecycle-provider.js\";\n"]}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,GAC9B,MAAM,yBAAyB,CAAC","sourcesContent":["export {\n NextLifecycleProvider,\n useRepositoryActions,\n type NextLifecycleProviderProps,\n type RepositoryActionBindings,\n} from \"./lifecycle-provider.js\";\n"]}
@@ -1,2 +1,2 @@
1
- export { NextLifecycleProvider, } from "./lifecycle-provider.js";
1
+ export { NextLifecycleProvider, useRepositoryActions, } from "./lifecycle-provider.js";
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,GAEtB,MAAM,yBAAyB,CAAC","sourcesContent":["export {\n NextLifecycleProvider,\n type NextLifecycleProviderProps,\n} from \"./lifecycle-provider.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,oBAAoB,GAGrB,MAAM,yBAAyB,CAAC","sourcesContent":["export {\n NextLifecycleProvider,\n useRepositoryActions,\n type NextLifecycleProviderProps,\n type RepositoryActionBindings,\n} from \"./lifecycle-provider.js\";\n"]}
@@ -1,13 +1,16 @@
1
- import { type LifecycleActionBindings } from "@ebay-dt/bonfire-react/lifecycle";
1
+ import { type LifecycleActionBindings, type RepositoryActionBindings } from "@ebay-dt/bonfire-react/lifecycle";
2
2
  import type { BonfireIdentity } from "@ebay-dt/bonfire-core";
3
3
  import { type ReactNode } from "react";
4
+ export { useOptionalRepositoryActions as useRepositoryActions } from "@ebay-dt/bonfire-react/lifecycle";
5
+ export type { RepositoryActionBindings } from "@ebay-dt/bonfire-react/lifecycle";
4
6
  export type NextLifecycleProviderProps = {
5
7
  actions: LifecycleActionBindings;
8
+ repositoryActions?: RepositoryActionBindings;
6
9
  children: ReactNode;
7
10
  enabled?: boolean;
8
11
  user?: BonfireIdentity | null;
9
12
  dirtyEndpoint?: string;
10
13
  deploymentAvailable?: boolean;
11
14
  };
12
- export declare function NextLifecycleProvider({ actions, children, enabled, user, dirtyEndpoint, deploymentAvailable, }: NextLifecycleProviderProps): string | number | bigint | boolean | import("react").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | Iterable<ReactNode> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal | null | undefined> | null | undefined;
15
+ export declare function NextLifecycleProvider({ actions, repositoryActions, children, enabled, user, dirtyEndpoint, deploymentAvailable, }: NextLifecycleProviderProps): string | number | bigint | boolean | import("react").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | Iterable<ReactNode> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal | null | undefined> | null | undefined;
13
16
  //# sourceMappingURL=lifecycle-provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"lifecycle-provider.d.ts","sourceRoot":"","sources":["../../src/client/lifecycle-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,uBAAuB,EAG7B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAuB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5D,MAAM,MAAM,0BAA0B,GAAG;IACvC,OAAO,EAAE,uBAAuB,CAAC;IACjC,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,EACpC,OAAO,EACP,QAAQ,EACR,OAAc,EACd,IAAW,EACX,aAAa,EACb,mBAAmB,GACpB,EAAE,0BAA0B,+TAY5B","sourcesContent":["\"use client\";\n\nimport {\n createDirtyObservationAdapter,\n createLifecycleController,\n LifecycleProvider,\n type LifecycleActionBindings,\n type LifecycleNavigationAdapter,\n type LifecycleRouteAdapter,\n} from \"@ebay-dt/bonfire-react/lifecycle\";\nimport type { BonfireIdentity } from \"@ebay-dt/bonfire-core\";\nimport { usePathname, useRouter } from \"next/navigation.js\";\nimport { useEffect, useState, type ReactNode } from \"react\";\n\nexport type NextLifecycleProviderProps = {\n actions: LifecycleActionBindings;\n children: ReactNode;\n enabled?: boolean;\n user?: BonfireIdentity | null;\n dirtyEndpoint?: string;\n deploymentAvailable?: boolean;\n};\n\nexport function NextLifecycleProvider({\n actions,\n children,\n enabled = true,\n user = null,\n dirtyEndpoint,\n deploymentAvailable,\n}: NextLifecycleProviderProps) {\n if (!enabled) return children;\n return (\n <EnabledNextLifecycleProvider\n actions={actions}\n dirtyEndpoint={dirtyEndpoint}\n deploymentAvailable={deploymentAvailable}\n user={user}\n >\n {children}\n </EnabledNextLifecycleProvider>\n );\n}\n\nfunction EnabledNextLifecycleProvider({\n actions,\n children,\n user,\n dirtyEndpoint,\n deploymentAvailable,\n}: Pick<\n NextLifecycleProviderProps,\n \"actions\" | \"children\" | \"user\" | \"dirtyEndpoint\" | \"deploymentAvailable\"\n>) {\n const pathname = usePathname() ?? \"/\";\n const router = useRouter();\n const [route] = useState(() => {\n let currentPathname = pathname;\n const listeners = new Set<() => void>();\n const adapter: LifecycleRouteAdapter = {\n getPathname: () => currentPathname,\n subscribe: (listener) => {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n return {\n adapter,\n setPathname(nextPathname: string) {\n if (nextPathname === currentPathname) return;\n currentPathname = nextPathname;\n for (const listener of listeners) listener();\n },\n };\n });\n const [navigation] = useState<LifecycleNavigationAdapter>(() => ({\n pathname,\n push: (href) => router.push(href),\n replace: (href) => router.replace(href),\n back: () => router.back(),\n refresh: () => router.refresh(),\n }));\n const [dirtyObservation] = useState(() =>\n createDirtyObservationAdapter({ endpoint: dirtyEndpoint }),\n );\n const [controller] = useState(() =>\n createLifecycleController({\n actions,\n navigation,\n route: route.adapter,\n user,\n dirtyObservation,\n deploymentAvailable,\n }),\n );\n\n useEffect(() => {\n route.setPathname(pathname);\n }, [pathname, route]);\n\n return (\n <LifecycleProvider controller={controller}>{children}</LifecycleProvider>\n );\n}\n"]}
1
+ {"version":3,"file":"lifecycle-provider.d.ts","sourceRoot":"","sources":["../../src/client/lifecycle-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,uBAAuB,EAG5B,KAAK,wBAAwB,EAC9B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAuB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5D,OAAO,EAAE,4BAA4B,IAAI,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxG,YAAY,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAEjF,MAAM,MAAM,0BAA0B,GAAG;IACvC,OAAO,EAAE,uBAAuB,CAAC;IACjC,iBAAiB,CAAC,EAAE,wBAAwB,CAAC;IAC7C,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,EACpC,OAAO,EACP,iBAAiB,EACjB,QAAQ,EACR,OAAc,EACd,IAAW,EACX,aAAa,EACb,mBAAmB,GACpB,EAAE,0BAA0B,+TAa5B","sourcesContent":["\"use client\";\n\nimport {\n createDirtyObservationAdapter,\n createLifecycleController,\n LifecycleProvider,\n RepositoryActionsProvider,\n type LifecycleActionBindings,\n type LifecycleNavigationAdapter,\n type LifecycleRouteAdapter,\n type RepositoryActionBindings,\n} from \"@ebay-dt/bonfire-react/lifecycle\";\nimport type { BonfireIdentity } from \"@ebay-dt/bonfire-core\";\nimport { usePathname, useRouter } from \"next/navigation.js\";\nimport { useEffect, useState, type ReactNode } from \"react\";\n\nexport { useOptionalRepositoryActions as useRepositoryActions } from \"@ebay-dt/bonfire-react/lifecycle\";\nexport type { RepositoryActionBindings } from \"@ebay-dt/bonfire-react/lifecycle\";\n\nexport type NextLifecycleProviderProps = {\n actions: LifecycleActionBindings;\n repositoryActions?: RepositoryActionBindings;\n children: ReactNode;\n enabled?: boolean;\n user?: BonfireIdentity | null;\n dirtyEndpoint?: string;\n deploymentAvailable?: boolean;\n};\n\nexport function NextLifecycleProvider({\n actions,\n repositoryActions,\n children,\n enabled = true,\n user = null,\n dirtyEndpoint,\n deploymentAvailable,\n}: NextLifecycleProviderProps) {\n if (!enabled) return children;\n return (\n <EnabledNextLifecycleProvider\n actions={actions}\n repositoryActions={repositoryActions}\n dirtyEndpoint={dirtyEndpoint}\n deploymentAvailable={deploymentAvailable}\n user={user}\n >\n {children}\n </EnabledNextLifecycleProvider>\n );\n}\n\nfunction EnabledNextLifecycleProvider({\n actions,\n repositoryActions,\n children,\n user,\n dirtyEndpoint,\n deploymentAvailable,\n}: Pick<\n NextLifecycleProviderProps,\n \"actions\" | \"repositoryActions\" | \"children\" | \"user\" | \"dirtyEndpoint\" | \"deploymentAvailable\"\n>) {\n const pathname = usePathname() ?? \"/\";\n const router = useRouter();\n const [route] = useState(() => {\n let currentPathname = pathname;\n const listeners = new Set<() => void>();\n const adapter: LifecycleRouteAdapter = {\n getPathname: () => currentPathname,\n subscribe: (listener) => {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n return {\n adapter,\n setPathname(nextPathname: string) {\n if (nextPathname === currentPathname) return;\n currentPathname = nextPathname;\n for (const listener of listeners) listener();\n },\n };\n });\n const [navigation] = useState<LifecycleNavigationAdapter>(() => ({\n pathname,\n push: (href) => router.push(href),\n replace: (href) => router.replace(href),\n back: () => router.back(),\n refresh: () => router.refresh(),\n }));\n const [dirtyObservation] = useState(() =>\n createDirtyObservationAdapter({ endpoint: dirtyEndpoint }),\n );\n const [controller] = useState(() =>\n createLifecycleController({\n actions,\n navigation,\n route: route.adapter,\n user,\n dirtyObservation,\n deploymentAvailable,\n }),\n );\n\n useEffect(() => {\n route.setPathname(pathname);\n }, [pathname, route]);\n\n return (\n <RepositoryActionsProvider actions={repositoryActions}>\n <LifecycleProvider controller={controller}>{children}</LifecycleProvider>\n </RepositoryActionsProvider>\n );\n}\n"]}
@@ -1,14 +1,15 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import { createDirtyObservationAdapter, createLifecycleController, LifecycleProvider, } from "@ebay-dt/bonfire-react/lifecycle";
3
+ import { createDirtyObservationAdapter, createLifecycleController, LifecycleProvider, RepositoryActionsProvider, } from "@ebay-dt/bonfire-react/lifecycle";
4
4
  import { usePathname, useRouter } from "next/navigation.js";
5
5
  import { useEffect, useState } from "react";
6
- export function NextLifecycleProvider({ actions, children, enabled = true, user = null, dirtyEndpoint, deploymentAvailable, }) {
6
+ export { useOptionalRepositoryActions as useRepositoryActions } from "@ebay-dt/bonfire-react/lifecycle";
7
+ export function NextLifecycleProvider({ actions, repositoryActions, children, enabled = true, user = null, dirtyEndpoint, deploymentAvailable, }) {
7
8
  if (!enabled)
8
9
  return children;
9
- return (_jsx(EnabledNextLifecycleProvider, { actions: actions, dirtyEndpoint: dirtyEndpoint, deploymentAvailable: deploymentAvailable, user: user, children: children }));
10
+ return (_jsx(EnabledNextLifecycleProvider, { actions: actions, repositoryActions: repositoryActions, dirtyEndpoint: dirtyEndpoint, deploymentAvailable: deploymentAvailable, user: user, children: children }));
10
11
  }
11
- function EnabledNextLifecycleProvider({ actions, children, user, dirtyEndpoint, deploymentAvailable, }) {
12
+ function EnabledNextLifecycleProvider({ actions, repositoryActions, children, user, dirtyEndpoint, deploymentAvailable, }) {
12
13
  const pathname = usePathname() ?? "/";
13
14
  const router = useRouter();
14
15
  const [route] = useState(() => {
@@ -51,6 +52,6 @@ function EnabledNextLifecycleProvider({ actions, children, user, dirtyEndpoint,
51
52
  useEffect(() => {
52
53
  route.setPathname(pathname);
53
54
  }, [pathname, route]);
54
- return (_jsx(LifecycleProvider, { controller: controller, children: children }));
55
+ return (_jsx(RepositoryActionsProvider, { actions: repositoryActions, children: _jsx(LifecycleProvider, { controller: controller, children: children }) }));
55
56
  }
56
57
  //# sourceMappingURL=lifecycle-provider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lifecycle-provider.js","sourceRoot":"","sources":["../../src/client/lifecycle-provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EACL,6BAA6B,EAC7B,yBAAyB,EACzB,iBAAiB,GAIlB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AAW5D,MAAM,UAAU,qBAAqB,CAAC,EACpC,OAAO,EACP,QAAQ,EACR,OAAO,GAAG,IAAI,EACd,IAAI,GAAG,IAAI,EACX,aAAa,EACb,mBAAmB,GACQ;IAC3B,IAAI,CAAC,OAAO;QAAE,OAAO,QAAQ,CAAC;IAC9B,OAAO,CACL,KAAC,4BAA4B,IAC3B,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,aAAa,EAC5B,mBAAmB,EAAE,mBAAmB,EACxC,IAAI,EAAE,IAAI,YAET,QAAQ,GACoB,CAChC,CAAC;AACJ,CAAC;AAED,SAAS,4BAA4B,CAAC,EACpC,OAAO,EACP,QAAQ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Q,CAAC,GAAG,EAAE,CACvC,6BAA6B,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC,CAC3D,CAAC;IACF,MAAM,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CACjC,yBAAyB,CAAC;QACxB,OAAO;QACP,UAAU;QACV,KAAK,EAAE,KAAK,CAAC,OAAO;QACpB,IAAI;QACJ,gBAAgB;QAChB,mBAAmB;KACpB,CAAC,CACH,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;IAEtB,OAAO,CACL,KAAC,iBAAiB,IAAC,UAAU,EAAE,UAAU,YAAG,QAAQ,GAAqB,CAC1E,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport {\n createDirtyObservationAdapter,\n createLifecycleController,\n LifecycleProvider,\n type LifecycleActionBindings,\n type LifecycleNavigationAdapter,\n type LifecycleRouteAdapter,\n} from \"@ebay-dt/bonfire-react/lifecycle\";\nimport type { BonfireIdentity } from \"@ebay-dt/bonfire-core\";\nimport { usePathname, useRouter } from \"next/navigation.js\";\nimport { useEffect, useState, type ReactNode } from \"react\";\n\nexport type NextLifecycleProviderProps = {\n actions: LifecycleActionBindings;\n children: ReactNode;\n enabled?: boolean;\n user?: BonfireIdentity | null;\n dirtyEndpoint?: string;\n deploymentAvailable?: boolean;\n};\n\nexport function NextLifecycleProvider({\n actions,\n children,\n enabled = true,\n user = null,\n dirtyEndpoint,\n deploymentAvailable,\n}: NextLifecycleProviderProps) {\n if (!enabled) return children;\n return (\n <EnabledNextLifecycleProvider\n actions={actions}\n dirtyEndpoint={dirtyEndpoint}\n deploymentAvailable={deploymentAvailable}\n user={user}\n >\n {children}\n </EnabledNextLifecycleProvider>\n );\n}\n\nfunction EnabledNextLifecycleProvider({\n actions,\n children,\n user,\n dirtyEndpoint,\n deploymentAvailable,\n}: Pick<\n NextLifecycleProviderProps,\n \"actions\" | \"children\" | \"user\" | \"dirtyEndpoint\" | \"deploymentAvailable\"\n>) {\n const pathname = usePathname() ?? \"/\";\n const router = useRouter();\n const [route] = useState(() => {\n let currentPathname = pathname;\n const listeners = new Set<() => void>();\n const adapter: LifecycleRouteAdapter = {\n getPathname: () => currentPathname,\n subscribe: (listener) => {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n return {\n adapter,\n setPathname(nextPathname: string) {\n if (nextPathname === currentPathname) return;\n currentPathname = nextPathname;\n for (const listener of listeners) listener();\n },\n };\n });\n const [navigation] = useState<LifecycleNavigationAdapter>(() => ({\n pathname,\n push: (href) => router.push(href),\n replace: (href) => router.replace(href),\n back: () => router.back(),\n refresh: () => router.refresh(),\n }));\n const [dirtyObservation] = useState(() =>\n createDirtyObservationAdapter({ endpoint: dirtyEndpoint }),\n );\n const [controller] = useState(() =>\n createLifecycleController({\n actions,\n navigation,\n route: route.adapter,\n user,\n dirtyObservation,\n deploymentAvailable,\n }),\n );\n\n useEffect(() => {\n route.setPathname(pathname);\n }, [pathname, route]);\n\n return (\n <LifecycleProvider controller={controller}>{children}</LifecycleProvider>\n );\n}\n"]}
1
+ {"version":3,"file":"lifecycle-provider.js","sourceRoot":"","sources":["../../src/client/lifecycle-provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EACL,6BAA6B,EAC7B,yBAAyB,EACzB,iBAAiB,EACjB,yBAAyB,GAK1B,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AAE5D,OAAO,EAAE,4BAA4B,IAAI,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAaxG,MAAM,UAAU,qBAAqB,CAAC,EACpC,OAAO,EACP,iBAAiB,EACjB,QAAQ,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B,GAAG,EAAE,CAAC,CAAC;QAC/D,QAAQ;QACR,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;QACjC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;QACvC,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE;QACzB,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE;KAChC,CAAC,CAAC,CAAC;IACJ,MAAM,CAAC,gBAAgB,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CACvC,6BAA6B,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC,CAC3D,CAAC;IACF,MAAM,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CACjC,yBAAyB,CAAC;QACxB,OAAO;QACP,UAAU;QACV,KAAK,EAAE,KAAK,CAAC,OAAO;QACpB,IAAI;QACJ,gBAAgB;QAChB,mBAAmB;KACpB,CAAC,CACH,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;IAEtB,OAAO,CACL,KAAC,yBAAyB,IAAC,OAAO,EAAE,iBAAiB,YACnD,KAAC,iBAAiB,IAAC,UAAU,EAAE,UAAU,YAAG,QAAQ,GAAqB,GAC/C,CAC7B,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport {\n createDirtyObservationAdapter,\n createLifecycleController,\n LifecycleProvider,\n RepositoryActionsProvider,\n type LifecycleActionBindings,\n type LifecycleNavigationAdapter,\n type LifecycleRouteAdapter,\n type RepositoryActionBindings,\n} from \"@ebay-dt/bonfire-react/lifecycle\";\nimport type { BonfireIdentity } from \"@ebay-dt/bonfire-core\";\nimport { usePathname, useRouter } from \"next/navigation.js\";\nimport { useEffect, useState, type ReactNode } from \"react\";\n\nexport { useOptionalRepositoryActions as useRepositoryActions } from \"@ebay-dt/bonfire-react/lifecycle\";\nexport type { RepositoryActionBindings } from \"@ebay-dt/bonfire-react/lifecycle\";\n\nexport type NextLifecycleProviderProps = {\n actions: LifecycleActionBindings;\n repositoryActions?: RepositoryActionBindings;\n children: ReactNode;\n enabled?: boolean;\n user?: BonfireIdentity | null;\n dirtyEndpoint?: string;\n deploymentAvailable?: boolean;\n};\n\nexport function NextLifecycleProvider({\n actions,\n repositoryActions,\n children,\n enabled = true,\n user = null,\n dirtyEndpoint,\n deploymentAvailable,\n}: NextLifecycleProviderProps) {\n if (!enabled) return children;\n return (\n <EnabledNextLifecycleProvider\n actions={actions}\n repositoryActions={repositoryActions}\n dirtyEndpoint={dirtyEndpoint}\n deploymentAvailable={deploymentAvailable}\n user={user}\n >\n {children}\n </EnabledNextLifecycleProvider>\n );\n}\n\nfunction EnabledNextLifecycleProvider({\n actions,\n repositoryActions,\n children,\n user,\n dirtyEndpoint,\n deploymentAvailable,\n}: Pick<\n NextLifecycleProviderProps,\n \"actions\" | \"repositoryActions\" | \"children\" | \"user\" | \"dirtyEndpoint\" | \"deploymentAvailable\"\n>) {\n const pathname = usePathname() ?? \"/\";\n const router = useRouter();\n const [route] = useState(() => {\n let currentPathname = pathname;\n const listeners = new Set<() => void>();\n const adapter: LifecycleRouteAdapter = {\n getPathname: () => currentPathname,\n subscribe: (listener) => {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n return {\n adapter,\n setPathname(nextPathname: string) {\n if (nextPathname === currentPathname) return;\n currentPathname = nextPathname;\n for (const listener of listeners) listener();\n },\n };\n });\n const [navigation] = useState<LifecycleNavigationAdapter>(() => ({\n pathname,\n push: (href) => router.push(href),\n replace: (href) => router.replace(href),\n back: () => router.back(),\n refresh: () => router.refresh(),\n }));\n const [dirtyObservation] = useState(() =>\n createDirtyObservationAdapter({ endpoint: dirtyEndpoint }),\n );\n const [controller] = useState(() =>\n createLifecycleController({\n actions,\n navigation,\n route: route.adapter,\n user,\n dirtyObservation,\n deploymentAvailable,\n }),\n );\n\n useEffect(() => {\n route.setPathname(pathname);\n }, [pathname, route]);\n\n return (\n <RepositoryActionsProvider actions={repositoryActions}>\n <LifecycleProvider controller={controller}>{children}</LifecycleProvider>\n </RepositoryActionsProvider>\n );\n}\n"]}
@@ -1,8 +1,9 @@
1
- import { type AgentActionResult, type BonfireIdentity, type OpenInAgentInput, type OpenInClaudeCodeInput } from "@ebay-dt/bonfire-core";
1
+ import { type AgentActionResult, type BonfireIdentity, type OpenInAgentInput, type OpenInClaudeCodeInput, type PrototypePathValue } from "@ebay-dt/bonfire-core";
2
2
  import type { PrototypeAgentServiceLike } from "@ebay-dt/bonfire-node";
3
3
  export type PrototypeAgentActions = {
4
4
  openInCursor(input: OpenInAgentInput): Promise<AgentActionResult>;
5
5
  openInClaudeCode(input: OpenInClaudeCodeInput): Promise<AgentActionResult>;
6
+ copyPrototypePath(input: OpenInAgentInput): Promise<AgentActionResult<PrototypePathValue>>;
6
7
  };
7
8
  export type PrototypeAgentActionsOptions = {
8
9
  production: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"agent-actions.d.ts","sourceRoot":"","sources":["../../src/server/agent-actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAEvE,MAAM,MAAM,qBAAqB,GAAG;IAClC,YAAY,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAClE,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC5E,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IACzC,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,EAAE,MAAM,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC;IACtD,MAAM,EAAE,yBAAyB,GAAG,IAAI,CAAC;CAC1C,CAAC;AAkCF,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,4BAA4B,GACpC,qBAAqB,CA8CvB","sourcesContent":["import {\n AgentInputError,\n parseOpenInAgentInput,\n parseOpenInClaudeCodeInput,\n type AgentActionResult,\n type BonfireIdentity,\n type OpenInAgentInput,\n type OpenInClaudeCodeInput,\n} from \"@ebay-dt/bonfire-core\";\nimport type { PrototypeAgentServiceLike } from \"@ebay-dt/bonfire-node\";\n\nexport type PrototypeAgentActions = {\n openInCursor(input: OpenInAgentInput): Promise<AgentActionResult>;\n openInClaudeCode(input: OpenInClaudeCodeInput): Promise<AgentActionResult>;\n};\n\nexport type PrototypeAgentActionsOptions = {\n production: boolean;\n getCurrentUser: () => Promise<BonfireIdentity | null>;\n agents: PrototypeAgentServiceLike | null;\n};\n\nfunction forbidden() {\n return {\n ok: false,\n error: { code: \"forbidden\" },\n } satisfies AgentActionResult;\n}\n\nfunction unauthenticated() {\n return {\n ok: false,\n error: { code: \"unauthenticated\" },\n } satisfies AgentActionResult;\n}\n\nfunction invalidInput() {\n return {\n ok: false,\n error: { code: \"invalid-input\" },\n } satisfies AgentActionResult;\n}\n\nfunction unexpectedFailure() {\n return {\n ok: false,\n error: { code: \"launch-failed\" },\n } satisfies AgentActionResult;\n}\n\nfunction logUnexpectedFailure(operation: \"cursor\" | \"claude-code\") {\n console.error(`Bonfire ${operation} agent action failed unexpectedly.`);\n}\n\nexport function createPrototypeAgentActions(\n options: PrototypeAgentActionsOptions,\n): PrototypeAgentActions {\n async function openInCursor(input: OpenInAgentInput) {\n if (options.production || options.agents === null) return forbidden();\n\n let parsedInput;\n try {\n parsedInput = parseOpenInAgentInput(input);\n } catch (error) {\n if (error instanceof AgentInputError) return invalidInput();\n logUnexpectedFailure(\"cursor\");\n return unexpectedFailure();\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return unauthenticated();\n return await options.agents.openInCursor(identity, parsedInput);\n } catch {\n logUnexpectedFailure(\"cursor\");\n return unexpectedFailure();\n }\n }\n\n async function openInClaudeCode(input: OpenInClaudeCodeInput) {\n if (options.production || options.agents === null) return forbidden();\n\n let parsedInput;\n try {\n parsedInput = parseOpenInClaudeCodeInput(input);\n } catch (error) {\n if (error instanceof AgentInputError) return invalidInput();\n logUnexpectedFailure(\"claude-code\");\n return unexpectedFailure();\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return unauthenticated();\n return await options.agents.openInClaudeCode(identity, parsedInput);\n } catch {\n logUnexpectedFailure(\"claude-code\");\n return unexpectedFailure();\n }\n }\n\n return { openInCursor, openInClaudeCode };\n}\n"]}
1
+ {"version":3,"file":"agent-actions.d.ts","sourceRoot":"","sources":["../../src/server/agent-actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAEvE,MAAM,MAAM,qBAAqB,GAAG;IAClC,YAAY,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAClE,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC3E,iBAAiB,CACf,KAAK,EAAE,gBAAgB,GACtB,OAAO,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,CAAC,CAAC;CACnD,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IACzC,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,EAAE,MAAM,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC;IACtD,MAAM,EAAE,yBAAyB,GAAG,IAAI,CAAC;CAC1C,CAAC;AAkCF,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,4BAA4B,GACpC,qBAAqB,CA0EvB","sourcesContent":["import {\n AgentInputError,\n parseOpenInAgentInput,\n parseOpenInClaudeCodeInput,\n type AgentActionResult,\n type BonfireIdentity,\n type OpenInAgentInput,\n type OpenInClaudeCodeInput,\n type PrototypePathValue,\n} from \"@ebay-dt/bonfire-core\";\nimport type { PrototypeAgentServiceLike } from \"@ebay-dt/bonfire-node\";\n\nexport type PrototypeAgentActions = {\n openInCursor(input: OpenInAgentInput): Promise<AgentActionResult>;\n openInClaudeCode(input: OpenInClaudeCodeInput): Promise<AgentActionResult>;\n copyPrototypePath(\n input: OpenInAgentInput,\n ): Promise<AgentActionResult<PrototypePathValue>>;\n};\n\nexport type PrototypeAgentActionsOptions = {\n production: boolean;\n getCurrentUser: () => Promise<BonfireIdentity | null>;\n agents: PrototypeAgentServiceLike | null;\n};\n\nfunction forbidden<Value = never>() {\n return {\n ok: false,\n error: { code: \"forbidden\" },\n } satisfies AgentActionResult<Value>;\n}\n\nfunction unauthenticated<Value = never>() {\n return {\n ok: false,\n error: { code: \"unauthenticated\" },\n } satisfies AgentActionResult<Value>;\n}\n\nfunction invalidInput<Value = never>() {\n return {\n ok: false,\n error: { code: \"invalid-input\" },\n } satisfies AgentActionResult<Value>;\n}\n\nfunction unexpectedFailure() {\n return {\n ok: false,\n error: { code: \"launch-failed\" },\n } satisfies AgentActionResult;\n}\n\nfunction logUnexpectedFailure(operation: \"cursor\" | \"claude-code\" | \"path\") {\n console.error(`Bonfire ${operation} agent action failed unexpectedly.`);\n}\n\nexport function createPrototypeAgentActions(\n options: PrototypeAgentActionsOptions,\n): PrototypeAgentActions {\n async function openInCursor(input: OpenInAgentInput) {\n if (options.production || options.agents === null) return forbidden();\n\n let parsedInput;\n try {\n parsedInput = parseOpenInAgentInput(input);\n } catch (error) {\n if (error instanceof AgentInputError) return invalidInput();\n logUnexpectedFailure(\"cursor\");\n return unexpectedFailure();\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return unauthenticated();\n return await options.agents.openInCursor(identity, parsedInput);\n } catch {\n logUnexpectedFailure(\"cursor\");\n return unexpectedFailure();\n }\n }\n\n async function openInClaudeCode(input: OpenInClaudeCodeInput) {\n if (options.production || options.agents === null) return forbidden();\n\n let parsedInput;\n try {\n parsedInput = parseOpenInClaudeCodeInput(input);\n } catch (error) {\n if (error instanceof AgentInputError) return invalidInput();\n logUnexpectedFailure(\"claude-code\");\n return unexpectedFailure();\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return unauthenticated();\n return await options.agents.openInClaudeCode(identity, parsedInput);\n } catch {\n logUnexpectedFailure(\"claude-code\");\n return unexpectedFailure();\n }\n }\n\n async function copyPrototypePath(input: OpenInAgentInput) {\n if (\n options.production ||\n options.agents === null ||\n options.agents.copyPrototypePath === undefined\n )\n return forbidden<PrototypePathValue>();\n\n let parsedInput;\n try {\n parsedInput = parseOpenInAgentInput(input);\n } catch (error) {\n if (error instanceof AgentInputError)\n return invalidInput<PrototypePathValue>();\n logUnexpectedFailure(\"path\");\n return unexpectedFailure() as AgentActionResult<PrototypePathValue>;\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return unauthenticated<PrototypePathValue>();\n return await options.agents.copyPrototypePath(identity, parsedInput);\n } catch {\n logUnexpectedFailure(\"path\");\n return unexpectedFailure() as AgentActionResult<PrototypePathValue>;\n }\n }\n\n return { openInCursor, openInClaudeCode, copyPrototypePath };\n}\n"]}
@@ -75,6 +75,32 @@ export function createPrototypeAgentActions(options) {
75
75
  return unexpectedFailure();
76
76
  }
77
77
  }
78
- return { openInCursor, openInClaudeCode };
78
+ async function copyPrototypePath(input) {
79
+ if (options.production ||
80
+ options.agents === null ||
81
+ options.agents.copyPrototypePath === undefined)
82
+ return forbidden();
83
+ let parsedInput;
84
+ try {
85
+ parsedInput = parseOpenInAgentInput(input);
86
+ }
87
+ catch (error) {
88
+ if (error instanceof AgentInputError)
89
+ return invalidInput();
90
+ logUnexpectedFailure("path");
91
+ return unexpectedFailure();
92
+ }
93
+ try {
94
+ const identity = await options.getCurrentUser();
95
+ if (identity === null)
96
+ return unauthenticated();
97
+ return await options.agents.copyPrototypePath(identity, parsedInput);
98
+ }
99
+ catch {
100
+ logUnexpectedFailure("path");
101
+ return unexpectedFailure();
102
+ }
103
+ }
104
+ return { openInCursor, openInClaudeCode, copyPrototypePath };
79
105
  }
80
106
  //# sourceMappingURL=agent-actions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent-actions.js","sourceRoot":"","sources":["../../src/server/agent-actions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,0BAA0B,GAK3B,MAAM,uBAAuB,CAAC;AAc/B,SAAS,SAAS;IAChB,OAAO;QACL,EAAE,EAAE,KAAK;QACT,KAAK,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE;KACD,CAAC;AAChC,CAAC;AAED,SAAS,eAAe;IACtB,OAAO;QACL,EAAE,EAAE,KAAK;QACT,KAAK,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE;KACP,CAAC;AAChC,CAAC;AAED,SAAS,YAAY;IACnB,OAAO;QACL,EAAE,EAAE,KAAK;QACT,KAAK,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE;KACL,CAAC;AAChC,CAAC;AAED,SAAS,iBAAiB;IACxB,OAAO;QACL,EAAE,EAAE,KAAK;QACT,KAAK,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE;KACL,CAAC;AAChC,CAAC;AAED,SAAS,oBAAoB,CAAC,SAAmC;IAC/D,OAAO,CAAC,KAAK,CAAC,WAAW,SAAS,oCAAoC,CAAC,CAAC;AAC1E,CAAC;AAED,MAAM,UAAU,2BAA2B,CACzC,OAAqC;IAErC,KAAK,UAAU,YAAY,CAAC,KAAuB;QACjD,IAAI,OAAO,C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AAI;gBAAE,OAAO,eAAe,EAAE,CAAC;YAChD,OAAO,MAAM,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QACtE,CAAC;QAAC,MAAM,CAAC;YACP,oBAAoB,CAAC,aAAa,CAAC,CAAC;YACpC,OAAO,iBAAiB,EAAE,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAC5C,CAAC","sourcesContent":["import {\n AgentInputError,\n parseOpenInAgentInput,\n parseOpenInClaudeCodeInput,\n type AgentActionResult,\n type BonfireIdentity,\n type OpenInAgentInput,\n type OpenInClaudeCodeInput,\n} from \"@ebay-dt/bonfire-core\";\nimport type { PrototypeAgentServiceLike } from \"@ebay-dt/bonfire-node\";\n\nexport type PrototypeAgentActions = {\n openInCursor(input: OpenInAgentInput): Promise<AgentActionResult>;\n openInClaudeCode(input: OpenInClaudeCodeInput): Promise<AgentActionResult>;\n};\n\nexport type PrototypeAgentActionsOptions = {\n production: boolean;\n getCurrentUser: () => Promise<BonfireIdentity | null>;\n agents: PrototypeAgentServiceLike | null;\n};\n\nfunction forbidden() {\n return {\n ok: false,\n error: { code: \"forbidden\" },\n } satisfies AgentActionResult;\n}\n\nfunction unauthenticated() {\n return {\n ok: false,\n error: { code: \"unauthenticated\" },\n } satisfies AgentActionResult;\n}\n\nfunction invalidInput() {\n return {\n ok: false,\n error: { code: \"invalid-input\" },\n } satisfies AgentActionResult;\n}\n\nfunction unexpectedFailure() {\n return {\n ok: false,\n error: { code: \"launch-failed\" },\n } satisfies AgentActionResult;\n}\n\nfunction logUnexpectedFailure(operation: \"cursor\" | \"claude-code\") {\n console.error(`Bonfire ${operation} agent action failed unexpectedly.`);\n}\n\nexport function createPrototypeAgentActions(\n options: PrototypeAgentActionsOptions,\n): PrototypeAgentActions {\n async function openInCursor(input: OpenInAgentInput) {\n if (options.production || options.agents === null) return forbidden();\n\n let parsedInput;\n try {\n parsedInput = parseOpenInAgentInput(input);\n } catch (error) {\n if (error instanceof AgentInputError) return invalidInput();\n logUnexpectedFailure(\"cursor\");\n return unexpectedFailure();\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return unauthenticated();\n return await options.agents.openInCursor(identity, parsedInput);\n } catch {\n logUnexpectedFailure(\"cursor\");\n return unexpectedFailure();\n }\n }\n\n async function openInClaudeCode(input: OpenInClaudeCodeInput) {\n if (options.production || options.agents === null) return forbidden();\n\n let parsedInput;\n try {\n parsedInput = parseOpenInClaudeCodeInput(input);\n } catch (error) {\n if (error instanceof AgentInputError) return invalidInput();\n logUnexpectedFailure(\"claude-code\");\n return unexpectedFailure();\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return unauthenticated();\n return await options.agents.openInClaudeCode(identity, parsedInput);\n } catch {\n logUnexpectedFailure(\"claude-code\");\n return unexpectedFailure();\n }\n }\n\n return { openInCursor, openInClaudeCode };\n}\n"]}
1
+ {"version":3,"file":"agent-actions.js","sourceRoot":"","sources":["../../src/server/agent-actions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,0BAA0B,GAM3B,MAAM,uBAAuB,CAAC;AAiB/B,SAAS,SAAS;IAChB,OAAO;QACL,EAAE,EAAE,KAAK;QACT,KAAK,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE;KACM,CAAC;AACvC,CAAC;AAED,SAAS,eAAe;IACtB,OAAO;QACL,EAAE,EAAE,KAAK;QACT,KAAK,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE;KACA,CAAC;AACvC,CAAC;AAED,SAAS,YAAY;IACnB,OAAO;QACL,EAAE,EAAE,KAAK;QACT,KAAK,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE;KACE,CAAC;AACvC,CAAC;AAED,SAAS,iBAAiB;IACxB,OAAO;QACL,EAAE,EAAE,KAAK;QACT,KAAK,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE;K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,CAAC;YAC7B,OAAO,iBAAiB,EAA2C,CAAC;QACtE,CAAC;IACH,CAAC;IAED,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,CAAC;AAC/D,CAAC","sourcesContent":["import {\n AgentInputError,\n parseOpenInAgentInput,\n parseOpenInClaudeCodeInput,\n type AgentActionResult,\n type BonfireIdentity,\n type OpenInAgentInput,\n type OpenInClaudeCodeInput,\n type PrototypePathValue,\n} from \"@ebay-dt/bonfire-core\";\nimport type { PrototypeAgentServiceLike } from \"@ebay-dt/bonfire-node\";\n\nexport type PrototypeAgentActions = {\n openInCursor(input: OpenInAgentInput): Promise<AgentActionResult>;\n openInClaudeCode(input: OpenInClaudeCodeInput): Promise<AgentActionResult>;\n copyPrototypePath(\n input: OpenInAgentInput,\n ): Promise<AgentActionResult<PrototypePathValue>>;\n};\n\nexport type PrototypeAgentActionsOptions = {\n production: boolean;\n getCurrentUser: () => Promise<BonfireIdentity | null>;\n agents: PrototypeAgentServiceLike | null;\n};\n\nfunction forbidden<Value = never>() {\n return {\n ok: false,\n error: { code: \"forbidden\" },\n } satisfies AgentActionResult<Value>;\n}\n\nfunction unauthenticated<Value = never>() {\n return {\n ok: false,\n error: { code: \"unauthenticated\" },\n } satisfies AgentActionResult<Value>;\n}\n\nfunction invalidInput<Value = never>() {\n return {\n ok: false,\n error: { code: \"invalid-input\" },\n } satisfies AgentActionResult<Value>;\n}\n\nfunction unexpectedFailure() {\n return {\n ok: false,\n error: { code: \"launch-failed\" },\n } satisfies AgentActionResult;\n}\n\nfunction logUnexpectedFailure(operation: \"cursor\" | \"claude-code\" | \"path\") {\n console.error(`Bonfire ${operation} agent action failed unexpectedly.`);\n}\n\nexport function createPrototypeAgentActions(\n options: PrototypeAgentActionsOptions,\n): PrototypeAgentActions {\n async function openInCursor(input: OpenInAgentInput) {\n if (options.production || options.agents === null) return forbidden();\n\n let parsedInput;\n try {\n parsedInput = parseOpenInAgentInput(input);\n } catch (error) {\n if (error instanceof AgentInputError) return invalidInput();\n logUnexpectedFailure(\"cursor\");\n return unexpectedFailure();\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return unauthenticated();\n return await options.agents.openInCursor(identity, parsedInput);\n } catch {\n logUnexpectedFailure(\"cursor\");\n return unexpectedFailure();\n }\n }\n\n async function openInClaudeCode(input: OpenInClaudeCodeInput) {\n if (options.production || options.agents === null) return forbidden();\n\n let parsedInput;\n try {\n parsedInput = parseOpenInClaudeCodeInput(input);\n } catch (error) {\n if (error instanceof AgentInputError) return invalidInput();\n logUnexpectedFailure(\"claude-code\");\n return unexpectedFailure();\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return unauthenticated();\n return await options.agents.openInClaudeCode(identity, parsedInput);\n } catch {\n logUnexpectedFailure(\"claude-code\");\n return unexpectedFailure();\n }\n }\n\n async function copyPrototypePath(input: OpenInAgentInput) {\n if (\n options.production ||\n options.agents === null ||\n options.agents.copyPrototypePath === undefined\n )\n return forbidden<PrototypePathValue>();\n\n let parsedInput;\n try {\n parsedInput = parseOpenInAgentInput(input);\n } catch (error) {\n if (error instanceof AgentInputError)\n return invalidInput<PrototypePathValue>();\n logUnexpectedFailure(\"path\");\n return unexpectedFailure() as AgentActionResult<PrototypePathValue>;\n }\n\n try {\n const identity = await options.getCurrentUser();\n if (identity === null) return unauthenticated<PrototypePathValue>();\n return await options.agents.copyPrototypePath(identity, parsedInput);\n } catch {\n logUnexpectedFailure(\"path\");\n return unexpectedFailure() as AgentActionResult<PrototypePathValue>;\n }\n }\n\n return { openInCursor, openInClaudeCode, copyPrototypePath };\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { type BranchPreparationValue, type LifecycleResult, type BonfireIdentity } from "@ebay-dt/bonfire-core";
1
+ import type { BonfireIdentity } from "@ebay-dt/bonfire-core";
2
2
  import { type GitHubCliClientLike } from "@ebay-dt/bonfire-node";
3
3
  import { NextResponse } from "next/server.js";
4
4
  import type { NextRequest } from "next/server.js";
@@ -7,7 +7,6 @@ export type AuthRouteOptions = {
7
7
  githubCli: GitHubCliClientLike;
8
8
  createSession: (identity: BonfireIdentity) => Promise<void>;
9
9
  clearSession: () => Promise<void>;
10
- prepareIdentity?: (identity: BonfireIdentity) => Promise<LifecycleResult<BranchPreparationValue>>;
11
10
  };
12
11
  export declare function createAuthRoutes(options: AuthRouteOptions): {
13
12
  login: (request: NextRequest) => Promise<NextResponse<unknown>>;
@@ -1 +1 @@
1
- {"version":3,"file":"auth-routes.d.ts","sourceRoot":"","sources":["../../src/server/auth-routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,KAAK,eAAe,EACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,mBAAmB,CAAC;IAC/B,aAAa,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,YAAY,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,eAAe,CAAC,EAAE,CAChB,QAAQ,EAAE,eAAe,KACtB,OAAO,CAAC,eAAe,CAAC,sBAAsB,CAAC,CAAC,CAAC;CACvD,CAAC;AAqCF,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,gBAAgB;qBAC1B,WAAW;;sBAqEV,WAAW;EAM3C","sourcesContent":["import {\n lifecycleFailure,\n lifecycleSuccess,\n type BranchPreparationValue,\n type LifecycleResult,\n type BonfireIdentity,\n} from \"@ebay-dt/bonfire-core\";\nimport {\n GitHubCliError,\n type GitHubCliClientLike,\n} from \"@ebay-dt/bonfire-node\";\nimport { NextResponse } from \"next/server.js\";\nimport type { NextRequest } from \"next/server.js\";\n\nexport type AuthRouteOptions = {\n production: boolean;\n githubCli: GitHubCliClientLike;\n createSession: (identity: BonfireIdentity) => Promise<void>;\n clearSession: () => Promise<void>;\n prepareIdentity?: (\n identity: BonfireIdentity,\n ) => Promise<LifecycleResult<BranchPreparationValue>>;\n};\n\nfunction notFound() {\n return new NextResponse(null, { status: 404 });\n}\n\nfunction redirect(request: NextRequest, path: string, status = 307) {\n return NextResponse.redirect(new URL(path, request.url), status);\n}\n\nfunction logLoginFailure(message: string) {\n console.error(`Bonfire GitHub CLI login failed: ${message}`);\n}\n\nfunction logBranchPreparationFailure() {\n console.error(\"Bonfire branch preparation failed.\");\n}\n\nasync function prepareIdentity(\n options: AuthRouteOptions,\n identity: BonfireIdentity,\n) {\n try {\n return (\n (await options.prepareIdentity?.(identity)) ??\n lifecycleSuccess({ status: \"disabled\" } satisfies BranchPreparationValue)\n );\n } catch {\n return lifecycleFailure(\"unexpected-failure\");\n }\n}\n\nfunction branchPreparationFailed(request: NextRequest): NextResponse {\n logBranchPreparationFailure();\n return redirect(request, \"/login?error=branch_prepare_failed\");\n}\n\nexport function createAuthRoutes(options: AuthRouteOptions) {\n async function login(request: NextRequest) {\n if (options.production) return notFound();\n\n let user: BonfireIdentity;\n try {\n user = await options.githubCli.getUser();\n } catch (error) {\n if (\n error instanceof GitHubCliError &&\n error.reason === \"unauthenticated\"\n ) {\n try {\n const webLogin = await options.githubCli.startWebLogin();\n const loginUrl = new URL(\"/login\", request.url);\n loginUrl.searchParams.set(\"auth\", \"started\");\n if (webLogin.code) loginUrl.searchParams.set(\"code\", webLogin.code);\n return NextResponse.redirect(loginUrl);\n } catch {\n logLoginFailure(\"device login could not be started\");\n }\n }\n\n logLoginFailure(\"the configured GitHub CLI request failed\");\n return redirect(request, \"/login?error=gh_cli_failed\");\n }\n\n const preparation = await prepareIdentity(options, user);\n if (!preparation.ok) return branchPreparationFailed(request);\n\n try {\n await options.createSession(user);\n return redirect(request, \"/\");\n } catch {\n logLoginFailure(\"the configured GitHub CLI request failed\");\n return redirect(request, \"/login?error=gh_cli_failed\");\n }\n }\n\n async function status() {\n const response = options.production\n ? notFound()\n : await (async () => {\n let user: BonfireIdentity;\n try {\n user = await options.githubCli.getUser();\n } catch {\n return NextResponse.json({ authenticated: false });\n }\n\n const preparation = await prepareIdentity(options, user);\n if (!preparation.ok) {\n logBranchPreparationFailure();\n return NextResponse.json({\n authenticated: false,\n error: \"branch_prepare_failed\" as const,\n });\n }\n\n try {\n await options.createSession(user);\n return NextResponse.json({ authenticated: true });\n } catch {\n return NextResponse.json({ authenticated: false });\n }\n })();\n response.headers.set(\"Cache-Control\", \"no-store\");\n return response;\n }\n\n async function logout(request: NextRequest) {\n await options.clearSession();\n return redirect(request, options.production ? \"/\" : \"/login\", 303);\n }\n\n return { login, status, logout };\n}\n"]}
1
+ {"version":3,"file":"auth-routes.d.ts","sourceRoot":"","sources":["../../src/server/auth-routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,mBAAmB,CAAC;IAC/B,aAAa,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,YAAY,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACnC,CAAC;AAcF,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,gBAAgB;qBAC1B,WAAW;;sBAyDV,WAAW;EAM3C","sourcesContent":["import type { BonfireIdentity } from \"@ebay-dt/bonfire-core\";\nimport {\n GitHubCliError,\n type GitHubCliClientLike,\n} from \"@ebay-dt/bonfire-node\";\nimport { NextResponse } from \"next/server.js\";\nimport type { NextRequest } from \"next/server.js\";\n\nexport type AuthRouteOptions = {\n production: boolean;\n githubCli: GitHubCliClientLike;\n createSession: (identity: BonfireIdentity) => Promise<void>;\n clearSession: () => Promise<void>;\n};\n\nfunction notFound() {\n return new NextResponse(null, { status: 404 });\n}\n\nfunction redirect(request: NextRequest, path: string, status = 307) {\n return NextResponse.redirect(new URL(path, request.url), status);\n}\n\nfunction logLoginFailure(message: string) {\n console.error(`Bonfire GitHub CLI login failed: ${message}`);\n}\n\nexport function createAuthRoutes(options: AuthRouteOptions) {\n async function login(request: NextRequest) {\n if (options.production) return notFound();\n\n let user: BonfireIdentity;\n try {\n user = await options.githubCli.getUser();\n } catch (error) {\n if (\n error instanceof GitHubCliError &&\n error.reason === \"unauthenticated\"\n ) {\n try {\n const webLogin = await options.githubCli.startWebLogin();\n const loginUrl = new URL(\"/login\", request.url);\n loginUrl.searchParams.set(\"auth\", \"started\");\n if (webLogin.code) loginUrl.searchParams.set(\"code\", webLogin.code);\n return NextResponse.redirect(loginUrl);\n } catch {\n logLoginFailure(\"device login could not be started\");\n }\n }\n\n logLoginFailure(\"the configured GitHub CLI request failed\");\n return redirect(request, \"/login?error=gh_cli_failed\");\n }\n\n try {\n await options.createSession(user);\n return redirect(request, \"/\");\n } catch {\n logLoginFailure(\"the configured GitHub CLI request failed\");\n return redirect(request, \"/login?error=gh_cli_failed\");\n }\n }\n\n async function status() {\n const response = options.production\n ? notFound()\n : await (async () => {\n let user: BonfireIdentity;\n try {\n user = await options.githubCli.getUser();\n } catch {\n return NextResponse.json({ authenticated: false });\n }\n\n try {\n await options.createSession(user);\n return NextResponse.json({ authenticated: true });\n } catch {\n return NextResponse.json({ authenticated: false });\n }\n })();\n response.headers.set(\"Cache-Control\", \"no-store\");\n return response;\n }\n\n async function logout(request: NextRequest) {\n await options.clearSession();\n return redirect(request, options.production ? \"/\" : \"/login\", 303);\n }\n\n return { login, status, logout };\n}\n"]}
@@ -1,4 +1,3 @@
1
- import { lifecycleFailure, lifecycleSuccess, } from "@ebay-dt/bonfire-core";
2
1
  import { GitHubCliError, } from "@ebay-dt/bonfire-node";
3
2
  import { NextResponse } from "next/server.js";
4
3
  function notFound() {
@@ -10,22 +9,6 @@ function redirect(request, path, status = 307) {
10
9
  function logLoginFailure(message) {
11
10
  console.error(`Bonfire GitHub CLI login failed: ${message}`);
12
11
  }
13
- function logBranchPreparationFailure() {
14
- console.error("Bonfire branch preparation failed.");
15
- }
16
- async function prepareIdentity(options, identity) {
17
- try {
18
- return ((await options.prepareIdentity?.(identity)) ??
19
- lifecycleSuccess({ status: "disabled" }));
20
- }
21
- catch {
22
- return lifecycleFailure("unexpected-failure");
23
- }
24
- }
25
- function branchPreparationFailed(request) {
26
- logBranchPreparationFailure();
27
- return redirect(request, "/login?error=branch_prepare_failed");
28
- }
29
12
  export function createAuthRoutes(options) {
30
13
  async function login(request) {
31
14
  if (options.production)
@@ -52,9 +35,6 @@ export function createAuthRoutes(options) {
52
35
  logLoginFailure("the configured GitHub CLI request failed");
53
36
  return redirect(request, "/login?error=gh_cli_failed");
54
37
  }
55
- const preparation = await prepareIdentity(options, user);
56
- if (!preparation.ok)
57
- return branchPreparationFailed(request);
58
38
  try {
59
39
  await options.createSession(user);
60
40
  return redirect(request, "/");
@@ -75,14 +55,6 @@ export function createAuthRoutes(options) {
75
55
  catch {
76
56
  return NextResponse.json({ authenticated: false });
77
57
  }
78
- const preparation = await prepareIdentity(options, user);
79
- if (!preparation.ok) {
80
- logBranchPreparationFailure();
81
- return NextResponse.json({
82
- authenticated: false,
83
- error: "branch_prepare_failed",
84
- });
85
- }
86
58
  try {
87
59
  await options.createSession(user);
88
60
  return NextResponse.json({ authenticated: true });
@@ -1 +1 @@
1
- {"version":3,"file":"auth-routes.js","sourceRoot":"","sources":["../../src/server/auth-routes.ts"],"names":[],"mappings":"AA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QAC7B,OAAO,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IACrE,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AACnC,CAAC","sourcesContent":["import {\n lifecycleFailure,\n lifecycleSuccess,\n type BranchPreparationValue,\n type LifecycleResult,\n type BonfireIdentity,\n} from \"@ebay-dt/bonfire-core\";\nimport {\n GitHubCliError,\n type GitHubCliClientLike,\n} from \"@ebay-dt/bonfire-node\";\nimport { NextResponse } from \"next/server.js\";\nimport type { NextRequest } from \"next/server.js\";\n\nexport type AuthRouteOptions = {\n production: boolean;\n githubCli: GitHubCliClientLike;\n createSession: (identity: BonfireIdentity) => Promise<void>;\n clearSession: () => Promise<void>;\n prepareIdentity?: (\n identity: BonfireIdentity,\n ) => Promise<LifecycleResult<BranchPreparationValue>>;\n};\n\nfunction notFound() {\n return new NextResponse(null, { status: 404 });\n}\n\nfunction redirect(request: NextRequest, path: string, status = 307) {\n return NextResponse.redirect(new URL(path, request.url), status);\n}\n\nfunction logLoginFailure(message: string) {\n console.error(`Bonfire GitHub CLI login failed: ${message}`);\n}\n\nfunction logBranchPreparationFailure() {\n console.error(\"Bonfire branch preparation failed.\");\n}\n\nasync function prepareIdentity(\n options: AuthRouteOptions,\n identity: BonfireIdentity,\n) {\n try {\n return (\n (await options.prepareIdentity?.(identity)) ??\n lifecycleSuccess({ status: \"disabled\" } satisfies BranchPreparationValue)\n );\n } catch {\n return lifecycleFailure(\"unexpected-failure\");\n }\n}\n\nfunction branchPreparationFailed(request: NextRequest): NextResponse {\n logBranchPreparationFailure();\n return redirect(request, \"/login?error=branch_prepare_failed\");\n}\n\nexport function createAuthRoutes(options: AuthRouteOptions) {\n async function login(request: NextRequest) {\n if (options.production) return notFound();\n\n let user: BonfireIdentity;\n try {\n user = await options.githubCli.getUser();\n } catch (error) {\n if (\n error instanceof GitHubCliError &&\n error.reason === \"unauthenticated\"\n ) {\n try {\n const webLogin = await options.githubCli.startWebLogin();\n const loginUrl = new URL(\"/login\", request.url);\n loginUrl.searchParams.set(\"auth\", \"started\");\n if (webLogin.code) loginUrl.searchParams.set(\"code\", webLogin.code);\n return NextResponse.redirect(loginUrl);\n } catch {\n logLoginFailure(\"device login could not be started\");\n }\n }\n\n logLoginFailure(\"the configured GitHub CLI request failed\");\n return redirect(request, \"/login?error=gh_cli_failed\");\n }\n\n const preparation = await prepareIdentity(options, user);\n if (!preparation.ok) return branchPreparationFailed(request);\n\n try {\n await options.createSession(user);\n return redirect(request, \"/\");\n } catch {\n logLoginFailure(\"the configured GitHub CLI request failed\");\n return redirect(request, \"/login?error=gh_cli_failed\");\n }\n }\n\n async function status() {\n const response = options.production\n ? notFound()\n : await (async () => {\n let user: BonfireIdentity;\n try {\n user = await options.githubCli.getUser();\n } catch {\n return NextResponse.json({ authenticated: false });\n }\n\n const preparation = await prepareIdentity(options, user);\n if (!preparation.ok) {\n logBranchPreparationFailure();\n return NextResponse.json({\n authenticated: false,\n error: \"branch_prepare_failed\" as const,\n });\n }\n\n try {\n await options.createSession(user);\n return NextResponse.json({ authenticated: true });\n } catch {\n return NextResponse.json({ authenticated: false });\n }\n })();\n response.headers.set(\"Cache-Control\", \"no-store\");\n return response;\n }\n\n async function logout(request: NextRequest) {\n await options.clearSession();\n return redirect(request, options.production ? \"/\" : \"/login\", 303);\n }\n\n return { login, status, logout };\n}\n"]}
1
+ {"version":3,"file":"auth-routes.js","sourceRoot":"","sources":["../../src/server/auth-routes.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,GAEf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAU9C,SAAS,QAAQ;IACf,OAAO,IAAI,YAAY,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;AACjD,CAAC;A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OAAO,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IACrE,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AACnC,CAAC","sourcesContent":["import type { BonfireIdentity } from \"@ebay-dt/bonfire-core\";\nimport {\n GitHubCliError,\n type GitHubCliClientLike,\n} from \"@ebay-dt/bonfire-node\";\nimport { NextResponse } from \"next/server.js\";\nimport type { NextRequest } from \"next/server.js\";\n\nexport type AuthRouteOptions = {\n production: boolean;\n githubCli: GitHubCliClientLike;\n createSession: (identity: BonfireIdentity) => Promise<void>;\n clearSession: () => Promise<void>;\n};\n\nfunction notFound() {\n return new NextResponse(null, { status: 404 });\n}\n\nfunction redirect(request: NextRequest, path: string, status = 307) {\n return NextResponse.redirect(new URL(path, request.url), status);\n}\n\nfunction logLoginFailure(message: string) {\n console.error(`Bonfire GitHub CLI login failed: ${message}`);\n}\n\nexport function createAuthRoutes(options: AuthRouteOptions) {\n async function login(request: NextRequest) {\n if (options.production) return notFound();\n\n let user: BonfireIdentity;\n try {\n user = await options.githubCli.getUser();\n } catch (error) {\n if (\n error instanceof GitHubCliError &&\n error.reason === \"unauthenticated\"\n ) {\n try {\n const webLogin = await options.githubCli.startWebLogin();\n const loginUrl = new URL(\"/login\", request.url);\n loginUrl.searchParams.set(\"auth\", \"started\");\n if (webLogin.code) loginUrl.searchParams.set(\"code\", webLogin.code);\n return NextResponse.redirect(loginUrl);\n } catch {\n logLoginFailure(\"device login could not be started\");\n }\n }\n\n logLoginFailure(\"the configured GitHub CLI request failed\");\n return redirect(request, \"/login?error=gh_cli_failed\");\n }\n\n try {\n await options.createSession(user);\n return redirect(request, \"/\");\n } catch {\n logLoginFailure(\"the configured GitHub CLI request failed\");\n return redirect(request, \"/login?error=gh_cli_failed\");\n }\n }\n\n async function status() {\n const response = options.production\n ? notFound()\n : await (async () => {\n let user: BonfireIdentity;\n try {\n user = await options.githubCli.getUser();\n } catch {\n return NextResponse.json({ authenticated: false });\n }\n\n try {\n await options.createSession(user);\n return NextResponse.json({ authenticated: true });\n } catch {\n return NextResponse.json({ authenticated: false });\n }\n })();\n response.headers.set(\"Cache-Control\", \"no-store\");\n return response;\n }\n\n async function logout(request: NextRequest) {\n await options.clearSession();\n return redirect(request, options.production ? \"/\" : \"/login\", 303);\n }\n\n return { login, status, logout };\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { type BonfireConfigInput, type BonfireIdentity } from "@ebay-dt/bonfire-core";
1
+ import { type BonfireConfigInput, type BonfireIdentity, type GitManagementCapabilities, type GitMode } from "@ebay-dt/bonfire-core";
2
2
  import { type DeploymentProvider, type GitHubCliClientLike, type PreparePrototypeFiles, type PrototypeAgentServiceLike, type PrototypeCatalogLike, type PrototypeLifecycle } from "@ebay-dt/bonfire-node";
3
3
  import type { PrototypeWatcher } from "@ebay-dt/bonfire-node/watcher";
4
4
  import { type CSSProperties } from "react";
@@ -16,9 +16,11 @@ export type CreateBonfireNextOptions = BonfireConfigInput & {
16
16
  prototypeWatcher?: PrototypeWatcher;
17
17
  preparePrototypeFiles?: PreparePrototypeFiles;
18
18
  disableAutoBranchSwitch?: string;
19
+ gitMode?: GitMode;
19
20
  };
20
21
  export type PrototypeCapabilities = {
21
22
  deployment: boolean;
23
+ git: GitManagementCapabilities;
22
24
  };
23
25
  type AppLayoutModel = {
24
26
  htmlProps: {
@@ -37,11 +39,24 @@ export declare function createBonfireNext(options: CreateBonfireNextOptions): {
37
39
  getSummary: (ref: import("@ebay-dt/bonfire-core").PrototypeRef) => Promise<import("@ebay-dt/bonfire-core").PrototypeSummary | null>;
38
40
  capabilities: {
39
41
  deployment: boolean;
42
+ git: {
43
+ mode: GitMode;
44
+ filesystemLifecycle: boolean;
45
+ gitObservation: boolean;
46
+ save: boolean;
47
+ discard: boolean;
48
+ getUpdates: boolean;
49
+ deploy: boolean;
50
+ };
40
51
  };
41
52
  lifecycle: PrototypeLifecycle | null;
42
53
  actions: import("./prototype-actions.js").PrototypeActions;
54
+ repository: import("./repository-actions.js").RepositoryActions;
43
55
  agents: import("./agent-actions.js").PrototypeAgentActions;
44
- routes: import("./prototype-routes.js").PrototypeRoutes;
56
+ routes: {
57
+ dirty(request: import("next/server.js").NextRequest): Promise<Response>;
58
+ repository: import("./repository-routes.js").RepositoryRoutes;
59
+ };
45
60
  };
46
61
  auth: {
47
62
  getSession: () => Promise<{
@@ -1 +1 @@
1
- {"version":3,"file":"create-bonfire-next.d.ts","sourceRoot":"","sources":["../../src/server/create-bonfire-next.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAML,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAS,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAGlD,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,uBAAuB,CAAC;AAQ/B,MAAM,MAAM,wBAAwB,GAAG,kBAAkB,GAAG;IAC1D,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,mBAAmB,CAAC;IAChC,gBAAgB,CAAC,EAAE,oBAAoB,CAAC;IACxC,eAAe,CAAC,EAAE,yBAAyB,CAAC;IAC5C,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;IAC9C,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,SAAS,EAAE;QACT,KAAK,EAAE,aAAa,CAAC;KACtB,CAAC;IACF,WAAW,EAAE;QACX,eAAe,EAAE,MAAM,CAAC;QACxB,IAAI,EAAE,eAAe,GAAG,IAAI,CAAC;KAC9B,CAAC;CACH,CAAC;AAQF,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;iCAyHvB,OAAO,CAAC,cAAc,CAAC;2CAgBhD,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;;;;;;;;;;;;;;;;;;;EA8ChE","sourcesContent":["import { join, resolve } from \"node:path\";\nimport {\n defineConfig,\n lifecycleSuccess,\n parseAutomaticBranchSwitchSetting,\n type BranchPreparationValue,\n type BonfireConfigInput,\n type BonfireIdentity,\n} from \"@ebay-dt/bonfire-core\";\nimport {\n GitHubCliClient,\n LocalPrototypeLifecycle,\n PrototypeAgentService,\n PrototypeCatalog,\n resolvePrototypeCatalogPaths,\n type DeploymentProvider,\n type GitHubCliClientLike,\n type PreparePrototypeFiles,\n type PrototypeAgentServiceLike,\n type PrototypeCatalogLike,\n type PrototypeLifecycle,\n} from \"@ebay-dt/bonfire-node\";\nimport type { PrototypeWatcher } from \"@ebay-dt/bonfire-node/watcher\";\nimport { cache, type CSSProperties } from \"react\";\nimport { createAuthProxy } from \"./auth-boundary.js\";\nimport { createAuthRoutes } from \"./auth-routes.js\";\nimport {\n createLoginPageModel,\n getLoginPageSearchParams,\n type LoginSearchParams,\n} from \"./login-page-model.js\";\nimport { createSessionAdapter } from \"./session.js\";\nimport { createPrototypeActions } from \"./prototype-actions.js\";\nimport { createPrototypeAgentActions } from \"./agent-actions.js\";\nimport { createPrototypeDashboardModelLoader } from \"./prototype-dashboard.js\";\nimport { createPrototypeEnvironmentModelLoader } from \"./prototype-environment.js\";\nimport { createPrototypeRoutes } from \"./prototype-routes.js\";\n\nexport type CreateBonfireNextOptions = BonfireConfigInput & {\n repositoryRoot: string;\n prototypeRoot?: string;\n primaryBranch?: string;\n sessionSecret?: string;\n githubCli?: GitHubCliClientLike;\n prototypeCatalog?: PrototypeCatalogLike;\n prototypeAgents?: PrototypeAgentServiceLike;\n prototypeLifecycle?: PrototypeLifecycle;\n deploymentProvider?: DeploymentProvider;\n prototypeWatcher?: PrototypeWatcher;\n preparePrototypeFiles?: PreparePrototypeFiles;\n disableAutoBranchSwitch?: string;\n};\n\nexport type PrototypeCapabilities = {\n deployment: boolean;\n};\n\ntype AppLayoutModel = {\n htmlProps: {\n style: CSSProperties;\n };\n headerProps: {\n applicationName: string;\n user: BonfireIdentity | null;\n };\n};\n\ntype CustomProperties = CSSProperties &\n Record<`--${string}`, string | number | undefined>;\n\nconst APP_HEADER_BLOCK_SIZE_PROPERTY = \"--app-header-block-size\";\nconst APP_HEADER_PRESENT_BLOCK_SIZE = \"2.5rem\";\n\nexport function createBonfireNext(options: CreateBonfireNextOptions) {\n const config = defineConfig({\n appId: options.appId,\n name: options.name,\n auth: options.auth,\n ...(options.themes === undefined ? {} : { themes: options.themes }),\n });\n const production = process.env.NODE_ENV === \"production\";\n if (options.prototypeLifecycle && options.deploymentProvider) {\n throw new Error(\n \"prototypeLifecycle and deploymentProvider cannot be supplied together\",\n );\n }\n if (options.prototypeLifecycle && options.preparePrototypeFiles) {\n throw new Error(\n \"prototypeLifecycle and preparePrototypeFiles cannot be supplied together\",\n );\n }\n const automaticBranchSwitch = parseAutomaticBranchSwitchSetting(\n options.disableAutoBranchSwitch,\n );\n const session = createSessionAdapter({\n appId: config.appId,\n sessionSecret: options.sessionSecret,\n production,\n });\n const githubCli =\n options.githubCli ??\n new GitHubCliClient({ hostname: config.auth.github.hostname });\n const getSession = session.getSession;\n const prototypeCatalog =\n options.prototypeCatalog ??\n new PrototypeCatalog({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n themeRegistry: config.themes,\n });\n const lifecycle =\n options.prototypeLifecycle ??\n (production\n ? null\n : new LocalPrototypeLifecycle({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n primaryBranch: options.primaryBranch,\n automaticBranchSwitch,\n applicationId: config.appId,\n catalog: prototypeCatalog,\n deploymentProvider: options.deploymentProvider,\n preparePrototypeFiles: options.preparePrototypeFiles,\n themeRegistry: config.themes,\n }));\n const deploymentAvailable =\n !production &&\n (options.deploymentProvider !== undefined ||\n options.prototypeLifecycle?.deploy !== undefined);\n const getCurrentUser = cache(() => getSession());\n const prepareIdentity = production\n ? undefined\n : automaticBranchSwitch === \"enabled\" && lifecycle\n ? lifecycle.prepareBranch.bind(lifecycle)\n : async () =>\n lifecycleSuccess({\n status: \"disabled\",\n } satisfies BranchPreparationValue);\n const prototypeActions = createPrototypeActions({\n production,\n getCurrentUser: getSession,\n lifecycle,\n themeRegistry: config.themes,\n });\n const prototypeAgents = production\n ? null\n : (options.prototypeAgents ??\n new PrototypeAgentService({\n runtime: resolvePrototypeCatalogPaths({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n }),\n catalog: prototypeCatalog,\n }));\n const prototypeAgentActions = createPrototypeAgentActions({\n production,\n getCurrentUser: getSession,\n agents: prototypeAgents,\n });\n let prototypeWatcher = options.prototypeWatcher;\n const getWatcher = async () => {\n if (prototypeWatcher) return prototypeWatcher;\n if (production) return null;\n\n const { createPrototypeWatcher } =\n await import(\"@ebay-dt/bonfire-node/watcher\");\n prototypeWatcher = createPrototypeWatcher({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: resolve(\n options.repositoryRoot,\n options.prototypeRoot ?? join(\"src\", \"app\", \"(prototypes)\"),\n ),\n });\n return prototypeWatcher;\n };\n const prototypeRoutes = createPrototypeRoutes({\n production,\n getCurrentUser: getSession,\n lifecycle,\n getWatcher,\n });\n const getDashboardModel = createPrototypeDashboardModelLoader({\n applicationName: config.name,\n production,\n catalog: prototypeCatalog,\n getCurrentUser,\n themeRegistry: config.themes,\n });\n const { getRouteModel, getCurrentRouteModel: getCurrentRouteModelUncached } =\n createPrototypeEnvironmentModelLoader({\n catalog: prototypeCatalog,\n themeRegistry: config.themes,\n });\n const getCurrentRouteModel = cache(getCurrentRouteModelUncached);\n const getAppLayoutModel = cache(async (): Promise<AppLayoutModel> => {\n const user = production ? null : await getCurrentUser();\n const style: CustomProperties = {\n [APP_HEADER_BLOCK_SIZE_PROPERTY]:\n user === null ? \"0px\" : APP_HEADER_PRESENT_BLOCK_SIZE,\n };\n\n return {\n htmlProps: { style },\n headerProps: {\n applicationName: config.name,\n user,\n },\n };\n });\n async function getLoginPageModel(\n searchParams?: LoginSearchParams | Promise<LoginSearchParams>,\n ) {\n // Keep Next's navigation module out of route-handler bundles. The same\n // factory instance supplies both route handlers and server-page helpers.\n const { redirect } = await import(\"next/navigation.js\");\n if (production) redirect(\"/\");\n if (await getSession()) redirect(\"/\");\n\n const params = await getLoginPageSearchParams(searchParams);\n return createLoginPageModel(config, params);\n }\n const proxy = createAuthProxy({\n appId: config.appId,\n sessionSecret: options.sessionSecret,\n production,\n });\n const routes = createAuthRoutes({\n production,\n githubCli,\n createSession: session.createSession,\n clearSession: session.clearSession,\n prepareIdentity,\n });\n return {\n prototypes: {\n getDashboardModel,\n getRouteModel,\n getCurrentRouteModel,\n getSummary: prototypeCatalog.getSummary.bind(prototypeCatalog),\n capabilities: {\n deployment: deploymentAvailable,\n } satisfies PrototypeCapabilities,\n lifecycle,\n actions: prototypeActions,\n agents: prototypeAgentActions,\n routes: prototypeRoutes,\n },\n auth: {\n getSession,\n getCurrentUser,\n getAppLayoutModel,\n getLoginPageModel,\n proxy,\n routes,\n },\n };\n}\n"]}
1
+ {"version":3,"file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ACT,KAAK,EAAE,aAAa,CAAC;KACtB,CAAC;IACF,WAAW,EAAE;QACX,eAAe,EAAE,MAAM,CAAC;QACxB,IAAI,EAAE,eAAe,GAAG,IAAI,CAAC;KAC9B,CAAC;CACH,CAAC;AAQF,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iCA2KvB,OAAO,CAAC,cAAc,CAAC;2CAiBhD,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;;;;;;;;;;;;;;;;;;;EA2DhE","sourcesContent":["import { join, resolve } from \"node:path\";\nimport {\n defineConfig,\n getGitManagementCapabilities,\n parseAutomaticBranchSwitchSetting,\n parseGitModeSetting,\n type BonfireConfigInput,\n type BonfireIdentity,\n type GitManagementCapabilities,\n type GitMode,\n} from \"@ebay-dt/bonfire-core\";\nimport {\n GitHubCliClient,\n LocalPrototypeLifecycle,\n PrototypeAgentService,\n PrototypeCatalog,\n resolvePrototypeCatalogPaths,\n type DeploymentProvider,\n type GitHubCliClientLike,\n type PreparePrototypeFiles,\n type PrototypeAgentServiceLike,\n type PrototypeCatalogLike,\n type PrototypeLifecycle,\n} from \"@ebay-dt/bonfire-node\";\nimport type { PrototypeWatcher } from \"@ebay-dt/bonfire-node/watcher\";\nimport { cache, type CSSProperties } from \"react\";\nimport { createAuthProxy } from \"./auth-boundary.js\";\nimport { createAuthRoutes } from \"./auth-routes.js\";\nimport {\n createLoginPageModel,\n getLoginPageSearchParams,\n type LoginSearchParams,\n} from \"./login-page-model.js\";\nimport { createSessionAdapter } from \"./session.js\";\nimport { createPrototypeActions } from \"./prototype-actions.js\";\nimport { createPrototypeAgentActions } from \"./agent-actions.js\";\nimport { createPrototypeDashboardModelLoader } from \"./prototype-dashboard.js\";\nimport { createPrototypeEnvironmentModelLoader } from \"./prototype-environment.js\";\nimport { createPrototypeRoutes } from \"./prototype-routes.js\";\nimport { createEntrySynchronizationCoordinator } from \"./entry-coordinator.js\";\nimport { createRepositoryActions } from \"./repository-actions.js\";\nimport { createRepositoryRoutes } from \"./repository-routes.js\";\n\nexport type CreateBonfireNextOptions = BonfireConfigInput & {\n repositoryRoot: string;\n prototypeRoot?: string;\n primaryBranch?: string;\n sessionSecret?: string;\n githubCli?: GitHubCliClientLike;\n prototypeCatalog?: PrototypeCatalogLike;\n prototypeAgents?: PrototypeAgentServiceLike;\n prototypeLifecycle?: PrototypeLifecycle;\n deploymentProvider?: DeploymentProvider;\n prototypeWatcher?: PrototypeWatcher;\n preparePrototypeFiles?: PreparePrototypeFiles;\n disableAutoBranchSwitch?: string;\n gitMode?: GitMode;\n};\n\nexport type PrototypeCapabilities = {\n deployment: boolean;\n git: GitManagementCapabilities;\n};\n\ntype AppLayoutModel = {\n htmlProps: {\n style: CSSProperties;\n };\n headerProps: {\n applicationName: string;\n user: BonfireIdentity | null;\n };\n};\n\ntype CustomProperties = CSSProperties &\n Record<`--${string}`, string | number | undefined>;\n\nconst APP_HEADER_BLOCK_SIZE_PROPERTY = \"--app-header-block-size\";\nconst APP_HEADER_PRESENT_BLOCK_SIZE = \"2.5rem\";\n\nexport function createBonfireNext(options: CreateBonfireNextOptions) {\n const config = defineConfig({\n appId: options.appId,\n name: options.name,\n auth: options.auth,\n ...(options.themes === undefined ? {} : { themes: options.themes }),\n });\n const production = process.env.NODE_ENV === \"production\";\n if (options.prototypeLifecycle && options.deploymentProvider) {\n throw new Error(\n \"prototypeLifecycle and deploymentProvider cannot be supplied together\",\n );\n }\n if (options.prototypeLifecycle && options.preparePrototypeFiles) {\n throw new Error(\n \"prototypeLifecycle and preparePrototypeFiles cannot be supplied together\",\n );\n }\n const automaticBranchSwitch = parseAutomaticBranchSwitchSetting(\n options.disableAutoBranchSwitch,\n );\n const gitMode = parseGitModeSetting(\n options.gitMode ?? process.env.BF_GIT_MODE,\n );\n const injectedLifecycleMode = options.prototypeLifecycle?.gitMode;\n if (\n options.prototypeLifecycle !== undefined &&\n ((gitMode === \"manual\" && injectedLifecycleMode !== \"manual\") ||\n (injectedLifecycleMode !== undefined && injectedLifecycleMode !== gitMode))\n ) {\n throw new TypeError(\n gitMode === \"manual\"\n ? \"prototypeLifecycle must declare manual mode when gitMode is manual\"\n : \"prototypeLifecycle gitMode does not match configured gitMode\",\n );\n }\n const session = createSessionAdapter({\n appId: config.appId,\n sessionSecret: options.sessionSecret,\n production,\n });\n const githubCli =\n options.githubCli ??\n new GitHubCliClient({ hostname: config.auth.github.hostname });\n const getSession = session.getSession;\n const prototypeCatalog =\n options.prototypeCatalog ??\n new PrototypeCatalog({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n themeRegistry: config.themes,\n });\n const lifecycle =\n options.prototypeLifecycle ??\n (production\n ? null\n : new LocalPrototypeLifecycle({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n primaryBranch: options.primaryBranch,\n automaticBranchSwitch,\n gitMode,\n applicationId: config.appId,\n catalog: prototypeCatalog,\n deploymentProvider: options.deploymentProvider,\n preparePrototypeFiles: options.preparePrototypeFiles,\n themeRegistry: config.themes,\n }));\n const deploymentAvailable =\n !production &&\n gitMode === \"managed\" &&\n (options.deploymentProvider !== undefined ||\n options.prototypeLifecycle?.deploy !== undefined);\n const entrySynchronization = createEntrySynchronizationCoordinator({\n lifecycle,\n onStatus: production\n ? undefined\n : ({ identity, status, result }) => {\n if (status === \"started\") {\n console.info(\n `[bonfire] Preparing repository branch for ${identity.login}…`,\n );\n } else if (status === \"deferred\") {\n console.warn(\n `[bonfire] Branch preparation for ${identity.login} is taking longer than 10s; continuing page rendering while it finishes.`,\n );\n } else if (result?.status === \"ready\") {\n console.info(\n `[bonfire] Branch preparation completed for ${identity.login}.`,\n );\n } else if (result?.status === \"disabled\") {\n console.info(\n `[bonfire] Branch preparation skipped for ${identity.login}.`,\n );\n } else {\n console.warn(\n `[bonfire] Branch preparation completed with repository attention for ${identity.login}.`,\n );\n }\n },\n });\n const getCurrentUser = cache(() => getSession());\n const prototypeActions = createPrototypeActions({\n production,\n gitMode,\n getCurrentUser: getSession,\n lifecycle,\n themeRegistry: config.themes,\n });\n const repositoryActions = createRepositoryActions({\n production,\n gitMode,\n getCurrentUser: getSession,\n lifecycle,\n entrySynchronizationInFlight: entrySynchronization.isInFlight,\n waitForEntrySynchronization: entrySynchronization.waitForCompletion,\n });\n const repositoryRoutes = createRepositoryRoutes({\n production,\n actions: repositoryActions,\n });\n const prototypeAgents = production\n ? null\n : (options.prototypeAgents ??\n new PrototypeAgentService({\n runtime: resolvePrototypeCatalogPaths({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n }),\n catalog: prototypeCatalog,\n }));\n const prototypeAgentActions = createPrototypeAgentActions({\n production,\n getCurrentUser: getSession,\n agents: prototypeAgents,\n });\n let prototypeWatcher = options.prototypeWatcher;\n const getWatcher = async () => {\n if (prototypeWatcher) return prototypeWatcher;\n if (production) return null;\n\n const { createPrototypeWatcher } =\n await import(\"@ebay-dt/bonfire-node/watcher\");\n prototypeWatcher = createPrototypeWatcher({\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: resolve(\n options.repositoryRoot,\n options.prototypeRoot ?? join(\"src\", \"app\", \"(prototypes)\"),\n ),\n });\n return prototypeWatcher;\n };\n const prototypeRoutes = createPrototypeRoutes({\n production,\n getCurrentUser: getSession,\n lifecycle,\n getWatcher,\n });\n const getDashboardModel = createPrototypeDashboardModelLoader({\n applicationName: config.name,\n production,\n catalog: prototypeCatalog,\n getCurrentUser,\n themeRegistry: config.themes,\n });\n const { getRouteModel, getCurrentRouteModel: getCurrentRouteModelUncached } =\n createPrototypeEnvironmentModelLoader({\n catalog: prototypeCatalog,\n themeRegistry: config.themes,\n });\n const getCurrentRouteModel = cache(getCurrentRouteModelUncached);\n const getAppLayoutModel = cache(async (): Promise<AppLayoutModel> => {\n const user = production ? null : await getCurrentUser();\n if (user !== null) await entrySynchronization.synchronize(user);\n const style: CustomProperties = {\n [APP_HEADER_BLOCK_SIZE_PROPERTY]:\n user === null ? \"0px\" : APP_HEADER_PRESENT_BLOCK_SIZE,\n };\n\n return {\n htmlProps: { style },\n headerProps: {\n applicationName: config.name,\n user,\n },\n };\n });\n async function getLoginPageModel(\n searchParams?: LoginSearchParams | Promise<LoginSearchParams>,\n ) {\n // Keep Next's navigation module out of route-handler bundles. The same\n // factory instance supplies both route handlers and server-page helpers.\n const { redirect } = await import(\"next/navigation.js\");\n if (production) redirect(\"/\");\n if (await getSession()) redirect(\"/\");\n\n const params = await getLoginPageSearchParams(searchParams);\n return createLoginPageModel(config, params);\n }\n const proxy = createAuthProxy({\n appId: config.appId,\n sessionSecret: options.sessionSecret,\n production,\n });\n const routes = createAuthRoutes({\n production,\n githubCli,\n createSession: session.createSession,\n clearSession: session.clearSession,\n });\n return {\n prototypes: {\n getDashboardModel,\n getRouteModel,\n getCurrentRouteModel,\n getSummary: prototypeCatalog.getSummary.bind(prototypeCatalog),\n capabilities: {\n deployment: deploymentAvailable,\n git: {\n ...getGitManagementCapabilities(gitMode),\n ...(production\n ? {\n filesystemLifecycle: false,\n gitObservation: false,\n save: false,\n discard: false,\n getUpdates: false,\n deploy: false,\n }\n : {}),\n },\n } satisfies PrototypeCapabilities,\n lifecycle,\n actions: prototypeActions,\n repository: repositoryActions,\n agents: prototypeAgentActions,\n routes: { ...prototypeRoutes, repository: repositoryRoutes },\n },\n auth: {\n getSession,\n getCurrentUser,\n getAppLayoutModel,\n getLoginPageModel,\n proxy,\n routes,\n },\n };\n}\n"]}