@oked/sdk 0.6.13 → 0.6.15
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 -21
- package/README.md +2 -2
- package/dist/classify.js +97 -25
- package/package.json +3 -3
package/LICENSE
CHANGED
|
@@ -1,21 +1,201 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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 the 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 the 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 any 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 reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and 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 Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
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 [yyyy] [name of copyright owner]
|
|
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 implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @oked/sdk
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@oked/sdk)
|
|
4
|
-
[](./LICENSE)
|
|
5
5
|
[](./dist/index.d.ts)
|
|
6
6
|
|
|
7
7
|
Core library - programmatic approval API for AI agents. Sends sensitive actions to the OKed backend, waits for a human decision, and resolves only when the user approves or denies.
|
|
@@ -112,4 +112,4 @@ npm run build
|
|
|
112
112
|
|
|
113
113
|
## License
|
|
114
114
|
|
|
115
|
-
[
|
|
115
|
+
[Apache-2.0](./LICENSE)
|
package/dist/classify.js
CHANGED
|
@@ -16,11 +16,13 @@ import { TIER_ORDER } from "./degraded.js";
|
|
|
16
16
|
// code-exec, SQL INSERT/CREATE).
|
|
17
17
|
// Tier 3 - review: push notification, tap to approve. Prompt-worthy but not
|
|
18
18
|
// catastrophic: sensitive-path writes (~/.ssh, shell rc, system
|
|
19
|
-
// dirs, OKed's own config), sudo, outward message/email sends
|
|
19
|
+
// dirs, OKed's own config), sudo, outward message/email sends,
|
|
20
|
+
// curl POST/PUT/PATCH with an inline body.
|
|
20
21
|
// Tier 4 - high_stakes: push + number matching. Destructive / irreversible /
|
|
21
22
|
// external: rm of non-temp data, DROP/TRUNCATE/DELETE FROM,
|
|
22
23
|
// git push --force / reset --hard / branch -D, mkfs / dd-to-device /
|
|
23
|
-
// shutdown, curl
|
|
24
|
+
// shutdown, curl DELETE / file upload / pay-or-send API, ssh/scp,
|
|
25
|
+
// npm publish, kill.
|
|
24
26
|
// Tools that are always safe (read-only, no side effects)
|
|
25
27
|
const SAFE_TOOLS = new Set([
|
|
26
28
|
"Read",
|
|
@@ -189,7 +191,7 @@ const HIGH_STAKES_COMMANDS = [
|
|
|
189
191
|
// grab a flag belonging to a LATER command (e.g. `curl -o … && unzip … -d dir`
|
|
190
192
|
// false-matched the curl `-d` POST-body pattern on unzip's destination flag).
|
|
191
193
|
// They belong to a single curl invocation, so they're scanned PER-STAGE in
|
|
192
|
-
//
|
|
194
|
+
// OUTWARD_CURL_STAGE below. Only the download-and-execute patterns
|
|
193
195
|
// (`curl|wget … | sh`) genuinely span a pipe and stay in this full scan.
|
|
194
196
|
/\bwget\s+.*\|\s*(bash|sh|zsh)\b/,
|
|
195
197
|
/\bcurl\s+.*\|\s*(bash|sh|zsh)\b/,
|
|
@@ -256,11 +258,12 @@ const HIGH_STAKES_STAGE = [
|
|
|
256
258
|
// curl request-method / request-body flags, scanned PER-STAGE (a single stage
|
|
257
259
|
// has no top-level pipe, so `\bcurl\b.*` can't cross into another command — the
|
|
258
260
|
// `-d`/`-T`/etc. it finds belongs to THIS curl). A curl that sends a body or a
|
|
259
|
-
// mutating method (POST/PUT/PATCH/DELETE) is an outward write →
|
|
261
|
+
// mutating method (POST/PUT/PATCH/DELETE) is an outward write → at least review
|
|
262
|
+
// (see CURL_HIGH_STAKES_STAGE for the ones that stay high_stakes).
|
|
260
263
|
// A plain `curl -o file URL` download has none of these and stays safe.
|
|
261
|
-
const
|
|
264
|
+
const OUTWARD_CURL_STAGE = [
|
|
262
265
|
/\bcurl\s+.*-X\s*(DELETE|PUT|POST|PATCH)\b/i,
|
|
263
|
-
/\bcurl\s+.*--request\s*(DELETE|PUT|POST|PATCH)\b/i,
|
|
266
|
+
/\bcurl\s+.*--request[\s=]*(DELETE|PUT|POST|PATCH)\b/i,
|
|
264
267
|
// curl flags that send a request body (POST/PUT/PATCH) without an explicit -X
|
|
265
268
|
/\bcurl\b.*\s-d[\s=]/,
|
|
266
269
|
/\bcurl\b.*\s--data(-raw|-binary|-urlencode|-ascii)?[\s=]/,
|
|
@@ -269,6 +272,36 @@ const HIGH_STAKES_CURL_STAGE = [
|
|
|
269
272
|
/\bcurl\b.*\s(-T|--upload-file)[\s=]/,
|
|
270
273
|
/\bcurl\b.*\s--json[\s=]/,
|
|
271
274
|
];
|
|
275
|
+
// An outward curl that is hard to undo, or that sends local files, stays
|
|
276
|
+
// high_stakes: a DELETE, a file upload (`-T f`, `-d @f`, `-F x=@f`) that can
|
|
277
|
+
// carry secrets off the machine, and a request to an API that pays or sends
|
|
278
|
+
// messages. Any other inline-body write (a waitlist signup, a webhook ping) is
|
|
279
|
+
// review: it asks, without Face ID.
|
|
280
|
+
const CURL_HIGH_STAKES_STAGE = [
|
|
281
|
+
/\bcurl\s+.*-X\s*DELETE\b/i,
|
|
282
|
+
/\bcurl\s+.*--request[\s=]*DELETE\b/i,
|
|
283
|
+
/\bcurl\b.*\s(-T|--upload-file)[\s=]/,
|
|
284
|
+
/\bcurl\b.*\s(?:-d|--data(?:-binary|-ascii|-raw)?|--json)(?:\s+|=)['"]?@/,
|
|
285
|
+
/\bcurl\b.*\s--data-urlencode(?:\s+|=)['"]?[^\s'"=]*@/,
|
|
286
|
+
/\bcurl\b.*\s(?:-F|--form)(?:\s+|=)['"]?[^\s'"]*=[@<]/,
|
|
287
|
+
// A body built by the shell (`-d "$(cat ~/.ssh/id_rsa)"`) can carry any
|
|
288
|
+
// local file, like `-d @file`.
|
|
289
|
+
/\bcurl\b.*\s(?:-d|--data(?:-[a-z]+)?|--json|-F|--form)(?:\s+|=)(?:"[^"]*|[^\s'"]*)(?:\$\(|`)/,
|
|
290
|
+
];
|
|
291
|
+
// Hosts whose write APIs pay, charge or send a message. Matched as the host or
|
|
292
|
+
// a parent domain of a curl URL.
|
|
293
|
+
const PAY_OR_SEND_HOSTS = [
|
|
294
|
+
"stripe.com", "paypal.com", "squareup.com", "braintreegateway.com",
|
|
295
|
+
"slack.com", "discord.com", "discordapp.com", "api.telegram.org",
|
|
296
|
+
"twilio.com", "sendgrid.com", "sendgrid.net", "mailgun.net", "postmarkapp.com",
|
|
297
|
+
"resend.com", "api.mailchimp.com", "api.github.com",
|
|
298
|
+
];
|
|
299
|
+
function isPayOrSendCurlStage(stage) {
|
|
300
|
+
return [...stage.matchAll(/\bhttps?:\/\/(?:[^@/\s'"]*@)?([^/:\s'"]+)/g)].some((m) => {
|
|
301
|
+
const host = m[1].toLowerCase();
|
|
302
|
+
return PAY_OR_SEND_HOSTS.some((h) => host === h || host.endsWith(`.${h}`));
|
|
303
|
+
});
|
|
304
|
+
}
|
|
272
305
|
// Outward-but-recoverable commands → review (prompt, simple approve). Sending
|
|
273
306
|
// mail/messages can't be unsent, but it isn't destructive to local state, so it
|
|
274
307
|
// sits below high_stakes. Matched per-stage. (Destructive himalaya verbs —
|
|
@@ -363,24 +396,32 @@ const MKTEMP_ASSIGN_RE = /^(?:export\s+|declare\s+|local\s+|readonly\s+)?(\w+)=[
|
|
|
363
396
|
// Process names and command lines of local dev servers and dev tooling: Node
|
|
364
397
|
// and Python app servers, bundlers, package-manager scripts, and Node scripts.
|
|
365
398
|
const DEV_PROCESS_RE = /\b(?:node|nodemon|tsx|ts-node|vite|next|nuxt|astro|remix|webpack(?:-dev-server)?|esbuild|parcel|turbo|npm|pnpm|yarn|bun|deno|wrangler|miniflare|uvicorn|gunicorn|flask|runserver|rails|puma|http\.server|http-server|live-server|serve|hugo|jekyll|storybook|expo|metro)\b|\.(?:[cm]?js|tsx?)\b/;
|
|
399
|
+
// Command lines of read-only watchers: a CI watcher (`gh pr checks 136 --watch`,
|
|
400
|
+
// `gh run watch`), a log tail, or a sleep. Stopping one loses nothing, and the
|
|
401
|
+
// agent can start it again.
|
|
402
|
+
const WATCHER_PROCESS_RE = /^(?:gh\s+(?:pr\s+checks|run\s+watch)\b|tail(?:\s+-\w*[fF]\b|$)|sleep\b|watch\b)/;
|
|
403
|
+
function isRestartableProcess(pattern) {
|
|
404
|
+
return DEV_PROCESS_RE.test(pattern) || WATCHER_PROCESS_RE.test(pattern);
|
|
405
|
+
}
|
|
366
406
|
/**
|
|
367
|
-
* A kill of a local dev server: `pkill -f "tsx src/main.ts"`,
|
|
368
|
-
* `kill $(pgrep -f vite)`, or a
|
|
369
|
-
* (`kill $(lsof -t -iTCP:3000 -sTCP:LISTEN)`).
|
|
370
|
-
* ID) for
|
|
371
|
-
*
|
|
407
|
+
* A kill of a local dev server or a read-only watcher: `pkill -f "tsx src/main.ts"`,
|
|
408
|
+
* `pkill -f "gh pr checks 136"`, `killall node`, `kill $(pgrep -f vite)`, or a
|
|
409
|
+
* kill of whatever listens on a port (`kill $(lsof -t -iTCP:3000 -sTCP:LISTEN)`).
|
|
410
|
+
* Oren chose `review` (no Face ID) for dev servers on 2026-10-18 and for
|
|
411
|
+
* watchers on 2026-10-21. A bare `kill <pid>` names no process, so it stays
|
|
412
|
+
* high stakes.
|
|
372
413
|
*/
|
|
373
|
-
function
|
|
414
|
+
function isRestartableKill(stage) {
|
|
374
415
|
const pkill = stage.match(/^pkill\s+(.+)$/);
|
|
375
416
|
if (pkill) {
|
|
376
417
|
const args = splitArgs(pkill[1]).filter((a) => !a.startsWith("-") || a === "-f");
|
|
377
418
|
const pattern = unquote(args[args.indexOf("-f") + 1] ?? args[args.length - 1] ?? "");
|
|
378
|
-
return
|
|
419
|
+
return isRestartableProcess(pattern);
|
|
379
420
|
}
|
|
380
421
|
const killall = stage.match(/^killall\s+(.+)$/);
|
|
381
422
|
if (killall) {
|
|
382
423
|
const names = splitArgs(killall[1]).filter((a) => !a.startsWith("-")).map(unquote);
|
|
383
|
-
return names.length > 0 && names.every((n) =>
|
|
424
|
+
return names.length > 0 && names.every((n) => isRestartableProcess(n));
|
|
384
425
|
}
|
|
385
426
|
const kill = stage.match(/^kill\s+(?:-\w+\s+)*\$\((.+)\)\s*(?:2>\/dev\/null)?$/);
|
|
386
427
|
if (kill) {
|
|
@@ -389,7 +430,7 @@ function isDevServerKill(stage) {
|
|
|
389
430
|
return true;
|
|
390
431
|
const pg = inner.match(/^pgrep\s+(?:-\w+\s+)*(?:-f\s+)?(.+)$/);
|
|
391
432
|
if (pg)
|
|
392
|
-
return
|
|
433
|
+
return isRestartableProcess(unquote(pg[1].trim()));
|
|
393
434
|
}
|
|
394
435
|
return false;
|
|
395
436
|
}
|
|
@@ -576,6 +617,14 @@ export function splitTopLevel(cmd, opts = {}) {
|
|
|
576
617
|
let i = 0;
|
|
577
618
|
while (i < cmd.length) {
|
|
578
619
|
const ch = cmd[i];
|
|
620
|
+
// A backslash escapes the next character outside quotes and inside double
|
|
621
|
+
// quotes (`grep "a\|b(\"\|c"`), so `\"` does not end the string and `\|` or
|
|
622
|
+
// `\;` is not an operator. Inside single quotes it is a plain character.
|
|
623
|
+
if (ch === "\\" && quote !== "'" && i + 1 < cmd.length) {
|
|
624
|
+
cur += ch + cmd[i + 1];
|
|
625
|
+
i += 2;
|
|
626
|
+
continue;
|
|
627
|
+
}
|
|
579
628
|
if (quote) {
|
|
580
629
|
cur += ch;
|
|
581
630
|
if (ch === quote)
|
|
@@ -1041,22 +1090,27 @@ function classifyStageShellEffects(stage, ephemeralVars = new Set()) {
|
|
|
1041
1090
|
if (/(?:^|\/)scratchpad\//.test(pattern) || EPHEMERAL_PATH_RE.test(pattern))
|
|
1042
1091
|
return "warning";
|
|
1043
1092
|
}
|
|
1044
|
-
// Stopping a local dev server is review: it asks,
|
|
1045
|
-
|
|
1093
|
+
// Stopping a local dev server or a read-only watcher is review: it asks,
|
|
1094
|
+
// without Face ID.
|
|
1095
|
+
if (isRestartableKill(bareStage))
|
|
1046
1096
|
return "review";
|
|
1047
1097
|
for (const pattern of HIGH_STAKES_STAGE) {
|
|
1048
1098
|
if (pattern.test(bareStage))
|
|
1049
1099
|
return "high_stakes";
|
|
1050
1100
|
}
|
|
1051
|
-
// curl with a mutating method or request body → high_stakes
|
|
1052
|
-
//
|
|
1053
|
-
//
|
|
1101
|
+
// curl with a mutating method or request body → review, or high_stakes for a
|
|
1102
|
+
// DELETE, a file upload or a pay/send API. Scanned per-stage (not on the full
|
|
1103
|
+
// compound command) so the greedy `.*` can't reach across a `&&`/`|` and match
|
|
1104
|
+
// a `-d`/`-T`/etc. flag belonging to a different command.
|
|
1054
1105
|
// A request to a LOOPBACK host (localhost/127.x/::1) is a local action, not an
|
|
1055
1106
|
// outward one, so it downgrades to `warning` (logged, no prompt).
|
|
1056
|
-
|
|
1057
|
-
if (
|
|
1058
|
-
return
|
|
1107
|
+
if (OUTWARD_CURL_STAGE.some((pattern) => pattern.test(stage))) {
|
|
1108
|
+
if (isLoopbackHttpStage(stage))
|
|
1109
|
+
return "warning";
|
|
1110
|
+
if (CURL_HIGH_STAKES_STAGE.some((pattern) => pattern.test(stage)) || isPayOrSendCurlStage(stage)) {
|
|
1111
|
+
return "high_stakes";
|
|
1059
1112
|
}
|
|
1113
|
+
return "review";
|
|
1060
1114
|
}
|
|
1061
1115
|
// `DATABASE_URL=<local> npx prisma migrate deploy`: the assignment prefix
|
|
1062
1116
|
// below would classify the bare `npx … deploy` without its local URL.
|
|
@@ -1324,6 +1378,13 @@ export function stripInlineScriptBodies(command) {
|
|
|
1324
1378
|
// curl request-body flags whose quoted value is payload sent to a server,
|
|
1325
1379
|
// never run locally.
|
|
1326
1380
|
const CURL_DATA_FLAG_RE = /^(?:-d|--data(?:-raw|-binary|-urlencode|-ascii)?|--json|-F|--form)(?:\s+|=)(['"])/;
|
|
1381
|
+
function isCurlFileBody(flag, body) {
|
|
1382
|
+
if (/^(?:-F|--form)\b/.test(flag))
|
|
1383
|
+
return /=[@<]/.test(body);
|
|
1384
|
+
if (/^--data-urlencode\b/.test(flag))
|
|
1385
|
+
return /^[^\s=]*@/.test(body);
|
|
1386
|
+
return body.startsWith("@");
|
|
1387
|
+
}
|
|
1327
1388
|
/**
|
|
1328
1389
|
* Blank the interior of quoted curl request bodies, keeping the quotes and the
|
|
1329
1390
|
* flag so the per-stage curl rules still see a POST. A JSON payload that
|
|
@@ -1365,7 +1426,16 @@ export function stripCurlDataBodies(command) {
|
|
|
1365
1426
|
j++;
|
|
1366
1427
|
j++;
|
|
1367
1428
|
}
|
|
1368
|
-
|
|
1429
|
+
// A file reference (`'@secrets.json'`, `'file=@x'`) or a double-quoted
|
|
1430
|
+
// command substitution is an upload, not payload text: keep it so the
|
|
1431
|
+
// curl upload rules still see it.
|
|
1432
|
+
const body = command.slice(bodyStart, j);
|
|
1433
|
+
if (isCurlFileBody(m[0], body) || (quote === '"' && /\$\(|`/.test(body))) {
|
|
1434
|
+
out += command.slice(i, j + 1);
|
|
1435
|
+
}
|
|
1436
|
+
else {
|
|
1437
|
+
out += command.slice(i, bodyStart) + quote;
|
|
1438
|
+
}
|
|
1369
1439
|
i = j + 1;
|
|
1370
1440
|
continue;
|
|
1371
1441
|
}
|
|
@@ -1410,7 +1480,9 @@ function findRedirects(cmd) {
|
|
|
1410
1480
|
j++; // closing quote
|
|
1411
1481
|
}
|
|
1412
1482
|
else {
|
|
1413
|
-
|
|
1483
|
+
// A `)` ends the target too: `$(npm view x 2>/dev/null)` redirects to
|
|
1484
|
+
// /dev/null, not to a file named `/dev/null)`.
|
|
1485
|
+
while (j < cmd.length && !/[\s>|&;)]/.test(cmd[j]))
|
|
1414
1486
|
target += cmd[j++];
|
|
1415
1487
|
}
|
|
1416
1488
|
if (target && !/^\d+$/.test(target) && !isDevNullish(target)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oked/sdk",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.15",
|
|
4
4
|
"description": "OKed SDK - human approval layer for AI agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"url": "https://github.com/oked-ai/oked-sdk/issues"
|
|
38
38
|
},
|
|
39
39
|
"homepage": "https://github.com/oked-ai/oked-sdk#readme",
|
|
40
|
-
"license": "
|
|
40
|
+
"license": "Apache-2.0",
|
|
41
41
|
"engines": {
|
|
42
42
|
"node": ">=18"
|
|
43
43
|
},
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@oked/receipt-core": "0.6.
|
|
48
|
+
"@oked/receipt-core": "0.6.15"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/node": "^22.13.10",
|