@tailor-platform/sdk 2.0.0-next.0 → 2.0.0-next.2

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 (208) hide show
  1. package/CHANGELOG.md +161 -0
  2. package/dist/application-Dtqap5jM.mjs +3 -0
  3. package/dist/{client-CobIRHl-.mjs → application-XuMWK4eq.mjs} +5869 -25
  4. package/dist/application-XuMWK4eq.mjs.map +1 -0
  5. package/dist/{assert-CKfwrmCV.mjs → assert-DBxo8jPo.mjs} +1 -2
  6. package/dist/{assert-CKfwrmCV.mjs.map → assert-DBxo8jPo.mjs.map} +1 -1
  7. package/dist/{authconnection-D8SJGMpj.mjs → authconnection-D2MhtTN5.mjs} +2 -3
  8. package/dist/{authconnection-D8SJGMpj.mjs.map → authconnection-D2MhtTN5.mjs.map} +1 -1
  9. package/dist/{authconnection-BIYzEh2p.d.mts → authconnection-DvUQAjQS.d.mts} +1 -1
  10. package/dist/{brand-DlnJ375c.mjs → brand-Eo4pLXPJ.mjs} +1 -2
  11. package/dist/{brand-DlnJ375c.mjs.map → brand-Eo4pLXPJ.mjs.map} +1 -1
  12. package/dist/cli/index.mjs +241 -237
  13. package/dist/cli/index.mjs.map +1 -1
  14. package/dist/cli/lib.d.mts +547 -620
  15. package/dist/cli/lib.mjs +9 -11
  16. package/dist/cli/lib.mjs.map +1 -1
  17. package/dist/completion/zsh-worker.zsh +4108 -0
  18. package/dist/configure/index.d.mts +9 -7
  19. package/dist/configure/index.mjs +76 -40
  20. package/dist/configure/index.mjs.map +1 -1
  21. package/dist/{context-s0lxhu8_.mjs → context-Bd266-ru.mjs} +2 -3
  22. package/dist/context-Bd266-ru.mjs.map +1 -0
  23. package/dist/{context-CUBwSBq4.d.mts → context-C2lEi9uw.d.mts} +7 -28
  24. package/dist/{crashreport-D1wKBJ8N.mjs → crashreport-BMWcxeSE.mjs} +1 -2
  25. package/dist/{crashreport-BhD0y14F.mjs → crashreport-DFq-vsU0.mjs} +21 -14
  26. package/dist/{crashreport-BhD0y14F.mjs.map → crashreport-DFq-vsU0.mjs.map} +1 -1
  27. package/dist/{enum-constants-C7DaWeQo.mjs → enum-constants-j9QBF0cB.mjs} +1 -2
  28. package/dist/enum-constants-j9QBF0cB.mjs.map +1 -0
  29. package/dist/{errors-EsY4XO6O.mjs → errors-Dtf2WPaW.mjs} +1 -2
  30. package/dist/{errors-EsY4XO6O.mjs.map → errors-Dtf2WPaW.mjs.map} +1 -1
  31. package/dist/{field-C4zdJLW5.mjs → field-DOsJCPFa.mjs} +1 -2
  32. package/dist/field-DOsJCPFa.mjs.map +1 -0
  33. package/dist/{file-B58Dm-2P.mjs → file-BbdFGdMV.mjs} +3 -12
  34. package/dist/file-BbdFGdMV.mjs.map +1 -0
  35. package/dist/{file-BzK8z3X-.d.mts → file-Dq3NIt_F.d.mts} +3 -42
  36. package/dist/{file-utils-BHPxPXmn.mjs → file-utils-CYZnO1pX.mjs} +6 -7
  37. package/dist/file-utils-CYZnO1pX.mjs.map +1 -0
  38. package/dist/{globals-ByrCoDip.mjs → globals-Cf0sxIt8.mjs} +53 -5
  39. package/dist/globals-Cf0sxIt8.mjs.map +1 -0
  40. package/dist/http-adapter.generated-DFsXDdm5.d.mts +581 -0
  41. package/dist/{iconv-kwrmd1U_.d.mts → iconv-Co-TOPuH.d.mts} +1 -1
  42. package/dist/{iconv-DreIffeM.mjs → iconv-D2vi8G36.mjs} +2 -3
  43. package/dist/{iconv-DreIffeM.mjs.map → iconv-D2vi8G36.mjs.map} +1 -1
  44. package/dist/{idp-Ch95ag8h.mjs → idp-BDbK5gjm.mjs} +2 -3
  45. package/dist/{idp-Ch95ag8h.mjs.map → idp-BDbK5gjm.mjs.map} +1 -1
  46. package/dist/{idp-BlBPtXJ-.d.mts → idp-DrhVrLmV.d.mts} +1 -1
  47. package/dist/{index-CLxubakC.d.mts → index-BI-_j9Z3.d.mts} +49 -261
  48. package/dist/{index-CPRnOjjt.d.mts → index-C4JirJH8.d.mts} +2 -2
  49. package/dist/{index-CQZVJ5SX.d.mts → index-CZfWhr0a.d.mts} +2 -2
  50. package/dist/{index-DRhMpdnA.d.mts → index-Cg8VKAdN.d.mts} +8 -8
  51. package/dist/{index-CfRFkXIO.d.mts → index-DYRjoLXD.d.mts} +2 -2
  52. package/dist/index-lFpcjHPU.d.mts +201 -0
  53. package/dist/{index-DUupuPhZ.d.mts → index-nW7hE6oE.d.mts} +2 -2
  54. package/dist/{interceptor-DOqRkCya.mjs → interceptor-D-q1rvRl.mjs} +1 -2
  55. package/dist/{interceptor-DOqRkCya.mjs.map → interceptor-D-q1rvRl.mjs.map} +1 -1
  56. package/dist/kysely/index.mjs +0 -1
  57. package/dist/kysely/index.mjs.map +1 -1
  58. package/dist/{kysely-type-D1e0Vwkd.mjs → kysely-type-DR8uzZTA.mjs} +2 -3
  59. package/dist/kysely-type-DR8uzZTA.mjs.map +1 -0
  60. package/dist/{logger-DpJyJvNz.mjs → logger-CxF-Ex5d.mjs} +1 -2
  61. package/dist/{logger-DpJyJvNz.mjs.map → logger-CxF-Ex5d.mjs.map} +1 -1
  62. package/dist/{mock-DMgIygjE.mjs → mock-FPxmnt-y.mjs} +9 -56
  63. package/dist/mock-FPxmnt-y.mjs.map +1 -0
  64. package/dist/{multiline-Cf9ODpr1.mjs → multiline-sfHpTZZK.mjs} +1 -2
  65. package/dist/{multiline-Cf9ODpr1.mjs.map → multiline-sfHpTZZK.mjs.map} +1 -1
  66. package/dist/{package-json-DcQApfPQ.mjs → package-json-8b0O9TlX.mjs} +1 -2
  67. package/dist/{package-json-DcQApfPQ.mjs.map → package-json-8b0O9TlX.mjs.map} +1 -1
  68. package/dist/package-json-Cv2Z-TqQ.mjs +3 -0
  69. package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
  70. package/dist/plugin/builtin/enum-constants/index.mjs +1 -2
  71. package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
  72. package/dist/plugin/builtin/file-utils/index.mjs +1 -2
  73. package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
  74. package/dist/plugin/builtin/kysely-type/index.mjs +1 -2
  75. package/dist/plugin/builtin/seed/index.d.mts +1 -1
  76. package/dist/plugin/builtin/seed/index.mjs +1 -2
  77. package/dist/plugin/index.d.mts +4 -5
  78. package/dist/plugin/index.mjs +0 -1
  79. package/dist/plugin/index.mjs.map +1 -1
  80. package/dist/registry-DH4m7eYo.mjs +53 -0
  81. package/dist/registry-DH4m7eYo.mjs.map +1 -0
  82. package/dist/{repl-editor-CJG3sz7A.mjs → repl-editor-DmGr9zMw.mjs} +2 -3
  83. package/dist/{repl-editor-CJG3sz7A.mjs.map → repl-editor-DmGr9zMw.mjs.map} +1 -1
  84. package/dist/{chunk-BkoGK1jX.mjs → rolldown-runtime-DXywRVcq.mjs} +0 -1
  85. package/dist/runtime/authconnection.d.mts +1 -1
  86. package/dist/runtime/authconnection.mjs +1 -2
  87. package/dist/runtime/context.d.mts +1 -1
  88. package/dist/runtime/context.mjs +1 -2
  89. package/dist/runtime/file.d.mts +2 -2
  90. package/dist/runtime/file.mjs +2 -3
  91. package/dist/runtime/globals.d.mts +8 -41
  92. package/dist/runtime/globals.mjs +0 -1
  93. package/dist/runtime/iconv.d.mts +1 -1
  94. package/dist/runtime/iconv.mjs +1 -2
  95. package/dist/runtime/idp.d.mts +1 -1
  96. package/dist/runtime/idp.mjs +1 -2
  97. package/dist/runtime/index.d.mts +8 -8
  98. package/dist/runtime/index.mjs +7 -8
  99. package/dist/runtime/secretmanager.d.mts +1 -1
  100. package/dist/runtime/secretmanager.mjs +1 -2
  101. package/dist/runtime/workflow.d.mts +2 -2
  102. package/dist/runtime/workflow.mjs +1 -2
  103. package/dist/{runtime-C7qTBDD2.mjs → runtime-CY4JvrDj.mjs} +1069 -542
  104. package/dist/runtime-CY4JvrDj.mjs.map +1 -0
  105. package/dist/{schema-1msIhXwA.mjs → schema-Dtw9Orye.mjs} +18 -16
  106. package/dist/schema-Dtw9Orye.mjs.map +1 -0
  107. package/dist/{secret-file-CWzF8rry.mjs → secret-file-VSVGy1V0.mjs} +27 -3
  108. package/dist/{secret-file-CWzF8rry.mjs.map → secret-file-VSVGy1V0.mjs.map} +1 -1
  109. package/dist/{secretmanager-CKLB3wAQ.d.mts → secretmanager-B3n4KHfm.d.mts} +1 -1
  110. package/dist/{secretmanager-B9h-U_8U.mjs → secretmanager-BVxw3ih_.mjs} +2 -3
  111. package/dist/{secretmanager-B9h-U_8U.mjs.map → secretmanager-BVxw3ih_.mjs.map} +1 -1
  112. package/dist/seed/index.mjs +0 -1
  113. package/dist/seed/index.mjs.map +1 -1
  114. package/dist/{seed-BH2FbrPV.mjs → seed-izIEyP3z.mjs} +7 -19
  115. package/dist/seed-izIEyP3z.mjs.map +1 -0
  116. package/dist/service-DCqIWibD.mjs +3 -0
  117. package/dist/{service-DMohAx8a2.mjs → service-DU1mVzri2.mjs} +3 -4
  118. package/dist/{service-DMohAx8a2.mjs.map → service-DU1mVzri2.mjs.map} +1 -1
  119. package/dist/{service-wI3Hvrgx.mjs → service-DjyqbCaJ.mjs} +9 -10
  120. package/dist/service-DjyqbCaJ.mjs.map +1 -0
  121. package/dist/{telemetry-BQbbVo2t.mjs → telemetry-CdqJEzkj.mjs} +2 -3
  122. package/dist/{telemetry-BQbbVo2t.mjs.map → telemetry-CdqJEzkj.mjs.map} +1 -1
  123. package/dist/telemetry-ClwW5ohF.mjs +3 -0
  124. package/dist/test-env-key-D7UkZp99.mjs +75 -0
  125. package/dist/test-env-key-D7UkZp99.mjs.map +1 -0
  126. package/dist/type-source-DH_LH20p.mjs +13 -0
  127. package/dist/type-source-DH_LH20p.mjs.map +1 -0
  128. package/dist/types-74etvaxy.mjs +4 -0
  129. package/dist/{plugin-C_FyVSdl.d.mts → types-BDRml5C3.d.mts} +128 -188
  130. package/dist/{types-CmzfQP_m.mjs → types-BQijbo4m.mjs} +10 -11
  131. package/dist/types-BQijbo4m.mjs.map +1 -0
  132. package/dist/types-BX4q6Mo6.d.mts +339 -0
  133. package/dist/types-BZ7QKVE8.d.mts +21 -0
  134. package/dist/{tailordb-BlBGmQK-.d.mts → types-CdcQh4Z2.d.mts} +92 -242
  135. package/dist/utils/test/index.d.mts +6 -14
  136. package/dist/utils/test/index.mjs +4 -14
  137. package/dist/utils/test/index.mjs.map +1 -1
  138. package/dist/vitest/environment.mjs +1 -2
  139. package/dist/vitest/environment.mjs.map +1 -1
  140. package/dist/vitest/index.d.mts +42 -5
  141. package/dist/vitest/index.mjs +133 -4
  142. package/dist/vitest/index.mjs.map +1 -1
  143. package/dist/vitest/setup.mjs +2 -3
  144. package/dist/vitest/setup.mjs.map +1 -1
  145. package/dist/{workflow--aPbA8Uq.mjs → workflow-BOmaZwwG.mjs} +9 -5
  146. package/dist/workflow-BOmaZwwG.mjs.map +1 -0
  147. package/dist/{workflow-CMamswkK.d.mts → workflow-BVy4XWjS.d.mts} +15 -10
  148. package/dist/workflow.generated-ClEjBYhm.d.mts +671 -0
  149. package/docs/cli/application.md +0 -2
  150. package/docs/cli/completion.md +3 -0
  151. package/docs/cli/crashreport.md +0 -2
  152. package/docs/cli/executor.md +53 -0
  153. package/docs/cli/function.md +1 -1
  154. package/docs/cli/setup.md +35 -33
  155. package/docs/cli/user.md +3 -3
  156. package/docs/cli/workflow.md +157 -20
  157. package/docs/cli/workspace.md +3 -3
  158. package/docs/cli-reference.md +26 -20
  159. package/docs/configuration.md +0 -2
  160. package/docs/github-actions.md +29 -16
  161. package/docs/migration/v2.md +475 -0
  162. package/docs/plugin/custom.md +2 -2
  163. package/docs/plugin/index.md +1 -1
  164. package/docs/runtime.md +4 -4
  165. package/docs/services/aigateway.md +97 -0
  166. package/docs/services/auth.md +31 -14
  167. package/docs/services/executor.md +3 -5
  168. package/docs/services/resolver.md +8 -10
  169. package/docs/services/tailordb.md +15 -13
  170. package/docs/services/workflow.md +17 -19
  171. package/docs/testing.md +75 -56
  172. package/package.json +18 -17
  173. package/dist/actor-J2gJ0eK5.d.mts +0 -24
  174. package/dist/application-76hhIhnJ.mjs +0 -5594
  175. package/dist/application-76hhIhnJ.mjs.map +0 -1
  176. package/dist/application-av2raLs6.mjs +0 -4
  177. package/dist/cli/skills.d.mts +0 -1
  178. package/dist/cli/skills.mjs +0 -22
  179. package/dist/cli/skills.mjs.map +0 -1
  180. package/dist/client-C68VWo4g.mjs +0 -4
  181. package/dist/client-CobIRHl-.mjs.map +0 -1
  182. package/dist/context-s0lxhu8_.mjs.map +0 -1
  183. package/dist/enum-constants-C7DaWeQo.mjs.map +0 -1
  184. package/dist/env-B-g-qgE4.d.mts +0 -7
  185. package/dist/field-C4zdJLW5.mjs.map +0 -1
  186. package/dist/file-B58Dm-2P.mjs.map +0 -1
  187. package/dist/file-utils-BHPxPXmn.mjs.map +0 -1
  188. package/dist/globals-ByrCoDip.mjs.map +0 -1
  189. package/dist/job-BpsFXPbi.mjs +0 -54
  190. package/dist/job-BpsFXPbi.mjs.map +0 -1
  191. package/dist/kysely-type-D1e0Vwkd.mjs.map +0 -1
  192. package/dist/mock-DMgIygjE.mjs.map +0 -1
  193. package/dist/package-json-wzO6nV9O.mjs +0 -4
  194. package/dist/registry-D0uB0OrK.mjs +0 -178
  195. package/dist/registry-D0uB0OrK.mjs.map +0 -1
  196. package/dist/runtime-C7qTBDD2.mjs.map +0 -1
  197. package/dist/schema-1msIhXwA.mjs.map +0 -1
  198. package/dist/seed-BH2FbrPV.mjs.map +0 -1
  199. package/dist/service-BHQIerYh.mjs +0 -4
  200. package/dist/service-wI3Hvrgx.mjs.map +0 -1
  201. package/dist/telemetry-w92bvGdC.mjs +0 -4
  202. package/dist/types-2Be3wSMc.mjs +0 -5
  203. package/dist/types-CmzfQP_m.mjs.map +0 -1
  204. package/dist/workflow--aPbA8Uq.mjs.map +0 -1
  205. package/dist/workflow.generated-Bf1tWylx.d.mts +0 -1416
  206. package/docs/generator/builtin.md +0 -257
  207. package/docs/generator/custom.md +0 -147
  208. package/docs/generator/index.md +0 -66
