apexrest 1.3.0-beta.1 → 1.3.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 (182) hide show
  1. package/README.md +90 -140
  2. package/dist/codex-compat/.claude-plugin/marketplace.json +20 -0
  3. package/dist/codex-compat/plugins/apexrest-apex/.claude-plugin/plugin.json +28 -0
  4. package/dist/codex-compat/plugins/apexrest-apex/.codex-plugin/plugin.json +7 -7
  5. package/dist/codex-compat/plugins/apexrest-apex/resources/blocks/generator.json +1 -1
  6. package/dist/codex-compat/plugins/apexrest-apex/resources/blocks/manifest.json +6 -6
  7. package/dist/codex-compat/plugins/apexrest-apex/resources/blocks/packages/analytics/status-summary/1.0.0/block.yaml +1 -1
  8. package/dist/codex-compat/plugins/apexrest-apex/resources/blocks/packages/crud/report-dialog/1.0.0/block.yaml +1 -1
  9. package/dist/codex-compat/plugins/apexrest-apex/resources/blocks/packages/read/detail/1.0.0/block.yaml +1 -1
  10. package/dist/codex-compat/plugins/apexrest-apex/resources/blocks/packages/read/filtered-list/1.0.0/block.yaml +1 -1
  11. package/dist/codex-compat/plugins/apexrest-apex/resources/blocks/packages/read/history/1.0.0/block.yaml +1 -1
  12. package/dist/codex-compat/plugins/apexrest-apex/resources/blocks/packages/read/master-detail/1.0.0/block.yaml +1 -1
  13. package/dist/codex-compat/plugins/apexrest-apex/resources/schemas/composer-blueprint.schema.json +5 -4
  14. package/dist/codex-compat/plugins/apexrest-apex/resources/schemas/composer-contract.schema.json +2 -2
  15. package/dist/codex-compat/plugins/apexrest-apex/resources/schemas/composer-entity.schema.json +2 -1
  16. package/dist/codex-compat/plugins/apexrest-apex/resources/schemas/composer-field.schema.json +2 -1
  17. package/dist/codex-compat/plugins/apexrest-apex/resources/schemas/composer-instance.schema.json +1 -1
  18. package/dist/codex-compat/plugins/apexrest-apex/resources/schemas/composer-operation.schema.json +1 -1
  19. package/dist/codex-compat/plugins/apexrest-apex/resources/schemas/composer-plan.schema.json +5 -4
  20. package/dist/codex-compat/plugins/apexrest-apex/resources/schemas/deploy-plan.schema.json +18 -24
  21. package/dist/codex-compat/plugins/apexrest-apex/resources/schemas/operations.schema.json +352 -569
  22. package/dist/codex-compat/plugins/apexrest-apex/resources/schemas/policy.schema.json +21 -0
  23. package/dist/codex-compat/plugins/apexrest-apex/resources/schemas/project.schema.json +4 -7
  24. package/dist/codex-compat/plugins/apexrest-apex/resources/templates/blank-app/README.md +0 -2
  25. package/dist/codex-compat/plugins/apexrest-apex/resources/templates/customer-crm/README.md +1 -3
  26. package/dist/codex-compat/plugins/apexrest-apex/resources/templates/existing-app/README.md +0 -2
  27. package/dist/codex-compat/plugins/apexrest-apex/runtime/apexrest.mjs +70 -44
  28. package/dist/codex-compat/plugins/apexrest-apex/runtime/chunk-5PCC7GZM.mjs +4090 -0
  29. package/dist/codex-compat/plugins/apexrest-apex/runtime/chunk-BVPAS3TD.mjs +18 -0
  30. package/dist/codex-compat/plugins/apexrest-apex/runtime/chunk-CVMECW6D.mjs +65 -0
  31. package/dist/codex-compat/plugins/apexrest-apex/runtime/{chunk-EBBEN4AV.mjs → chunk-JYN3YHP3.mjs} +4220 -10639
  32. package/dist/codex-compat/plugins/apexrest-apex/runtime/chunk-KGTE7Q5Y.mjs +23 -0
  33. package/dist/{runtime/chunk-33GE2NWZ.mjs → codex-compat/plugins/apexrest-apex/runtime/chunk-KKRFM7Q7.mjs} +21 -4
  34. package/dist/codex-compat/plugins/apexrest-apex/runtime/{chunk-2VBZESVC.mjs → chunk-MNU54A7W.mjs} +7 -1
  35. package/dist/codex-compat/plugins/apexrest-apex/runtime/chunk-N4C2SKCN.mjs +6912 -0
  36. package/dist/{runtime/chunk-KQ5IDT7Z.mjs → codex-compat/plugins/apexrest-apex/runtime/chunk-P3CVQAZW.mjs} +822 -102
  37. package/dist/{runtime/chunk-BAHECVGO.mjs → codex-compat/plugins/apexrest-apex/runtime/chunk-QKYF6N6U.mjs} +192 -114
  38. package/dist/codex-compat/plugins/apexrest-apex/runtime/{chunk-G3KR57BY.mjs → chunk-RBJJNQ5O.mjs} +7 -7
  39. package/dist/codex-compat/plugins/apexrest-apex/runtime/{chunk-YPLIIQ4Y.mjs → chunk-TMSMKVRP.mjs} +486 -352
  40. package/dist/codex-compat/plugins/apexrest-apex/runtime/{chunk-2Z3BZF66.mjs → chunk-WPS3CSQJ.mjs} +124 -11
  41. package/dist/codex-compat/plugins/apexrest-apex/runtime/mcp.mjs +5 -10
  42. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-apexlang/SKILL.md +22 -25
  43. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-apexlang/agents/openai.yaml +3 -3
  44. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-apexlang/references/component-routes.md +1 -5
  45. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-pattern-catalog/SKILL.md +4 -4
  46. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-pattern-catalog/agents/openai.yaml +1 -1
  47. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-pattern-catalog/references/capture-and-curation.md +2 -2
  48. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-safety/SKILL.md +18 -0
  49. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-safety/agents/openai.yaml +4 -0
  50. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-setup/SKILL.md +20 -10
  51. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-setup/agents/openai.yaml +3 -3
  52. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-work/SKILL.md +11 -8
  53. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-work/agents/openai.yaml +3 -3
  54. package/dist/resources/blocks/generator.json +1 -1
  55. package/dist/resources/blocks/manifest.json +6 -6
  56. package/dist/resources/blocks/packages/analytics/status-summary/1.0.0/block.yaml +1 -1
  57. package/dist/resources/blocks/packages/crud/report-dialog/1.0.0/block.yaml +1 -1
  58. package/dist/resources/blocks/packages/read/detail/1.0.0/block.yaml +1 -1
  59. package/dist/resources/blocks/packages/read/filtered-list/1.0.0/block.yaml +1 -1
  60. package/dist/resources/blocks/packages/read/history/1.0.0/block.yaml +1 -1
  61. package/dist/resources/blocks/packages/read/master-detail/1.0.0/block.yaml +1 -1
  62. package/dist/resources/schemas/composer-blueprint.schema.json +5 -4
  63. package/dist/resources/schemas/composer-contract.schema.json +2 -2
  64. package/dist/resources/schemas/composer-entity.schema.json +2 -1
  65. package/dist/resources/schemas/composer-field.schema.json +2 -1
  66. package/dist/resources/schemas/composer-instance.schema.json +1 -1
  67. package/dist/resources/schemas/composer-operation.schema.json +1 -1
  68. package/dist/resources/schemas/composer-plan.schema.json +5 -4
  69. package/dist/resources/schemas/deploy-plan.schema.json +18 -24
  70. package/dist/resources/schemas/operations.schema.json +352 -569
  71. package/dist/resources/schemas/policy.schema.json +21 -0
  72. package/dist/resources/schemas/project.schema.json +4 -7
  73. package/dist/resources/templates/blank-app/README.md +0 -2
  74. package/dist/resources/templates/customer-crm/README.md +1 -3
  75. package/dist/resources/templates/existing-app/README.md +0 -2
  76. package/dist/runtime/apexrest.mjs +70 -44
  77. package/dist/runtime/chunk-5PCC7GZM.mjs +4090 -0
  78. package/dist/runtime/chunk-BVPAS3TD.mjs +18 -0
  79. package/dist/runtime/chunk-CVMECW6D.mjs +65 -0
  80. package/dist/runtime/{chunk-EBBEN4AV.mjs → chunk-JYN3YHP3.mjs} +4220 -10639
  81. package/dist/runtime/chunk-KGTE7Q5Y.mjs +23 -0
  82. package/dist/{codex-compat/plugins/apexrest-apex/runtime/chunk-33GE2NWZ.mjs → runtime/chunk-KKRFM7Q7.mjs} +21 -4
  83. package/dist/runtime/{chunk-2VBZESVC.mjs → chunk-MNU54A7W.mjs} +7 -1
  84. package/dist/runtime/chunk-N4C2SKCN.mjs +6912 -0
  85. package/dist/{codex-compat/plugins/apexrest-apex/runtime/chunk-KQ5IDT7Z.mjs → runtime/chunk-P3CVQAZW.mjs} +822 -102
  86. package/dist/{codex-compat/plugins/apexrest-apex/runtime/chunk-BAHECVGO.mjs → runtime/chunk-QKYF6N6U.mjs} +192 -114
  87. package/dist/runtime/{chunk-G3KR57BY.mjs → chunk-RBJJNQ5O.mjs} +7 -7
  88. package/dist/runtime/{chunk-YPLIIQ4Y.mjs → chunk-TMSMKVRP.mjs} +486 -352
  89. package/dist/runtime/{chunk-2Z3BZF66.mjs → chunk-WPS3CSQJ.mjs} +124 -11
  90. package/dist/runtime/mcp.mjs +5 -10
  91. package/package.json +6 -6
  92. package/README.uk.md +0 -212
  93. package/dist/codex-compat/plugins/apexrest-apex/resources/panel/index.html +0 -68
  94. package/dist/codex-compat/plugins/apexrest-apex/resources/panel/panel.css +0 -627
  95. package/dist/codex-compat/plugins/apexrest-apex/resources/panel/panel.js +0 -861
  96. package/dist/codex-compat/plugins/apexrest-apex/resources/templates/blank-app/README.uk.md +0 -5
  97. package/dist/codex-compat/plugins/apexrest-apex/resources/templates/customer-crm/README.uk.md +0 -7
  98. package/dist/codex-compat/plugins/apexrest-apex/resources/templates/database-control/install.sql +0 -17
  99. package/dist/codex-compat/plugins/apexrest-apex/resources/templates/existing-app/README.uk.md +0 -9
  100. package/dist/codex-compat/plugins/apexrest-apex/resources/third-party/node_modules__@playwright__test__LICENSE +0 -202
  101. package/dist/codex-compat/plugins/apexrest-apex/resources/third-party/node_modules__@playwright__test__NOTICE +0 -5
  102. package/dist/codex-compat/plugins/apexrest-apex/resources/third-party/node_modules__@types__node__LICENSE +0 -21
  103. package/dist/codex-compat/plugins/apexrest-apex/resources/third-party/node_modules__@types__yauzl__LICENSE +0 -21
  104. package/dist/codex-compat/plugins/apexrest-apex/resources/third-party/node_modules__@typescript__typescript-darwin-arm64__LICENSE +0 -55
  105. package/dist/codex-compat/plugins/apexrest-apex/resources/third-party/node_modules__@typescript__typescript-darwin-arm64__NOTICE.txt +0 -436
  106. package/dist/codex-compat/plugins/apexrest-apex/resources/third-party/node_modules__esbuild__LICENSE.md +0 -21
  107. package/dist/codex-compat/plugins/apexrest-apex/resources/third-party/node_modules__fflate__LICENSE +0 -21
  108. package/dist/codex-compat/plugins/apexrest-apex/resources/third-party/node_modules__marked__LICENSE +0 -44
  109. package/dist/codex-compat/plugins/apexrest-apex/resources/third-party/node_modules__playwright-core__LICENSE +0 -202
  110. package/dist/codex-compat/plugins/apexrest-apex/resources/third-party/node_modules__playwright-core__NOTICE +0 -5
  111. package/dist/codex-compat/plugins/apexrest-apex/resources/third-party/node_modules__playwright__LICENSE +0 -202
  112. package/dist/codex-compat/plugins/apexrest-apex/resources/third-party/node_modules__playwright__NOTICE +0 -5
  113. package/dist/codex-compat/plugins/apexrest-apex/resources/third-party/node_modules__prettier__LICENSE +0 -7
  114. package/dist/codex-compat/plugins/apexrest-apex/resources/third-party/node_modules__typescript__LICENSE +0 -55
  115. package/dist/codex-compat/plugins/apexrest-apex/resources/third-party/node_modules__typescript__NOTICE.txt +0 -436
  116. package/dist/codex-compat/plugins/apexrest-apex/resources/third-party/node_modules__undici-types__LICENSE +0 -21
  117. package/dist/codex-compat/plugins/apexrest-apex/runtime/chunk-2BBNJVKW.mjs +0 -1996
  118. package/dist/codex-compat/plugins/apexrest-apex/runtime/chunk-5JI3XEAK.mjs +0 -14
  119. package/dist/codex-compat/plugins/apexrest-apex/runtime/chunk-CYPFCUNE.mjs +0 -150
  120. package/dist/codex-compat/plugins/apexrest-apex/runtime/chunk-ESDVN7DS.mjs +0 -14
  121. package/dist/codex-compat/plugins/apexrest-apex/runtime/chunk-FTTPESNK.mjs +0 -203
  122. package/dist/codex-compat/plugins/apexrest-apex/runtime/chunk-HKJVCGQQ.mjs +0 -1302
  123. package/dist/codex-compat/plugins/apexrest-apex/runtime/chunk-RWGJITHZ.mjs +0 -992
  124. package/dist/codex-compat/plugins/apexrest-apex/runtime/chunk-TLYYCRQA.mjs +0 -329
  125. package/dist/codex-compat/plugins/apexrest-apex/runtime/chunk-WXP75UUP.mjs +0 -18
  126. package/dist/codex-compat/plugins/apexrest-apex/runtime/chunk-YQHHPRJH.mjs +0 -14
  127. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-compose/SKILL.md +0 -18
  128. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-compose/agents/openai.yaml +0 -4
  129. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-compose/references/workflow.md +0 -15
  130. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-database/SKILL.md +0 -9
  131. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-database/agents/openai.yaml +0 -4
  132. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-debug/SKILL.md +0 -9
  133. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-debug/agents/openai.yaml +0 -4
  134. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-deploy/SKILL.md +0 -21
  135. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-deploy/agents/openai.yaml +0 -4
  136. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-install-dependencies/SKILL.md +0 -38
  137. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-install-dependencies/agents/openai.yaml +0 -4
  138. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-menu/SKILL.md +0 -30
  139. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-menu/agents/openai.yaml +0 -4
  140. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-menu/references/cli-catalog.md +0 -30
  141. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-panel/SKILL.md +0 -14
  142. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-panel/agents/openai.yaml +0 -4
  143. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-project/SKILL.md +0 -11
  144. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-project/agents/openai.yaml +0 -4
  145. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-review/SKILL.md +0 -11
  146. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-review/agents/openai.yaml +0 -4
  147. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-test/SKILL.md +0 -29
  148. package/dist/codex-compat/plugins/apexrest-apex/skills/apexrest-test/agents/openai.yaml +0 -4
  149. package/dist/resources/panel/index.html +0 -68
  150. package/dist/resources/panel/panel.css +0 -627
  151. package/dist/resources/panel/panel.js +0 -861
  152. package/dist/resources/templates/blank-app/README.uk.md +0 -5
  153. package/dist/resources/templates/customer-crm/README.uk.md +0 -7
  154. package/dist/resources/templates/database-control/install.sql +0 -17
  155. package/dist/resources/templates/existing-app/README.uk.md +0 -9
  156. package/dist/resources/third-party/node_modules__@playwright__test__LICENSE +0 -202
  157. package/dist/resources/third-party/node_modules__@playwright__test__NOTICE +0 -5
  158. package/dist/resources/third-party/node_modules__@types__node__LICENSE +0 -21
  159. package/dist/resources/third-party/node_modules__@types__yauzl__LICENSE +0 -21
  160. package/dist/resources/third-party/node_modules__@typescript__typescript-darwin-arm64__LICENSE +0 -55
  161. package/dist/resources/third-party/node_modules__@typescript__typescript-darwin-arm64__NOTICE.txt +0 -436
  162. package/dist/resources/third-party/node_modules__esbuild__LICENSE.md +0 -21
  163. package/dist/resources/third-party/node_modules__fflate__LICENSE +0 -21
  164. package/dist/resources/third-party/node_modules__marked__LICENSE +0 -44
  165. package/dist/resources/third-party/node_modules__playwright-core__LICENSE +0 -202
  166. package/dist/resources/third-party/node_modules__playwright-core__NOTICE +0 -5
  167. package/dist/resources/third-party/node_modules__playwright__LICENSE +0 -202
  168. package/dist/resources/third-party/node_modules__playwright__NOTICE +0 -5
  169. package/dist/resources/third-party/node_modules__prettier__LICENSE +0 -7
  170. package/dist/resources/third-party/node_modules__typescript__LICENSE +0 -55
  171. package/dist/resources/third-party/node_modules__typescript__NOTICE.txt +0 -436
  172. package/dist/resources/third-party/node_modules__undici-types__LICENSE +0 -21
  173. package/dist/runtime/chunk-2BBNJVKW.mjs +0 -1996
  174. package/dist/runtime/chunk-5JI3XEAK.mjs +0 -14
  175. package/dist/runtime/chunk-CYPFCUNE.mjs +0 -150
  176. package/dist/runtime/chunk-ESDVN7DS.mjs +0 -14
  177. package/dist/runtime/chunk-FTTPESNK.mjs +0 -203
  178. package/dist/runtime/chunk-HKJVCGQQ.mjs +0 -1302
  179. package/dist/runtime/chunk-RWGJITHZ.mjs +0 -992
  180. package/dist/runtime/chunk-TLYYCRQA.mjs +0 -329
  181. package/dist/runtime/chunk-WXP75UUP.mjs +0 -18
  182. package/dist/runtime/chunk-YQHHPRJH.mjs +0 -14
