@namzu/sdk 44.2.0 → 45.0.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/CHANGELOG.md +49 -0
- package/dist/authorization/command-line.d.ts +66 -19
- package/dist/authorization/command-line.d.ts.map +1 -1
- package/dist/authorization/command-line.js +130 -270
- package/dist/authorization/command-line.js.map +1 -1
- package/dist/authorization/gate.d.ts +7 -0
- package/dist/authorization/gate.d.ts.map +1 -1
- package/dist/authorization/gate.js +1 -1
- package/dist/authorization/gate.js.map +1 -1
- package/dist/authorization/rules.d.ts +10 -1
- package/dist/authorization/rules.d.ts.map +1 -1
- package/dist/authorization/rules.js +21 -5
- package/dist/authorization/rules.js.map +1 -1
- package/dist/authorization/shell-lexer.d.ts +138 -0
- package/dist/authorization/shell-lexer.d.ts.map +1 -0
- package/dist/authorization/shell-lexer.js +2143 -0
- package/dist/authorization/shell-lexer.js.map +1 -0
- package/dist/authorization/skill-grant.d.ts +182 -0
- package/dist/authorization/skill-grant.d.ts.map +1 -0
- package/dist/authorization/skill-grant.js +314 -0
- package/dist/authorization/skill-grant.js.map +1 -0
- package/dist/persona/assembler.d.ts.map +1 -1
- package/dist/persona/assembler.js +5 -2
- package/dist/persona/assembler.js.map +1 -1
- package/dist/prompt/coding-agent-doctrine.d.ts +1 -1
- package/dist/prompt/coding-agent-doctrine.d.ts.map +1 -1
- package/dist/prompt/coding-agent-doctrine.js +1 -1
- package/dist/prompt/coding-agent-doctrine.js.map +1 -1
- package/dist/public-runtime.d.ts +1 -0
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +4 -0
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-tools.d.ts.map +1 -1
- package/dist/public-tools.js +2 -1
- package/dist/public-tools.js.map +1 -1
- package/dist/public-types.d.ts +3 -1
- package/dist/public-types.d.ts.map +1 -1
- package/dist/runtime/jobs/registry.d.ts +2 -2
- package/dist/runtime/jobs/registry.d.ts.map +1 -1
- package/dist/runtime/jobs/registry.js +6 -2
- package/dist/runtime/jobs/registry.js.map +1 -1
- package/dist/runtime/query/executor.d.ts +34 -40
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +81 -51
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +7 -0
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +6 -0
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context.d.ts +7 -0
- package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/context.js.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.js +48 -0
- package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
- package/dist/runtime/query/review-policy.d.ts +11 -0
- package/dist/runtime/query/review-policy.d.ts.map +1 -1
- package/dist/runtime/query/review-policy.js +32 -0
- package/dist/runtime/query/review-policy.js.map +1 -1
- package/dist/runtime/query/tooling.d.ts +3 -0
- package/dist/runtime/query/tooling.d.ts.map +1 -1
- package/dist/runtime/query/tooling.js +1 -0
- package/dist/runtime/query/tooling.js.map +1 -1
- package/dist/skills/loader.d.ts +8 -0
- package/dist/skills/loader.d.ts.map +1 -1
- package/dist/skills/loader.js +7 -1
- package/dist/skills/loader.js.map +1 -1
- package/dist/tools/builtins/bash.d.ts.map +1 -1
- package/dist/tools/builtins/bash.js +18 -6
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/skill.d.ts +2 -9
- package/dist/tools/builtins/skill.d.ts.map +1 -1
- package/dist/tools/builtins/skill.js +59 -51
- package/dist/tools/builtins/skill.js.map +1 -1
- package/dist/tools/command-shell.d.ts +90 -0
- package/dist/tools/command-shell.d.ts.map +1 -0
- package/dist/tools/command-shell.js +129 -0
- package/dist/tools/command-shell.js.map +1 -0
- package/dist/tools/defineTool.d.ts +11 -0
- package/dist/tools/defineTool.d.ts.map +1 -1
- package/dist/tools/defineTool.js +29 -1
- package/dist/tools/defineTool.js.map +1 -1
- package/dist/types/hitl/index.d.ts +23 -0
- package/dist/types/hitl/index.d.ts.map +1 -1
- package/dist/types/hitl/index.js.map +1 -1
- package/dist/types/provider/stream.d.ts +10 -0
- package/dist/types/provider/stream.d.ts.map +1 -1
- package/dist/types/tool/index.d.ts +67 -5
- package/dist/types/tool/index.d.ts.map +1 -1
- package/dist/types/tool/index.js.map +1 -1
- package/dist/utils/frontmatter.d.ts +17 -1
- package/dist/utils/frontmatter.d.ts.map +1 -1
- package/dist/utils/frontmatter.js +32 -2
- package/dist/utils/frontmatter.js.map +1 -1
- package/package.json +1 -1
- package/src/authorization/command-line.ts +148 -293
- package/src/authorization/gate.ts +8 -0
- package/src/authorization/rules.ts +33 -4
- package/src/authorization/shell-lexer.ts +2319 -0
- package/src/authorization/skill-grant.ts +400 -0
- package/src/persona/assembler.ts +5 -2
- package/src/prompt/coding-agent-doctrine.ts +1 -1
- package/src/public-runtime.ts +9 -0
- package/src/public-tools.ts +2 -1
- package/src/public-types.ts +7 -0
- package/src/runtime/jobs/registry.ts +19 -11
- package/src/runtime/query/executor.ts +99 -55
- package/src/runtime/query/index.ts +7 -0
- package/src/runtime/query/iteration/index.ts +5 -0
- package/src/runtime/query/iteration/phases/context.ts +7 -0
- package/src/runtime/query/iteration/phases/tool-review.ts +45 -0
- package/src/runtime/query/review-policy.ts +53 -0
- package/src/runtime/query/tooling.ts +4 -0
- package/src/skills/loader.ts +8 -1
- package/src/tools/builtins/bash.ts +24 -6
- package/src/tools/builtins/skill.ts +74 -53
- package/src/tools/command-shell.ts +166 -0
- package/src/tools/defineTool.ts +33 -1
- package/src/types/hitl/index.ts +21 -0
- package/src/types/provider/stream.ts +10 -0
- package/src/types/tool/index.ts +67 -5
- package/src/utils/frontmatter.ts +52 -2
package/src/utils/frontmatter.ts
CHANGED
|
@@ -117,6 +117,23 @@ export type FrontmatterValue =
|
|
|
117
117
|
| { readonly kind: 'scalar'; readonly value: string }
|
|
118
118
|
| { readonly kind: 'mapping'; readonly entries: Readonly<Record<string, string>> }
|
|
119
119
|
|
|
120
|
+
/** What a caller lets {@link parseFrontmatter} accept beyond flat scalars. */
|
|
121
|
+
export interface FrontmatterOptions {
|
|
122
|
+
/**
|
|
123
|
+
* Keys that may be written as a YAML list — a block sequence (`- item`
|
|
124
|
+
* lines) or a flow sequence (`[a, b]`) — and come back as ONE scalar, the
|
|
125
|
+
* items joined with `", "`.
|
|
126
|
+
*
|
|
127
|
+
* Opt-in per key, because a list is refused everywhere else for a reason:
|
|
128
|
+
* a key the caller reads as a scalar would otherwise come back absent. A
|
|
129
|
+
* caller names a key here only when a comma-separated scalar is already
|
|
130
|
+
* a spelling it reads, so the joined value means what the list did.
|
|
131
|
+
* `allowed-tools` is the case: the Agent Skills format writes it either
|
|
132
|
+
* way.
|
|
133
|
+
*/
|
|
134
|
+
readonly lists?: readonly string[]
|
|
135
|
+
}
|
|
136
|
+
|
|
120
137
|
export interface ParsedFrontmatter {
|
|
121
138
|
/**
|
|
122
139
|
* Every top-level key, in the order the file declared it.
|
|
@@ -146,7 +163,12 @@ export interface ParsedFrontmatter {
|
|
|
146
163
|
* does not implement. It never returns a partial or empty result to stand in
|
|
147
164
|
* for a file it could not read.
|
|
148
165
|
*/
|
|
149
|
-
export function parseFrontmatter(
|
|
166
|
+
export function parseFrontmatter(
|
|
167
|
+
raw: string,
|
|
168
|
+
source: string,
|
|
169
|
+
options: FrontmatterOptions = {},
|
|
170
|
+
): ParsedFrontmatter {
|
|
171
|
+
const listKeys = new Set(options.lists ?? [])
|
|
150
172
|
const trimmed = raw.trimStart()
|
|
151
173
|
|
|
152
174
|
if (!trimmed.startsWith(FRONTMATTER_DELIMITER)) {
|
|
@@ -174,6 +196,7 @@ export function parseFrontmatter(raw: string, source: string): ParsedFrontmatter
|
|
|
174
196
|
// round trip is safe at both ends.
|
|
175
197
|
const data = new Map<string, string>()
|
|
176
198
|
const blocks = new Map<string, Map<string, string>>()
|
|
199
|
+
const lists = new Map<string, string[]>()
|
|
177
200
|
let currentKey: string | undefined
|
|
178
201
|
|
|
179
202
|
for (const line of frontmatterRaw.split(LINE_SPLIT)) {
|
|
@@ -182,7 +205,8 @@ export function parseFrontmatter(raw: string, source: string): ParsedFrontmatter
|
|
|
182
205
|
if (/^\s/.test(line)) {
|
|
183
206
|
if (!currentKey) continue
|
|
184
207
|
|
|
185
|
-
// A block sequence item.
|
|
208
|
+
// A block sequence item. Read as a list when the caller named this
|
|
209
|
+
// key in `options.lists`; refused, not skipped, everywhere else.
|
|
186
210
|
//
|
|
187
211
|
// These lines carry no `:`, so the `continue` below used to drop them
|
|
188
212
|
// and the key — having no scalar value and no mapping entries — came
|
|
@@ -195,6 +219,18 @@ export function parseFrontmatter(raw: string, source: string): ParsedFrontmatter
|
|
|
195
219
|
// and silently did not get it is indistinguishable from one that never
|
|
196
220
|
// asked. A capability quietly not granted is the worst thing this
|
|
197
221
|
// reader can produce.
|
|
222
|
+
if (listKeys.has(currentKey) && !data.has(currentKey) && /^\s*-(\s|$)/.test(line)) {
|
|
223
|
+
const item = normalizeScalar(line.replace(/^\s*-/, ''))
|
|
224
|
+
if (item) {
|
|
225
|
+
let list = lists.get(currentKey)
|
|
226
|
+
if (!list) {
|
|
227
|
+
list = []
|
|
228
|
+
lists.set(currentKey, list)
|
|
229
|
+
}
|
|
230
|
+
list.push(item)
|
|
231
|
+
}
|
|
232
|
+
continue
|
|
233
|
+
}
|
|
198
234
|
if (/^\s*-\s/.test(line)) {
|
|
199
235
|
throw new Error(
|
|
200
236
|
`${source}: "${currentKey}" uses a block sequence (a "- " list), which this reader does not support. Write it as a single-line value instead. Refusing rather than reading "${currentKey}" as absent, which is what silently dropping the list would mean.`,
|
|
@@ -220,6 +256,17 @@ export function parseFrontmatter(raw: string, source: string): ParsedFrontmatter
|
|
|
220
256
|
const key = line.slice(0, colonIdx).trim()
|
|
221
257
|
const value = normalizeScalar(line.slice(colonIdx + 1))
|
|
222
258
|
|
|
259
|
+
if (listKeys.has(key) && /^\[.*\]$/.test(value)) {
|
|
260
|
+
currentKey = key
|
|
261
|
+
const items = value
|
|
262
|
+
.slice(1, -1)
|
|
263
|
+
.split(',')
|
|
264
|
+
.map(normalizeScalar)
|
|
265
|
+
.filter((item) => item.length > 0)
|
|
266
|
+
// `[]` is a list the author declared empty, which is not absence.
|
|
267
|
+
data.set(key, items.join(', '))
|
|
268
|
+
continue
|
|
269
|
+
}
|
|
223
270
|
assertReadableScalar(key, value, source)
|
|
224
271
|
|
|
225
272
|
currentKey = key
|
|
@@ -230,6 +277,9 @@ export function parseFrontmatter(raw: string, source: string): ParsedFrontmatter
|
|
|
230
277
|
// that — so refusing here is what makes the illegal state unrepresentable
|
|
231
278
|
// in the returned type rather than merely undocumented. The alternative,
|
|
232
279
|
// picking a precedence, would silently drop half of what the author wrote.
|
|
280
|
+
for (const [key, items] of lists) {
|
|
281
|
+
if (!data.has(key)) data.set(key, items.join(', '))
|
|
282
|
+
}
|
|
233
283
|
for (const key of blocks.keys()) {
|
|
234
284
|
if (!data.has(key)) continue
|
|
235
285
|
throw new Error(
|