@@ -1,16 +1,15 @@
1
1
  #!/usr/bin/env node
2
-
3
- import { Et as AuthInvokerSchema, L as CustomDomainStatus, Nt as PATScope, Q as FunctionExecution_Type, _ as userAgent, a as fetchAll, c as fetchPlatformMachineUserToken, d as initOAuth2Client, f as initOperatorClient, l as fetchUserInfo, r as closeConnectionPool, s as fetchPaged } from "../client-CobIRHl-.mjs";
4
- import { t as assertDefined } from "../assert-CKfwrmCV.mjs";
5
- import { n as logger, r as styles } from "../logger-DpJyJvNz.mjs";
6
- import { $ as listCommand$10, $t as INITIAL_SCHEMA_NUMBER, An as commonArgs, At as startCommand, B as logBetaWarning, C as listCommand$13, Cn as PluginManager, Dt as jobsCommand, E as resumeCommand, En as apiCommand, F as writeDbTypesFile, Fn as pagedLogArgs, Gt as MIGRATION_LABEL_KEY, H as removeCommand$1, Ht as executeScript, I as getConfiguredEditorCommand, In as paginationArgs, Jt as compareSnapshotWithRemote, K as treeCommand, Kt as handleOptionalToRequiredError, L as openInConfiguredEditor, Ln as toPageDirection, Lt as functionExecutionStatusToString, Mn as confirmationArgs, Mt as getCommand$6, N as generateCommand$1, Nn as deploymentArgs, O as listCommand$12, On as assertWritable, P as generateMigrationScript, Pn as isVerbose, Pt as executionsCommand, Rn as workspaceArgs, Rt as formatKeyValueTable, Sn as sdkNameLabelKey, St as triggerCommand, T as healthCommand, Tn as prompt, U as updateCommand$3, Vt as deploy, Xt as protoGqlPermission, Y as getCommand$5, Yt as generateAllTypeManifestsFromSnapshot, Z as updateCommand$2, _n as formatMigrationDiff, an as createSnapshotFromLocalTypes, at as createCommand$3, b as createCommand$4, bn as ensureConfigId, c as listCommand$14, cn as getMigrationFilePath, dn as isValidMigrationNumber, f as restoreCommand, fn as loadDiff, ft as tokenCommand, g as getCommand$7, gt as listCommand$7, hn as parseMigrationNumberArg, ht as generate, i as updateCommand$4, j as truncateCommand, jn as configArg, kn as defineAppCommand, ln as getMigrationFiles, lt as getCommand$3, m as listCommand$15, mn as formatMigrationNumber, nn as assertValidMigrationFiles, o as removeCommand, on as getLatestMigrationNumber, pn as reconstructSnapshotFromMigrations, pt as listCommand$8, q as listCommand$11, qt as parseMigrationLabelNumber, r as queryCommand, rn as compareLocalTypesWithSnapshot, rt as deleteCommand$3, st as listCommand$9, t as isNativeTypeScriptRuntime, tt as getCommand$4, u as inviteCommand, v as deleteCommand$4, vn as hasChanges, vt as getCommand$2, wn as generateUserTypes, wt as listCommand$6, xn as resourceTrn, xt as webhookCommand, yn as getNamespacesWithMigrations, z as showCommand, zt as getCommand$1 } from "../runtime-C7qTBDD2.mjs";
7
- import { A as readPlatformConfig, C as loadConfig, E as loadAccessToken, M as saveUserTokens, N as writePlatformConfig, O as loadMachineUserName, T as fetchLatestToken, _ as createLogLevelTreeshakeOptions, a as WorkflowJobSchema, b as getDistDir, c as INVOKER_EXPR, g as composeFunctionTreeshakeOptions, h as platformBundleDefinePlugin, i as resolveInlineSourcemap, j as resolveTokens, k as loadWorkspaceId, o as ResolverSchema, t as defineApplication, v as resolveBundleLogLevel, w as deleteUserTokens, x as hashContent$1 } from "../application-76hhIhnJ.mjs";
8
- import { n as ExecutorSchema } from "../service-wI3Hvrgx.mjs";
9
- import { t as multiline } from "../multiline-Cf9ODpr1.mjs";
10
- import { r as isPluginGeneratedType } from "../seed-BH2FbrPV.mjs";
11
- import { t as readPackageJson } from "../package-json-DcQApfPQ.mjs";
12
- import { n as isCLIError } from "../errors-EsY4XO6O.mjs";
13
- import { a as JSON_FOOTER_MARKER, i as CRASH_LOG_EXTENSION, o as parseCrashReportConfig, r as sendCrashReport, t as initCrashReporting } from "../crashreport-BhD0y14F.mjs";
2
+ import { A as loadAccessToken, At as FunctionExecution_Type, B as fetchAll, C as getDistDir, D as deleteUserTokens, E as loadConfig, F as removeLegacyUserAlias, G as initOAuth2Client, H as fetchPaged, I as resolveTokens, K as initOperatorClient, L as saveUserTokens, M as loadMachineUserName, N as loadWorkspaceId, O as fetchLatestToken, P as readPlatformConfig, R as writePlatformConfig, U as fetchPlatformMachineUserToken, W as fetchUserInfo, _ as composeFunctionTreeshakeOptions, dn as PATScope, g as platformBundleDefinePlugin, ht as CustomDomainStatus, i as resolveInlineSourcemap, in as AuthInvokerSchema, k as findConfigUserKey, l as INVOKER_EXPR, o as WorkflowJobSchema, s as ResolverSchema, t as defineApplication, v as createLogLevelTreeshakeOptions, w as hashContent$1, y as resolveBundleLogLevel, z as closeConnectionPool } from "../application-XuMWK4eq.mjs";
3
+ import { t as assertDefined } from "../assert-DBxo8jPo.mjs";
4
+ import { n as logger, r as styles } from "../logger-CxF-Ex5d.mjs";
5
+ import { $ as updateCommand$2, $t as protoGqlPermission, A as listCommand$12, At as jobsCommand, Bn as toPageDirection, Bt as functionExecutionStatusToString, C as listCommand$13, Cn as ensureConfigId, Ct as webhookCommand, Dn as generateUserTypes, E as waitCommand, En as PluginManager, Et as listCommand$6, F as generateCommand$1, Fn as confirmationArgs, Ft as getCommand$6, G as updateCommand$3, Gt as executeScript, H as logBetaWarning, Ht as getCommand$1, I as generateMigrationScript, In as deploymentArgs, J as treeCommand, Jt as MIGRATION_LABEL_KEY, L as writeDbTypesFile, Ln as isVerbose, Lt as executionsCommand, Mn as defineAppCommand, N as truncateCommand, Nn as commonArgs, Nt as startCommand, O as resumeCommand, On as prompt, Pn as configArg, Qt as generateAllTypeManifestsFromSnapshot, R as getConfiguredEditorCommand, Rn as pagedLogArgs, Sn as getNamespacesWithMigrations, T as healthCommand, Tn as sdkNameLabelKey, V as showCommand, Vn as workspaceArgs, Vt as formatKeyValueTable, W as removeCommand$1, Wt as deploy, Xt as parseMigrationLabelNumber, Y as listCommand$11, Yt as handleOptionalToRequiredError, Z as getCommand$5, Zt as compareSnapshotWithRemote, _n as formatMigrationNumber, _t as generate, an as assertValidMigrationFiles, at as deleteCommand$3, b as createCommand$4, bn as formatMigrationDiff, bt as getCommand$2, c as listCommand$14, cn as createSnapshotFromLocalTypes, dn as getMigrationFilePath, dt as getCommand$3, f as restoreCommand, fn as getMigrationFiles, g as getCommand$7, gn as reconstructSnapshotFromMigrations, hn as loadDiff, ht as listCommand$8, i as updateCommand$4, jn as assertWritable, kn as apiCommand, ln as getLatestMigrationNumber, lt as listCommand$9, m as listCommand$15, mn as isValidMigrationNumber, mt as tokenCommand, nn as INITIAL_SCHEMA_NUMBER, o as removeCommand, on as compareLocalTypesWithSnapshot, r as queryCommand, rt as getCommand$4, st as createCommand$3, t as isNativeTypeScriptRuntime, tt as listCommand$10, u as inviteCommand, v as deleteCommand$4, vn as parseMigrationNumberArg, vt as listCommand$7, wn as resourceTrn, wt as triggerCommand, xn as hasChanges, z as openInConfiguredEditor, zn as paginationArgs } from "../runtime-CY4JvrDj.mjs";
6
+ import { n as ExecutorSchema } from "../service-DjyqbCaJ.mjs";
7
+ import { t as multiline } from "../multiline-sfHpTZZK.mjs";
8
+ import { t as readPackageJson } from "../package-json-8b0O9TlX.mjs";
9
+ import { i as userAgent } from "../secret-file-VSVGy1V0.mjs";
10
+ import { n as isCLIError } from "../errors-Dtf2WPaW.mjs";
11
+ import { a as JSON_FOOTER_MARKER, i as CRASH_LOG_EXTENSION, o as parseCrashReportConfig, r as sendCrashReport, t as initCrashReporting } from "../crashreport-DFq-vsU0.mjs";
12
+ import { t as isPluginGeneratedType } from "../type-source-DH_LH20p.mjs";
14
13
  import { arg, defineCommand, runCommand, runMain } from "politty";