@@ -1,14 +0,0 @@
1
- import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
- import {
3
- startMcp
4
- } from "./chunk-BAHECVGO.mjs";
5
- import "./chunk-HKJVCGQQ.mjs";
6
- import "./chunk-FTTPESNK.mjs";
7
- import "./chunk-2BBNJVKW.mjs";
8
- import "./chunk-YPLIIQ4Y.mjs";
9
- import "./chunk-G3KR57BY.mjs";
10
- import "./chunk-EBBEN4AV.mjs";
11
- import "./chunk-2Z3BZF66.mjs";
12
- export {
13
- startMcp
14
- };
@@ -1,150 +0,0 @@
1
- import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
- import {
3
- clip,
4
- paint,
5
- wrap
6
- } from "./chunk-TLYYCRQA.mjs";
7
- import {
8
- PanelService
9
- } from "./chunk-2BBNJVKW.mjs";
10
- import "./chunk-YPLIIQ4Y.mjs";
11
- import "./chunk-G3KR57BY.mjs";
12
- import "./chunk-EBBEN4AV.mjs";
13
- import {
14
- Fault
15
- } from "./chunk-2Z3BZF66.mjs";
16
-
17
- // packages/cli/src/panel-tui.ts
18
- import { emitKeypressEvents } from "node:readline";
19
- function panelLines(data, tab) {
20
- if (tab === 2)
21
- return [
22
- `Database network: ${data.sqlcl.databaseTransport === "ords" ? "ORDS HTTP(S)" : "Direct Oracle listener"}`,
23
- `SQLcl execution: ${data.sqlcl.mode.toUpperCase()} \xB7 restriction ${data.sqlcl.mcpRestrictLevel}`,
24
- `Trusted: ${data.trusted} \xB7 configured: ${data.configured}`,
25
- "Verification browser: " + data.preferences.browserMode,
26
- ...JSON.stringify(
27
- {
28
- project: data.configuration,
29
- toolchain: data.toolchain,
30
- connections: data.connections,
31
- authorization: data.permissions
32
- },
33
- null,
34
- 2
35
- ).split("\n")
36
- ];
37
- if (tab === 1)
38
- return [
39
- "APEX OPERATIONS",
40
- ...data.jobs.flatMap((job) => [`${job.operation} \xB7 ${job.status}`, job.summary]),
41
- ...data.jobs.length ? [] : ["No operation jobs recorded."],
42
- "",
43
- "WORKING-COPY SYNC (local only)",
44
- ...data.sync.flatMap((row) => [row.environment + " \xB7 " + row.status, JSON.stringify(row)]),
45
- "",
46
- "DEPLOYMENT & IMPORT JOURNAL",
47
- ...data.deployments.flatMap((run) => [run.status + " \xB7 " + run.at, run.details]),
48
- "",
49
- "Commands: apexrest apex validate \xB7 apexrest test unit \xB7 apexrest deploy plan --env NAME --out PATH",
50
- "Existing project trust and deployment authorization remain required."
51
- ];
52
- return [
53
- "CURRENT CODEX SESSION",
54
- "Describe changes and review results in your open Codex conversation.",
55
- "This panel runs APEX operations and manages project settings.",
56
- "",
57
- `Application: ${data.configuration?.application.alias ?? "Not configured"}`,
58
- `Source: ${data.configuration?.application.sourceDir ?? "Not configured"}`,
59
- "Environments: " + (Object.keys(data.configuration?.environments ?? {}).join(", ") || "None configured"),
60
- "Required suites: " + (data.configuration?.tests.requiredSuites.join(", ") || "None declared"),
61
- `Trusted: ${data.trusted} \xB7 configured: ${data.configured}`,
62
- "",
63
- "WORKING CHANGES",
64
- ...data.changes.files.length ? data.changes.files : [data.changes.status === "available" ? "No uncommitted Git changes." : "Git status unavailable."]
65
- ];
66
- }
67
- async function runPanelTui(root) {
68
- if (!process.stdin.isTTY || !process.stdout.isTTY || process.env.TERM === "dumb")
69
- throw new Fault("TTY_REQUIRED", "Use an interactive Codex terminal, or apexrest panel status --json.", 2);
70
- const service = new PanelService(root), output = process.stdout, input = process.stdin;
71
- let data, error = "", tab = 0, offset = 0, refreshing = false, stopped = false;
72
- const color = !process.env.NO_COLOR;
73
- const draw = () => {
74
- if (stopped) return;
75
- const width = Math.max(20, output.columns || 80), height = Math.max(7, output.rows || 24);
76
- const body = data ? panelLines(data, tab).flatMap((line) => wrap(line, width - 2)) : [];
77
- offset = Math.max(0, Math.min(offset, Math.max(0, body.length - (height - 6))));
78
- const lines = [
79
- paint(" APEXREST \xB7 Development panel", "accent", color),
80
- clip(" " + root, width),
81
- ["Overview", "APEX operations", "Settings"].map((name, i) => `${i + 1} ${i === tab ? "[" + name + "]" : name}`).join(" "),
82
- error ? "Disconnected \xB7 " + error : data ? "Live \xB7 " + new Date(data.updatedAt).toLocaleTimeString() : "Connecting\u2026",
83
- ...body.slice(offset, offset + height - 6),
84
- "1\u20133 / \u2190\u2192 views \xB7 \u2191\u2193 scroll \xB7 r refresh \xB7 q exit | Actions: apexrest panel action --help"
85
- ];
86
- output.write("\x1B[H\x1B[2J" + lines.map((line, i) => i === 0 ? line : clip(line, width)).join("\r\n"));
87
- };
88
- const refresh = async () => {
89
- if (refreshing || stopped) return;
90
- refreshing = true;
91
- try {
92
- data = await service.snapshot();
93
- error = "";
94
- } catch (e) {
95
- error = e instanceof Error ? e.message : String(e);
96
- } finally {
97
- refreshing = false;
98
- draw();
99
- }
100
- };
101
- const wasRaw = input.isRaw;
102
- emitKeypressEvents(input);
103
- input.setRawMode(true);
104
- input.resume();
105
- output.write("\x1B[?1049h\x1B[?25l");
106
- await new Promise((resolve) => {
107
- const close = () => {
108
- if (stopped) return;
109
- stopped = true;
110
- clearInterval(timer);
111
- input.off("keypress", key);
112
- output.off("resize", draw);
113
- process.off("SIGINT", close);
114
- process.off("SIGTERM", close);
115
- input.setRawMode(wasRaw);
116
- input.pause();
117
- output.write("\x1B[?25h\x1B[?1049l");
118
- resolve();
119
- };
120
- const key = (_text, k) => {
121
- if (k.name === "q" || k.ctrl && k.name === "c") return close();
122
- if (/^[1-3]$/.test(k.name ?? "")) {
123
- tab = Number(k.name) - 1;
124
- offset = 0;
125
- }
126
- if (k.name === "right" || k.name === "left") {
127
- tab = (tab + (k.name === "right" ? 1 : 2)) % 3;
128
- offset = 0;
129
- }
130
- if (k.name === "up") offset--;
131
- if (k.name === "down") offset++;
132
- if (k.name === "pageup") offset -= 10;
133
- if (k.name === "pagedown") offset += 10;
134
- if (k.name === "r") void refresh();
135
- else draw();
136
- };
137
- const timer = setInterval(() => {
138
- void refresh();
139
- }, 2e3);
140
- input.on("keypress", key);
141
- output.on("resize", draw);
142
- process.once("SIGINT", close);
143
- process.once("SIGTERM", close);
144
- void refresh();
145
- });
146
- }
147
- export {
148
- panelLines,
149
- runPanelTui
150
- };
@@ -1,14 +0,0 @@
1
- import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
- import {
3
- browserInstructions,
4
- externalBrowserCommand,
5
- openVerificationBrowser
6
- } from "./chunk-YPLIIQ4Y.mjs";
7
- import "./chunk-G3KR57BY.mjs";
8
- import "./chunk-EBBEN4AV.mjs";
9
- import "./chunk-2Z3BZF66.mjs";
10
- export {
11
- browserInstructions,
12
- externalBrowserCommand,
13
- openVerificationBrowser
14
- };
@@ -1,203 +0,0 @@
1
- import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
- import {
3
- PanelService,
4
- panelActionSchema
5
- } from "./chunk-2BBNJVKW.mjs";
6
- import {
7
- parse,
8
- resourceRoot
9
- } from "./chunk-EBBEN4AV.mjs";
10
- import {
11
- Fault,
12
- contained,
13
- exists,
14
- failure,
15
- readJson,
16
- withLock,
17
- writeJson
18
- } from "./chunk-2Z3BZF66.mjs";
19
-
20
- // packages/core/src/panel-server.ts
21
- import path from "node:path";
22
- import { fileURLToPath } from "node:url";
23
- import { createServer } from "node:http";
24
- import { randomBytes, timingSafeEqual } from "node:crypto";
25
- import { readFile } from "node:fs/promises";
26
- import { spawn } from "node:child_process";
27
- import { setTimeout as delay } from "node:timers/promises";
28
- function validSession(value) {
29
- const s = value;
30
- return !!s && Number.isInteger(s.port) && s.port > 0 && s.port < 65536 && typeof s.token === "string" && /^[a-f0-9]{64}$/.test(s.token) && typeof s.project === "string";
31
- }
32
- async function panelDocument() {
33
- const root = path.join(resourceRoot(), "panel");
34
- const [html, css, js] = await Promise.all(
35
- ["index.html", "panel.css", "panel.js"].map((file) => readFile(path.join(root, file), "utf8"))
36
- );
37
- return html.replace('<link rel="stylesheet" href="/panel.css">', () => "<style>" + css + "</style>").replace('<script src="/panel.js" defer></script>', "").replace("</body>", () => "<script>" + js.replaceAll("</script", "<\\/script") + "</script>\n</body>");
38
- }
39
- async function startPanelServer(root, idleMs = 36e5) {
40
- const token = randomBytes(32).toString("hex");
41
- const service = new PanelService(root);
42
- let lastRequest = Date.now(), origin = "";
43
- const server = createServer(async (req, res) => {
44
- res.setHeader("Cache-Control", "no-store");
45
- res.setHeader("X-Content-Type-Options", "nosniff");
46
- res.setHeader("Referrer-Policy", "no-referrer");
47
- res.setHeader(
48
- "Content-Security-Policy",
49
- "default-src 'self'; script-src 'self'; style-src 'self'; connect-src 'self'; img-src 'self' data:; frame-ancestors 'self'"
50
- );
51
- const json = (status, data) => {
52
- res.writeHead(status, { "Content-Type": "application/json" });
53
- res.end(JSON.stringify(data));
54
- };
55
- try {
56
- if (req.headers.host !== origin.slice(7) || req.headers.origin && req.headers.origin !== origin) {
57
- json(403, { error: "Origin rejected." });
58
- return;
59
- }
60
- const url = new URL(req.url ?? "/", origin);
61
- const assets = {
62
- "/": ["index.html", "text/html; charset=utf-8"],
63
- "/panel.css": ["panel.css", "text/css; charset=utf-8"],
64
- "/panel.js": ["panel.js", "text/javascript; charset=utf-8"]
65
- };
66
- if (req.method === "GET" && assets[url.pathname]) {
67
- const [file, type] = assets[url.pathname];
68
- res.writeHead(200, { "Content-Type": type });
69
- res.end(await readFile(path.join(resourceRoot(), "panel", file)));
70
- return;
71
- }
72
- const supplied = Buffer.from(String(req.headers.authorization ?? "").replace(/^Bearer /, ""));
73
- if (supplied.length !== token.length || !timingSafeEqual(supplied, Buffer.from(token))) {
74
- json(401, { error: "Open this panel from Codex to authorize the local session." });
75
- return;
76
- }
77
- lastRequest = Date.now();
78
- if (req.method === "GET" && url.pathname === "/health") {
79
- json(200, { project: root });
80
- return;
81
- }
82
- if (req.method === "GET" && url.pathname === "/api/status") {
83
- json(200, await service.snapshot());
84
- return;
85
- }
86
- if (req.method === "POST" && url.pathname === "/api/action") {
87
- if (req.headers["content-type"] !== "application/json") {
88
- json(415, { error: "Expected JSON." });
89
- return;
90
- }
91
- const chunks = [];
92
- let bytes = 0;
93
- for await (const chunk of req) {
94
- bytes += chunk.length;
95
- if (bytes > 32768) {
96
- json(413, { error: "Request too large." });
97
- return;
98
- }
99
- chunks.push(chunk);
100
- }
101
- const { action } = parse(panelActionSchema, {
102
- action: JSON.parse(Buffer.concat(chunks).toString("utf8"))
103
- });
104
- json(200, await service.act(action));
105
- return;
106
- }
107
- json(404, { error: "Not found." });
108
- } catch (error) {
109
- json(400, failure("panel", error));
110
- }
111
- });
112
- server.requestTimeout = 15e3;
113
- server.headersTimeout = 1e4;
114
- await new Promise((resolve, reject) => {
115
- server.once("error", reject);
116
- server.listen(0, "127.0.0.1", resolve);
117
- });
118
- const address = server.address();
119
- if (!address || typeof address === "string") throw new Error("Panel could not bind localhost.");
120
- origin = `http://127.0.0.1:${address.port}`;
121
- const timer = setInterval(
122
- () => {
123
- if (Date.now() - lastRequest > idleMs) void close();
124
- },
125
- Math.min(idleMs, 6e4)
126
- );
127
- const close = () => {
128
- clearInterval(timer);
129
- server.closeIdleConnections();
130
- return new Promise((resolve) => server.close(() => resolve()));
131
- };
132
- return {
133
- session: { port: address.port, token, project: root, pid: process.pid },
134
- close
135
- };
136
- }
137
- async function servePanel(root) {
138
- const handle = await startPanelServer(root);
139
- await writeJson(await contained(root, ".apexrest/panel/session.json"), handle.session);
140
- process.once("SIGTERM", () => {
141
- void handle.close();
142
- });
143
- process.once("SIGINT", () => {
144
- void handle.close();
145
- });
146
- }
147
- async function openPanel(root) {
148
- const file = await contained(root, ".apexrest/panel/session.json");
149
- const read = async () => {
150
- if (!await exists(file)) return null;
151
- const session = await readJson(file).catch(() => null);
152
- if (!validSession(session) || session.project !== root) return null;
153
- try {
154
- const response = await fetch(`http://127.0.0.1:${session.port}/health`, {
155
- headers: { Authorization: "Bearer " + session.token },
156
- redirect: "error",
157
- signal: AbortSignal.timeout(1e3)
158
- });
159
- if (response.ok && (await response.json()).project === root) return session;
160
- } catch {
161
- }
162
- return null;
163
- };
164
- return withLock(await contained(root, ".apexrest/panel/start.lock"), async () => {
165
- let session = await read();
166
- if (!session) {
167
- const worker = spawn(
168
- process.execPath,
169
- [path.join(path.dirname(fileURLToPath(import.meta.url)), "apexrest.mjs"), "--panel-worker", root],
170
- {
171
- cwd: root,
172
- env: process.env,
173
- detached: true,
174
- stdio: "ignore",
175
- windowsHide: true
176
- }
177
- );
178
- await new Promise((resolve, reject) => {
179
- worker.once("spawn", resolve);
180
- worker.once("error", reject);
181
- });
182
- worker.unref();
183
- for (let i = 0; i < 50 && !session; i++) {
184
- await delay(100);
185
- session = await read();
186
- }
187
- if (!session)
188
- throw new Fault("PANEL_START_FAILED", "The local panel did not become ready.", 3, "blocked");
189
- }
190
- return {
191
- project: root,
192
- url: `http://127.0.0.1:${session.port}/#session=${session.token}`,
193
- nextAction: "Open this URL in the Codex in-app browser using open_in_codex when available. Codex CLI: apexrest panel tui --project PATH."
194
- };
195
- });
196
- }
197
-
198
- export {
199
- panelDocument,
200
- startPanelServer,
201
- servePanel,
202
- openPanel
203
- };