@codemieai/code 0.11.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (253) hide show
  1. package/README.md +109 -56
  2. package/bin/codemie-copilot.js +224 -0
  3. package/bin/codemie-pi.js +18 -0
  4. package/dist/agents/core/AgentCLI.d.ts.map +1 -1
  5. package/dist/agents/core/AgentCLI.js +16 -10
  6. package/dist/agents/core/AgentCLI.js.map +1 -1
  7. package/dist/agents/core/BaseAgentAdapter.d.ts.map +1 -1
  8. package/dist/agents/core/BaseAgentAdapter.js +43 -19
  9. package/dist/agents/core/BaseAgentAdapter.js.map +1 -1
  10. package/dist/agents/core/agent-aliases.d.ts +17 -0
  11. package/dist/agents/core/agent-aliases.d.ts.map +1 -0
  12. package/dist/agents/core/agent-aliases.js +41 -0
  13. package/dist/agents/core/agent-aliases.js.map +1 -0
  14. package/dist/agents/core/session/BaseSessionAdapter.d.ts +19 -0
  15. package/dist/agents/core/session/BaseSessionAdapter.d.ts.map +1 -1
  16. package/dist/agents/core/session/session-origin-audit.d.ts +13 -0
  17. package/dist/agents/core/session/session-origin-audit.d.ts.map +1 -1
  18. package/dist/agents/core/session/session-origin-audit.js +34 -0
  19. package/dist/agents/core/session/session-origin-audit.js.map +1 -1
  20. package/dist/agents/core/session/stale-session-reconciliation.d.ts +42 -0
  21. package/dist/agents/core/session/stale-session-reconciliation.d.ts.map +1 -0
  22. package/dist/agents/core/session/stale-session-reconciliation.js +141 -0
  23. package/dist/agents/core/session/stale-session-reconciliation.js.map +1 -0
  24. package/dist/agents/core/session/types.d.ts +19 -0
  25. package/dist/agents/core/session/types.d.ts.map +1 -1
  26. package/dist/agents/core/session/types.js +17 -1
  27. package/dist/agents/core/session/types.js.map +1 -1
  28. package/dist/agents/core/types.d.ts +11 -0
  29. package/dist/agents/core/types.d.ts.map +1 -1
  30. package/dist/agents/plugins/codex/codex.reconciliation.d.ts +15 -35
  31. package/dist/agents/plugins/codex/codex.reconciliation.d.ts.map +1 -1
  32. package/dist/agents/plugins/codex/codex.reconciliation.js +8 -139
  33. package/dist/agents/plugins/codex/codex.reconciliation.js.map +1 -1
  34. package/dist/agents/plugins/copilot-cli/copilot-cli-event-types.d.ts +146 -0
  35. package/dist/agents/plugins/copilot-cli/copilot-cli-event-types.d.ts.map +1 -0
  36. package/dist/agents/plugins/copilot-cli/copilot-cli-event-types.js +12 -0
  37. package/dist/agents/plugins/copilot-cli/copilot-cli-event-types.js.map +1 -0
  38. package/dist/agents/plugins/copilot-cli/copilot-cli.constants.d.ts +15 -0
  39. package/dist/agents/plugins/copilot-cli/copilot-cli.constants.d.ts.map +1 -0
  40. package/dist/agents/plugins/copilot-cli/copilot-cli.constants.js +15 -0
  41. package/dist/agents/plugins/copilot-cli/copilot-cli.constants.js.map +1 -0
  42. package/dist/agents/plugins/copilot-cli/copilot-cli.models.d.ts +8 -0
  43. package/dist/agents/plugins/copilot-cli/copilot-cli.models.d.ts.map +1 -0
  44. package/dist/agents/plugins/copilot-cli/copilot-cli.models.js +195 -0
  45. package/dist/agents/plugins/copilot-cli/copilot-cli.models.js.map +1 -0
  46. package/dist/agents/plugins/copilot-cli/copilot-cli.paths.d.ts +11 -0
  47. package/dist/agents/plugins/copilot-cli/copilot-cli.paths.d.ts.map +1 -0
  48. package/dist/agents/plugins/copilot-cli/copilot-cli.paths.js +21 -0
  49. package/dist/agents/plugins/copilot-cli/copilot-cli.paths.js.map +1 -0
  50. package/dist/agents/plugins/copilot-cli/copilot-cli.plugin.d.ts +14 -0
  51. package/dist/agents/plugins/copilot-cli/copilot-cli.plugin.d.ts.map +1 -0
  52. package/dist/agents/plugins/copilot-cli/copilot-cli.plugin.js +263 -0
  53. package/dist/agents/plugins/copilot-cli/copilot-cli.plugin.js.map +1 -0
  54. package/dist/agents/plugins/copilot-cli/copilot-cli.session.d.ts +43 -0
  55. package/dist/agents/plugins/copilot-cli/copilot-cli.session.d.ts.map +1 -0
  56. package/dist/agents/plugins/copilot-cli/copilot-cli.session.js +343 -0
  57. package/dist/agents/plugins/copilot-cli/copilot-cli.session.js.map +1 -0
  58. package/dist/agents/plugins/copilot-cli/copilot-cli.storage-utils.d.ts +10 -0
  59. package/dist/agents/plugins/copilot-cli/copilot-cli.storage-utils.d.ts.map +1 -0
  60. package/dist/agents/plugins/copilot-cli/copilot-cli.storage-utils.js +41 -0
  61. package/dist/agents/plugins/copilot-cli/copilot-cli.storage-utils.js.map +1 -0
  62. package/dist/agents/plugins/copilot-cli/copilot-cli.usage.d.ts +37 -0
  63. package/dist/agents/plugins/copilot-cli/copilot-cli.usage.d.ts.map +1 -0
  64. package/dist/agents/plugins/copilot-cli/copilot-cli.usage.js +96 -0
  65. package/dist/agents/plugins/copilot-cli/copilot-cli.usage.js.map +1 -0
  66. package/dist/agents/plugins/copilot-cli/copilot-cli.workspace.d.ts +17 -0
  67. package/dist/agents/plugins/copilot-cli/copilot-cli.workspace.d.ts.map +1 -0
  68. package/dist/agents/plugins/copilot-cli/copilot-cli.workspace.js +58 -0
  69. package/dist/agents/plugins/copilot-cli/copilot-cli.workspace.js.map +1 -0
  70. package/dist/agents/plugins/copilot-cli/index.d.ts +3 -0
  71. package/dist/agents/plugins/copilot-cli/index.d.ts.map +1 -0
  72. package/dist/agents/plugins/copilot-cli/index.js +3 -0
  73. package/dist/agents/plugins/copilot-cli/index.js.map +1 -0
  74. package/dist/agents/plugins/copilot-cli/session/processors/copilot-cli.conversations-processor.d.ts +18 -0
  75. package/dist/agents/plugins/copilot-cli/session/processors/copilot-cli.conversations-processor.d.ts.map +1 -0
  76. package/dist/agents/plugins/copilot-cli/session/processors/copilot-cli.conversations-processor.js +313 -0
  77. package/dist/agents/plugins/copilot-cli/session/processors/copilot-cli.conversations-processor.js.map +1 -0
  78. package/dist/agents/plugins/copilot-cli/session/processors/copilot-cli.metrics-processor.d.ts +16 -0
  79. package/dist/agents/plugins/copilot-cli/session/processors/copilot-cli.metrics-processor.d.ts.map +1 -0
  80. package/dist/agents/plugins/copilot-cli/session/processors/copilot-cli.metrics-processor.js +22 -0
  81. package/dist/agents/plugins/copilot-cli/session/processors/copilot-cli.metrics-processor.js.map +1 -0
  82. package/dist/agents/plugins/pi/__tests__/home-redirect.d.ts +12 -0
  83. package/dist/agents/plugins/pi/__tests__/home-redirect.d.ts.map +1 -0
  84. package/dist/agents/plugins/pi/__tests__/home-redirect.js +27 -0
  85. package/dist/agents/plugins/pi/__tests__/home-redirect.js.map +1 -0
  86. package/dist/agents/plugins/pi/extension/README.md +68 -0
  87. package/dist/agents/plugins/pi/extension/index.js +161 -0
  88. package/dist/agents/plugins/pi/extension/package.json +8 -0
  89. package/dist/agents/plugins/pi/index.d.ts +3 -0
  90. package/dist/agents/plugins/pi/index.d.ts.map +1 -0
  91. package/dist/agents/plugins/pi/index.js +3 -0
  92. package/dist/agents/plugins/pi/index.js.map +1 -0
  93. package/dist/agents/plugins/pi/pi.extension.d.ts +60 -0
  94. package/dist/agents/plugins/pi/pi.extension.d.ts.map +1 -0
  95. package/dist/agents/plugins/pi/pi.extension.js +201 -0
  96. package/dist/agents/plugins/pi/pi.extension.js.map +1 -0
  97. package/dist/agents/plugins/pi/pi.incremental-sync.d.ts +63 -0
  98. package/dist/agents/plugins/pi/pi.incremental-sync.d.ts.map +1 -0
  99. package/dist/agents/plugins/pi/pi.incremental-sync.js +266 -0
  100. package/dist/agents/plugins/pi/pi.incremental-sync.js.map +1 -0
  101. package/dist/agents/plugins/pi/pi.models.d.ts +20 -0
  102. package/dist/agents/plugins/pi/pi.models.d.ts.map +1 -0
  103. package/dist/agents/plugins/pi/pi.models.js +201 -0
  104. package/dist/agents/plugins/pi/pi.models.js.map +1 -0
  105. package/dist/agents/plugins/pi/pi.packages.d.ts +11 -0
  106. package/dist/agents/plugins/pi/pi.packages.d.ts.map +1 -0
  107. package/dist/agents/plugins/pi/pi.packages.js +35 -0
  108. package/dist/agents/plugins/pi/pi.packages.js.map +1 -0
  109. package/dist/agents/plugins/pi/pi.paths.d.ts +37 -0
  110. package/dist/agents/plugins/pi/pi.paths.d.ts.map +1 -0
  111. package/dist/agents/plugins/pi/pi.paths.js +146 -0
  112. package/dist/agents/plugins/pi/pi.paths.js.map +1 -0
  113. package/dist/agents/plugins/pi/pi.plugin.d.ts +30 -0
  114. package/dist/agents/plugins/pi/pi.plugin.d.ts.map +1 -0
  115. package/dist/agents/plugins/pi/pi.plugin.js +453 -0
  116. package/dist/agents/plugins/pi/pi.plugin.js.map +1 -0
  117. package/dist/agents/plugins/pi/pi.session.d.ts +114 -0
  118. package/dist/agents/plugins/pi/pi.session.d.ts.map +1 -0
  119. package/dist/agents/plugins/pi/pi.session.js +388 -0
  120. package/dist/agents/plugins/pi/pi.session.js.map +1 -0
  121. package/dist/agents/plugins/pi/pi.setup.d.ts +2 -0
  122. package/dist/agents/plugins/pi/pi.setup.d.ts.map +1 -0
  123. package/dist/agents/plugins/pi/pi.setup.js +33 -0
  124. package/dist/agents/plugins/pi/pi.setup.js.map +1 -0
  125. package/dist/agents/plugins/pi/pi.types.d.ts +143 -0
  126. package/dist/agents/plugins/pi/pi.types.d.ts.map +1 -0
  127. package/dist/agents/plugins/pi/pi.types.js +74 -0
  128. package/dist/agents/plugins/pi/pi.types.js.map +1 -0
  129. package/dist/agents/plugins/pi/session/pi-file-operations.d.ts +17 -0
  130. package/dist/agents/plugins/pi/session/pi-file-operations.d.ts.map +1 -0
  131. package/dist/agents/plugins/pi/session/pi-file-operations.js +98 -0
  132. package/dist/agents/plugins/pi/session/pi-file-operations.js.map +1 -0
  133. package/dist/agents/plugins/pi/session/pi-named-invocations.d.ts +52 -0
  134. package/dist/agents/plugins/pi/session/pi-named-invocations.d.ts.map +1 -0
  135. package/dist/agents/plugins/pi/session/pi-named-invocations.js +189 -0
  136. package/dist/agents/plugins/pi/session/pi-named-invocations.js.map +1 -0
  137. package/dist/agents/plugins/pi/session/pi-user-prompt.d.ts +14 -0
  138. package/dist/agents/plugins/pi/session/pi-user-prompt.d.ts.map +1 -0
  139. package/dist/agents/plugins/pi/session/pi-user-prompt.js +51 -0
  140. package/dist/agents/plugins/pi/session/pi-user-prompt.js.map +1 -0
  141. package/dist/agents/plugins/pi/session/processors/pi.conversations-processor.d.ts +52 -0
  142. package/dist/agents/plugins/pi/session/processors/pi.conversations-processor.d.ts.map +1 -0
  143. package/dist/agents/plugins/pi/session/processors/pi.conversations-processor.js +716 -0
  144. package/dist/agents/plugins/pi/session/processors/pi.conversations-processor.js.map +1 -0
  145. package/dist/agents/plugins/pi/session/processors/pi.metrics-processor.d.ts +104 -0
  146. package/dist/agents/plugins/pi/session/processors/pi.metrics-processor.d.ts.map +1 -0
  147. package/dist/agents/plugins/pi/session/processors/pi.metrics-processor.js +595 -0
  148. package/dist/agents/plugins/pi/session/processors/pi.metrics-processor.js.map +1 -0
  149. package/dist/agents/registry.d.ts +20 -0
  150. package/dist/agents/registry.d.ts.map +1 -1
  151. package/dist/agents/registry.js +29 -2
  152. package/dist/agents/registry.js.map +1 -1
  153. package/dist/cli/commands/analytics/agent-labels.d.ts +3 -0
  154. package/dist/cli/commands/analytics/agent-labels.d.ts.map +1 -0
  155. package/dist/cli/commands/analytics/agent-labels.js +20 -0
  156. package/dist/cli/commands/analytics/agent-labels.js.map +1 -0
  157. package/dist/cli/commands/analytics/cost/cost-enricher.d.ts.map +1 -1
  158. package/dist/cli/commands/analytics/cost/cost-enricher.js +12 -0
  159. package/dist/cli/commands/analytics/cost/cost-enricher.js.map +1 -1
  160. package/dist/cli/commands/analytics/cost/types.d.ts +10 -0
  161. package/dist/cli/commands/analytics/cost/types.d.ts.map +1 -1
  162. package/dist/cli/commands/analytics/cost/usage-readers.d.ts +24 -0
  163. package/dist/cli/commands/analytics/cost/usage-readers.d.ts.map +1 -1
  164. package/dist/cli/commands/analytics/cost/usage-readers.js +253 -54
  165. package/dist/cli/commands/analytics/cost/usage-readers.js.map +1 -1
  166. package/dist/cli/commands/analytics/formatter.d.ts.map +1 -1
  167. package/dist/cli/commands/analytics/formatter.js +10 -2
  168. package/dist/cli/commands/analytics/formatter.js.map +1 -1
  169. package/dist/cli/commands/analytics/index.d.ts.map +1 -1
  170. package/dist/cli/commands/analytics/index.js +22 -0
  171. package/dist/cli/commands/analytics/index.js.map +1 -1
  172. package/dist/cli/commands/analytics/native-loader.d.ts +21 -4
  173. package/dist/cli/commands/analytics/native-loader.d.ts.map +1 -1
  174. package/dist/cli/commands/analytics/native-loader.js +267 -88
  175. package/dist/cli/commands/analytics/native-loader.js.map +1 -1
  176. package/dist/cli/commands/analytics/report/client/app.js +77 -15
  177. package/dist/cli/commands/analytics/report/payload-builder.d.ts.map +1 -1
  178. package/dist/cli/commands/analytics/report/payload-builder.js +32 -2
  179. package/dist/cli/commands/analytics/report/payload-builder.js.map +1 -1
  180. package/dist/cli/commands/analytics/report/types.d.ts +11 -0
  181. package/dist/cli/commands/analytics/report/types.d.ts.map +1 -1
  182. package/dist/cli/commands/hook.d.ts.map +1 -1
  183. package/dist/cli/commands/hook.js +71 -29
  184. package/dist/cli/commands/hook.js.map +1 -1
  185. package/dist/cli/commands/install.d.ts.map +1 -1
  186. package/dist/cli/commands/install.js +9 -7
  187. package/dist/cli/commands/install.js.map +1 -1
  188. package/dist/cli/commands/list.d.ts.map +1 -1
  189. package/dist/cli/commands/list.js +4 -2
  190. package/dist/cli/commands/list.js.map +1 -1
  191. package/dist/cli/commands/setup.d.ts +3 -1
  192. package/dist/cli/commands/setup.d.ts.map +1 -1
  193. package/dist/cli/commands/setup.js +87 -63
  194. package/dist/cli/commands/setup.js.map +1 -1
  195. package/dist/cli/commands/uninstall.d.ts.map +1 -1
  196. package/dist/cli/commands/uninstall.js +6 -4
  197. package/dist/cli/commands/uninstall.js.map +1 -1
  198. package/dist/cli/commands/update.d.ts.map +1 -1
  199. package/dist/cli/commands/update.js +7 -5
  200. package/dist/cli/commands/update.js.map +1 -1
  201. package/dist/cli/first-time.d.ts.map +1 -1
  202. package/dist/cli/first-time.js +10 -9
  203. package/dist/cli/first-time.js.map +1 -1
  204. package/dist/providers/core/auth-validation.d.ts +7 -2
  205. package/dist/providers/core/auth-validation.d.ts.map +1 -1
  206. package/dist/providers/core/auth-validation.js +11 -5
  207. package/dist/providers/core/auth-validation.js.map +1 -1
  208. package/dist/providers/core/types.d.ts +16 -0
  209. package/dist/providers/core/types.d.ts.map +1 -1
  210. package/dist/providers/core/types.js.map +1 -1
  211. package/dist/providers/plugins/sso/proxy/plugins/claude-request-normalizer.plugin.d.ts +8 -3
  212. package/dist/providers/plugins/sso/proxy/plugins/claude-request-normalizer.plugin.d.ts.map +1 -1
  213. package/dist/providers/plugins/sso/proxy/plugins/claude-request-normalizer.plugin.js +46 -11
  214. package/dist/providers/plugins/sso/proxy/plugins/claude-request-normalizer.plugin.js.map +1 -1
  215. package/dist/providers/plugins/sso/proxy/plugins/codex-encrypted-content-sanitizer.plugin.d.ts +23 -13
  216. package/dist/providers/plugins/sso/proxy/plugins/codex-encrypted-content-sanitizer.plugin.d.ts.map +1 -1
  217. package/dist/providers/plugins/sso/proxy/plugins/codex-encrypted-content-sanitizer.plugin.js +75 -18
  218. package/dist/providers/plugins/sso/proxy/plugins/codex-encrypted-content-sanitizer.plugin.js.map +1 -1
  219. package/dist/providers/plugins/sso/proxy/plugins/copilot-encrypted-content-sanitizer.plugin.d.ts +21 -0
  220. package/dist/providers/plugins/sso/proxy/plugins/copilot-encrypted-content-sanitizer.plugin.d.ts.map +1 -0
  221. package/dist/providers/plugins/sso/proxy/plugins/copilot-encrypted-content-sanitizer.plugin.js +133 -0
  222. package/dist/providers/plugins/sso/proxy/plugins/copilot-encrypted-content-sanitizer.plugin.js.map +1 -0
  223. package/dist/providers/plugins/sso/proxy/plugins/header-injection.plugin.js +1 -1
  224. package/dist/providers/plugins/sso/proxy/plugins/header-injection.plugin.js.map +1 -1
  225. package/dist/providers/plugins/sso/proxy/plugins/index.d.ts +2 -1
  226. package/dist/providers/plugins/sso/proxy/plugins/index.d.ts.map +1 -1
  227. package/dist/providers/plugins/sso/proxy/plugins/index.js +4 -2
  228. package/dist/providers/plugins/sso/proxy/plugins/index.js.map +1 -1
  229. package/dist/providers/plugins/sso/proxy/plugins/types.d.ts +11 -0
  230. package/dist/providers/plugins/sso/proxy/plugins/types.d.ts.map +1 -1
  231. package/dist/providers/plugins/sso/proxy/sso.proxy.d.ts +2 -0
  232. package/dist/providers/plugins/sso/proxy/sso.proxy.d.ts.map +1 -1
  233. package/dist/providers/plugins/sso/proxy/sso.proxy.js +37 -1
  234. package/dist/providers/plugins/sso/proxy/sso.proxy.js.map +1 -1
  235. package/dist/providers/plugins/sso/session/SessionSyncer.d.ts.map +1 -1
  236. package/dist/providers/plugins/sso/session/SessionSyncer.js +13 -0
  237. package/dist/providers/plugins/sso/session/SessionSyncer.js.map +1 -1
  238. package/dist/providers/plugins/sso/session/processors/conversations/syncProcessor.js +6 -0
  239. package/dist/providers/plugins/sso/session/processors/conversations/syncProcessor.js.map +1 -1
  240. package/dist/providers/plugins/sso/session/processors/metrics/metrics-post-processor.d.ts +0 -6
  241. package/dist/providers/plugins/sso/session/processors/metrics/metrics-post-processor.d.ts.map +1 -1
  242. package/dist/providers/plugins/sso/session/processors/metrics/metrics-post-processor.js +28 -19
  243. package/dist/providers/plugins/sso/session/processors/metrics/metrics-post-processor.js.map +1 -1
  244. package/dist/providers/plugins/sso/sso.setup-steps.d.ts.map +1 -1
  245. package/dist/providers/plugins/sso/sso.setup-steps.js +39 -22
  246. package/dist/providers/plugins/sso/sso.setup-steps.js.map +1 -1
  247. package/dist/utils/interactive.d.ts +14 -0
  248. package/dist/utils/interactive.d.ts.map +1 -0
  249. package/dist/utils/interactive.js +16 -0
  250. package/dist/utils/interactive.js.map +1 -0
  251. package/package.json +6 -5
  252. package/scripts/copy-plugins.js +6 -0
  253. package/scripts/release.sh +54 -0