15
14
  import { withCompletionCommand } from "politty/completion";
16
15
  import { z } from "zod";
@@ -22,6 +21,7 @@ import { dirname, resolve } from "pathe";
22
21
  import { fileURLToPath, pathToFileURL } from "node:url";
23
22
  import { generateCodeVerifier } from "@badgateway/oauth2-client";
24
23
  import { Code, ConnectError } from "@connectrpc/connect";
24
+ import pLimit from "p-limit";
25
25
  import { resolvePackageJSON, resolveTSConfig } from "pkg-types";
26
26
  import * as crypto from "node:crypto";
27
27
  import { createHash } from "node:crypto";
@@ -30,13 +30,12 @@ import open from "open";
30
30
  import * as rolldown from "rolldown";
31
31
  import * as fsPromises from "node:fs/promises";
32
32
  import { glob } from "node:fs/promises";
33
- import pLimit from "p-limit";
33
+ import { setTimeout as setTimeout$1 } from "node:timers/promises";
34
34
  import { TraceMap, generatedPositionFor, originalPositionFor } from "@jridgewell/trace-mapping";
35
35
  import { spawn, spawnSync } from "node:child_process";
36
36
  import { watch } from "chokidar";
37
37
  import * as fs from "fs";
38
38
  import { lookup } from "mime-types";
39
- import { setTimeout as setTimeout$1 } from "node:timers/promises";
40
39
 
41
40
  //#region src/cli/commands/authconnection/args.ts
42
41
  /**
@@ -453,7 +452,6 @@ function parseCrashLogFile(content) {
453
452
  //#region src/cli/commands/crashreport/index.ts
454
453
  const crashReportCommand = defineCommand({
455
454
  name: "crashreport",
456
- aliases: ["crash-report"],
457
455
  description: "Manage crash reports.",
458
456
  subCommands: {
459
457
  list: listCommand$5,
@@ -468,7 +466,6 @@ const crashReportCommand = defineCommand({
468
466
  //#region src/cli/commands/deploy/index.ts
469
467
  const deployCommand$1 = defineAppCommand({
470
468
  name: "deploy",
471
- aliases: ["apply"],
472
469
  description: "Deploy your application by applying the Tailor configuration.",
473
470
  args: z.object({
474
471
  ...deploymentArgs,
@@ -484,7 +481,7 @@ const deployCommand$1 = defineAppCommand({
484
481
  }).strict(),
485
482
  run: async (args) => {
486
483
  await assertWritable({ profile: args.profile });
487
- const { initTelemetry } = await import("../telemetry-w92bvGdC.mjs");
484
+ const { initTelemetry } = await import("../telemetry-ClwW5ohF.mjs");
488
485
  await initTelemetry();
489
486
  await deploy({
490
487
  workspaceId: args["workspace-id"],
@@ -572,32 +569,24 @@ function scriptNameToRegistryName(scriptName, executionType) {
572
569
  /**
573
570
  * Download a deployed function script.
574
571
  *
575
- * Returns the bundled script content together with the registry
576
- * entry's `updatedAt` timestamp. Returns null when the download fails
577
- * (script removed, network error, etc.) or when no content chunks are
578
- * received; errors are swallowed so callers can fall back to a
579
- * non-sourcemap display.
572
+ * Returns the bundled script content. Returns null when the download
573
+ * fails (script removed, network error, etc.) or when no content
574
+ * chunks are received; errors are swallowed so callers can fall back
575
+ * to a non-sourcemap display.
580
576
  * @param options - Download options
581
- * @returns Script content plus metadata, or null on failure / empty response
577
+ * @returns Script content, or null on failure / empty response
582
578
  */
583
579
  async function downloadFunctionScript(options) {
584
580
  const { client, workspaceId, name, contentHash } = options;
585
581
  try {
586
582
  const chunks = [];
587
- let registryUpdatedAt = null;
588
583
  for await (const response of client.downloadFunctionRegistryScript({
589
584
  workspaceId,
590
585
  name,
591
586
  contentHash
592
- })) if (response.payload.case === "metadata") {
593
- const updatedAt = response.payload.value.function?.updatedAt;
594
- if (updatedAt) registryUpdatedAt = timestampDate(updatedAt);
595
- } else if (response.payload.case === "chunk") chunks.push(response.payload.value);
587
+ })) if (response.payload.case === "chunk") chunks.push(response.payload.value);
596
588
  if (chunks.length === 0) return null;
