@namzu/sdk 69.2.0 → 69.4.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 +25 -0
- package/dist/authorization/readonly-commands.d.ts.map +1 -1
- package/dist/authorization/readonly-commands.js +30 -2
- package/dist/authorization/readonly-commands.js.map +1 -1
- package/dist/constants/plugin/index.d.ts +8 -0
- package/dist/constants/plugin/index.d.ts.map +1 -1
- package/dist/constants/plugin/index.js +8 -0
- package/dist/constants/plugin/index.js.map +1 -1
- package/dist/plugin/common-layout/index.d.ts +5 -0
- package/dist/plugin/common-layout/index.d.ts.map +1 -0
- package/dist/plugin/common-layout/index.js +3 -0
- package/dist/plugin/common-layout/index.js.map +1 -0
- package/dist/plugin/common-layout/mcp.d.ts +21 -0
- package/dist/plugin/common-layout/mcp.d.ts.map +1 -0
- package/dist/plugin/common-layout/mcp.js +305 -0
- package/dist/plugin/common-layout/mcp.js.map +1 -0
- package/dist/plugin/common-layout/paths.d.ts +27 -0
- package/dist/plugin/common-layout/paths.d.ts.map +1 -0
- package/dist/plugin/common-layout/paths.js +48 -0
- package/dist/plugin/common-layout/paths.js.map +1 -0
- package/dist/plugin/common-layout/read.d.ts +25 -0
- package/dist/plugin/common-layout/read.d.ts.map +1 -0
- package/dist/plugin/common-layout/read.js +1155 -0
- package/dist/plugin/common-layout/read.js.map +1 -0
- package/dist/plugin/common-layout/types.d.ts +66 -0
- package/dist/plugin/common-layout/types.d.ts.map +1 -0
- package/dist/plugin/common-layout/types.js +2 -0
- package/dist/plugin/common-layout/types.js.map +1 -0
- package/dist/plugin/common-layout-names.d.ts +65 -0
- package/dist/plugin/common-layout-names.d.ts.map +1 -0
- package/dist/plugin/common-layout-names.js +94 -0
- package/dist/plugin/common-layout-names.js.map +1 -0
- package/dist/plugin/hook-module/capabilities.d.ts +41 -0
- package/dist/plugin/hook-module/capabilities.d.ts.map +1 -0
- package/dist/plugin/hook-module/capabilities.js +438 -0
- package/dist/plugin/hook-module/capabilities.js.map +1 -0
- package/dist/plugin/hook-module/consent.d.ts +39 -0
- package/dist/plugin/hook-module/consent.d.ts.map +1 -0
- package/dist/plugin/hook-module/consent.js +59 -0
- package/dist/plugin/hook-module/consent.js.map +1 -0
- package/dist/plugin/hook-module/events.d.ts +33 -0
- package/dist/plugin/hook-module/events.d.ts.map +1 -0
- package/dist/plugin/hook-module/events.js +149 -0
- package/dist/plugin/hook-module/events.js.map +1 -0
- package/dist/plugin/hook-module/host.d.ts +79 -0
- package/dist/plugin/hook-module/host.d.ts.map +1 -0
- package/dist/plugin/hook-module/host.js +546 -0
- package/dist/plugin/hook-module/host.js.map +1 -0
- package/dist/plugin/hook-module/index.d.ts +11 -0
- package/dist/plugin/hook-module/index.d.ts.map +1 -0
- package/dist/plugin/hook-module/index.js +6 -0
- package/dist/plugin/hook-module/index.js.map +1 -0
- package/dist/plugin/hook-module/scan.d.ts +99 -0
- package/dist/plugin/hook-module/scan.d.ts.map +1 -0
- package/dist/plugin/hook-module/scan.js +789 -0
- package/dist/plugin/hook-module/scan.js.map +1 -0
- package/dist/plugin/hook-module/worker-source.d.ts +31 -0
- package/dist/plugin/hook-module/worker-source.d.ts.map +1 -0
- package/dist/plugin/hook-module/worker-source.js +498 -0
- package/dist/plugin/hook-module/worker-source.js.map +1 -0
- package/dist/plugin/index.d.ts +5 -2
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +4 -1
- package/dist/plugin/index.js.map +1 -1
- package/dist/plugin/lifecycle.d.ts +57 -0
- package/dist/plugin/lifecycle.d.ts.map +1 -1
- package/dist/plugin/lifecycle.js +92 -11
- package/dist/plugin/lifecycle.js.map +1 -1
- package/dist/plugin/loader.d.ts +30 -0
- package/dist/plugin/loader.d.ts.map +1 -1
- package/dist/plugin/loader.js +76 -19
- package/dist/plugin/loader.js.map +1 -1
- package/dist/plugin/shell-hook-env.d.ts +7 -0
- package/dist/plugin/shell-hook-env.d.ts.map +1 -1
- package/dist/plugin/shell-hook-env.js.map +1 -1
- package/dist/plugin/shell-hook.d.ts +10 -1
- package/dist/plugin/shell-hook.d.ts.map +1 -1
- package/dist/plugin/shell-hook.js +81 -70
- package/dist/plugin/shell-hook.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/provider/side-request-reasoning.d.ts.map +1 -1
- package/dist/provider/side-request-reasoning.js +5 -1
- package/dist/provider/side-request-reasoning.js.map +1 -1
- package/dist/public-runtime.d.ts +3 -2
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +2 -2
- package/dist/public-runtime.js.map +1 -1
- package/dist/runtime/query/auto-review/classifier.d.ts.map +1 -1
- package/dist/runtime/query/auto-review/classifier.js +13 -2
- package/dist/runtime/query/auto-review/classifier.js.map +1 -1
- package/dist/runtime/query/auto-review/failure.d.ts +12 -5
- package/dist/runtime/query/auto-review/failure.d.ts.map +1 -1
- package/dist/runtime/query/auto-review/failure.js +42 -7
- package/dist/runtime/query/auto-review/failure.js.map +1 -1
- package/dist/runtime/query/review-policy.d.ts.map +1 -1
- package/dist/runtime/query/review-policy.js +22 -6
- package/dist/runtime/query/review-policy.js.map +1 -1
- package/dist/runtime/query/turn/check-scope.d.ts +18 -0
- package/dist/runtime/query/turn/check-scope.d.ts.map +1 -0
- package/dist/runtime/query/turn/check-scope.js +90 -0
- package/dist/runtime/query/turn/check-scope.js.map +1 -0
- package/dist/runtime/query/turn/outcome-ledger.d.ts.map +1 -1
- package/dist/runtime/query/turn/outcome-ledger.js +13 -0
- package/dist/runtime/query/turn/outcome-ledger.js.map +1 -1
- package/dist/skills/loader.d.ts +8 -2
- package/dist/skills/loader.d.ts.map +1 -1
- package/dist/skills/loader.js +22 -11
- package/dist/skills/loader.js.map +1 -1
- package/dist/skills/registry.d.ts.map +1 -1
- package/dist/skills/registry.js +9 -1
- package/dist/skills/registry.js.map +1 -1
- package/dist/tools/builtins/job.d.ts.map +1 -1
- package/dist/tools/builtins/job.js +4 -1
- package/dist/tools/builtins/job.js.map +1 -1
- package/dist/tools/builtins/wait-for-job.d.ts.map +1 -1
- package/dist/tools/builtins/wait-for-job.js +2 -1
- package/dist/tools/builtins/wait-for-job.js.map +1 -1
- package/dist/types/plugin/index.d.ts +73 -0
- package/dist/types/plugin/index.d.ts.map +1 -1
- package/dist/types/plugin/index.js +28 -6
- package/dist/types/plugin/index.js.map +1 -1
- package/dist/types/skills/index.d.ts +6 -0
- package/dist/types/skills/index.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/authorization/readonly-commands.ts +30 -2
- package/src/constants/plugin/index.ts +9 -0
- package/src/plugin/common-layout/index.ts +19 -0
- package/src/plugin/common-layout/mcp.ts +362 -0
- package/src/plugin/common-layout/paths.ts +70 -0
- package/src/plugin/common-layout/read.ts +1282 -0
- package/src/plugin/common-layout/types.ts +77 -0
- package/src/plugin/common-layout-names.ts +108 -0
- package/src/plugin/hook-module/capabilities.ts +500 -0
- package/src/plugin/hook-module/consent.ts +96 -0
- package/src/plugin/hook-module/events.ts +177 -0
- package/src/plugin/hook-module/host.ts +649 -0
- package/src/plugin/hook-module/index.ts +52 -0
- package/src/plugin/hook-module/scan.ts +1004 -0
- package/src/plugin/hook-module/worker-source.ts +500 -0
- package/src/plugin/index.ts +13 -1
- package/src/plugin/lifecycle.ts +179 -17
- package/src/plugin/loader.ts +97 -18
- package/src/plugin/shell-hook-env.ts +7 -0
- package/src/plugin/shell-hook.ts +91 -70
- package/src/prompt/coding-agent-doctrine.ts +1 -1
- package/src/provider/side-request-reasoning.ts +5 -1
- package/src/public-runtime.ts +35 -0
- package/src/runtime/query/auto-review/classifier.ts +14 -2
- package/src/runtime/query/auto-review/failure.ts +52 -7
- package/src/runtime/query/review-policy.ts +30 -6
- package/src/runtime/query/turn/check-scope.ts +90 -0
- package/src/runtime/query/turn/outcome-ledger.ts +11 -0
- package/src/skills/loader.ts +26 -9
- package/src/skills/registry.ts +9 -1
- package/src/tools/builtins/job.ts +4 -1
- package/src/tools/builtins/wait-for-job.ts +3 -1
- package/src/types/plugin/index.ts +81 -24
- package/src/types/skills/index.ts +7 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { classicWrittenName } from './events.js'
|
|
2
|
+
import type { HookModuleScan } from './scan.js'
|
|
3
|
+
|
|
4
|
+
/** What a hooks module does, in the terms a person is asked about. */
|
|
5
|
+
export interface HookModuleSummary {
|
|
6
|
+
/** The module, relative to the plugin. */
|
|
7
|
+
readonly entry: string
|
|
8
|
+
/** The events it hooks and Namzu runs, as the module spells them (`PreToolUse`). */
|
|
9
|
+
readonly events: readonly string[]
|
|
10
|
+
/** It starts programs. */
|
|
11
|
+
readonly runsCommands: boolean
|
|
12
|
+
/** It reads files in the plugin's folder and the project. */
|
|
13
|
+
readonly readsFiles: boolean
|
|
14
|
+
/** It makes network requests. */
|
|
15
|
+
readonly usesNetwork: boolean
|
|
16
|
+
/** It keeps data between sessions in the plugin's data folder. */
|
|
17
|
+
readonly keepsData: boolean
|
|
18
|
+
/** The variables it reads, by name. */
|
|
19
|
+
readonly readsEnvironment: readonly string[]
|
|
20
|
+
/** What it hooks or calls that Namzu has no place for, one line each. */
|
|
21
|
+
readonly notUsed: readonly string[]
|
|
22
|
+
/** Why it is refused and does not load, one line each. */
|
|
23
|
+
readonly refused: readonly string[]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Read a scan as a summary of what the module does. */
|
|
27
|
+
export function summarizeHookModule(scan: HookModuleScan): HookModuleSummary {
|
|
28
|
+
const events = new Set<string>()
|
|
29
|
+
const notUsed: string[] = []
|
|
30
|
+
for (const hook of scan.hooks) {
|
|
31
|
+
for (const event of hook.runs) {
|
|
32
|
+
const written = classicWrittenName(event)
|
|
33
|
+
if (written !== undefined) events.add(written)
|
|
34
|
+
}
|
|
35
|
+
if (hook.notUsed !== undefined) notUsed.push(hook.notUsed)
|
|
36
|
+
}
|
|
37
|
+
const supportedCalls = scan.calls.filter((call) => call.supported).map((call) => call.call)
|
|
38
|
+
for (const call of scan.calls) {
|
|
39
|
+
if (call.supported) continue
|
|
40
|
+
notUsed.push(
|
|
41
|
+
call.neverRuns === true
|
|
42
|
+
? `${call.call} is not available in Namzu; the hook that calls it is not run, so it is never called.`
|
|
43
|
+
: `${call.call} is not available in Namzu; calling it throws.`,
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
const uses = (prefix: string): boolean => supportedCalls.some((call) => call.startsWith(prefix))
|
|
47
|
+
return {
|
|
48
|
+
entry: scan.entry,
|
|
49
|
+
events: [...events].sort(),
|
|
50
|
+
runsCommands: uses('$.process.'),
|
|
51
|
+
readsFiles: uses('$.fs.'),
|
|
52
|
+
usesNetwork: uses('$.http.'),
|
|
53
|
+
keepsData: uses('$.store.'),
|
|
54
|
+
readsEnvironment: scan.envNames,
|
|
55
|
+
notUsed: [...new Set(notUsed)],
|
|
56
|
+
refused: scan.refusals.map((refusal) => `${refusal.file}:${refusal.line}: ${refusal.message}`),
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** One line per thing a person is told about before a module is allowed to run. */
|
|
61
|
+
export function hookModuleConsentLines(summary: HookModuleSummary): string[] {
|
|
62
|
+
const lines: string[] = []
|
|
63
|
+
lines.push(
|
|
64
|
+
summary.events.length > 0
|
|
65
|
+
? `hooks ${summary.events.join(', ')}`
|
|
66
|
+
: 'hooks no event that Namzu runs',
|
|
67
|
+
)
|
|
68
|
+
if (summary.runsCommands) lines.push('runs commands')
|
|
69
|
+
if (summary.readsFiles) lines.push('reads files in the plugin and the project')
|
|
70
|
+
if (summary.usesNetwork) lines.push('uses the network')
|
|
71
|
+
if (summary.keepsData) lines.push("keeps data in the plugin's data folder")
|
|
72
|
+
if (summary.readsEnvironment.length > 0) {
|
|
73
|
+
lines.push(`reads environment variables ${summary.readsEnvironment.join(', ')}`)
|
|
74
|
+
}
|
|
75
|
+
return lines
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The entry a consent surface (the trust screen, an install prompt) shows for a
|
|
80
|
+
* plugin's hooks module: who ships it, which file, and what it does.
|
|
81
|
+
*/
|
|
82
|
+
export interface HookModuleConsentEntry {
|
|
83
|
+
readonly plugin: string
|
|
84
|
+
readonly module: string
|
|
85
|
+
/** What the module does, one line each, ready to show. */
|
|
86
|
+
readonly lines: readonly string[]
|
|
87
|
+
readonly summary: HookModuleSummary
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function hookModuleConsentEntry(
|
|
91
|
+
plugin: string,
|
|
92
|
+
scan: HookModuleScan,
|
|
93
|
+
): HookModuleConsentEntry {
|
|
94
|
+
const summary = summarizeHookModule(scan)
|
|
95
|
+
return { plugin, module: scan.entry, lines: hookModuleConsentLines(summary), summary }
|
|
96
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { COMMON_MODULE_EVENT_NAMESPACE } from '../common-layout-names.js'
|
|
2
|
+
import {
|
|
3
|
+
SHELL_HOOK_EVENTS,
|
|
4
|
+
SHELL_HOOK_PASCAL_EVENT_NAMES,
|
|
5
|
+
type ShellHookEvent,
|
|
6
|
+
} from '../shell-hook.js'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The settings-style hook events a hooks module may name, as `classic.<Event>`.
|
|
10
|
+
* Some have no counterpart in Namzu; they are accepted and never run.
|
|
11
|
+
*/
|
|
12
|
+
export const CLASSIC_HOOK_EVENTS: readonly string[] = [
|
|
13
|
+
'PreToolUse',
|
|
14
|
+
'PostToolUse',
|
|
15
|
+
'PostToolUseFailure',
|
|
16
|
+
'PostToolBatch',
|
|
17
|
+
'PermissionDenied',
|
|
18
|
+
'Notification',
|
|
19
|
+
'UserPromptSubmit',
|
|
20
|
+
'UserPromptExpansion',
|
|
21
|
+
'SessionStart',
|
|
22
|
+
'SessionEnd',
|
|
23
|
+
'Stop',
|
|
24
|
+
'StopFailure',
|
|
25
|
+
'SubagentStart',
|
|
26
|
+
'SubagentStop',
|
|
27
|
+
'PreCompact',
|
|
28
|
+
'PostCompact',
|
|
29
|
+
'PreModelSwitch',
|
|
30
|
+
'PostModelSwitch',
|
|
31
|
+
'PermissionRequest',
|
|
32
|
+
'Setup',
|
|
33
|
+
'TeammateIdle',
|
|
34
|
+
'TaskCreated',
|
|
35
|
+
'TaskCompleted',
|
|
36
|
+
'Elicitation',
|
|
37
|
+
'ElicitationResult',
|
|
38
|
+
'ConfigChange',
|
|
39
|
+
'InstructionsLoaded',
|
|
40
|
+
'WorktreeCreate',
|
|
41
|
+
'WorktreeRemove',
|
|
42
|
+
'CwdChanged',
|
|
43
|
+
'FileChanged',
|
|
44
|
+
'DirectoryAdded',
|
|
45
|
+
'MessageDisplay',
|
|
46
|
+
'PreSkillShellCommand',
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The namespaces of the events the other engine runs inside itself (tool calls,
|
|
51
|
+
* the interface, agents and the rest). A module may register on them; Namzu has
|
|
52
|
+
* no such events, so none of those hooks run.
|
|
53
|
+
*/
|
|
54
|
+
const ENGINE_NAMESPACES: ReadonlySet<string> = new Set([
|
|
55
|
+
'tool',
|
|
56
|
+
'turn',
|
|
57
|
+
'session',
|
|
58
|
+
'prompt',
|
|
59
|
+
'agent',
|
|
60
|
+
'command',
|
|
61
|
+
'config',
|
|
62
|
+
'settings',
|
|
63
|
+
'env',
|
|
64
|
+
'state',
|
|
65
|
+
'store',
|
|
66
|
+
'telemetry',
|
|
67
|
+
'skill',
|
|
68
|
+
'attribution',
|
|
69
|
+
'ui',
|
|
70
|
+
'theme',
|
|
71
|
+
'vcs',
|
|
72
|
+
'process',
|
|
73
|
+
'fs',
|
|
74
|
+
'http',
|
|
75
|
+
'model',
|
|
76
|
+
'mcp',
|
|
77
|
+
'audio',
|
|
78
|
+
'clock',
|
|
79
|
+
'wasm',
|
|
80
|
+
'plugin',
|
|
81
|
+
'engine',
|
|
82
|
+
])
|
|
83
|
+
|
|
84
|
+
const NAMESPACE = COMMON_MODULE_EVENT_NAMESPACE
|
|
85
|
+
|
|
86
|
+
/** Each classic name that Namzu has an event for, to that event. */
|
|
87
|
+
const CLASSIC_TO_NAMZU: ReadonlyMap<string, ShellHookEvent> = new Map(
|
|
88
|
+
SHELL_HOOK_EVENTS.flatMap((event) => {
|
|
89
|
+
const written = SHELL_HOOK_PASCAL_EVENT_NAMES[event]
|
|
90
|
+
return written !== undefined && CLASSIC_HOOK_EVENTS.includes(written)
|
|
91
|
+
? [[written, event] as const]
|
|
92
|
+
: []
|
|
93
|
+
}),
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
const NAMZU_TO_CLASSIC: ReadonlyMap<ShellHookEvent, string> = new Map(
|
|
97
|
+
[...CLASSIC_TO_NAMZU].map(([classic, event]) => [event, classic] as const),
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
/** The Namzu events a module can run on. */
|
|
101
|
+
export const MODULE_HOOK_EVENTS: readonly ShellHookEvent[] = [...NAMZU_TO_CLASSIC.keys()]
|
|
102
|
+
|
|
103
|
+
/** The name a module registers on for a Namzu event: `classic.PreToolUse`. */
|
|
104
|
+
export function classicEventName(event: ShellHookEvent): string | undefined {
|
|
105
|
+
const written = NAMZU_TO_CLASSIC.get(event)
|
|
106
|
+
return written === undefined ? undefined : `${NAMESPACE}.${written}`
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** The written (PascalCase) name of a Namzu event, as a module's `e.hook_event_name` spells it. */
|
|
110
|
+
export function classicWrittenName(event: ShellHookEvent): string | undefined {
|
|
111
|
+
return NAMZU_TO_CLASSIC.get(event)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export type ResolvedPattern =
|
|
115
|
+
| {
|
|
116
|
+
readonly ok: true
|
|
117
|
+
/** The Namzu events the pattern selects and Namzu runs. */
|
|
118
|
+
readonly runs: readonly ShellHookEvent[]
|
|
119
|
+
/**
|
|
120
|
+
* Set when the pattern names only events Namzu does not have: nothing it
|
|
121
|
+
* hooks ever runs, and the message says so.
|
|
122
|
+
*/
|
|
123
|
+
readonly notUsed?: string
|
|
124
|
+
}
|
|
125
|
+
| { readonly ok: false; readonly message: string }
|
|
126
|
+
|
|
127
|
+
function notAvailable(pattern: string): string {
|
|
128
|
+
return `Namzu runs ${NAMESPACE}.* hooks from modules; ${pattern} is not available.`
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function isEngineName(name: string): boolean {
|
|
132
|
+
const dot = name.indexOf('.')
|
|
133
|
+
if (dot <= 0 || dot === name.length - 1) return false
|
|
134
|
+
return (
|
|
135
|
+
ENGINE_NAMESPACES.has(name.slice(0, dot)) && /^[A-Za-z][A-Za-z0-9]*$/.test(name.slice(dot + 1))
|
|
136
|
+
)
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* What a pattern selects: one event by name, every event under a namespace
|
|
141
|
+
* (`classic.*`), every event (`*`), or every event but those another pattern
|
|
142
|
+
* selects (`!tool.*`, `!classic.Stop`). A name that is no event and a glob that
|
|
143
|
+
* selects nothing are refused.
|
|
144
|
+
*/
|
|
145
|
+
export function resolvePattern(pattern: string): ResolvedPattern {
|
|
146
|
+
const all = (): readonly ShellHookEvent[] => [...MODULE_HOOK_EVENTS]
|
|
147
|
+
if (pattern === '*') return { ok: true, runs: all() }
|
|
148
|
+
if (pattern.startsWith('!')) {
|
|
149
|
+
const inner = resolvePattern(pattern.slice(1))
|
|
150
|
+
if (!inner.ok) return inner
|
|
151
|
+
if (pattern.startsWith('!!')) {
|
|
152
|
+
return { ok: false, message: `"${pattern}" is not a pattern: a negation is made once` }
|
|
153
|
+
}
|
|
154
|
+
const taken = new Set(inner.runs)
|
|
155
|
+
return { ok: true, runs: all().filter((event) => !taken.has(event)) }
|
|
156
|
+
}
|
|
157
|
+
if (pattern.endsWith('.*')) {
|
|
158
|
+
const space = pattern.slice(0, -2)
|
|
159
|
+
if (space === NAMESPACE) return { ok: true, runs: all() }
|
|
160
|
+
if (ENGINE_NAMESPACES.has(space)) {
|
|
161
|
+
return { ok: true, runs: [], notUsed: notAvailable(pattern) }
|
|
162
|
+
}
|
|
163
|
+
return { ok: false, message: `"${pattern}" is not a pattern: it selects no event` }
|
|
164
|
+
}
|
|
165
|
+
if (pattern.startsWith(`${NAMESPACE}.`)) {
|
|
166
|
+
const name = pattern.slice(NAMESPACE.length + 1)
|
|
167
|
+
if (!CLASSIC_HOOK_EVENTS.includes(name)) {
|
|
168
|
+
return { ok: false, message: `"${pattern}" is not an event` }
|
|
169
|
+
}
|
|
170
|
+
const event = CLASSIC_TO_NAMZU.get(name)
|
|
171
|
+
return event === undefined
|
|
172
|
+
? { ok: true, runs: [], notUsed: notAvailable(pattern) }
|
|
173
|
+
: { ok: true, runs: [event] }
|
|
174
|
+
}
|
|
175
|
+
if (isEngineName(pattern)) return { ok: true, runs: [], notUsed: notAvailable(pattern) }
|
|
176
|
+
return { ok: false, message: `"${pattern}" is not an event` }
|
|
177
|
+
}
|