@@ -0,0 +1,20 @@
1
+ import type { LlmModel } from '../../../providers/plugins/sso/sso.http-client.js';
2
+ export interface PiModelClassification {
3
+ provider: 'codemie-proxy' | 'codemie-anthropic';
4
+ api?: 'openai-responses';
5
+ }
6
+ export declare function classifyPiModel(modelId: string): PiModelClassification;
7
+ export interface PiModelEntry {
8
+ id: string;
9
+ name: string;
10
+ api?: 'openai-responses';
11
+ reasoning?: boolean;
12
+ thinkingLevelMap?: Record<string, string | null>;
13
+ input: ('text' | 'image')[];
14
+ contextWindow: number;
15
+ maxTokens: number;
16
+ compat?: Record<string, unknown>;
17
+ }
18
+ export declare function convertLlmModelToPiEntry(model: LlmModel): PiModelEntry;
19
+ export declare function fetchAndBuildPiModels(env: NodeJS.ProcessEnv, cwd?: string): Promise<void>;
20
+ //# sourceMappingURL=pi.models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pi.models.d.ts","sourceRoot":"","sources":["../../../../src/agents/plugins/pi/pi.models.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mDAAmD,CAAC;AAMlF,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,eAAe,GAAG,mBAAmB,CAAC;IAChD,GAAG,CAAC,EAAE,kBAAkB,CAAC;CAC1B;AAiBD,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,qBAAqB,CAQtE;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,kBAAkB,CAAC;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;IACjD,KAAK,EAAE,CAAC,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AA0CD,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,QAAQ,GAAG,YAAY,CAgCtE;AAqGD,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,MAAM,CAAC,UAAU,EACtB,GAAG,GAAE,MAAsB,GAC1B,OAAO,CAAC,IAAI,CAAC,CAgCf"}
@@ -0,0 +1,201 @@
1
+ import { mkdir, writeFile } from 'fs/promises';
2
+ import { fetchCodeMieLlmModels } from '../../../providers/plugins/sso/sso.http-client.js';
3
+ import { CodeMieSSO } from '../../../providers/plugins/sso/sso.auth.js';
4
+ import { logger } from '../../../utils/logger.js';
5
+ import { getPiAgentDir, getPiModelsPath } from './pi.paths.js';
6
+ const RESPONSES_API_PATTERNS = [
7
+ /^gpt-5-2-/,
8
+ /^gpt-5\.2-/,
9
+ /^gpt-5-1-codex/,
10
+ /^gpt-5\.1-codex/,
11
+ /^gpt-5-3-codex/,
12
+ /^gpt-5\.3-codex/,
13
+ /^gpt-5\.4-/,
14
+ /^gpt-5-4-/,
15
+ /^gpt-5\.5-/,
16
+ /^gpt-5-5-/,
17
+ /^gpt-5\.6-/,
18
+ /^gpt-5-6-/,
19
+ ];
20
+ export function classifyPiModel(modelId) {
21
+ if (modelId.startsWith('claude')) {
22
+ return { provider: 'codemie-anthropic' };
23
+ }
24
+ if (RESPONSES_API_PATTERNS.some(pattern => pattern.test(modelId))) {
25
+ return { provider: 'codemie-proxy', api: 'openai-responses' };
26
+ }
27
+ return { provider: 'codemie-proxy' };
28
+ }
29
+ function detectLimits(id) {
30
+ if (id.startsWith('claude'))
31
+ return { contextWindow: 200000, maxTokens: 64000 };
32
+ if (id.startsWith('gemini'))
33
+ return { contextWindow: 1048576, maxTokens: 65536 };
34
+ if (id.startsWith('gpt-4.1'))
35
+ return { contextWindow: 1048576, maxTokens: 32768 };
36
+ if (/^gpt-5\.5-/.test(id) || /^gpt-5-5-/.test(id))
37
+ return { contextWindow: 1050000, maxTokens: 128000 };
38
+ if (/^gpt-5\.6-/.test(id) || /^gpt-5-6-/.test(id))
39
+ return { contextWindow: 1050000, maxTokens: 128000 };
40
+ if (id.startsWith('gpt-5'))
41
+ return { contextWindow: 400000, maxTokens: 128000 };
42
+ if (/^o[134]-/.test(id) || id === 'o1')
43
+ return { contextWindow: 200000, maxTokens: 100000 };
44
+ if (id.startsWith('qwen') || id.startsWith('moonshotai') || id.startsWith('kimi')) {
45
+ return { contextWindow: 262144, maxTokens: 131072 };
46
+ }
47
+ if (id.startsWith('deepseek'))
48
+ return { contextWindow: 65536, maxTokens: 65536 };
49
+ return { contextWindow: 128000, maxTokens: 4096 };
50
+ }
51
+ function defaultThinkingLevelMap() {
52
+ return {
53
+ off: null,
54
+ minimal: 'minimal',
55
+ low: 'low',
56
+ medium: 'medium',
57
+ high: 'high',
58
+ xhigh: 'high',
59
+ max: 'high',
60
+ };
61
+ }
62
+ function isReasoningModel(id) {
63
+ return (id.startsWith('claude') ||
64
+ id.startsWith('gemini') ||
65
+ id.startsWith('gpt-5') ||
66
+ /^o[134]-/.test(id) ||
67
+ id === 'o1' ||
68
+ id.startsWith('deepseek') ||
69
+ id.startsWith('moonshotai') ||
70
+ id.startsWith('kimi'));
71
+ }
72
+ export function convertLlmModelToPiEntry(model) {
73
+ const id = model.deployment_name || model.base_name || model.label;
74
+ const limits = detectLimits(id);
75
+ const entry = {
76
+ id,
77
+ name: model.label || id,
78
+ input: model.multimodal ? ['text', 'image'] : ['text'],
79
+ contextWindow: limits.contextWindow,
80
+ maxTokens: limits.maxTokens,
81
+ };
82
+ const classification = classifyPiModel(id);
83
+ if (classification.api) {
84
+ entry.api = classification.api;
85
+ }
86
+ if (isReasoningModel(id)) {
87
+ entry.reasoning = true;
88
+ entry.thinkingLevelMap = defaultThinkingLevelMap();
89
+ }
90
+ if (id.startsWith('claude-sonnet-4-6') ||
91
+ id.startsWith('claude-sonnet-5') ||
92
+ /^claude-opus-4-[6-8]/.test(id) ||
93
+ id.startsWith('claude-opus-5')) {
94
+ entry.compat = { forceAdaptiveThinking: true };
95
+ }
96
+ return entry;
97
+ }
98
+ async function fetchCodeMieModels(env) {
99
+ const jwtToken = env.CODEMIE_JWT_TOKEN;
100
+ const baseUrl = env.CODEMIE_BASE_URL;
101
+ if (jwtToken && baseUrl) {
102
+ logger.debug('[pi-models] Fetching CodeMie model list via JWT auth');
103
+ return fetchCodeMieLlmModels(baseUrl, jwtToken);
104
+ }
105
+ const codeMieUrl = env.CODEMIE_URL;
106
+ if (codeMieUrl) {
107
+ const sso = new CodeMieSSO();
108
+ const credentials = await sso.getStoredCredentials(codeMieUrl);
109
+ if (!credentials) {
110
+ throw new Error(`SSO credentials not found for ${codeMieUrl}. Run: codemie profile login --url ${codeMieUrl}`);
111
+ }
112
+ logger.debug('[pi-models] Fetching CodeMie model list via SSO auth');
113
+ return fetchCodeMieLlmModels(credentials.apiUrl, credentials.cookies);
114
+ }
115
+ throw new Error('No CodeMie authentication available. Run codemie setup or set CODEMIE_JWT_TOKEN.');
116
+ }
117
+ function buildModelsConfig(entries, baseUrl, apiKey) {
118
+ const proxyModels = [];
119
+ const anthropicModels = [];
120
+ for (const entry of entries) {
121
+ const classification = classifyPiModel(entry.id);
122
+ if (classification.provider === 'codemie-anthropic') {
123
+ anthropicModels.push(entry);
124
+ }
125
+ else {
126
+ proxyModels.push(entry);
127
+ }
128
+ }
129
+ const providers = {};
130
+ if (proxyModels.length > 0) {
131
+ providers['codemie-proxy'] = {
132
+ baseUrl: `${baseUrl.replace(/\/$/, '')}/v1`,
133
+ api: 'openai-completions',
134
+ apiKey,
135
+ compat: {
136
+ supportsReasoningEffort: true,
137
+ thinkingFormat: 'reasoning_effort',
138
+ },
139
+ models: proxyModels,
140
+ };
141
+ }
142
+ if (anthropicModels.length > 0) {
143
+ providers['codemie-anthropic'] = {
144
+ baseUrl: baseUrl.replace(/\/$/, ''),
145
+ api: 'anthropic-messages',
146
+ apiKey,
147
+ authHeader: true,
148
+ compat: {
149
+ supportsReasoningEffort: true,
150
+ thinkingFormat: 'reasoning_effort',
151
+ },
152
+ models: anthropicModels,
153
+ };
154
+ }
155
+ return { providers };
156
+ }
157
+ function createSyntheticLlmModel(modelId) {
158
+ return {
159
+ base_name: modelId,
160
+ deployment_name: modelId,
161
+ label: modelId,
162
+ enabled: true,
163
+ multimodal: false,
164
+ features: {},
165
+ };
166
+ }
167
+ function buildStaticFallbackModel(modelId, baseUrl, apiKey) {
168
+ const entry = convertLlmModelToPiEntry(createSyntheticLlmModel(modelId));
169
+ return buildModelsConfig([entry], baseUrl, apiKey);
170
+ }
171
+ export async function fetchAndBuildPiModels(env, cwd = process.cwd()) {
172
+ const agentDir = getPiAgentDir(cwd);
173
+ await mkdir(agentDir, { recursive: true });
174
+ const baseUrl = env.CODEMIE_BASE_URL || '';
175
+ const apiKey = env.CODEMIE_API_KEY || 'proxy-handled';
176
+ let entries = [];
177
+ try {
178
+ const rawModels = await fetchCodeMieModels(env);
179
+ entries = rawModels
180
+ .filter(model => model.enabled)
181
+ .map(convertLlmModelToPiEntry);
182
+ logger.debug(`[pi-models] Loaded ${entries.length} models from CodeMie API`);
183
+ }
184
+ catch (error) {
185
+ const message = error instanceof Error ? error.message : String(error);
186
+ logger.warn(`[pi-models] Failed to fetch live models, falling back to static model: ${message}`);
187
+ const configuredModel = env.CODEMIE_MODEL;
188
+ if (!configuredModel) {
189
+ throw new Error('No CodeMie model configured and live model fetch failed.');
190
+ }
191
+ const fallback = buildStaticFallbackModel(configuredModel, baseUrl, apiKey);
192
+ await writeFile(getPiModelsPath(cwd), JSON.stringify(fallback, null, 2), 'utf-8');
193
+ return;
194
+ }
195
+ if (entries.length === 0) {
196
+ throw new Error('CodeMie returned no enabled models for codemie-pi.');
197
+ }
198
+ const config = buildModelsConfig(entries, baseUrl, apiKey);
199
+ await writeFile(getPiModelsPath(cwd), JSON.stringify(config, null, 2), 'utf-8');
200
+ }
201
+ //# sourceMappingURL=pi.models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pi.models.js","sourceRoot":"","sources":["../../../../src/agents/plugins/pi/pi.models.ts"],"names":[],"mappings":"AAA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,EAAE,CAAC,CAAC;QACjG,MAAM,eAAe,GAAG,GAAG,CAAC,aAAa,CAAC;QAC1C,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;QAC9E,CAAC;QACD,MAAM,QAAQ,GAAG,wBAAwB,CAAC,eAAe,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAC5E,MAAM,SAAS,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;QAClF,OAAO;IACT,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IACxE,CAAC;IAED,MAAM,MAAM,GAAG,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAC3D,MAAM,SAAS,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AAClF,CAAC"}
@@ -0,0 +1,11 @@
1
+ export declare const REQUIRED_PI_PACKAGES: readonly string[];
2
+ export interface InstallPiPackagesOptions {
3
+ /** Pi CLI command name or path (default: 'pi') */
4
+ cliCommand?: string | null;
5
+ /** Working directory for the install commands (default: process.cwd()) */
6
+ cwd?: string;
7
+ /** Per-package timeout in milliseconds (default: 300000) */
8
+ timeout?: number;
9
+ }
10
+ export declare function installRequiredPiPackages(options?: InstallPiPackagesOptions): Promise<void>;
11
+ //# sourceMappingURL=pi.packages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pi.packages.d.ts","sourceRoot":"","sources":["../../../../src/agents/plugins/pi/pi.packages.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,oBAAoB,EAAE,SAAS,MAAM,EAIjD,CAAC;AAEF,MAAM,WAAW,wBAAwB;IACvC,kDAAkD;IAClD,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,0EAA0E;IAC1E,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,4DAA4D;IAC5D,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAID,wBAAsB,yBAAyB,CAC7C,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,IAAI,CAAC,CAkCf"}
@@ -0,0 +1,35 @@
1
+ import { exec } from '../../../utils/exec.js';
2
+ import { logger } from '../../../utils/logger.js';
3
+ import { AgentInstallationError } from '../../../utils/errors.js';
4
+ export const REQUIRED_PI_PACKAGES = [
5
+ 'git:github.com/obra/superpowers',
6
+ 'npm:pi-subagents',
7
+ 'npm:pi-mcp-adapter',
8
+ ];
9
+ const DEFAULT_TIMEOUT_MS = 300_000;
10
+ export async function installRequiredPiPackages(options = {}) {
11
+ const cliCommand = options.cliCommand || 'pi';
12
+ const cwd = options.cwd ?? process.cwd();
13
+ const timeout = options.timeout ?? DEFAULT_TIMEOUT_MS;
14
+ logger.info(`[pi] Installing required Pi packages using ${cliCommand}`);
15
+ for (const pkg of REQUIRED_PI_PACKAGES) {
16
+ logger.info(`[pi] Installing package: ${pkg}`);
17
+ let result;
18
+ try {
19
+ result = await exec(cliCommand, ['install', pkg], {
20
+ cwd,
21
+ timeout,
22
+ });
23
+ }
24
+ catch (error) {
25
+ const message = error instanceof Error ? error.message : String(error);
26
+ throw new AgentInstallationError('pi', `Failed to install Pi package "${pkg}": ${message}`);
27
+ }
28
+ if (result.code !== 0) {
29
+ const output = [result.stdout, result.stderr].filter(Boolean).join('\n');
30
+ throw new AgentInstallationError('pi', `Failed to install Pi package "${pkg}": ${output}`);
31
+ }
32
+ logger.success(`[pi] Installed package: ${pkg}`);
33
+ }
34
+ }
35
+ //# sourceMappingURL=pi.packages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pi.packages.js","sour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,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;YACtB,MAAM,MAAM,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACzE,MAAM,IAAI,sBAAsB,CAC9B,IAAI,EACJ,iCAAiC,GAAG,MAAM,MAAM,EAAE,CACnD,CAAC;QACJ,CAAC;QAED,MAAM,CAAC,OAAO,CAAC,2BAA2B,GAAG,EAAE,CAAC,CAAC;IACnD,CAAC;AACH,CAAC"}
@@ -0,0 +1,37 @@
1
+ export declare function getUserPiAgentDir(): string;
2
+ export declare function getPiAgentDir(cwd?: string): string;
3
+ export declare function getPiModelsPath(cwd?: string): string;
4
+ /**
5
+ * Compute the default Pi session storage directory for a given cwd.
6
+ *
7
+ * Pi encodes the cwd as `--<cwd with leading slash removed and path
8
+ * separators/colons replaced by dashes>--` under the agent dir's `sessions/`.
9
+ */
10
+ export declare function getPiSessionDir(cwd?: string): string;
11
+ export interface PiSessionDirResolution {
12
+ /**
13
+ * Where Pi keeps this project's transcripts. Always an absolute path, so every caller
14
+ * may hand it to Pi and to the filesystem without a further check.
15
+ */
16
+ sessionDir: string;
17
+ /** Whether the user configured a usable directory of their own. */
18
+ isCustom: boolean;
19
+ }
20
+ /**
21
+ * Resolve the effective Pi session directory: the configured one when it has a path form,
22
+ * the default per-cwd encoded directory from {@link getPiSessionDir} otherwise.
23
+ *
24
+ * Falling back is not a substitute directory handed to Pi. `isCustom` is false with it, so
25
+ * no caller injects `PI_CODING_AGENT_SESSION_DIR`, and Pi still reads the user's own value
26
+ * from the flag, the environment, or `settings.json` and aborts on it exactly as a bare
27
+ * `pi` would — the wrapper neither rescues the run nor relocates the transcripts of one
28
+ * that works.
29
+ *
30
+ * What the fallback does prevent is a value with no path form reaching the filesystem.
31
+ * Every unresolvable value is a `file://` URL, and to `existsSync` those are RELATIVE
32
+ * paths: `file://bad` is `<cwd>/file:/bad`, an ordinary directory any working tree may
33
+ * happen to contain. Returning one would have discovery list whatever `.jsonl` files live
34
+ * there and upload them as this session's transcripts.
35
+ */
36
+ export declare function resolvePiSessionDir(cwd?: string, env?: NodeJS.ProcessEnv): PiSessionDirResolution;
37
+ //# sourceMappingURL=pi.paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pi.paths.d.ts","sourceRoot":"","sources":["../../../../src/agents/plugins/pi/pi.paths.ts"],"names":[],"mappings":"AAMA,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,aAAa,CAAC,GAAG,GAAE,MAAsB,GAAG,MAAM,CAEjE;AAED,wBAAgB,eAAe,CAAC,GAAG,GAAE,MAAsB,GAAG,MAAM,CAEnE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,GAAE,MAAsB,GAAG,MAAM,CAInE;AAED,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB,mEAAmE;IACnE,QAAQ,EAAE,OAAO,CAAC;CACnB;AAqGD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,GAAE,MAAsB,EAC3B,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,sBAAsB,CAaxB"}
@@ -0,0 +1,146 @@
1
+ import { join, resolve } from 'path';
2
+ import { homedir } from 'os';
3
+ import { existsSync, readFileSync } from 'fs';
4
+ import { fileURLToPath } from 'url';
5
+ import { logger } from '../../../utils/logger.js';
6
+ export function getUserPiAgentDir() {
7
+ return join(homedir(), '.pi', 'agent');
8
+ }
9
+ export function getPiAgentDir(cwd = process.cwd()) {
10
+ return join(cwd, '.pi', 'codemie', 'agent');
11
+ }
12
+ export function getPiModelsPath(cwd = process.cwd()) {
13
+ return join(getPiAgentDir(cwd), 'models.json');
14
+ }
15
+ /**
16
+ * Compute the default Pi session storage directory for a given cwd.
17
+ *
18
+ * Pi encodes the cwd as `--<cwd with leading slash removed and path
19
+ * separators/colons replaced by dashes>--` under the agent dir's `sessions/`.
20
+ */
21
+ export function getPiSessionDir(cwd = process.cwd()) {
22
+ const resolved = resolve(cwd);
23
+ const safeName = `--${resolved.replace(/^[/\\]/, '').replace(/[/\\:]/g, '-')}--`;
24
+ return join(getPiAgentDir(cwd), 'sessions', safeName);
25
+ }
26
+ /**
27
+ * Convert a Git Bash / MSYS / Cygwin / WSL drive path to native Windows form,
28
+ * matching Pi's `normalizeWindowsShellPath()`.
29
+ */
30
+ function normalizeWindowsShellPath(filePath) {
31
+ if (!filePath.startsWith('/') || filePath.startsWith('//') || filePath.includes('\\')) {
32
+ return filePath;
33
+ }
34
+ const match = filePath.match(/^\/(?:mnt\/|cygdrive\/)?([a-z])(?:\/(.*))?$/i);
35
+ if (!match) {
36
+ return filePath;
37
+ }
38
+ const suffix = match[2]?.replace(/\//g, '\\');
39
+ return `${match[1].toUpperCase()}:\\${suffix ?? ''}`;
40
+ }
41
+ /**
42
+ * Normalize a session-directory path the way Pi does, then resolve it to an
43
+ * absolute path. Returns undefined for a configured value that has no path form.
44
+ *
45
+ * Every channel Pi accepts a path from runs through `normalizePath()`, which
46
+ * rewrites Windows shell paths, expands a leading `~`, and converts `file://`
47
+ * URLs. Node's `resolve()` does none of that, so a raw `~/pi-sessions` would
48
+ * create a literal `~` directory and `file:///tmp/x` would become
49
+ * `<cwd>/file:/tmp/x` — in both cases discovery would scan a directory Pi never
50
+ * writes to, and the run's metrics would be lost without a trace.
51
+ *
52
+ * A `file://` URL that `fileURLToPath` rejects is the one value with no path form. Pi's
53
+ * `normalizePath()` lets the conversion throw, so a bare `pi` aborts before writing
54
+ * anything, whichever channel carried the value. This function cannot throw — it also runs
55
+ * during discovery after the agent has exited, where it would take the whole metrics upload
56
+ * with it — so it reports the absence instead; see {@link resolvePiSessionDir} for what is
57
+ * done with it.
58
+ */
59
+ function normalizeSessionDir(inputPath) {
60
+ const normalized = process.platform === 'win32' ? normalizeWindowsShellPath(inputPath) : inputPath;
61
+ if (normalized === '~') {
62
+ return homedir();
63
+ }
64
+ const hasTildePrefix = normalized.startsWith('~/') || (process.platform === 'win32' && normalized.startsWith('~\\'));
65
+ if (hasTildePrefix) {
66
+ return join(homedir(), normalized.slice(2));
67
+ }
68
+ if (/^file:\/\//.test(normalized)) {
69
+ try {
70
+ return fileURLToPath(normalized);
71
+ }
72
+ catch {
73
+ return undefined;
74
+ }
75
+ }
76
+ return resolve(normalized);
77
+ }
78
+ /**
79
+ * Read `sessionDir` from a Pi `settings.json`, if the file exists and declares one.
80
+ * Malformed JSON is ignored so a broken settings file cannot break discovery.
81
+ */
82
+ function readSettingsSessionDir(settingsPath) {
83
+ if (!existsSync(settingsPath)) {
84
+ return undefined;
85
+ }
86
+ try {
87
+ const settings = JSON.parse(readFileSync(settingsPath, 'utf-8'));
88
+ if (typeof settings.sessionDir === 'string' && settings.sessionDir.length > 0) {
89
+ return settings.sessionDir;
90
+ }
91
+ }
92
+ catch {
93
+ // Malformed settings.json is ignored; fall back to the next source.
94
+ }
95
+ return undefined;
96
+ }
97
+ /**
98
+ * The session directory the user configured, from the highest-precedence source that
99
+ * declares one.
100
+ *
101
+ * Mirrors Pi's own precedence (`main.ts` session-dir resolution and `SettingsManager`,
102
+ * which deep-merges global settings under project settings):
103
+ * 1. `PI_CODING_AGENT_SESSION_DIR` environment variable (set by the user or by
104
+ * this plugin when it injects `--session-dir`).
105
+ * 2. `sessionDir` from the project-local `<cwd>/.pi/settings.json`.
106
+ * 3. `sessionDir` from the Pi `settings.json` located under the effective agent
107
+ * directory (`PI_CODING_AGENT_DIR` or the project-local default).
108
+ */
109
+ function readConfiguredSessionDir(cwd, env) {
110
+ if (env.PI_CODING_AGENT_SESSION_DIR) {
111
+ return env.PI_CODING_AGENT_SESSION_DIR;
112
+ }
113
+ const agentDir = env.PI_CODING_AGENT_DIR ? resolve(env.PI_CODING_AGENT_DIR) : getPiAgentDir(cwd);
114
+ return (readSettingsSessionDir(join(resolve(cwd), '.pi', 'settings.json')) ??
115
+ readSettingsSessionDir(join(agentDir, 'settings.json')));
116
+ }
117
+ /**
118
+ * Resolve the effective Pi session directory: the configured one when it has a path form,
119
+ * the default per-cwd encoded directory from {@link getPiSessionDir} otherwise.
120
+ *
121
+ * Falling back is not a substitute directory handed to Pi. `isCustom` is false with it, so
122
+ * no caller injects `PI_CODING_AGENT_SESSION_DIR`, and Pi still reads the user's own value
123
+ * from the flag, the environment, or `settings.json` and aborts on it exactly as a bare
124
+ * `pi` would — the wrapper neither rescues the run nor relocates the transcripts of one
125
+ * that works.
126
+ *
127
+ * What the fallback does prevent is a value with no path form reaching the filesystem.
128
+ * Every unresolvable value is a `file://` URL, and to `existsSync` those are RELATIVE
129
+ * paths: `file://bad` is `<cwd>/file:/bad`, an ordinary directory any working tree may
130
+ * happen to contain. Returning one would have discovery list whatever `.jsonl` files live
131
+ * there and upload them as this session's transcripts.
132
+ */
133
+ export function resolvePiSessionDir(cwd = process.cwd(), env = process.env) {
134
+ const configured = readConfiguredSessionDir(cwd, env);
135
+ if (configured) {
136
+ const sessionDir = normalizeSessionDir(configured);
137
+ if (sessionDir) {
138
+ return { sessionDir, isCustom: true };
139
+ }
140
+ logger.debug('[pi-paths] Session directory has no path form; using the default', {
141
+ configured,
142
+ });
143
+ }
144
+ return { sessionDir: getPiSessionDir(cwd), isCustom: false };
145
+ }
146
+ //# sourceMappingURL=pi.paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pi.paths.js","sourceRoot":"","sources":["../../../../src/agents/plugins/pi/pi.paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,E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AAE,UAAU,EAAE,eAAe,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;AAC/D,CAAC"}
@@ -0,0 +1,30 @@
1
+ import type { AgentMetadata } from '../../core/types.js';
2
+ import { BaseAgentAdapter } from '../../core/BaseAgentAdapter.js';
3
+ import type { SessionAdapter } from '../../core/session/BaseSessionAdapter.js';
4
+ /**
5
+ * Reconcile CodeMie's CLI surface with Pi's session flags before the run starts.
6
+ *
7
+ * Two argv-derived facts are needed later by hooks that cannot see argv:
8
+ * `beforeRun` receives only `env`, and `enrichArgs` receives no env at all. Both
9
+ * are published through `envOverrides`, which `BaseAgentAdapter` spreads into the
10
+ * run-scoped `env` object that also reaches `onSessionEnd` and session discovery.
11
+ */
12
+ export declare function preparePiInvocation(args: string[], envOverrides?: Record<string, string>): {
13
+ args: string[];
14
+ envOverrides: Record<string, string>;
15
+ };
16
+ export declare const PiPluginMetadata: AgentMetadata;
17
+ export declare class PiPlugin extends BaseAgentAdapter {
18
+ private sessionAdapter;
19
+ constructor();
20
+ getSessionAdapter(): SessionAdapter;
21
+ /**
22
+ * Translate CodeMie's session flags to Pi's and publish the argv-derived facts
23
+ * that `beforeRun` and `enrichArgs` need but cannot read from argv themselves.
24
+ */
25
+ run(args: string[], envOverrides?: Record<string, string>, runOptions?: {
26
+ dryRun?: boolean;
27
+ }): Promise<void>;
28
+ additionalInstallation(_options?: import('../../core/types.js').AgentInstallationOptions): Promise<void>;
29
+ }
30
+ //# sourceMappingURL=pi.plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pi.plugin.d.ts","sourceRoot":"","sources":["../../../../src/agents/plugins/pi/pi.plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAe,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AA4C/E;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EAAE,EACd,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACpC;IAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CA4B1D;AA6ED,eAAO,MAAM,gBAAgB,EAAE,aAmU9B,CAAC;AAEF,qBAAa,QAAS,SAAQ,gBAAgB;IAC5C,OAAO,CAAC,cAAc,CAAiB;;IAOvC,iBAAiB,IAAI,cAAc;IAInC;;;OAGG;IACG,GAAG,CACP,IAAI,EAAE,MAAM,EAAE,EACd,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACrC,UAAU,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,GAChC,OAAO,CAAC,IAAI,CAAC;IAKV,sBAAsB,CAC1B,QAAQ,CAAC,EAAE,OAAO,qBAAqB,EAAE,wBAAwB,GAChE,OAAO,CAAC,IAAI,CAAC;CAGjB"}