@tidegap/cli 0.0.0-stage → 0.19.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.
- package/LICENSE +201 -0
- package/README.md +136 -2
- package/dist/commands/clients.d.ts +20 -0
- package/dist/commands/clients.d.ts.map +1 -0
- package/dist/commands/clients.js +36 -0
- package/dist/commands/clients.js.map +1 -0
- package/dist/commands/env-file.d.ts +54 -0
- package/dist/commands/env-file.d.ts.map +1 -0
- package/dist/commands/env-file.js +153 -0
- package/dist/commands/env-file.js.map +1 -0
- package/dist/commands/install.d.ts +83 -0
- package/dist/commands/install.d.ts.map +1 -0
- package/dist/commands/install.js +297 -0
- package/dist/commands/install.js.map +1 -0
- package/dist/commands/queue.d.ts +139 -0
- package/dist/commands/queue.d.ts.map +1 -0
- package/dist/commands/queue.js +491 -0
- package/dist/commands/queue.js.map +1 -0
- package/dist/commands/receipts.d.ts +15 -0
- package/dist/commands/receipts.d.ts.map +1 -0
- package/dist/commands/receipts.js +70 -0
- package/dist/commands/receipts.js.map +1 -0
- package/dist/commands/register-wake.d.ts +21 -0
- package/dist/commands/register-wake.d.ts.map +1 -0
- package/dist/commands/register-wake.js +76 -0
- package/dist/commands/register-wake.js.map +1 -0
- package/dist/commands/stats.d.ts +31 -0
- package/dist/commands/stats.d.ts.map +1 -0
- package/dist/commands/stats.js +165 -0
- package/dist/commands/stats.js.map +1 -0
- package/dist/commands/tick.d.ts +73 -0
- package/dist/commands/tick.d.ts.map +1 -0
- package/dist/commands/tick.js +294 -0
- package/dist/commands/tick.js.map +1 -0
- package/dist/commands/ui.d.ts +33 -0
- package/dist/commands/ui.d.ts.map +1 -0
- package/dist/commands/ui.js +119 -0
- package/dist/commands/ui.js.map +1 -0
- package/dist/commands/verify.d.ts +32 -0
- package/dist/commands/verify.d.ts.map +1 -0
- package/dist/commands/verify.js +135 -0
- package/dist/commands/verify.js.map +1 -0
- package/dist/env.d.ts +57 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +105 -0
- package/dist/env.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +366 -0
- package/dist/index.js.map +1 -0
- package/dist/platform/index.d.ts +30 -0
- package/dist/platform/index.d.ts.map +1 -0
- package/dist/platform/index.js +66 -0
- package/dist/platform/index.js.map +1 -0
- package/dist/platform/linux.d.ts +81 -0
- package/dist/platform/linux.d.ts.map +1 -0
- package/dist/platform/linux.js +158 -0
- package/dist/platform/linux.js.map +1 -0
- package/dist/platform/macos.d.ts +69 -0
- package/dist/platform/macos.d.ts.map +1 -0
- package/dist/platform/macos.js +151 -0
- package/dist/platform/macos.js.map +1 -0
- package/dist/platform/windows.d.ts +31 -0
- package/dist/platform/windows.d.ts.map +1 -0
- package/dist/platform/windows.js +58 -0
- package/dist/platform/windows.js.map +1 -0
- package/dist/ui/api.d.ts +66 -0
- package/dist/ui/api.d.ts.map +1 -0
- package/dist/ui/api.js +613 -0
- package/dist/ui/api.js.map +1 -0
- package/dist/ui/clients.d.ts +65 -0
- package/dist/ui/clients.d.ts.map +1 -0
- package/dist/ui/clients.js +179 -0
- package/dist/ui/clients.js.map +1 -0
- package/dist/ui/discovery.d.ts +25 -0
- package/dist/ui/discovery.d.ts.map +1 -0
- package/dist/ui/discovery.js +46 -0
- package/dist/ui/discovery.js.map +1 -0
- package/dist/ui/dispatcher.d.ts +84 -0
- package/dist/ui/dispatcher.d.ts.map +1 -0
- package/dist/ui/dispatcher.js +150 -0
- package/dist/ui/dispatcher.js.map +1 -0
- package/dist/ui/events.d.ts +27 -0
- package/dist/ui/events.d.ts.map +1 -0
- package/dist/ui/events.js +85 -0
- package/dist/ui/events.js.map +1 -0
- package/dist/ui/server.d.ts +84 -0
- package/dist/ui/server.d.ts.map +1 -0
- package/dist/ui/server.js +322 -0
- package/dist/ui/server.js.map +1 -0
- package/dist/ui/summary.d.ts +47 -0
- package/dist/ui/summary.d.ts.map +1 -0
- package/dist/ui/summary.js +120 -0
- package/dist/ui/summary.js.map +1 -0
- package/package.json +53 -3
- package/ui/agenda.js +256 -0
- package/ui/api.js +114 -0
- package/ui/app.css +713 -0
- package/ui/app.js +599 -0
- package/ui/clients.js +104 -0
- package/ui/detail.js +431 -0
- package/ui/dialog.js +284 -0
- package/ui/dnd.js +131 -0
- package/ui/dom.js +255 -0
- package/ui/index.html +38 -0
- package/ui/journal.js +207 -0
- package/ui/keys.js +92 -0
- package/ui/row.js +153 -0
- package/ui/state.js +412 -0
- package/ui/timeline.js +202 -0
- package/ui/toast.js +69 -0
- package/ui/tokens.css +108 -0
- package/ui/views.js +31 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Support. While redistributing the Work or
|
|
166
|
+
Derivative Works thereof, You may choose to offer, and charge a
|
|
167
|
+
fee for, acceptance of support, warranty, indemnity, or other
|
|
168
|
+
liability obligations and/or rights consistent with this License.
|
|
169
|
+
However, in accepting such obligations, You may act only on Your
|
|
170
|
+
own behalf and on Your sole responsibility, not on behalf of any
|
|
171
|
+
other Contributor, and only if You agree to indemnify, defend, and
|
|
172
|
+
hold each Contributor harmless for any liability incurred by, or
|
|
173
|
+
claims asserted against, such Contributor by reason of your accepting
|
|
174
|
+
any such warranty or support.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Vitalii Borovyk
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
200
|
+
implied. See the License for the specific language governing
|
|
201
|
+
permissions and limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,137 @@
|
|
|
1
|
-
|
|
1
|
+
<img src="https://www.tidegap.com/icon-192.png" alt="Tidegap" width="48" height="48">
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# @tidegap/cli
|
|
4
|
+
|
|
5
|
+
> Renamed from `@ebb-ai/cli` in 0.18.0. The `ebb` command and the `EBB_*` variables were removed in 0.19; use `tidegap` and `TIDEGAP_*`. If npm reports `EEXIST` on install, run `npm uninstall -g @ebb-ai/cli` first. See [Renamed from Ebb AI](https://github.com/tidegap/tidegap#renamed-from-ebb-ai).
|
|
6
|
+
|
|
7
|
+
**The `tidegap` command: runs your queued Tidegap tasks when their cleanest grid hour arrives.**
|
|
8
|
+
|
|
9
|
+
`tidegap` drains the Tidegap task queue on a timer. A task that your agent deferred runs at the lowest-carbon hour before its deadline, also when no agent session is open.
|
|
10
|
+
|
|
11
|
+
- `tidegap tick` dispatches every task that is due. `tidegap install` wires it to launchd on macOS.
|
|
12
|
+
- `tidegap queue list` and `tidegap receipts list` show queued tasks and their carbon receipts.
|
|
13
|
+
- `tidegap verify <task-id>` checks a receipt's Ed25519 signature offline.
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install -g @tidegap/cli
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
tidegap install --laptop # run `tidegap tick` on a schedule; register wake events across sleep
|
|
21
|
+
tidegap queue list # what is waiting, and for which hour
|
|
22
|
+
tidegap tick --region GB # dispatch what is due now
|
|
23
|
+
tidegap receipts list # one carbon receipt per completed task
|
|
24
|
+
tidegap verify <task-id> # check the receipt signature
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Proof: one real GB run, 2026-09-30 (`tidegap tick` + `tidegap verify`). Forecast peak 183 gCO2/kWh vs recommended window 88 gCO2/kWh, about 52 % lower for this run only (forecast, projected). The task had a 5-minute deadline and ran at once; its receipt records 158 gCO2/kWh (measured). Raw output: https://github.com/tidegap/tidegap/tree/main/docs/examples/2026-09-30-GB-tick
|
|
28
|
+
|
|
29
|
+
## Commands
|
|
30
|
+
|
|
31
|
+
```text
|
|
32
|
+
tidegap tick — drain due tasks via provider adapters; one OS notification per finished task (--no-notify, or TIDEGAP_NO_NOTIFY=1)
|
|
33
|
+
tidegap install — wire up launchd (macOS) or print systemd / schtasks templates
|
|
34
|
+
tidegap queue list — print tasks (--unread, --kind absolute|quota_reset, --json, --hook)
|
|
35
|
+
tidegap queue show — print one task's prompt, result and receipt; marks it read
|
|
36
|
+
tidegap queue unread — mark a task unread again
|
|
37
|
+
tidegap queue cancel — cancel a pending task (--series ends a repeating series)
|
|
38
|
+
tidegap queue reschedule — move a task: --by <2h|ISO>, --at <ISO>, or --day <yyyy-mm-dd>
|
|
39
|
+
tidegap queue run-now — mark a task due; the next tick runs it
|
|
40
|
+
tidegap queue reply — continue a completed task as a new task (--by, default 1h)
|
|
41
|
+
tidegap receipts list — print carbon receipts for completed tasks
|
|
42
|
+
tidegap stats — local-only personal-impact stats from the queue ledger
|
|
43
|
+
tidegap verify — verify the Ed25519 signature on a carbon receipt
|
|
44
|
+
tidegap register-wake — schedule a macOS wake event 30s before a task
|
|
45
|
+
tidegap ui — local task page: agenda, journal, timeline, task detail and actions (127.0.0.1 only; port 47821 by default)
|
|
46
|
+
tidegap clients add — mint a token for the browser extension or the Mac app (--name, --kind extension|macos, --json)
|
|
47
|
+
tidegap clients list — list client ids, kinds and names (never tokens)
|
|
48
|
+
tidegap clients revoke — remove a client; its token stops working on the next request
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Run `tidegap <command> --help` for flags.
|
|
52
|
+
|
|
53
|
+
`tidegap clients add` prints a `tgc_…` token once; store it then. The registry
|
|
54
|
+
`~/.tidegap/ui-clients.json` (mode 0600) keeps only the token's SHA-256.
|
|
55
|
+
A client token works only against `tidegap ui` on 127.0.0.1, survives restarts
|
|
56
|
+
and is never accepted on the client-management routes. The contract the
|
|
57
|
+
extension and the Mac app code against is `docs/spec/ui-client-api.md`.
|
|
58
|
+
|
|
59
|
+
The write commands and `tidegap ui` change the ledger only; `tidegap tick` (or the
|
|
60
|
+
OpenClaw loop) runs the task, and each command prints when the last tick ran.
|
|
61
|
+
`--day` and a repeating task's next occurrence can lie beyond the 72-hour
|
|
62
|
+
forecast. Such a task waits at a fallback hour (its current time of day, in
|
|
63
|
+
the new day) until a tick re-plans it once the forecast covers the day. If no
|
|
64
|
+
tick runs in that time, it runs at the fallback hour without a carbon choice.
|
|
65
|
+
|
|
66
|
+
## Quickstart — keep tasks alive across laptop sleep
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
tidegap install --laptop
|
|
70
|
+
# follow the printed launchctl load / systemctl commands
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
`tidegap install` resolves the daemon's invocation at install time to the exact
|
|
74
|
+
node interpreter plus the real `tidegap` entry (`[process.execPath,
|
|
75
|
+
realpath(argv[1])]`), so the launchd job / systemd unit does not depend on a
|
|
76
|
+
bare `PATH` or a `#!/usr/bin/env node` shebang. Set `TIDEGAP_BINARY` to override
|
|
77
|
+
with a single wrapper executable.
|
|
78
|
+
|
|
79
|
+
## Secrets
|
|
80
|
+
|
|
81
|
+
> **Scope:** the environment variables below configure **this CLI** (and the
|
|
82
|
+
> `@tidegap/mcp` server, which reads the same set). The CLI reads them at its own
|
|
83
|
+
> entry point and injects them into `@tidegap/core`, which is environment-pure.
|
|
84
|
+
> The `@vitalini/tidegap` **OpenClaw plugin reads no environment variables at all** —
|
|
85
|
+
> configure it under `plugins.entries.tidegap.config` in your gateway config
|
|
86
|
+
> (`anthropicApiKey`, `openaiApiKey`, `geminiApiKey`/`googleApiKey`,
|
|
87
|
+
> `ollamaHost`, `ollamaModels`, `eiaApiKey`, `electricityMapsApiKey`,
|
|
88
|
+
> `entsoeSecurityToken`, `wattTimeUsername`/`wattTimePassword`, `carbonBudgetG`,
|
|
89
|
+
> `carbonBudgetWindow`). OpenClaw resolves the `"${ENV_VAR}"` shorthand in those
|
|
90
|
+
> fields, so you can keep exporting the same variables and let the gateway read
|
|
91
|
+
> them on the plugin's behalf.
|
|
92
|
+
|
|
93
|
+
Provider (and grid-feed) API keys live in `~/.config/tidegap/env` — `KEY=VALUE`
|
|
94
|
+
lines, created `0600` with a commented template on first `tidegap install`. Both
|
|
95
|
+
`tidegap tick` (loads it at startup) and the systemd unit (`EnvironmentFile=`)
|
|
96
|
+
read it, so launchd, systemd, and manual cron all pick up keys the same way:
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
ANTHROPIC_API_KEY=sk-...
|
|
100
|
+
OPENAI_API_KEY=sk-...
|
|
101
|
+
GEMINI_API_KEY=... # or GOOGLE_API_KEY — Gemini (generativelanguage.googleapis.com)
|
|
102
|
+
OLLAMA_HOST=http://localhost:11434 # local Ollama; presence opts the ollama provider in
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Providers: `anthropic` and `openai` are batch-capable (their tasks can
|
|
106
|
+
auto-route through a 50%-cheaper Batch API — projected, provider list
|
|
107
|
+
price); `gemini` and `ollama` are
|
|
108
|
+
sync-only. Gemini reads `GEMINI_API_KEY`, falling back to `GOOGLE_API_KEY`.
|
|
109
|
+
Ollama is local and keyless — set `OLLAMA_HOST` (default `http://localhost:11434`)
|
|
110
|
+
to enable it; optionally list local model ids in `OLLAMA_MODELS` (comma-separated)
|
|
111
|
+
so `schedule_task` can infer the `ollama` provider from a bare model name.
|
|
112
|
+
|
|
113
|
+
`tidegap tick` prints a loud warning when pending tasks need a provider key that
|
|
114
|
+
is not set. (Ollama is keyless, so a pending Ollama task is never flagged.)
|
|
115
|
+
|
|
116
|
+
## Platform support
|
|
117
|
+
|
|
118
|
+
| Platform | Daemon install | Wake-from-sleep |
|
|
119
|
+
| --- | --- | --- |
|
|
120
|
+
| macOS | launchd plist (`tidegap install`) | `pmset schedule wake` via `tidegap register-wake` / the `--laptop` helper |
|
|
121
|
+
| Linux | systemd user `.service` + `.timer` (`tidegap install`) | `rtcwake` via `tidegap register-wake` / the `--laptop` helper |
|
|
122
|
+
| Windows | not auto-installed — `tidegap install` prints a ready-to-paste `schtasks` command; run `tidegap tick` under Task Scheduler or nssm yourself | not supported (use Task Scheduler's "wake the computer" option) |
|
|
123
|
+
|
|
124
|
+
Wake events (`pmset` / `rtcwake`) need root. When not running as root,
|
|
125
|
+
`tidegap register-wake` prints the exact `sudoers` line to pre-authorize the
|
|
126
|
+
command without a password prompt.
|
|
127
|
+
|
|
128
|
+
## Develop
|
|
129
|
+
|
|
130
|
+
From the root of a clone of https://github.com/tidegap/tidegap:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
pnpm install
|
|
134
|
+
pnpm --filter @tidegap/core build
|
|
135
|
+
pnpm --filter @tidegap/cli build
|
|
136
|
+
node packages/cli/dist/index.js --help
|
|
137
|
+
```
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `tidegap clients add | list | revoke` — manage the long-lived tokens that
|
|
3
|
+
* let the browser extension and the Mac app call `tidegap ui` (KTD2). The
|
|
4
|
+
* token is printed once by `add`; the registry keeps only its SHA-256.
|
|
5
|
+
*/
|
|
6
|
+
export interface ClientsOptions {
|
|
7
|
+
/** Directory of `ui-clients.json`; default: the Tidegap home. */
|
|
8
|
+
stateDir?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function runClientsAdd(input: {
|
|
11
|
+
name: string;
|
|
12
|
+
kind: string;
|
|
13
|
+
json?: boolean;
|
|
14
|
+
}, opts?: ClientsOptions): string;
|
|
15
|
+
export declare function runClientsList(input?: {
|
|
16
|
+
json?: boolean;
|
|
17
|
+
}, opts?: ClientsOptions): string;
|
|
18
|
+
/** Throws when no client has that id. */
|
|
19
|
+
export declare function runClientsRevoke(id: string, opts?: ClientsOptions): string;
|
|
20
|
+
//# sourceMappingURL=clients.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clients.d.ts","sourceRoot":"","sources":["../../src/commands/clients.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,WAAW,cAAc;IAC7B,iEAAiE;IACjE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAMD,wBAAgB,aAAa,CAC3B,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,EACrD,IAAI,GAAE,cAAmB,GACxB,MAAM,CAQR;AAUD,wBAAgB,cAAc,CAAC,KAAK,GAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAO,EAAE,IAAI,GAAE,cAAmB,GAAG,MAAM,CAGhG;AAED,yCAAyC;AACzC,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,GAAE,cAAmB,GAAG,MAAM,CAG9E"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `tidegap clients add | list | revoke` — manage the long-lived tokens that
|
|
3
|
+
* let the browser extension and the Mac app call `tidegap ui` (KTD2). The
|
|
4
|
+
* token is printed once by `add`; the registry keeps only its SHA-256.
|
|
5
|
+
*/
|
|
6
|
+
import { ClientRegistry } from "../ui/clients.js";
|
|
7
|
+
function registry(opts) {
|
|
8
|
+
return new ClientRegistry(opts.stateDir);
|
|
9
|
+
}
|
|
10
|
+
export function runClientsAdd(input, opts = {}) {
|
|
11
|
+
const { client, token } = registry(opts).add({ name: input.name, kind: input.kind });
|
|
12
|
+
if (input.json)
|
|
13
|
+
return JSON.stringify({ client_id: client.id, token });
|
|
14
|
+
return (`Added client ${client.id} (${client.kind}, "${client.name}").\n` +
|
|
15
|
+
`Token: ${token}\n` +
|
|
16
|
+
`Store it now: it is shown only once. Revoke it with \`tidegap clients revoke ${client.id}\`.`);
|
|
17
|
+
}
|
|
18
|
+
function renderClients(clients) {
|
|
19
|
+
if (clients.length === 0)
|
|
20
|
+
return "No clients. Add one with `tidegap clients add --name <name> --kind extension|macos`.";
|
|
21
|
+
const rows = clients.map((c) => [c.id, c.kind, c.created_at, c.name]);
|
|
22
|
+
const header = ["ID", "KIND", "CREATED", "NAME"];
|
|
23
|
+
const widths = header.map((h, i) => Math.max(h.length, ...rows.map((r) => r[i].length)));
|
|
24
|
+
return [header, ...rows].map((r) => r.map((cell, i) => (i < 3 ? cell.padEnd(widths[i]) : cell)).join(" ")).join("\n");
|
|
25
|
+
}
|
|
26
|
+
export function runClientsList(input = {}, opts = {}) {
|
|
27
|
+
const clients = registry(opts).list();
|
|
28
|
+
return input.json ? JSON.stringify({ clients }) : renderClients(clients);
|
|
29
|
+
}
|
|
30
|
+
/** Throws when no client has that id. */
|
|
31
|
+
export function runClientsRevoke(id, opts = {}) {
|
|
32
|
+
if (!registry(opts).revoke(id))
|
|
33
|
+
throw new Error(`no client with id ${id}`);
|
|
34
|
+
return `Revoked client ${id}. Its token stops working on the next request.`;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=clients.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clients.js","sourceRoot":"","sources":["../../src/commands/clients.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAmB,MAAM,kBAAkB,CAAC;AAOnE,SAAS,QAAQ,CAAC,IAAoB;IACpC,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,KAAqD,EACrD,OAAuB,EAAE;IAEzB,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;IACrF,IAAI,KAAK,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACvE,OAAO,CACL,gBAAgB,MAAM,CAAC,EAAE,KAAK,MAAM,CAAC,IAAI,MAAM,MAAM,CAAC,IAAI,OAAO;QACjE,UAAU,KAAK,IAAI;QACnB,gFAAgF,MAAM,CAAC,EAAE,KAAK,CAC/F,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,OAAqB;IAC1C,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,sFAAsF,CAAC;IACxH,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACtE,MAAM,MAAM,GAAG,CAAC,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AC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared secrets file: `~/.config/tidegap/env`.
|
|
3
|
+
*
|
|
4
|
+
* 0.17 kept it at `~/.config/ebb/env`. 0.18 still read that file; 0.19 does
|
|
5
|
+
* not. While the old file holds keys the new one lacks (none of them, by
|
|
6
|
+
* name, `EBB_*` counted as `TIDEGAP_*`), loading prints one stderr line
|
|
7
|
+
* naming it, and `tidegap install` lists it under its warnings.
|
|
8
|
+
*
|
|
9
|
+
* A single standardized location for provider API keys that works
|
|
10
|
+
* uniformly across launchd, systemd, and manual cron:
|
|
11
|
+
*
|
|
12
|
+
* - `tidegap install` creates it (0600) with a commented template if it
|
|
13
|
+
* does not already exist, so the user has one obvious place to drop
|
|
14
|
+
* `ANTHROPIC_API_KEY=…`.
|
|
15
|
+
* - `tidegap tick` loads it at startup into `process.env` for any key not
|
|
16
|
+
* already present — this covers launchd (which passes a bare
|
|
17
|
+
* environment) AND systemd (belt-and-braces with `EnvironmentFile=`)
|
|
18
|
+
* AND a hand-rolled crontab entry.
|
|
19
|
+
*
|
|
20
|
+
* The parser is intentionally tiny (no dotenv dependency): `KEY=VALUE`
|
|
21
|
+
* lines, `#` comments, blank lines, optional surrounding quotes.
|
|
22
|
+
*/
|
|
23
|
+
/** Absolute path to the standardized secrets file. */
|
|
24
|
+
export declare function envFilePath(home?: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* The notice for a 0.17 secrets file that holds keys while the new file has
|
|
27
|
+
* none of them, else `undefined`. The template `tidegap install` writes has
|
|
28
|
+
* no keys, so it does not hide the notice.
|
|
29
|
+
*/
|
|
30
|
+
export declare function oldEnvFileNotice(home?: string): string | undefined;
|
|
31
|
+
/** The commented template written when the file is first created. */
|
|
32
|
+
export declare function envFileTemplate(): string;
|
|
33
|
+
/**
|
|
34
|
+
* Parse `KEY=VALUE` lines. Ignores blank lines and `#` comments.
|
|
35
|
+
* Strips one layer of surrounding single/double quotes from the value.
|
|
36
|
+
*/
|
|
37
|
+
export declare function parseEnvFile(contents: string): Record<string, string>;
|
|
38
|
+
/**
|
|
39
|
+
* Load the env file into `process.env` for any key not already set.
|
|
40
|
+
* Returns the keys that were applied. A missing file is a no-op. With the
|
|
41
|
+
* default path, a 0.17 secrets file whose keys the new file lacks gets one
|
|
42
|
+
* stderr line per process.
|
|
43
|
+
*/
|
|
44
|
+
export declare function loadEnvFileIntoProcess(path?: string): string[];
|
|
45
|
+
export interface EnsureEnvFileResult {
|
|
46
|
+
path: string;
|
|
47
|
+
created: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Create the secrets file (0600) with the commented template if it does not
|
|
51
|
+
* already exist. Idempotent: never overwrites an existing file.
|
|
52
|
+
*/
|
|
53
|
+
export declare function ensureEnvFile(path?: string): EnsureEnvFileResult;
|
|
54
|
+
//# sourceMappingURL=env-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env-file.d.ts","sourceRoot":"","sources":["../../src/commands/env-file.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAMH,sDAAsD;AACtD,wBAAgB,WAAW,CAAC,IAAI,GAAE,MAAkB,GAAG,MAAM,CAE5D;AAmBD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,GAAE,MAAkB,GAAG,MAAM,GAAG,SAAS,CAU7E;AAID,qEAAqE;AACrE,wBAAgB,eAAe,IAAI,MAAM,CAmBxC;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAoBrE;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAwB9D;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,GAAE,MAAsB,GAAG,mBAAmB,CAK/E"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared secrets file: `~/.config/tidegap/env`.
|
|
3
|
+
*
|
|
4
|
+
* 0.17 kept it at `~/.config/ebb/env`. 0.18 still read that file; 0.19 does
|
|
5
|
+
* not. While the old file holds keys the new one lacks (none of them, by
|
|
6
|
+
* name, `EBB_*` counted as `TIDEGAP_*`), loading prints one stderr line
|
|
7
|
+
* naming it, and `tidegap install` lists it under its warnings.
|
|
8
|
+
*
|
|
9
|
+
* A single standardized location for provider API keys that works
|
|
10
|
+
* uniformly across launchd, systemd, and manual cron:
|
|
11
|
+
*
|
|
12
|
+
* - `tidegap install` creates it (0600) with a commented template if it
|
|
13
|
+
* does not already exist, so the user has one obvious place to drop
|
|
14
|
+
* `ANTHROPIC_API_KEY=…`.
|
|
15
|
+
* - `tidegap tick` loads it at startup into `process.env` for any key not
|
|
16
|
+
* already present — this covers launchd (which passes a bare
|
|
17
|
+
* environment) AND systemd (belt-and-braces with `EnvironmentFile=`)
|
|
18
|
+
* AND a hand-rolled crontab entry.
|
|
19
|
+
*
|
|
20
|
+
* The parser is intentionally tiny (no dotenv dependency): `KEY=VALUE`
|
|
21
|
+
* lines, `#` comments, blank lines, optional surrounding quotes.
|
|
22
|
+
*/
|
|
23
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
24
|
+
import { homedir } from "node:os";
|
|
25
|
+
import { dirname, join } from "node:path";
|
|
26
|
+
/** Absolute path to the standardized secrets file. */
|
|
27
|
+
export function envFilePath(home = homedir()) {
|
|
28
|
+
return join(home, ".config", "tidegap", "env");
|
|
29
|
+
}
|
|
30
|
+
/** The 0.17 secrets file, never read since 0.19; only checked for the notice. */
|
|
31
|
+
function oldEnvFilePath(home) {
|
|
32
|
+
return join(home, ".config", "ebb", "env");
|
|
33
|
+
}
|
|
34
|
+
/** The keys of a secrets file, `EBB_*` named as `TIDEGAP_*`; none when missing or unreadable. */
|
|
35
|
+
function envFileKeys(path) {
|
|
36
|
+
try {
|
|
37
|
+
if (!existsSync(path))
|
|
38
|
+
return [];
|
|
39
|
+
return Object.keys(parseEnvFile(readFileSync(path, "utf8"))).map((k) => k.startsWith("EBB_") ? `TIDEGAP_${k.slice(4)}` : k);
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The notice for a 0.17 secrets file that holds keys while the new file has
|
|
47
|
+
* none of them, else `undefined`. The template `tidegap install` writes has
|
|
48
|
+
* no keys, so it does not hide the notice.
|
|
49
|
+
*/
|
|
50
|
+
export function oldEnvFileNotice(home = homedir()) {
|
|
51
|
+
const old = oldEnvFilePath(home);
|
|
52
|
+
const oldKeys = envFileKeys(old);
|
|
53
|
+
if (oldKeys.length === 0)
|
|
54
|
+
return undefined;
|
|
55
|
+
const current = new Set(envFileKeys(envFilePath(home)));
|
|
56
|
+
if (oldKeys.some((k) => current.has(k)))
|
|
57
|
+
return undefined;
|
|
58
|
+
return (`tidegap: ${old} is no longer read (removed in 0.19); move its keys to ${envFilePath(home)} ` +
|
|
59
|
+
"and rename its EBB_* keys to TIDEGAP_*.");
|
|
60
|
+
}
|
|
61
|
+
let oldEnvFileReported = false;
|
|
62
|
+
/** The commented template written when the file is first created. */
|
|
63
|
+
export function envFileTemplate() {
|
|
64
|
+
return `# Tidegap secrets — KEY=VALUE per line. Loaded by \`tidegap tick\` at startup
|
|
65
|
+
# (and referenced by the systemd unit's EnvironmentFile=). This file is
|
|
66
|
+
# created 0600; keep it that way. Uncomment and fill the keys you use.
|
|
67
|
+
#
|
|
68
|
+
# Direct provider keys:
|
|
69
|
+
#ANTHROPIC_API_KEY=
|
|
70
|
+
#OPENAI_API_KEY=
|
|
71
|
+
#
|
|
72
|
+
# Per-region grid-data feed keys (only for the regions you schedule into):
|
|
73
|
+
#TIDEGAP_ELECTRICITY_MAPS_API_KEY=
|
|
74
|
+
#TIDEGAP_EIA_API_KEY=
|
|
75
|
+
#TIDEGAP_ENTSOE_SECURITY_TOKEN=
|
|
76
|
+
# WattTime marginal-emissions (US ISOs) — HTTP Basic login, takes
|
|
77
|
+
# precedence over EIA for the zones it covers. Username + password, not
|
|
78
|
+
# a single key:
|
|
79
|
+
#WATTTIME_USERNAME=
|
|
80
|
+
#WATTTIME_PASSWORD=
|
|
81
|
+
`;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Parse `KEY=VALUE` lines. Ignores blank lines and `#` comments.
|
|
85
|
+
* Strips one layer of surrounding single/double quotes from the value.
|
|
86
|
+
*/
|
|
87
|
+
export function parseEnvFile(contents) {
|
|
88
|
+
const out = {};
|
|
89
|
+
for (const rawLine of contents.split(/\r?\n/)) {
|
|
90
|
+
const line = rawLine.trim();
|
|
91
|
+
if (!line || line.startsWith("#"))
|
|
92
|
+
continue;
|
|
93
|
+
const eq = line.indexOf("=");
|
|
94
|
+
if (eq <= 0)
|
|
95
|
+
continue;
|
|
96
|
+
const key = line.slice(0, eq).trim();
|
|
97
|
+
if (!key)
|
|
98
|
+
continue;
|
|
99
|
+
let value = line.slice(eq + 1).trim();
|
|
100
|
+
if (value.length >= 2 &&
|
|
101
|
+
((value.startsWith('"') && value.endsWith('"')) ||
|
|
102
|
+
(value.startsWith("'") && value.endsWith("'")))) {
|
|
103
|
+
value = value.slice(1, -1);
|
|
104
|
+
}
|
|
105
|
+
out[key] = value;
|
|
106
|
+
}
|
|
107
|
+
return out;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Load the env file into `process.env` for any key not already set.
|
|
111
|
+
* Returns the keys that were applied. A missing file is a no-op. With the
|
|
112
|
+
* default path, a 0.17 secrets file whose keys the new file lacks gets one
|
|
113
|
+
* stderr line per process.
|
|
114
|
+
*/
|
|
115
|
+
export function loadEnvFileIntoProcess(path) {
|
|
116
|
+
if (path === undefined) {
|
|
117
|
+
path = envFilePath();
|
|
118
|
+
const notice = oldEnvFileReported ? undefined : oldEnvFileNotice();
|
|
119
|
+
if (notice) {
|
|
120
|
+
oldEnvFileReported = true;
|
|
121
|
+
process.stderr.write(`${notice}\n`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (!existsSync(path))
|
|
125
|
+
return [];
|
|
126
|
+
let parsed;
|
|
127
|
+
try {
|
|
128
|
+
parsed = parseEnvFile(readFileSync(path, "utf8"));
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
return [];
|
|
132
|
+
}
|
|
133
|
+
const applied = [];
|
|
134
|
+
for (const [k, v] of Object.entries(parsed)) {
|
|
135
|
+
if (process.env[k] === undefined) {
|
|
136
|
+
process.env[k] = v;
|
|
137
|
+
applied.push(k);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return applied;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Create the secrets file (0600) with the commented template if it does not
|
|
144
|
+
* already exist. Idempotent: never overwrites an existing file.
|
|
145
|
+
*/
|
|
146
|
+
export function ensureEnvFile(path = envFilePath()) {
|
|
147
|
+
if (existsSync(path))
|
|
148
|
+
return { path, created: false };
|
|
149
|
+
mkdirSync(dirname(path), { recursive: true, mode: 0o700 });
|
|
150
|
+
writeFileSync(path, envFileTemplate(), { encoding: "utf8", mode: 0o600 });
|
|
151
|
+
return { path, created: true };
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=env-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env-file.js","sourceRoot":"","sources":["../../src/commands/env-file.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;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