597
- return {
598
- code: Buffer.concat(chunks).toString("utf-8"),
599
- registryUpdatedAt
600
- };
589
+ return { code: Buffer.concat(chunks).toString("utf-8") };
601
590
  } catch (error) {
602
591
  logger.debug(`Failed to download function script "${options.name}": ${error}`);
603
592
  return null;
@@ -966,13 +955,12 @@ function printFunctionExecutionDetail(options) {
966
955
  /**
967
956
  * Download a deployed function script for sourcemap mapping. Logs a
968
957
  * debug message on failure but never throws. Error display falls back
969
- * to a plain-text format when the script cannot be retrieved or when
970
- * the current registry entry is stale relative to the execution.
958
+ * to a plain-text format when the script cannot be retrieved.
971
959
  *
972
960
  * When `executionContentHash` is non-empty, the download is pinned to
973
961
  * that exact bundle so mapping stays correct across redeploys. When
974
- * empty (older servers), falls back to comparing `registryUpdatedAt`
975
- * against `executionStartedAt`.
962
+ * empty, mapping is skipped because the exact bundle cannot be
963
+ * identified.
976
964
  *
977
965
  * `FunctionExecution.scriptName` does not match the function registry
978
966
  * name directly; `scriptNameToRegistryName` translates between the two
@@ -983,50 +971,37 @@ function printFunctionExecutionDetail(options) {
983
971
  * @param options.scriptName - Script name (matches FunctionExecution.scriptName)
984
972
  * @param options.executionType - Execution type used to discriminate registry name translation
985
973
  * @param options.executionContentHash - Content hash of the bundle that ran; pins the download when non-empty
986
- * @param options.executionStartedAt - Execution start timestamp used as fallback staleness signal
987
- * @returns Bundled script content, or null when unavailable / stale
974
+ * @returns Bundled script content, or null when unavailable
988
975
  */
989
976
  async function downloadScriptForMapping(options) {
990
- const { client, workspaceId, scriptName, executionType, executionContentHash, executionStartedAt } = options;
977
+ const { client, workspaceId, scriptName, executionType, executionContentHash } = options;
991
978
  const registryName = scriptNameToRegistryName(scriptName, executionType);
992
979
  if (registryName == null) {
993
980
  logger.debug(`Script "${scriptName}" is not a deployed registry script (e.g. test-run or seed); skipping sourcemap mapping.`);
994
981
  return null;
995
982
  }
996
- if (executionContentHash !== "") {
997
- const pinned = await downloadFunctionScript({
998
- client,
999
- workspaceId,
1000
- name: registryName,
1001
- contentHash: executionContentHash
1002
- });
1003
- if (pinned == null) {
1004
- logger.debug(`Could not download pinned script "${scriptName}" (registry: "${registryName}", contentHash: "${executionContentHash}") for stack trace mapping; showing raw stack trace.`);
1005
- return null;
1006
- }
1007
- return pinned.code;
983
+ if (executionContentHash === "") {
984
+ logger.debug(`Function execution "${scriptName}" has no contentHash; skipping sourcemap mapping because the exact bundle cannot be identified.`);
985
+ return null;
1008
986
  }
1009
- const result = await downloadFunctionScript({
987
+ const pinned = await downloadFunctionScript({
1010
988
  client,
1011
989
  workspaceId,
1012
- name: registryName
990
+ name: registryName,
991
+ contentHash: executionContentHash
1013
992
  });
1014
- if (result == null) {
1015
- logger.debug(`Could not download script "${scriptName}" (registry: "${registryName}") for stack trace mapping; showing raw stack trace.`);
993
+ if (pinned == null) {
994
+ logger.debug(`Could not download pinned script "${scriptName}" (registry: "${registryName}", contentHash: "${executionContentHash}") for stack trace mapping; showing raw stack trace.`);
1016
995
  return null;
1017
996
  }
1018
- if (executionStartedAt != null && result.registryUpdatedAt != null && result.registryUpdatedAt.getTime() > executionStartedAt.getTime()) {
1019
- logger.debug(`Registry script "${registryName}" was updated at ${result.registryUpdatedAt.toISOString()} after execution started at ${executionStartedAt.toISOString()}; skipping sourcemap mapping to avoid stale source locations.`);
1020
- return null;
1021
- }
1022
- return result.code;
997
+ return pinned.code;
1023
998
  }
1024
999
  const logsCommand = defineAppCommand({
1025
1000
  name: "logs",
1026
1001
  description: "List or get function execution logs.",
1027
1002
  notes: `When viewing a specific execution that failed, the command displays error details with the stack trace mapped back to your original source files (clickable file links and code snippets, matching \`function test-run\` output).
1028
1003
 
1029
- Stack traces stay accurate even after later redeploys, because the trace is resolved against the exact build that produced the execution. If that build is no longer available, the command falls back to a plain-text error display.`,
1004
+ Stack traces are mapped only when the execution includes a content hash for the exact build that ran. If the content hash is missing or the build is no longer available, the command falls back to a plain-text error display.`,
1030
1005
  examples: [
1031
1006
  {
1032
1007
  cmd: "",
@@ -1074,8 +1049,7 @@ Stack traces stay accurate even after later redeploys, because the trace is reso
1074
1049
  workspaceId,
1075
1050
  scriptName: detail.scriptName,
1076
1051
  executionType: execution.type,
1077
- executionContentHash: execution.contentHash,
1078
- executionStartedAt: detail.startedAt
1052
+ executionContentHash: execution.contentHash
1079
1053
  }) : null
1080
1054
  });
1081
1055
  } else {
@@ -1169,21 +1143,21 @@ function generateEntry(detected, sourceFile, env, machineUser, workspaceId) {
1169
1143
  export { _fn as main };
1170
1144
  `;
1171
1145
  case "resolver": {
1172
- const userExpr = buildMachineUserExpr(machineUser, workspaceId);
1146
+ const principalExpr = buildMachinePrincipalExpr(machineUser, workspaceId);
1173
1147
  return multiline`
1174
1148
  import _internalResolver from "${absoluteSourcePath}";
1175
1149
  import { t } from "@tailor-platform/sdk";
1176
1150
 
1177
1151
  const _env = ${JSON.stringify(env)};
1178
- const _user = ${userExpr};
1152
+ const _caller = ${principalExpr};
1179
1153
 
1180
1154
  const $tailor_resolver_body = async (context) => {
1181
- const _invoker = ${INVOKER_EXPR};
1155
+ const _invoker = ${INVOKER_EXPR} ?? _caller;
1182
1156
  if (_internalResolver.input) {
1183
1157
  const result = t.object(_internalResolver.input).parse({
1184
1158
  value: context,
1185
1159
  data: context,
1186
- user: _user,
1160
+ invoker: _invoker,
1187
1161
  });
1188
1162
 
1189
1163
  if (result.issues) {
@@ -1194,7 +1168,7 @@ function generateEntry(detected, sourceFile, env, machineUser, workspaceId) {
1194
1168
  }
1195
1169
  }
1196
1170
 
1197
- const enrichedContext = { input: context, env: _env, user: _user, invoker: _invoker };
1171
+ const enrichedContext = { input: context, env: _env, caller: _caller, invoker: _invoker };
1198
1172
  return _internalResolver.body(enrichedContext);
1199
1173
  };
1200
1174
 
@@ -1202,15 +1176,15 @@ function generateEntry(detected, sourceFile, env, machineUser, workspaceId) {
1202
1176
  `;
1203
1177
  }
1204
1178
  case "executor": {
1205
- const actorExpr = buildMachineActorExpr(machineUser, workspaceId);
1179
+ const principalExpr = buildMachinePrincipalExpr(machineUser, workspaceId);
1206
1180
  return multiline`
1207
1181
  import _internalExecutor from "${absoluteSourcePath}";
1208
1182
 
1209
1183
  const _env = ${JSON.stringify(env)};
1210
- const _actor = ${actorExpr};
1184
+ const _actor = ${principalExpr};
1211
1185
 
1212
1186
  const __executor_function = async (args) => {
1213
- const _invoker = ${INVOKER_EXPR};
1187
+ const _invoker = ${INVOKER_EXPR} ?? _actor;
1214
1188
  return _internalExecutor.operation.body({ ...args, env: _env, actor: _actor, invoker: _invoker });
1215
1189
  };
1216
1190
 
@@ -1219,13 +1193,15 @@ function generateEntry(detected, sourceFile, env, machineUser, workspaceId) {
1219
1193
  }
1220
1194
  case "workflow-job": {
1221
1195
  const exportName = assertDefined(detected.exportName, "workflow job export name missing");
1196
+ const principalExpr = buildMachinePrincipalExpr(machineUser, workspaceId);
1222
1197
  return multiline`
1223
1198
  import { ${exportName} } from "${absoluteSourcePath}";
1224
1199
 
1225
1200
  const env = ${JSON.stringify(env)};
1201
+ const fallbackInvoker = ${principalExpr};
1226
1202
 
1227
1203
  export async function main(input) {
1228
- const invoker = ${INVOKER_EXPR};
1204
+ const invoker = ${INVOKER_EXPR} ?? fallbackInvoker;
1229
1205
  return await ${exportName}.body(input, { env, invoker });
1230
1206
  }
1231
1207
  `;
@@ -1233,35 +1209,20 @@ function generateEntry(detected, sourceFile, env, machineUser, workspaceId) {
1233
1209
  }
1234
1210
  }
1235
1211
  /**
1236
- * Build a JSON expression for a machine user TailorUser object.
1212
+ * Build a JSON expression for a machine user TailorPrincipal object.
1237
1213
  * @param machineUser - Resolved machine user info
1238
1214
  * @param workspaceId - Workspace ID
1239
1215
  * @returns JSON string for the user expression
1240
1216
  */
1241
- function buildMachineUserExpr(machineUser, workspaceId) {
1217
+ function buildMachinePrincipalExpr(machineUser, workspaceId) {
1242
1218
  return JSON.stringify({
1243
1219
  id: machineUser.id,
1244
1220
  type: "machine_user",
1245
1221
  workspaceId,
1246
- attributes: machineUser.attributes,
1222
+ attributes: machineUser.attributes ?? {},
1247
1223
  attributeList: machineUser.attributeList
1248
1224
  });
1249
1225
  }
1250
- /**
1251
- * Build a JSON expression for a machine user TailorActor object.
1252
- * @param machineUser - Resolved machine user info
1253
- * @param workspaceId - Workspace ID
1254
- * @returns JSON string for the actor expression
1255
- */
1256
- function buildMachineActorExpr(machineUser, workspaceId) {
1257
- return JSON.stringify({
1258
- workspaceId,
1259
- userId: machineUser.id,
1260
- attributes: machineUser.attributes,
1261
- attributeList: machineUser.attributeList,
1262
- userType: "USER_TYPE_MACHINE_USER"
1263
- });
1264
- }
1265
1226
 
1266
1227
  //#endregion
1267
1228
  //#region src/cli/commands/function/detect.ts
@@ -1284,7 +1245,7 @@ async function detectFunctionType(options) {
1284
1245
  const rawInput = module.default.input;
1285
1246
  let inputSchema;
1286
1247
  if (rawInput) {
1287
- const { t } = await import("../types-2Be3wSMc.mjs");
1248
+ const { t } = await import("../types-74etvaxy.mjs");
1288
1249
  inputSchema = t.object(rawInput);
1289
1250
  }
1290
1251
  return {
@@ -1470,11 +1431,9 @@ When a \`.js\` file is provided, detection and bundling are skipped and the file
1470
1431
  functionType = detected.type;
1471
1432
  functionName = detected.name;
1472
1433
  logger.info(`Detected: ${styles.bold(detected.type)} ${styles.info(`"${detected.name}"`)}`);
1473
- if (detected.type === "resolver" && args.arg) {
1474
- if (!detected.hasInput) {
1475
- logger.warn("--arg is ignored because this resolver has no input schema. Define \"input\" in your resolver to use --arg.");
1476
- args.arg = void 0;
1477
- } else if (detected.inputSchema) args.arg = resolveResolverArg(args.arg, detected.inputSchema, machineUser, workspaceId);
1434
+ if (detected.type === "resolver" && args.arg && !detected.hasInput) {
1435
+ logger.warn("--arg is ignored because this resolver has no input schema. Define \"input\" in your resolver to use --arg.");
1436
+ args.arg = void 0;
1478
1437
  }
1479
1438
  logger.info("Bundling...");
1480
1439
  ({bundledCode, scriptName} = await bundleForTestRun({
@@ -1488,18 +1447,24 @@ When a \`.js\` file is provided, detection and bundling are skipped and the file
1488
1447
  }));
1489
1448
  logger.info(`Bundled as ${styles.bold(scriptName)}`);
1490
1449
  }
1491
- const authInvoker = create(AuthInvokerSchema, {
1450
+ const invoker = create(AuthInvokerSchema, {
1492
1451
  namespace: authNamespace,
1493
1452
  machineUserName: machineUser.name
1494
1453
  });
1495
1454
  logger.info(`Executing on workspace ${styles.dim(workspaceId)}...`);
1455
+ let parsedArg;
1456
+ if (args.arg !== void 0) try {
1457
+ parsedArg = JSON.parse(args.arg);
1458
+ } catch (error) {
1459
+ throw new Error(`Invalid --arg JSON: ${error instanceof Error ? error.message : error}`, { cause: error });
1460
+ }
1496
1461
  const result = await executeScript({
1497
1462
  client,
1498
1463
  workspaceId,
1499
1464
  name: scriptName,
1500
1465
  code: bundledCode,
1501
- arg: args.arg,
1502
- invoker: authInvoker
1466
+ arg: parsedArg,
1467
+ invoker
1503
1468
  });
1504
1469
  if (jsonOutput) logger.out({
1505
1470
  success: result.success,
@@ -1600,42 +1565,6 @@ async function resolveMachineUser(options) {
1600
1565
  attributeList
1601
1566
  };
1602
1567
  }
1603
- /**
1604
- * Resolve resolver arg format: detect and unwrap deprecated {"input":{...}} wrapper.
1605
- * Tries new format (arg = input fields) first via schema parse.
1606
- * If that fails and arg looks like old format, tries unwrapping.
1607
- * @param argStr - JSON string of the arg
1608
- * @param inputSchema - Pre-built schema object from detect (has .parse())
1609
- * @param machineUser - Resolved machine user info
1610
- * @param workspaceId - Workspace ID
1611
- * @returns Resolved JSON string (unwrapped if old format)
1612
- */
1613
- function resolveResolverArg(argStr, inputSchema, machineUser, workspaceId) {
1614
- const parsed = JSON.parse(argStr);
1615
- const user = {
1616
- id: machineUser.id,
1617
- type: "machine_user",
1618
- workspaceId,
1619
- attributes: machineUser.attributes ?? null,
1620
- attributeList: machineUser.attributeList
1621
- };
1622
- if (!inputSchema.parse({
1623
- value: parsed,
1624
- data: parsed,
1625
- user
1626
- }).issues) return argStr;
1627
- if (Object.keys(parsed).length === 1 && parsed.input != null && typeof parsed.input === "object" && !Array.isArray(parsed.input)) {
1628
- if (!inputSchema.parse({
1629
- value: parsed.input,
1630
- data: parsed.input,
1631
- user
1632
- }).issues) {
1633
- logger.warn("[DEPRECATED] Wrapping args with \"input\" key (e.g. {\"input\":{...}}) is deprecated. Pass input fields directly (e.g. {\"a\":1}). The \"input\" wrapper will be removed in v2.");
1634
- return JSON.stringify(parsed.input);
1635
- }
1636
- }
1637
- return argStr;
1638
- }
1639
1568
 
1640
1569
  //#endregion
1641
1570
  //#region src/cli/commands/function/index.ts
@@ -1669,7 +1598,7 @@ const generateCommand = defineAppCommand({
1669
1598
  })
1670
1599
  }).strict(),
1671
1600
  run: async (args) => {
1672
- const { initTelemetry } = await import("../telemetry-w92bvGdC.mjs");
1601
+ const { initTelemetry } = await import("../telemetry-ClwW5ohF.mjs");
1673
1602
  await initTelemetry();
1674
1603
  await generate({
1675
1604
  configPath: args.config,
@@ -1748,11 +1677,12 @@ const startAuthServer = async () => {
1748
1677
  });
1749
1678
  const userInfo = await fetchUserInfo(tokens.accessToken);
1750
1679
  const pfConfig = await readPlatformConfig();
1751
- await saveUserTokens(pfConfig, userInfo.email, {
1680
+ await saveUserTokens(pfConfig, userInfo.sub, {
1752
1681
  accessToken: tokens.accessToken,
1753
1682
  refreshToken: tokens.refreshToken ?? void 0
1754
- }, new Date(assertDefined(tokens.expiresAt, "token response missing expiresAt")).toISOString());
1755
- pfConfig.current_user = userInfo.email;
1683
+ }, new Date(assertDefined(tokens.expiresAt, "token response missing expiresAt")).toISOString(), { email: userInfo.email });
1684
+ await removeLegacyUserAlias(pfConfig, userInfo.email, userInfo.sub);
1685
+ pfConfig.current_user = userInfo.sub;
1756
1686
  writePlatformConfig(pfConfig);
1757
1687
  res.writeHead(200, { "Content-Type": "application/json" });
1758
1688
  res.end(JSON.stringify({
@@ -1806,7 +1736,6 @@ const loginCommand = defineAppCommand({
1806
1736
  description: "Login to Tailor Platform.",
1807
1737
  args: z.xor([z.object({}).strict().describe("User Login"), z.object({
1808
1738
  "machine-user": arg(z.literal(true), {
1809
- hiddenAlias: "machineuser",
1810
1739
  description: "Login as a platform machine user.",
1811
1740
  required: true
1812
1741
  }),
@@ -1977,7 +1906,7 @@ const createCommand$2 = defineAppCommand({
1977
1906
  }),
1978
1907
  user: arg(z.string(), {
1979
1908
  alias: "u",
1980
- description: "User email"
1909
+ description: "User email address or machine user client ID"
1981
1910
  }),
1982
1911
  "workspace-id": arg(z.string(), {
1983
1912
  alias: "w",
@@ -1994,7 +1923,8 @@ const createCommand$2 = defineAppCommand({
1994
1923
  if (args["machine-user-override"] === "deny" && !args["machine-user"]) throw new Error("--machine-user-override deny requires --machine-user.");
1995
1924
  const config = await readPlatformConfig();
1996
1925
  if (config.profiles[args.name]) throw new Error(`Profile "${args.name}" already exists.`);
1997
- const client = await initOperatorClient(await fetchLatestToken(config, args.user));
1926
+ const { accessToken: token, user: resolvedUser } = await fetchLatestToken(config, args.user);
1927
+ const client = await initOperatorClient(token);
1998
1928
  if (!(await fetchAll(async (pageToken, maxPageSize) => {
1999
1929
  const { workspaces, nextPageToken } = await client.listWorkspaces({
2000
1930
  pageToken,
@@ -2003,7 +1933,7 @@ const createCommand$2 = defineAppCommand({
2003
1933
  return [workspaces, nextPageToken];
2004
1934
  })).find((ws) => ws.id === args["workspace-id"])) throw new Error(`Workspace "${args["workspace-id"]}" not found.`);
2005
1935
  config.profiles[args.name] = {
2006
- user: args.user,
1936
+ user: resolvedUser,
2007
1937
  workspace_id: args["workspace-id"],
2008
1938
  ...args.permission === "read" ? { readonly: true } : {},
2009
1939
  ...args["machine-user"] ? { machine_user: args["machine-user"] } : {},
@@ -2013,7 +1943,7 @@ const createCommand$2 = defineAppCommand({
2013
1943
  if (!args.json) logger.success(`Profile "${args.name}" created successfully.`);
2014
1944
  const profileInfo = {
2015
1945
  name: args.name,
2016
- user: args.user,
1946
+ user: resolvedUser,
2017
1947
  workspaceId: args["workspace-id"],
2018
1948
  permission: args.permission,
2019
1949
  ...args["machine-user"] ? {
@@ -2090,7 +2020,7 @@ const updateCommand$1 = defineAppCommand({
2090
2020
  }),
2091
2021
  user: arg(z.string().optional(), {
2092
2022
  alias: "u",
2093
- description: "New user email"
2023
+ description: "New user email address or machine user client ID"
2094
2024
  }),
2095
2025
  "workspace-id": arg(z.string().optional(), {
2096
2026
  alias: "w",
@@ -2112,6 +2042,7 @@ const updateCommand$1 = defineAppCommand({
2112
2042
  const newUser = args.user || oldUser;
2113
2043
  const oldWorkspaceId = profile.workspace_id;
2114
2044
  const newWorkspaceId = args["workspace-id"] || oldWorkspaceId;
2045
+ let resolvedUser = newUser;
2115
2046
  const finalMachineUser = args["machine-user"] === "" ? void 0 : args["machine-user"] ?? profile.machine_user;
2116
2047
  const finalOverride = args["machine-user-override"] === "allow" ? void 0 : args["machine-user-override"] ?? profile.machine_user_override;
2117
2048
  if ((args["machine-user"] !== void 0 || args["machine-user-override"] !== void 0) && finalOverride === "deny" && !finalMachineUser) {
@@ -2119,7 +2050,9 @@ const updateCommand$1 = defineAppCommand({
2119
2050
  throw new Error(`Cannot clear the machine user while machine-user-override is "deny". Also pass --machine-user-override allow.`);
2120
2051
  }
2121
2052
  if (args.user !== void 0 || args["workspace-id"] !== void 0) {
2122
- const client = await initOperatorClient(await fetchLatestToken(config, newUser));
2053
+ const refreshed = await fetchLatestToken(config, newUser);
2054
+ resolvedUser = refreshed.user;
2055
+ const client = await initOperatorClient(refreshed.accessToken);
2123
2056
  if (!(await fetchAll(async (pageToken, maxPageSize) => {
2124
2057
  const { workspaces, nextPageToken } = await client.listWorkspaces({
2125
2058
  pageToken,
@@ -2128,7 +2061,7 @@ const updateCommand$1 = defineAppCommand({
2128
2061
  return [workspaces, nextPageToken];
2129
2062
  })).find((ws) => ws.id === newWorkspaceId)) throw new Error(`Workspace "${newWorkspaceId}" not found.`);
2130
2063
  }
2131
- profile.user = newUser;
2064
+ profile.user = resolvedUser;
2132
2065
  profile.workspace_id = newWorkspaceId;
2133
2066
  if (args.permission === "read") profile.readonly = true;
2134
2067
  else if (args.permission === "write") delete profile.readonly;
@@ -2140,7 +2073,7 @@ const updateCommand$1 = defineAppCommand({
2140
2073
  if (!args.json) logger.success(`Profile "${args.name}" updated successfully`);
2141
2074
  const profileInfo = {
2142
2075
  name: args.name,
2143
- user: newUser,
2076
+ user: resolvedUser,
2144
2077
  workspaceId: newWorkspaceId,
2145
2078
  permission: profile.readonly === true ? "read" : "write",
2146
2079
  ...profile.machine_user ? {
@@ -2609,7 +2542,7 @@ const secretCommand = defineCommand({
2609
2542
  });
2610
2543
 
2611
2544
  //#endregion
2612
- //#region src/cli/commands/setup/github/git.ts
2545
+ //#region src/cli/commands/setup/git.ts
2613
2546
  const defaultGitRunner = (args, cwd) => {
2614
2547
  const result = spawnSync("git", args, {
2615
2548
  cwd,
@@ -2640,7 +2573,7 @@ function detectDefaultBranch(cwd, run = defaultGitRunner) {
2640
2573
  }
2641
2574
 
2642
2575
  //#endregion
2643
- //#region src/cli/commands/setup/github/lock.ts
2576
+ //#region src/cli/commands/setup/lock.ts
2644
2577
  /** Current lock schema version. Bumped only on breaking lock-format changes. */
2645
2578
  const LOCK_VERSION = 1;
2646
2579
  /** Lock file path, relative to the repository root. */
@@ -2706,66 +2639,24 @@ function findTarget(lock, kind, workspaceName) {
2706
2639
  }
2707
2640
 
2708
2641
  //#endregion
2709
- //#region src/cli/commands/setup/github/branch.workflow.yml
2710
- var branch_workflow_default = "# __HEADER__\nname: Tailor (__WORKSPACE_NAME__)\n\non:\n # __PULL_REQUEST_START__\n pull_request:\n branches: [\"__BRANCH__\"]\n # __PATHS__\n # __PULL_REQUEST_END__\n push:\n branches: [\"__BRANCH__\"]\n # __PATHS__\n workflow_dispatch:\n # __DISPATCH_INPUTS_START__\n inputs:\n dry-run:\n description: Preview changes without deploying\n type: boolean\n default: false\n # __DISPATCH_INPUTS_END__\n\npermissions:\n contents: read\n\njobs:\n # __PLAN_JOB_START__\n tailor-plan:\n if: >-\n github.event_name == 'pull_request' ||\n (github.event_name == 'workflow_dispatch' && inputs['dry-run'])\n runs-on: ubuntu-latest\n timeout-minutes: 30\n environment: __ENVIRONMENT__\n permissions:\n contents: read\n pull-requests: write\n concurrency:\n group: tailor-plan-__WORKSPACE_NAME__-${{ github.event.pull_request.number || github.run_id }}\n cancel-in-progress: true\n steps:\n - id: tailor-checkout\n uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3\n # __SETUP_STEPS__\n - id: tailor-generate\n # __WORKING_DIRECTORY__\n run: __PM_EXEC__ tailor-sdk generate\n - id: tailor-generate-check\n run: |\n git add -A\n if ! git diff --cached --quiet; then\n git --no-pager diff --cached --stat\n echo \"::error::Generated files are out of date. Run 'tailor-sdk generate' locally and commit the result.\"\n exit 1\n fi\n - id: tailor-plan\n # Fork PRs cannot read secrets; the checks above still run for them.\n if: github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork\n uses: tailor-platform/actions/plan@4d0f160b6b5cc2f02594776665471497c297181e # v1.2.0\n with:\n workspace-id: ${{ vars.TAILOR_PLATFORM_WORKSPACE_ID }}\n label: __WORKSPACE_NAME__\n # __WORKING_DIRECTORY__\n platform-client-id: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID }}\n platform-client-secret: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET }}\n github-token: ${{ secrets.GITHUB_TOKEN }}\n # __PLAN_JOB_END__\n tailor-deploy:\n # __DEPLOY_IF__\n runs-on: ubuntu-latest\n timeout-minutes: 30\n permissions:\n contents: read\n environment: __ENVIRONMENT__\n concurrency:\n group: tailor-deploy-__WORKSPACE_NAME__\n cancel-in-progress: false\n steps:\n - id: tailor-checkout\n uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3\n # __SETUP_STEPS__\n - id: tailor-apply\n uses: tailor-platform/actions/deploy@4d0f160b6b5cc2f02594776665471497c297181e # v1.2.0\n with:\n workspace-id: ${{ vars.TAILOR_PLATFORM_WORKSPACE_ID }}\n # __WORKING_DIRECTORY__\n platform-client-id: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID }}\n platform-client-secret: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET }}\n";
2711
-
2712
- //#endregion
2713
- //#region src/cli/commands/setup/github/setup-bun.yml
2714
- var setup_bun_default = "- id: tailor-setup-bun\n uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0\n- id: tailor-install\n run: bun install --frozen-lockfile\n";
2642
+ //#region src/cli/commands/setup/branch.workflow.yml
2643
+ var branch_workflow_default = "# __HEADER__\nname: Tailor (__WORKSPACE_NAME__)\n\non:\n # __PULL_REQUEST_START__\n pull_request:\n branches: [\"__BRANCH__\"]\n # __PATHS__\n # __PULL_REQUEST_END__\n push:\n branches: [\"__BRANCH__\"]\n # __PATHS__\n workflow_dispatch:\n # __DISPATCH_INPUTS_START__\n inputs:\n dry-run:\n description: Preview changes without deploying\n type: boolean\n default: false\n # __DISPATCH_INPUTS_END__\n\npermissions:\n contents: read\n\njobs:\n # __PLAN_JOB_START__\n tailor-plan:\n if: >-\n github.event_name == 'pull_request' ||\n (github.event_name == 'workflow_dispatch' && inputs['dry-run'])\n runs-on: ubuntu-latest\n timeout-minutes: 30\n environment: __ENVIRONMENT__\n permissions:\n contents: read\n pull-requests: write\n concurrency:\n group: tailor-plan-__WORKSPACE_NAME__-${{ github.event.pull_request.number || github.run_id }}\n cancel-in-progress: true\n steps:\n - id: tailor-checkout\n uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3\n - id: tailor-setup\n uses: tailor-platform/actions/setup@7817f37adf2891fbb2ebbe0a3b222a5fa2ed0c1f # v1.3.0\n with:\n package-manager: __PACKAGE_MANAGER__\n - id: tailor-generate-check\n uses: tailor-platform/actions/generate-check@7817f37adf2891fbb2ebbe0a3b222a5fa2ed0c1f # v1.3.0\n with:\n package-manager: __PACKAGE_MANAGER__\n # __WORKING_DIRECTORY__\n - id: tailor-plan\n # Fork PRs cannot read secrets; the checks above still run for them.\n if: github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork\n uses: tailor-platform/actions/plan@7817f37adf2891fbb2ebbe0a3b222a5fa2ed0c1f # v1.3.0\n with:\n workspace-id: ${{ vars.TAILOR_PLATFORM_WORKSPACE_ID }}\n package-manager: __PACKAGE_MANAGER__\n label: __WORKSPACE_NAME__\n # __WORKING_DIRECTORY__\n platform-client-id: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID }}\n platform-client-secret: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET }}\n github-token: ${{ secrets.GITHUB_TOKEN }}\n # __PLAN_JOB_END__\n tailor-deploy:\n # __DEPLOY_IF__\n runs-on: ubuntu-latest\n timeout-minutes: 30\n permissions:\n contents: read\n environment: __ENVIRONMENT__\n concurrency:\n group: tailor-deploy-__WORKSPACE_NAME__\n cancel-in-progress: false\n steps:\n - id: tailor-checkout\n uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3\n - id: tailor-setup\n uses: tailor-platform/actions/setup@7817f37adf2891fbb2ebbe0a3b222a5fa2ed0c1f # v1.3.0\n with:\n package-manager: __PACKAGE_MANAGER__\n - id: tailor-apply\n uses: tailor-platform/actions/deploy@7817f37adf2891fbb2ebbe0a3b222a5fa2ed0c1f # v1.3.0\n with:\n workspace-id: ${{ vars.TAILOR_PLATFORM_WORKSPACE_ID }}\n package-manager: __PACKAGE_MANAGER__\n # __WORKING_DIRECTORY__\n platform-client-id: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID }}\n platform-client-secret: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET }}\n";
2715
2644
 
2716
2645
  //#endregion
2717
- //#region src/cli/commands/setup/github/setup-npm.yml
2718
- var setup_npm_default = "- id: tailor-setup-node\n uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0\n with:\n node-version-file: package.json\n cache: npm\n- id: tailor-install\n run: npm ci\n";
2646
+ //#region src/cli/commands/setup/tag.workflow.yml
2647
+ var tag_workflow_default = "# __HEADER__\nname: Tailor (__WORKSPACE_NAME__)\n\non:\n push:\n tags: [\"__TAG_PATTERN__\"]\n workflow_dispatch:\n inputs:\n dry-run:\n description: Preview changes without deploying\n type: boolean\n default: false\n\npermissions:\n contents: read\n\njobs:\n # __TAG_GUARD_JOB_START__\n tailor-tag-guard:\n runs-on: ubuntu-latest\n timeout-minutes: 10\n permissions:\n contents: read\n outputs:\n on-branch: ${{ steps.tailor-tag-guard.outputs.on-branch }}\n steps:\n - id: tailor-checkout\n uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3\n with:\n fetch-depth: 0\n - id: tailor-tag-guard\n uses: tailor-platform/actions/tag-guard@7817f37adf2891fbb2ebbe0a3b222a5fa2ed0c1f # v1.3.0\n with:\n target-branch: \"__BRANCH__\"\n # __TAG_GUARD_JOB_END__\n tailor-plan:\n # __PLAN_NEEDS__\n # __PLAN_IF__\n runs-on: ubuntu-latest\n timeout-minutes: 30\n environment: __ENVIRONMENT__\n permissions:\n contents: read\n steps:\n - id: tailor-checkout\n uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3\n - id: tailor-setup\n uses: tailor-platform/actions/setup@7817f37adf2891fbb2ebbe0a3b222a5fa2ed0c1f # v1.3.0\n with:\n package-manager: __PACKAGE_MANAGER__\n - id: tailor-generate-check\n uses: tailor-platform/actions/generate-check@7817f37adf2891fbb2ebbe0a3b222a5fa2ed0c1f # v1.3.0\n with:\n package-manager: __PACKAGE_MANAGER__\n # __WORKING_DIRECTORY__\n - id: tailor-plan\n uses: tailor-platform/actions/plan@7817f37adf2891fbb2ebbe0a3b222a5fa2ed0c1f # v1.3.0\n with:\n workspace-id: ${{ vars.TAILOR_PLATFORM_WORKSPACE_ID }}\n package-manager: __PACKAGE_MANAGER__\n label: __WORKSPACE_NAME__\n # __WORKING_DIRECTORY__\n platform-client-id: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID }}\n platform-client-secret: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET }}\n\n tailor-deploy:\n needs: tailor-plan\n if: ${{ !(github.event_name == 'workflow_dispatch' && inputs['dry-run']) }}\n environment: __ENVIRONMENT__\n runs-on: ubuntu-latest\n timeout-minutes: 30\n permissions:\n contents: read\n concurrency:\n group: tailor-deploy-__WORKSPACE_NAME__\n cancel-in-progress: false\n steps:\n - id: tailor-checkout\n uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3\n - id: tailor-setup\n uses: tailor-platform/actions/setup@7817f37adf2891fbb2ebbe0a3b222a5fa2ed0c1f # v1.3.0\n with:\n package-manager: __PACKAGE_MANAGER__\n - id: tailor-apply\n uses: tailor-platform/actions/deploy@7817f37adf2891fbb2ebbe0a3b222a5fa2ed0c1f # v1.3.0\n with:\n workspace-id: ${{ vars.TAILOR_PLATFORM_WORKSPACE_ID }}\n package-manager: __PACKAGE_MANAGER__\n # __WORKING_DIRECTORY__\n platform-client-id: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID }}\n platform-client-secret: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET }}\n";
2719
2648
 
2720
2649
  //#endregion
2721
- //#region src/cli/commands/setup/github/setup-pnpm.yml
2722
- var setup_pnpm_default = "- id: tailor-setup-pnpm\n uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9\n- id: tailor-setup-node\n uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0\n with:\n node-version-file: package.json\n cache: pnpm\n- id: tailor-install\n run: pnpm install --frozen-lockfile\n";
2723
-
2724
- //#endregion
2725
- //#region src/cli/commands/setup/github/setup-yarn.yml
2726
- var setup_yarn_default = "- id: tailor-setup-node\n uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0\n with:\n node-version-file: package.json\n cache: yarn\n- id: tailor-install\n run: yarn install --frozen-lockfile\n";
2727
-
2728
- //#endregion
2729
- //#region src/cli/commands/setup/github/tag.workflow.yml
2730
- var tag_workflow_default = "# __HEADER__\nname: Tailor (__WORKSPACE_NAME__)\n\non:\n push:\n tags: [\"__TAG_PATTERN__\"]\n workflow_dispatch:\n inputs:\n dry-run:\n description: Preview changes without deploying\n type: boolean\n default: false\n\npermissions:\n contents: read\n\njobs:\n # __TAG_GUARD_JOB_START__\n tailor-tag-guard:\n runs-on: ubuntu-latest\n timeout-minutes: 10\n permissions:\n contents: read\n outputs:\n on-branch: ${{ steps.tailor-tag-guard.outputs.on-branch }}\n steps:\n - id: tailor-checkout\n uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3\n with:\n fetch-depth: 0\n - id: tailor-tag-guard\n env:\n TARGET_BRANCH: \"__BRANCH__\"\n run: |\n git fetch origin \"$TARGET_BRANCH\"\n if git merge-base --is-ancestor \"$GITHUB_SHA\" \"origin/$TARGET_BRANCH\"; then\n echo \"on-branch=true\" >> \"$GITHUB_OUTPUT\"\n else\n # A tag outside the target branch is not an error — just skip.\n echo \"on-branch=false\" >> \"$GITHUB_OUTPUT\"\n echo \"::notice::Tag $GITHUB_REF_NAME is not reachable from $TARGET_BRANCH; skipping deploy.\"\n fi\n # __TAG_GUARD_JOB_END__\n tailor-plan:\n # __PLAN_NEEDS__\n # __PLAN_IF__\n runs-on: ubuntu-latest\n timeout-minutes: 30\n environment: __ENVIRONMENT__\n permissions:\n contents: read\n steps:\n - id: tailor-checkout\n uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3\n # __SETUP_STEPS__\n - id: tailor-generate\n # __WORKING_DIRECTORY__\n run: __PM_EXEC__ tailor-sdk generate\n - id: tailor-generate-check\n run: |\n git add -A\n if ! git diff --cached --quiet; then\n git --no-pager diff --cached --stat\n echo \"::error::Generated files are out of date. Run 'tailor-sdk generate' locally and commit the result.\"\n exit 1\n fi\n - id: tailor-plan\n uses: tailor-platform/actions/plan@4d0f160b6b5cc2f02594776665471497c297181e # v1.2.0\n with:\n workspace-id: ${{ vars.TAILOR_PLATFORM_WORKSPACE_ID }}\n label: __WORKSPACE_NAME__\n # __WORKING_DIRECTORY__\n platform-client-id: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID }}\n platform-client-secret: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET }}\n\n tailor-deploy:\n needs: tailor-plan\n if: ${{ !(github.event_name == 'workflow_dispatch' && inputs['dry-run']) }}\n environment: __ENVIRONMENT__\n runs-on: ubuntu-latest\n timeout-minutes: 30\n permissions:\n contents: read\n concurrency:\n group: tailor-deploy-__WORKSPACE_NAME__\n cancel-in-progress: false\n steps:\n - id: tailor-checkout\n uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3\n # __SETUP_STEPS__\n - id: tailor-apply\n uses: tailor-platform/actions/deploy@4d0f160b6b5cc2f02594776665471497c297181e # v1.2.0\n with:\n workspace-id: ${{ vars.TAILOR_PLATFORM_WORKSPACE_ID }}\n # __WORKING_DIRECTORY__\n platform-client-id: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID }}\n platform-client-secret: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET }}\n";
2731
-
2732
- //#endregion
2733
- //#region src/cli/commands/setup/github/templates.ts
2734
- const setupStepIds = {
2735
- pnpm: [
2736
- "tailor-setup-pnpm",
2737
- "tailor-setup-node",
2738
- "tailor-install"
2739
- ],
2740
- yarn: ["tailor-setup-node", "tailor-install"],
2741
- npm: ["tailor-setup-node", "tailor-install"],
2742
- bun: ["tailor-setup-bun", "tailor-install"]
2743
- };
2744
- const setupSteps = {
2745
- pnpm: setup_pnpm_default,
2746
- yarn: setup_yarn_default,
2747
- npm: setup_npm_default,
2748
- bun: setup_bun_default
2749
- };
2750
- const execPrefix = {
2751
- npm: "npx",
2752
- pnpm: "pnpm exec",
2753
- yarn: "yarn",
2754
- bun: "bunx"
2755
- };
2756
- const HEADER = `# Generated by \`tailor-sdk setup github\` — managed by the Tailor SDK.
2650
+ //#region src/cli/commands/setup/templates.ts
2651
+ const HEADER = `# Generated by \`tailor-sdk setup\` managed by the Tailor SDK.
2757
2652
  #
2758
2653
  # - Jobs and steps whose id starts with \`tailor-\` are managed by the SDK.
2759
2654
  # Do not edit or rename them.
2760
2655
  # - State is tracked in .github/tailor-sdk.lock (machine-owned: commit it, never edit it).
2761
- # - Re-running \`tailor-sdk setup github\` regenerates this file. If you have
2656
+ # - Re-running \`tailor-sdk setup\` regenerates this file. If you have
2762
2657
  # edited it by hand, regeneration stops and asks for --force (which discards
2763
2658
  # your edits), so prefer keeping customizations in your own jobs/steps and
2764
2659
  # re-running setup after SDK updates.`;
2765
- function indentSnippet(snippet, spaces) {
2766
- const indent = " ".repeat(spaces);
2767
- return snippet.trimEnd().split("\n").map((line) => line ? indent + line : line).join("\n");
2768
- }
2769
2660
  /**
2770
2661
  * Detect the package manager used in a project directory by checking for lockfiles.
2771
2662
  * @param dir - Project directory to inspect
@@ -2793,11 +2684,7 @@ function applyCommon(content, params) {
2793
2684
  const { workingDirectory, environment, packageManager } = params;
2794
2685
  let out = line(content, "HEADER", HEADER);
2795
2686
  out = line(out, "WORKING_DIRECTORY", workingDirectory ? `working-directory: ${workingDirectory}` : void 0);
2796
- out = out.replace(/^ *# __SETUP_STEPS__$/gm, () => indentSnippet(setupSteps[packageManager], 6));
2797
- return out.replaceAll("__WORKSPACE_NAME__", () => params.workspaceName).replaceAll("__ENVIRONMENT__", () => environment).replaceAll("__PM_EXEC__", () => execPrefix[packageManager]);
2798
- }
2799
- function setupIds(job, packageManager) {
2800
- return setupStepIds[packageManager].map((id) => `${job}/${id}`);
2687
+ return out.replaceAll("__WORKSPACE_NAME__", () => params.workspaceName).replaceAll("__ENVIRONMENT__", () => environment).replaceAll("__PACKAGE_MANAGER__", () => packageManager);
2801
2688
  }
2802
2689
  /**
2803
2690
  * Render the branch-target deploy workflow.
@@ -2809,7 +2696,7 @@ function setupIds(job, packageManager) {
2809
2696
  * @returns Rendered YAML and the list of managed job/step ids
2810
2697
  */
2811
2698
  function renderBranchWorkflow(params) {
2812
- const { branch, plan, packageManager } = params;
2699
+ const { branch, plan } = params;
2813
2700
  let out = branch_workflow_default;
2814
2701
  out = block(out, "PLAN_JOB", plan);
2815
2702
  out = block(out, "PULL_REQUEST", plan);
@@ -2818,8 +2705,8 @@ function renderBranchWorkflow(params) {
2818
2705
  out = line(out, "PATHS", params.workingDirectory ? `paths: ["${params.workingDirectory}/**"]` : void 0);
2819
2706
  out = applyCommon(out, params).replaceAll("__BRANCH__", () => branch);
2820
2707
  const generatedIds = [];
2821
- if (plan) generatedIds.push("tailor-plan", "tailor-plan/tailor-checkout", ...setupIds("tailor-plan", packageManager), "tailor-plan/tailor-generate", "tailor-plan/tailor-generate-check", "tailor-plan/tailor-plan");
2822
- generatedIds.push("tailor-deploy", "tailor-deploy/tailor-checkout", ...setupIds("tailor-deploy", packageManager), "tailor-deploy/tailor-apply");
2708
+ if (plan) generatedIds.push("tailor-plan", "tailor-plan/tailor-checkout", "tailor-plan/tailor-setup", "tailor-plan/tailor-generate-check", "tailor-plan/tailor-plan");
2709
+ generatedIds.push("tailor-deploy", "tailor-deploy/tailor-checkout", "tailor-deploy/tailor-setup", "tailor-deploy/tailor-apply");
2823
2710
  return {
2824
2711
  content: out,
2825
2712
  generatedIds
@@ -2834,7 +2721,7 @@ function renderBranchWorkflow(params) {
2834
2721
  * @returns Rendered YAML and the list of managed job/step ids
2835
2722
  */
2836
2723
  function renderTagWorkflow(params) {
2837
- const { tagPattern, branch, packageManager } = params;
2724
+ const { tagPattern, branch } = params;
2838
2725
  const hasGuard = branch !== void 0;
2839
2726
  let out = tag_workflow_default;
2840
2727
  out = block(out, "TAG_GUARD_JOB", hasGuard);
@@ -2844,7 +2731,7 @@ function renderTagWorkflow(params) {
2844
2731
  if (hasGuard) out = out.replaceAll("__BRANCH__", () => branch);
2845
2732
  const generatedIds = [];
2846
2733
  if (hasGuard) generatedIds.push("tailor-tag-guard", "tailor-tag-guard/tailor-checkout", "tailor-tag-guard/tailor-tag-guard");
2847
- generatedIds.push("tailor-plan", "tailor-plan/tailor-checkout", ...setupIds("tailor-plan", packageManager), "tailor-plan/tailor-generate", "tailor-plan/tailor-generate-check", "tailor-plan/tailor-plan", "tailor-deploy", "tailor-deploy/tailor-checkout", ...setupIds("tailor-deploy", packageManager), "tailor-deploy/tailor-apply");
2734
+ generatedIds.push("tailor-plan", "tailor-plan/tailor-checkout", "tailor-plan/tailor-setup", "tailor-plan/tailor-generate-check", "tailor-plan/tailor-plan", "tailor-deploy", "tailor-deploy/tailor-checkout", "tailor-deploy/tailor-setup", "tailor-deploy/tailor-apply");
2848
2735
  return {
2849
2736
  content: out,
2850
2737
  generatedIds
@@ -2852,7 +2739,110 @@ function renderTagWorkflow(params) {
2852
2739
  }
2853
2740
 
2854
2741
  //#endregion
2855
- //#region src/cli/commands/setup/github/github.ts
2742
+ //#region src/cli/commands/setup/check.ts
2743
+ /**
2744
+ * Compute drift findings for one target by comparing its recorded lock state
2745
+ * against the current repository/config state.
2746
+ * @param target - The lock target being audited
2747
+ * @param state - Current repository/config state for this target
2748
+ * @returns Drift findings (empty when the target is in sync)
2749
+ */
2750
+ function findTargetDrift(target, state) {
2751
+ const id = `${target.kind} ${target.workspaceName}`;
2752
+ const findings = [];
2753
+ if (!state.fileExists) findings.push({
2754
+ target: id,
2755
+ rule: "missing-file",
2756
+ message: `${target.file} is missing or unreadable. Re-run setup to restore it.`
2757
+ });
2758
+ else if (state.currentHash !== null && state.currentHash !== target.contentHash) findings.push({
2759
+ target: id,
2760
+ rule: "hand-edit",
2761
+ message: `${target.file} was edited by hand since it was generated. Re-run setup with --force to regenerate, or keep customizations in your own jobs/steps.`
2762
+ });
2763
+ if (target.templateVersion < state.templateVersion) findings.push({
2764
+ target: id,
2765
+ rule: "template-version",
2766
+ message: `A newer workflow template is available (generated with v${String(target.templateVersion)}, current v${String(state.templateVersion)}). Re-run setup to update.`
2767
+ });
2768
+ if (!state.configExists) findings.push({
2769
+ target: id,
2770
+ rule: "config-dir",
2771
+ message: `tailor.config.ts not found under "${target.inputs.dir}". The app directory may have moved; re-run setup with the correct --dir.`
2772
+ });
2773
+ if (target.kind === "branch" && target.inputs.branchAutoDetected !== false && state.defaultBranch !== null && target.inputs.branch !== null && target.inputs.branch !== state.defaultBranch) findings.push({
2774
+ target: id,
2775
+ rule: "default-branch",
2776
+ message: `The workflow triggers on "${target.inputs.branch}" but the repository default branch is now "${state.defaultBranch}". If this is intentional, ignore this; otherwise re-run setup so the trigger matches the default branch.`
2777
+ });
2778
+ return findings;
2779
+ }
2780
+ function detectDefaultBranchSafe(cwd, run) {
2781
+ try {
2782
+ return detectDefaultBranch(cwd, run);
2783
+ } catch {
2784
+ return null;
2785
+ }
2786
+ }
2787
+ function escapesRoot$1(rel) {
2788
+ return path.isAbsolute(rel) || rel === ".." || rel.startsWith(`..${path.sep}`) || rel.startsWith("../");
2789
+ }
2790
+ function resolveWithinRoot(outputDir, relPath) {
2791
+ if (path.isAbsolute(relPath)) return null;
2792
+ const abs = path.join(outputDir, relPath);
2793
+ if (escapesRoot$1(path.relative(outputDir, abs))) return null;
2794
+ try {
2795
+ if (escapesRoot$1(path.relative(fs$1.realpathSync(outputDir), fs$1.realpathSync(abs)))) return null;
2796
+ } catch {}
2797
+ return abs;
2798
+ }
2799
+ function readHash(absFile) {
2800
+ try {
2801
+ return hashContent(fs$1.readFileSync(absFile, "utf-8"));
2802
+ } catch {
2803
+ return null;
2804
+ }
2805
+ }
2806
+ /**
2807
+ * Audit the generated workflows for drift against the current config/repo
2808
+ * state. Read-only: never writes files, the lock, or the config.
2809
+ *
2810
+ * Throws when drift is found (so it composes like the other `:check`
2811
+ * commands). The workflow drift-check step layers advisory behaviour on top
2812
+ * (per-rule ignore / continue-on-error); the CLI itself reports via exit code.
2813
+ * @param options - Check options
2814
+ */
2815
+ function checkGitHub(options) {
2816
+ logBetaWarning("setup");
2817
+ const { outputDir } = options;
2818
+ const lock = readLock(outputDir);
2819
+ if (!lock || lock.targets.length === 0) throw new Error("No managed workflows found (.github/tailor-sdk.lock is missing or empty). Run `tailor-sdk setup` first.");
2820
+ const exists = options.configExistsAt ?? ((p) => fs$1.existsSync(p));
2821
+ const defaultBranch = detectDefaultBranchSafe(outputDir, options.gitRunner);
2822
+ const findings = [];
2823
+ for (const target of lock.targets) {
2824
+ const absFile = resolveWithinRoot(outputDir, target.file);
2825
+ const currentHash = absFile === null ? null : readHash(absFile);
2826
+ const configAbs = resolveWithinRoot(outputDir, path.join(target.inputs.dir, "tailor.config.ts"));
2827
+ findings.push(...findTargetDrift(target, {
2828
+ fileExists: currentHash !== null,
2829
+ currentHash,
2830
+ configExists: configAbs !== null && exists(configAbs),
2831
+ defaultBranch,
2832
+ templateVersion: 2
2833
+ }));
2834
+ }
2835
+ const count = lock.targets.length;
2836
+ if (findings.length === 0) {
2837
+ logger.success(`No drift detected across ${String(count)} target(s).`);
2838
+ return;
2839
+ }
2840
+ for (const finding of findings) logger.warn(`[${finding.target}] ${finding.message} (ignore key: ${finding.rule})`);
2841
+ throw new Error(`Detected ${String(findings.length)} drift finding(s) across ${String(count)} target(s). Re-run \`tailor-sdk setup\` to regenerate, or address each finding above.`);
2842
+ }
2843
+
2844
+ //#endregion
2845
+ //#region src/cli/commands/setup/generate.ts
2856
2846
  async function defaultLoadConfigName(configPath) {
2857
2847
  const { config } = await loadConfig(configPath);
2858
2848
  return config.name;
@@ -2924,8 +2914,10 @@ async function resolve$1(options) {
2924
2914
  validateEnvironment(environment);
2925
2915
  if (kind === "tag") validateTagPattern(options.tagPattern);
2926
2916
  let branch = null;
2917
+ let branchAutoDetected = false;
2927
2918
  let render;
2928
2919
  if (kind === "branch") {
2920
+ branchAutoDetected = options.branch === void 0;
2929
2921
  branch = options.branch ?? detectDefaultBranch(options.outputDir, options.gitRunner);
2930
2922
  validateBranch(branch);
2931
2923
  render = renderBranchWorkflow({
@@ -2951,6 +2943,7 @@ async function resolve$1(options) {
2951
2943
  const file = `.github/workflows/tailor-${workspaceName}.yml`;
2952
2944
  const inputs = {
2953
2945
  branch,
2946
+ branchAutoDetected: kind === "branch" ? branchAutoDetected : void 0,
2954
2947
  tagPattern: kind === "tag" ? options.tagPattern : null,
2955
2948
  environment,
2956
2949
  dir,
@@ -3039,7 +3032,7 @@ function printNextSteps(obj) {
3039
3032
  * @param options - Setup options
3040
3033
  */
3041
3034
  async function setupGitHub(options) {
3042
- logBetaWarning("setup github");
3035
+ logBetaWarning("setup");
3043
3036
  const resolved = await resolve$1(options);
3044
3037
  const lock = readLock(options.outputDir);
3045
3038
  const absFile = path.join(options.outputDir, resolved.file);
@@ -3067,7 +3060,7 @@ async function setupGitHub(options) {
3067
3060
  kind: resolved.kind,
3068
3061
  workspaceName: resolved.workspaceName,
3069
3062
  file: resolved.file,
3070
- templateVersion: 1,
3063
+ templateVersion: 2,
3071
3064
  inputs: resolved.inputs,
3072
3065
  generatedIds: resolved.render.generatedIds,
3073
3066
  ejectedIds: existing?.ejectedIds ?? [],
@@ -3091,11 +3084,23 @@ async function setupGitHub(options) {
3091
3084
  }
3092
3085
 
3093
3086
  //#endregion
3094
- //#region src/cli/commands/setup/github/index.ts
3095
- const githubCommand = defineAppCommand({
3096
- name: "github",
3097
- description: "Generate a GitHub Actions deploy workflow. (beta)",
3087
+ //#region src/cli/commands/setup/index.ts
3088
+ const checkCommand = defineAppCommand({
3089
+ name: "check",
3090
+ description: "Audit generated workflows for drift against the current config/repo (read-only).",
3091
+ args: z.object({}).strict(),
3092
+ run: () => {
3093
+ checkGitHub({ outputDir: process.cwd() });
3094
+ }
3095
+ });
3096
+ const setupCommand = defineAppCommand({
3097
+ name: "setup",
3098
+ description: "Generate a CI deploy workflow for your project. (beta)",
3098
3099
  args: z.object({
3100
+ provider: arg(z.enum(["github"], { message: "Only the 'github' provider is supported." }).default("github"), {
3101
+ alias: "p",
3102
+ description: "CI provider to generate for (only 'github' is supported)"
3103
+ }),
3099
3104
  "workspace-name": arg(z.string().min(1).optional(), {
3100
3105
  alias: "n",
3101
3106
  description: "Workspace name (defaults to the config 'name')"
@@ -3111,6 +3116,7 @@ const githubCommand = defineAppCommand({
3111
3116
  }),
3112
3117
  force: arg(z.boolean().default(false), { description: "Discard hand edits / take over unmanaged files and regenerate" })
3113
3118
  }).strict(),
3119
+ subCommands: { check: checkCommand },
3114
3120
  run: async (args) => {
3115
3121
  if (args["tag-pattern"] !== void 0 && !args.tag) throw new Error("--tag-pattern requires --tag.");
3116
3122
  if (args["no-plan"] && args.tag) throw new Error("--no-plan cannot be combined with --tag.");
@@ -3128,14 +3134,6 @@ const githubCommand = defineAppCommand({
3128
3134
  }
3129
3135
  });
3130
3136
 
3131
- //#endregion
3132
- //#region src/cli/commands/setup/index.ts
3133
- const setupCommand = defineCommand({
3134
- name: "setup",
3135
- description: "Set up project infrastructure.",
3136
- subCommands: { github: githubCommand }
3137
- });
3138
-
3139
3137
  //#endregion
3140
3138
  //#region src/cli/shared/skills-installer.ts
3141
3139
  const SKILL_NAME = "tailor-sdk";
@@ -4807,7 +4805,7 @@ async function fetchRemoteTypes(client, workspaceId, namespace) {
4807
4805
  async function assertMigrationsReproduceLocalTypes(loaded, target) {
4808
4806
  const { config, plugins } = loaded;
4809
4807
  const pluginManager = plugins.length > 0 ? new PluginManager(plugins) : void 0;
4810
- const { defineApplication, generatePluginFilesIfNeeded } = await import("../application-av2raLs6.mjs");
4808
+ const { defineApplication, generatePluginFilesIfNeeded } = await import("../application-Dtqap5jM.mjs");
4811
4809
  const application = defineApplication({
4812
4810
  config,
4813
4811
  pluginManager
@@ -4819,7 +4817,7 @@ async function assertMigrationsReproduceLocalTypes(loaded, target) {
4819
4817
  await service.processNamespacePlugins();
4820
4818
  }
4821
4819
  const pluginExecutorFiles = generatePluginFilesIfNeeded(pluginManager, application.tailorDBServices, config.path);
4822
- const executorService = application.executorService ?? (pluginExecutorFiles.length > 0 ? (await import("../service-BHQIerYh.mjs")).createExecutorService({ config: { files: [] } }) : void 0);
4820
+ const executorService = application.executorService ?? (pluginExecutorFiles.length > 0 ? (await import("../service-DCqIWibD.mjs")).createExecutorService({ config: { files: [] } }) : void 0);
4823
4821
  await executorService?.loadExecutors();
4824
4822
  if (pluginExecutorFiles.length > 0) await executorService?.loadPluginExecutorFiles([...pluginExecutorFiles]);
4825
4823
  const executorUsedTypes = /* @__PURE__ */ new Set();
@@ -5094,9 +5092,9 @@ const upgradeCommand = defineAppCommand({
5094
5092
  })
5095
5093
  }).strict(),
5096
5094
  run: async (args) => {
5097
- const { initTelemetry } = await import("../telemetry-w92bvGdC.mjs");
5095
+ const { initTelemetry } = await import("../telemetry-ClwW5ohF.mjs");
5098
5096
  await initTelemetry();
5099
- const { upgrade } = await import("../service-DMohAx8a2.mjs");
5097
+ const { upgrade } = await import("../service-DU1mVzri2.mjs");
5100
5098
  await upgrade({
5101
5099
  from: args.from,
5102
5100
  dryRun: args["dry-run"],
@@ -5237,7 +5235,8 @@ const createCommand = defineAppCommand({
5237
5235
  No user logged in.
5238
5236
  Please login first using 'tailor-sdk login' command.
5239
5237
  `);
5240
- const client = await initOperatorClient(await fetchLatestToken(config, config.current_user));
5238
+ const { accessToken: token } = await fetchLatestToken(config, config.current_user);
5239
+ const client = await initOperatorClient(token);
5241
5240
  const scopes = getScopesFromWriteFlag(args.write);
5242
5241
  const result = await client.createPersonalAccessToken({
5243
5242
  name: args.name,
@@ -5264,7 +5263,8 @@ const deleteCommand = defineAppCommand({
5264
5263
  No user logged in.
5265
5264
  Please login first using 'tailor-sdk login' command.
5266
5265
  `);
5267
- await (await initOperatorClient(await fetchLatestToken(config, config.current_user))).deletePersonalAccessToken({ name: args.name });
5266
+ const { accessToken: token } = await fetchLatestToken(config, config.current_user);
5267
+ await (await initOperatorClient(token)).deletePersonalAccessToken({ name: args.name });
5268
5268
  logger.success(`Personal access token "${args.name}" deleted successfully.`);
5269
5269
  }
5270
5270
  });
@@ -5282,7 +5282,8 @@ const listCommand = defineAppCommand({
5282
5282
  No user logged in.
5283
5283
  Please login first using 'tailor-sdk login' command.
5284
5284
  `);
5285
- const client = await initOperatorClient(await fetchLatestToken(config, config.current_user));
5285
+ const { accessToken: token } = await fetchLatestToken(config, config.current_user);
5286
+ const client = await initOperatorClient(token);
5286
5287
  const pageDirection = toPageDirection(args.order);
5287
5288
  const pats = await fetchPaged(async (pageToken, pageSize) => {
5288
5289
  const { personalAccessTokens, nextPageToken } = await client.listPersonalAccessTokens({
@@ -5335,7 +5336,8 @@ const updateCommand = defineAppCommand({
5335
5336
  No user logged in.
5336
5337
  Please login first using 'tailor-sdk login' command.
5337
5338
  `);
5338
- const client = await initOperatorClient(await fetchLatestToken(config, config.current_user));
5339
+ const { accessToken: token } = await fetchLatestToken(config, config.current_user);
5340
+ const client = await initOperatorClient(token);
5339
5341
  await client.deletePersonalAccessToken({ name: args.name });
5340
5342
  const scopes = getScopesFromWriteFlag(args.write);
5341
5343
  const result = await client.createPersonalAccessToken({
@@ -5370,15 +5372,16 @@ const switchCommand = defineAppCommand({
5370
5372
  description: "Set current user.",
5371
5373
  args: z.object({ user: arg(z.string(), {
5372
5374
  positional: true,
5373
- description: "User email"
5375
+ description: "User email address or machine user client ID"
5374
5376
  }) }).strict(),
5375
5377
  run: async (args) => {
5376
5378
  const config = await readPlatformConfig();
5377
- if (!config.users[args.user]) throw new Error(multiline`
5379
+ const user = findConfigUserKey(config, args.user);
5380
+ if (!user) throw new Error(multiline`
5378
5381
  User "${args.user}" not found.
5379
5382
  Please login first using 'tailor-sdk login' command to register this user.
5380
5383
  `);
5381
- config.current_user = args.user;
5384
+ config.current_user = user;
5382
5385
  writePlatformConfig(config);
5383
5386
  logger.success(`Current user set to "${args.user}" successfully.`);
5384
5387
  }
@@ -5409,6 +5412,7 @@ const workflowCommand = defineCommand({
5409
5412
  list: listCommand$12,
5410
5413
  get: getCommand$6,
5411
5414
  start: startCommand,
5415
+ wait: waitCommand,
5412
5416
  executions: executionsCommand,
5413
5417
  resume: resumeCommand
5414
5418
  },
@@ -5522,11 +5526,11 @@ runMain(mainCommand, {
5522
5526
  if (isVerbose() && error.stack) logger.debug(`\nStack trace:\n${error.stack}`);
5523
5527
  } else logger.error(`Unknown error: ${error}`);
5524
5528
  if (!isCLIError(error) && (!(error instanceof Error) || error instanceof TypeError || error instanceof RangeError)) {
5525
- const { reportCrash } = await import("../crashreport-D1wKBJ8N.mjs");
5529
+ const { reportCrash } = await import("../crashreport-BMWcxeSE.mjs");
5526
5530
  await reportCrash(error, "handledError");
5527
5531
  }
5528
5532
  }
5529
- const { shutdownTelemetry } = await import("../telemetry-w92bvGdC.mjs");
5533
+ const { shutdownTelemetry } = await import("../telemetry-ClwW5ohF.mjs");
5530
5534
  await shutdownTelemetry();
5531
5535
  }
5532
5536
  });