@hearsay-tools/squawk 0.18.0-dev.8167 → 0.18.0-dev.8169
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/dist/boot.d.ts +11 -2
- package/dist/boot.js +24 -4
- package/dist/boot.js.map +1 -1
- package/dist/built-in-cli-commands.d.ts +3 -0
- package/dist/built-in-cli-commands.js +8 -0
- package/dist/built-in-cli-commands.js.map +1 -1
- package/dist/cli-dispatch.d.ts +6 -0
- package/dist/cli-dispatch.js +61 -20
- package/dist/cli-dispatch.js.map +1 -1
- package/dist/contract/health.d.ts +67 -0
- package/dist/contract/index.js +18 -1
- package/dist/core/cli-registry.d.ts +2 -0
- package/dist/core/cli-registry.js +4 -0
- package/dist/core/cli-registry.js.map +1 -1
- package/dist/core/runner-registry.js +5 -1
- package/dist/core/runner-registry.js.map +1 -1
- package/dist/home/home.d.ts +2 -0
- package/dist/home/home.js +1 -1
- package/dist/home/home.js.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/plugin/api.d.ts +12 -2
- package/dist/plugin/api.js +14 -14
- package/dist/plugin/api.js.map +1 -1
- package/dist/plugin/cli.d.ts +5 -0
- package/dist/plugin/cli.js +53 -0
- package/dist/plugin/cli.js.map +1 -0
- package/dist/plugin/loader.d.ts +61 -0
- package/dist/plugin/loader.js +142 -0
- package/dist/plugin/loader.js.map +1 -0
- package/dist/plugin/resolve-hook.d.ts +15 -0
- package/dist/plugin/resolve-hook.js +39 -0
- package/dist/plugin/resolve-hook.js.map +1 -0
- package/dist/server/accept-negotiation.d.ts +17 -0
- package/dist/server/accept-negotiation.js +53 -0
- package/dist/server/accept-negotiation.js.map +1 -0
- package/dist/server/host-authority.d.ts +20 -0
- package/dist/server/host-authority.js +46 -0
- package/dist/server/host-authority.js.map +1 -0
- package/dist/server/server.d.ts +2088 -2075
- package/dist/server/server.js +16 -99
- package/dist/server/server.js.map +1 -1
- package/dist/subcommands.d.ts +5 -1
- package/dist/subcommands.js +11 -6
- package/dist/subcommands.js.map +1 -1
- package/dist/task-cli/discovery.js +5 -4
- package/dist/task-cli/discovery.js.map +1 -1
- package/package.json +4 -4
- package/web/dist/assets/{accounts-section-CRiql0cT.js → accounts-section-3TFV3bKA.js} +1 -1
- package/web/dist/assets/{activity-motion-Dic711r4.js → activity-motion-DIEqBTn_.js} +1 -1
- package/web/dist/assets/{activity-route-DkqFQfEX.js → activity-route-1e-zJAwF.js} +1 -1
- package/web/dist/assets/{agent-config-section-pDXHYHXz.js → agent-config-section-BEhRUFXI.js} +1 -1
- package/web/dist/assets/{agent-defaults-section-D_d24TE0.js → agent-defaults-section-CPFpExY0.js} +1 -1
- package/web/dist/assets/{appearance-BcCBqgn-.js → appearance-DmZqmV_h.js} +1 -1
- package/web/dist/assets/{archive-on-merge-field-BJoirmK5.js → archive-on-merge-field-BMxl0_RG.js} +1 -1
- package/web/dist/assets/attention-BiqSbE32.js +1 -0
- package/web/dist/assets/{automations-route-fR3nMyuy.js → automations-route-BQTvY9OZ.js} +1 -1
- package/web/dist/assets/{commit-diff-panel-Ox2k_MeC.js → commit-diff-panel-CrCQrLkj.js} +1 -1
- package/web/dist/assets/{diff-B-6M-t3K.js → diff-CSURjwWN.js} +2 -2
- package/web/dist/assets/{diff-view-nrQTDxks.js → diff-view-C0EkYWIb.js} +1 -1
- package/web/dist/assets/{file-preview-B3KVy73J.js → file-preview-Dwpny4J1.js} +1 -1
- package/web/dist/assets/{folder-browser-DwKXxvit.js → folder-browser-vE5IBaDD.js} +1 -1
- package/web/dist/assets/{git-toolbar-TX4S_cYI.js → git-toolbar-Cxylz9oM.js} +1 -1
- package/web/dist/assets/{github-DMMGSGqg.js → github-QMdDPo6m.js} +1 -1
- package/web/dist/assets/{global-activity-route-c5c5Q00Y.js → global-activity-route-CbOpfU7Q.js} +1 -1
- package/web/dist/assets/{index-DfmmHZB9.js → index-Bra3Zx6_.js} +5 -5
- package/web/dist/assets/{label-DozlouK_.js → label-uUv3KkFX.js} +1 -1
- package/web/dist/assets/{markdown-CH0W4B61.js → markdown-CVLWRUFa.js} +1 -1
- package/web/dist/assets/{notifications-section-bytadcE1.js → notifications-section-y0N1nPKx.js} +1 -1
- package/web/dist/assets/{open-in-menu-9Hic-2Jh.js → open-in-menu-szYIrLlc.js} +1 -1
- package/web/dist/assets/{preview-pane-connected-Be0ZQ1QZ.js → preview-pane-connected-DzLCKXRK.js} +1 -1
- package/web/dist/assets/{project-location-YHLlezCN.js → project-location-D5yAc-_A.js} +1 -1
- package/web/dist/assets/{project-router-CYJwJlJL.js → project-router-BYHPCHz0.js} +1 -1
- package/web/dist/assets/project-scope-context-C0FJXpqD.js +4 -0
- package/web/dist/assets/{projects-section-D2OikZvZ.js → projects-section-DwrBHp8U.js} +1 -1
- package/web/dist/assets/{prompt-templates-section-BZQcqxyC.js → prompt-templates-section-B63ytixw.js} +1 -1
- package/web/dist/assets/{queries-DeeY9cGJ.js → queries-CK9ZDDfL.js} +1 -1
- package/web/dist/assets/{reference-chip-BSXiknFh.js → reference-chip-jyOBNGWj.js} +1 -1
- package/web/dist/assets/{remote-settings-notice-B7vBsgJe.js → remote-settings-notice-BaEqkFLb.js} +1 -1
- package/web/dist/assets/{repo-git-4HLZT14I.js → repo-git-CY6YcBMo.js} +1 -1
- package/web/dist/assets/{report-reader-CmGgO12j.js → report-reader-4K1U0nwt.js} +1 -1
- package/web/dist/assets/{reports-B-AxM1y5.js → reports-DzfdonA_.js} +1 -1
- package/web/dist/assets/{resources-section-21R3ObSS.js → resources-section-Dzqw_Eh_.js} +1 -1
- package/web/dist/assets/{run-header-KmcjpBMq.js → run-header-BwxE9ges.js} +1 -1
- package/web/dist/assets/{settings-agent-picker-X-g0UKgD.js → settings-agent-picker-BsfSkgY9.js} +1 -1
- package/web/dist/assets/{settings-shell-DEbkOTuH.js → settings-shell-DDTVjo7C.js} +1 -1
- package/web/dist/assets/{sidebar-section-D7e8bdCc.js → sidebar-section-BFcDThEN.js} +1 -1
- package/web/dist/assets/{skills-DkL4o5z5.js → skills-Cw_PL5-A.js} +1 -1
- package/web/dist/assets/{tab-link-Bc33InzJ.js → tab-link-Crlr5m1D.js} +1 -1
- package/web/dist/assets/{task-changes-DggkNS5B.js → task-changes-DLzIXSTR.js} +1 -1
- package/web/dist/assets/{task-commits-xhACNoGj.js → task-commits-amn0LePZ.js} +1 -1
- package/web/dist/assets/{task-files-CL76uaPp.js → task-files-9b6zqJWa.js} +1 -1
- package/web/dist/assets/{task-github-item-CqID35v9.js → task-github-item-DJvWvk2q.js} +1 -1
- package/web/dist/assets/{task-groups-CC8zwSMv.js → task-groups-CZPi6W0m.js} +1 -1
- package/web/dist/assets/{task-thread-BuX8KtlY.js → task-thread-DA-IdbEA.js} +1 -1
- package/web/dist/assets/{tasks-table-_5cXATkO.js → tasks-table-Cim2-KSS.js} +1 -1
- package/web/dist/assets/{thread-state-dtADhBQ_.js → thread-state-PGrlMiQA.js} +1 -1
- package/web/dist/assets/{use-hand-to-agent-state-BD10hMfn.js → use-hand-to-agent-state-CMiYRssU.js} +1 -1
- package/web/dist/assets/{useInfiniteQuery-BswGDVd8.js → useInfiniteQuery-waSOS4EO.js} +1 -1
- package/web/dist/assets/useQuery-9BEU-yko.js +1 -0
- package/web/dist/assets/{workflows-C2H-HfDa.js → workflows-DowJdAnR.js} +1 -1
- package/web/dist/assets/{workspace-tools-Cyfz8V_L.js → workspace-tools-BPmJcyzi.js} +1 -1
- package/web/dist/assets/{worktrees-section-Doo2MjMH.js → worktrees-section-Bn-NIqrK.js} +1 -1
- package/web/dist/assets/{ws-CKLbENkm.js → ws-DQjRhoew.js} +1 -1
- package/web/dist/index.html +14 -14
- package/web/dist/assets/attention-D8ku2yDQ.js +0 -1
- package/web/dist/assets/project-scope-context-DqBHMdSb.js +0 -4
- package/web/dist/assets/useQuery-IS5tPlew.js +0 -1
package/dist/plugin/api.js
CHANGED
|
@@ -11,24 +11,12 @@ import { checkRunLifecycleListenerRegistration, registerRunLifecycleListener } f
|
|
|
11
11
|
import { checkRunSlotsRegistration, registerRunSlots } from '../runs/removal-slots.js';
|
|
12
12
|
import { checkWaitKindRegistration, registerWaitKind } from '../workflows/run/wait-kind-registry.js';
|
|
13
13
|
import { checkStepKindRegistration, registerStepKind } from '../workflows/step-kind-registry.js';
|
|
14
|
-
/** The longest runner id a stored setting keeps (spec § 6, `storedRunnerIdSchema`). */
|
|
15
|
-
const MAX_RUNNER_ID_LENGTH = 64;
|
|
16
|
-
function isControlCharacter(character) {
|
|
17
|
-
const code = character.codePointAt(0) ?? 0;
|
|
18
|
-
return code < 0x20 || (code >= 0x7f && code <= 0x9f);
|
|
19
|
-
}
|
|
20
|
-
function checkRunnerId(id) {
|
|
21
|
-
if (typeof id !== 'string' || id.length === 0 || id !== id.trim() || id.length > MAX_RUNNER_ID_LENGTH || [...id].some(isControlCharacter)) {
|
|
22
|
-
throw new Error(`Invalid runner id ${JSON.stringify(id)}: use a trimmed, non-empty string of at most ${MAX_RUNNER_ID_LENGTH} characters with no control characters.`);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
14
|
function checkKey(registry, key) {
|
|
26
15
|
if (typeof key !== 'string' || key.length === 0)
|
|
27
16
|
throw new Error(`${registry}: invalid key ${JSON.stringify(key)}.`);
|
|
28
17
|
}
|
|
29
18
|
const runners = {
|
|
30
|
-
name: 'Runner registry', key: value => value.id,
|
|
31
|
-
check: checkRunnerRegistration, commit: registerRunner,
|
|
19
|
+
name: 'Runner registry', key: value => value.id, check: checkRunnerRegistration, commit: registerRunner,
|
|
32
20
|
};
|
|
33
21
|
const tools = {
|
|
34
22
|
name: 'Agent tool registry', key: value => value.name, check: checkAgentToolRegistration, commit: registerAgentTool,
|
|
@@ -125,11 +113,22 @@ function stagingApi(staged, open) {
|
|
|
125
113
|
onRunLifecycle: stage(staged.lifecycle),
|
|
126
114
|
};
|
|
127
115
|
}
|
|
116
|
+
function contributions(staged) {
|
|
117
|
+
return {
|
|
118
|
+
runners: staged.runners.map(value => value.id),
|
|
119
|
+
agentTools: staged.tools.map(value => value.name),
|
|
120
|
+
waitKinds: staged.waitKinds.map(value => value.kind),
|
|
121
|
+
stepKinds: staged.stepKinds.map(value => value.kind),
|
|
122
|
+
cliCommands: staged.cliCommands.map(value => value.name),
|
|
123
|
+
removalSlots: staged.removalSlots.length,
|
|
124
|
+
runLifecycleListeners: staged.lifecycle.length,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
128
127
|
/**
|
|
129
128
|
* Run one plugin's setup and commit what it registered, all or nothing. A setup that throws or
|
|
130
129
|
* rejects, or a staged entry that a live registry would refuse (a taken or reserved key, a
|
|
131
130
|
* duplicate within the plugin, an invalid shape, a sealed registry), commits no entry anywhere and
|
|
132
|
-
* rethrows that error. The api refuses calls once setup has ended.
|
|
131
|
+
* rethrows that error. The api refuses calls once setup has ended. Returns what it committed.
|
|
133
132
|
*/
|
|
134
133
|
export async function runPluginSetup(plugin) {
|
|
135
134
|
const staged = { runners: [], tools: [], waitKinds: [], stepKinds: [], cliCommands: [], removalSlots: [], lifecycle: [] };
|
|
@@ -142,5 +141,6 @@ export async function runPluginSetup(plugin) {
|
|
|
142
141
|
}
|
|
143
142
|
checkStaged(staged);
|
|
144
143
|
commitStaged(staged);
|
|
144
|
+
return contributions(staged);
|
|
145
145
|
}
|
|
146
146
|
//# sourceMappingURL=api.js.map
|
package/dist/plugin/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/plugin/api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,0BAA0B,EAAE,iBAAiB,EAA4B,MAAM,6BAA6B,CAAC;AACtH,OAAO,EAAE,2BAA2B,EAAE,kBAAkB,EAA6B,MAAM,yBAAyB,CAAC;AAErH,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAErF,OAAO,EAAE,qCAAqC,EAAE,4BAA4B,EAAE,MAAM,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GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC;QACpD,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC;QACxD,YAAY,EAAE,MAAM,CAAC,YAAY,CAAC,MAAM;QACxC,qBAAqB,EAAE,MAAM,CAAC,SAAS,CAAC,MAAM;KAC/C,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,MAAoB;IACvD,MAAM,MAAM,GAAiB,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;IACxI,IAAI,IAAI,GAAG,IAAI,CAAC;IAChB,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/C,CAAC;YAAS,CAAC;QACT,IAAI,GAAG,KAAK,CAAC;IACf,CAAC;IACD,WAAW,CAAC,MAAM,CAAC,CAAC;IACpB,YAAY,CAAC,MAAM,CAAC,CAAC;IACrB,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type PluginLoadReport } from './loader.ts';
|
|
2
|
+
/** The human-readable report. */
|
|
3
|
+
export declare function formatPluginReport(report: PluginLoadReport): string;
|
|
4
|
+
/** `hsq plugins`: full boot has run, so the report holds this process's plugins. */
|
|
5
|
+
export declare function runPluginsCommand(argv: string[], _env: NodeJS.ProcessEnv, out?: Console): Promise<number>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { commandText } from '../home/command.js';
|
|
2
|
+
import { pluginLoadReport } from './loader.js';
|
|
3
|
+
const USAGE = `usage: cez plugins [--json]
|
|
4
|
+
|
|
5
|
+
Lists the plugins this process loaded from <config>/plugins/, what each one registered, and the
|
|
6
|
+
plugins it skipped with the reason. --json prints the same report as JSON.`;
|
|
7
|
+
const CONTRIBUTION_LABELS = [
|
|
8
|
+
['cliCommands', 'commands'], ['runners', 'runners'], ['agentTools', 'agent tools'],
|
|
9
|
+
['waitKinds', 'wait kinds'], ['stepKinds', 'step kinds'],
|
|
10
|
+
['removalSlots', 'removal slots'], ['runLifecycleListeners', 'run lifecycle listeners'],
|
|
11
|
+
];
|
|
12
|
+
function contributionLines(contributions) {
|
|
13
|
+
return CONTRIBUTION_LABELS.flatMap(([key, label]) => {
|
|
14
|
+
const value = contributions[key];
|
|
15
|
+
if (Array.isArray(value))
|
|
16
|
+
return value.length > 0 ? [` ${label}: ${value.join(', ')}`] : [];
|
|
17
|
+
return value ? [` ${label}: ${value}`] : [];
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/** The human-readable report. */
|
|
21
|
+
export function formatPluginReport(report) {
|
|
22
|
+
const lines = report.folders.length > 0
|
|
23
|
+
? report.folders.map(folder => `Plugin folder: ${folder}`)
|
|
24
|
+
: ['No plugin folder was read.'];
|
|
25
|
+
lines.push('', `Loaded (${report.loaded.length}):`);
|
|
26
|
+
if (report.loaded.length === 0)
|
|
27
|
+
lines.push(' none');
|
|
28
|
+
for (const plugin of report.loaded) {
|
|
29
|
+
lines.push(` ${plugin.name} ${plugin.path}`, ...contributionLines(plugin.contributions));
|
|
30
|
+
}
|
|
31
|
+
lines.push('', `Skipped (${report.failed.length}):`);
|
|
32
|
+
if (report.failed.length === 0)
|
|
33
|
+
lines.push(' none');
|
|
34
|
+
for (const plugin of report.failed)
|
|
35
|
+
lines.push(` ${plugin.name} ${plugin.path}`, ` error: ${plugin.error}`);
|
|
36
|
+
return lines.join('\n');
|
|
37
|
+
}
|
|
38
|
+
/** `hsq plugins`: full boot has run, so the report holds this process's plugins. */
|
|
39
|
+
export async function runPluginsCommand(argv, _env, out = console) {
|
|
40
|
+
if (argv.some(arg => arg === '--help' || arg === '-h' || arg === 'help')) {
|
|
41
|
+
out.log(commandText(USAGE));
|
|
42
|
+
return 0;
|
|
43
|
+
}
|
|
44
|
+
const unknown = argv.filter(arg => arg !== '--json');
|
|
45
|
+
if (unknown.length > 0) {
|
|
46
|
+
out.error(commandText(`unknown argument: ${unknown[0]}\n\n${USAGE}`));
|
|
47
|
+
return 1;
|
|
48
|
+
}
|
|
49
|
+
const report = pluginLoadReport();
|
|
50
|
+
out.log(argv.includes('--json') ? JSON.stringify(report, null, 2) : formatPluginReport(report));
|
|
51
|
+
return 0;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/plugin/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAyB,MAAM,aAAa,CAAC;AAEtE,MAAM,KAAK,GAAG;;;2EAG6D,CAAC;AAE5E,MAAM,mBAAmB,GAAuD;IAC9E,CAAC,aAAa,EAAE,UAAU,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,EAAE,CAAC,YAAY,EAAE,aAAa,CAAC;IAClF,CAAC,WAAW,EAAE,YAAY,CAAC,EAAE,CAAC,WAAW,EAAE,YAAY,CAAC;IACxD,CAAC,cAAc,EAAE,eAAe,CAAC,EAAE,CAAC,uBAAuB,EAAE,yBAAyB,CAAC;CACxF,CAAC;AAEF,SAAS,iBAAiB,CAAC,aAAkC;IAC3D,OAAO,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAClD,MAAM,KAAK,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,KAAK,CAAC,OAAO,CAA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
|
+
import { type PluginContributions } from './api.ts';
|
|
3
|
+
/**
|
|
4
|
+
* The plugin loader (spec 2026-11-24-plugin-loader-and-runner-kit § 4). A plugin is one folder
|
|
5
|
+
* whose `index.mjs` or `index.js` default-exports a setup function. The loader runs each folder's
|
|
6
|
+
* setup through `runPluginSetup`, so a plugin that throws or collides commits nothing. A broken
|
|
7
|
+
* plugin is skipped with one stderr warning and never stops boot.
|
|
8
|
+
*/
|
|
9
|
+
/** `bundled` ships inside Squawk; `host` comes from `<config>/plugins/`. */
|
|
10
|
+
export type PluginSource = 'bundled' | 'host';
|
|
11
|
+
export interface LoadedPlugin {
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly source: PluginSource;
|
|
14
|
+
readonly path: string;
|
|
15
|
+
readonly contributions: PluginContributions;
|
|
16
|
+
}
|
|
17
|
+
/** Why a plugin was skipped. Health sends only this; the message can carry any text. */
|
|
18
|
+
export type PluginFailureReason = 'missing-entry' | 'no-setup' | 'import' | 'setup';
|
|
19
|
+
export interface FailedPlugin {
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly source: PluginSource;
|
|
22
|
+
readonly path: string;
|
|
23
|
+
readonly reason: PluginFailureReason;
|
|
24
|
+
/** The full message, for the operator: stderr and `hsq plugins`. Never sent on health. */
|
|
25
|
+
readonly error: string;
|
|
26
|
+
}
|
|
27
|
+
/** What this process loaded. `folders` lists every folder the loader read, in load order. */
|
|
28
|
+
export interface PluginLoadReport {
|
|
29
|
+
readonly folders: readonly string[];
|
|
30
|
+
readonly loaded: readonly LoadedPlugin[];
|
|
31
|
+
readonly failed: readonly FailedPlugin[];
|
|
32
|
+
}
|
|
33
|
+
/** The plugins this process loaded and skipped. `hsq plugins` and `GET /api/v1/health` read it. */
|
|
34
|
+
export declare function pluginLoadReport(): PluginLoadReport;
|
|
35
|
+
/** The entry files the loader tries in each plugin folder, in order. */
|
|
36
|
+
export declare const PLUGIN_ENTRY_FILES: readonly ['index.mjs', 'index.js'];
|
|
37
|
+
export interface LoadPluginFolderOptions {
|
|
38
|
+
/** The folder whose child folders are plugins. A missing folder loads nothing. */
|
|
39
|
+
dir: string;
|
|
40
|
+
source: PluginSource;
|
|
41
|
+
/** Receives one line per skipped plugin. Default: stderr. */
|
|
42
|
+
warn?: (line: string) => void;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Load every plugin folder under `dir` in code-point order of folder name and add the outcome to
|
|
46
|
+
* the process report. Installs the `@hearsay-tools/squawk/plugin` resolve hook first.
|
|
47
|
+
*/
|
|
48
|
+
export declare function loadPluginFolder({ dir, source, warn }: LoadPluginFolderOptions): Promise<PluginLoadReport>;
|
|
49
|
+
/**
|
|
50
|
+
* The text health sends for each reason. A plugin's own message can name host paths or carry a
|
|
51
|
+
* secret, and health is CORS-open, so health never sends it; `hsq plugins` on the host does.
|
|
52
|
+
*/
|
|
53
|
+
export declare const PLUGIN_FAILURE_TEXT: Readonly<Record<PluginFailureReason, string>>;
|
|
54
|
+
/**
|
|
55
|
+
* The health payload for a report. A local cockpit sends each plugin's folder; a hosted one
|
|
56
|
+
* (`HSQ_REMOTE=1` or a non-loopback bind) sends no path. A skipped plugin's error is always the
|
|
57
|
+
* fixed text for its reason.
|
|
58
|
+
*/
|
|
59
|
+
export declare function pluginHealth(source: PluginLoadReport, { hostPaths }: {
|
|
60
|
+
hostPaths: boolean;
|
|
61
|
+
}): PluginsHealth;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
9
|
+
import { readdirSync, statSync } from 'node:fs';
|
|
10
|
+
import { join } from 'node:path';
|
|
11
|
+
import { pathToFileURL } from 'node:url';
|
|
12
|
+
import { runPluginSetup } from './api.js';
|
|
13
|
+
import { installPluginResolveHook } from './resolve-hook.js';
|
|
14
|
+
class PluginLoadFailure extends Error {
|
|
15
|
+
reason;
|
|
16
|
+
constructor(reason, message) {
|
|
17
|
+
super(message);
|
|
18
|
+
this.reason = reason;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const EMPTY_REPORT = Object.freeze({ folders: [], loaded: [], failed: [] });
|
|
22
|
+
let report = EMPTY_REPORT;
|
|
23
|
+
/** The plugins this process loaded and skipped. `hsq plugins` and `GET /api/v1/health` read it. */
|
|
24
|
+
export function pluginLoadReport() {
|
|
25
|
+
return report;
|
|
26
|
+
}
|
|
27
|
+
/** The entry files the loader tries in each plugin folder, in order. */
|
|
28
|
+
export const PLUGIN_ENTRY_FILES = ['index.mjs', 'index.js'];
|
|
29
|
+
/** Locale-independent code-point order, so every host loads plugins in the same order. */
|
|
30
|
+
function byCodePoint(a, b) {
|
|
31
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
32
|
+
}
|
|
33
|
+
function isDirectoryEntry(dir, entry) {
|
|
34
|
+
if (entry.isDirectory())
|
|
35
|
+
return true;
|
|
36
|
+
if (!entry.isSymbolicLink())
|
|
37
|
+
return false;
|
|
38
|
+
try {
|
|
39
|
+
return statSync(join(dir, entry.name)).isDirectory();
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function isFile(path) {
|
|
46
|
+
try {
|
|
47
|
+
return statSync(path).isFile();
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/** A thrown value as text. A value with no string conversion still gives a line. */
|
|
54
|
+
function errorText(error) {
|
|
55
|
+
if (error instanceof Error)
|
|
56
|
+
return error.message;
|
|
57
|
+
try {
|
|
58
|
+
return String(error);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return 'a thrown value with no string form';
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/** Child folder names in load order; a missing folder is an empty list. */
|
|
65
|
+
function pluginFolders(dir, warn) {
|
|
66
|
+
let entries;
|
|
67
|
+
try {
|
|
68
|
+
entries = readdirSync(dir, { withFileTypes: true });
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
if (error.code !== 'ENOENT')
|
|
72
|
+
warn(`[hsq] plugin folder ${dir} unreadable: ${errorText(error)}`);
|
|
73
|
+
return [];
|
|
74
|
+
}
|
|
75
|
+
return entries.filter(entry => isDirectoryEntry(dir, entry)).map(entry => entry.name).sort(byCodePoint);
|
|
76
|
+
}
|
|
77
|
+
/** Import one plugin folder's entry and run its setup. Throws the reason the plugin is skipped. */
|
|
78
|
+
async function loadOne(path) {
|
|
79
|
+
const entry = PLUGIN_ENTRY_FILES.map(file => join(path, file)).find(isFile);
|
|
80
|
+
if (!entry)
|
|
81
|
+
throw new PluginLoadFailure('missing-entry', `missing ${PLUGIN_ENTRY_FILES.join(' or ')}`);
|
|
82
|
+
const entryModule = await import(__rewriteRelativeImportExtension(pathToFileURL(entry).href)).catch((error) => {
|
|
83
|
+
throw new PluginLoadFailure('import', errorText(error));
|
|
84
|
+
});
|
|
85
|
+
if (typeof entryModule.default !== 'function')
|
|
86
|
+
throw new PluginLoadFailure('no-setup', `${entry.slice(path.length + 1)} has no default-exported setup function`);
|
|
87
|
+
return runPluginSetup(entryModule.default).catch((error) => {
|
|
88
|
+
throw new PluginLoadFailure('setup', errorText(error));
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Load every plugin folder under `dir` in code-point order of folder name and add the outcome to
|
|
93
|
+
* the process report. Installs the `@hearsay-tools/squawk/plugin` resolve hook first.
|
|
94
|
+
*/
|
|
95
|
+
export async function loadPluginFolder({ dir, source, warn = line => { process.stderr.write(`${line}\n`); } }) {
|
|
96
|
+
const names = pluginFolders(dir, warn);
|
|
97
|
+
const loaded = [];
|
|
98
|
+
const failed = [];
|
|
99
|
+
if (names.length > 0)
|
|
100
|
+
installPluginResolveHook();
|
|
101
|
+
for (const name of names) {
|
|
102
|
+
const path = join(dir, name);
|
|
103
|
+
try {
|
|
104
|
+
loaded.push(Object.freeze({ name, source, path, contributions: await loadOne(path) }));
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
const reason = error instanceof PluginLoadFailure ? error.reason : 'setup';
|
|
108
|
+
const failure = Object.freeze({ name, source, path, reason, error: errorText(error) });
|
|
109
|
+
failed.push(failure);
|
|
110
|
+
warn(`[hsq] plugin "${name}" skipped: ${failure.error}`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
report = Object.freeze({
|
|
114
|
+
folders: Object.freeze([...report.folders, dir]),
|
|
115
|
+
loaded: Object.freeze([...report.loaded, ...loaded]),
|
|
116
|
+
failed: Object.freeze([...report.failed, ...failed]),
|
|
117
|
+
});
|
|
118
|
+
return report;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The text health sends for each reason. A plugin's own message can name host paths or carry a
|
|
122
|
+
* secret, and health is CORS-open, so health never sends it; `hsq plugins` on the host does.
|
|
123
|
+
*/
|
|
124
|
+
export const PLUGIN_FAILURE_TEXT = {
|
|
125
|
+
'missing-entry': 'missing index.mjs or index.js',
|
|
126
|
+
'no-setup': 'the entry has no default-exported setup function',
|
|
127
|
+
import: 'the entry failed to import; run `hsq plugins` on the host for the error',
|
|
128
|
+
setup: 'setup failed or a registration was refused; run `hsq plugins` on the host for the error',
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* The health payload for a report. A local cockpit sends each plugin's folder; a hosted one
|
|
132
|
+
* (`HSQ_REMOTE=1` or a non-loopback bind) sends no path. A skipped plugin's error is always the
|
|
133
|
+
* fixed text for its reason.
|
|
134
|
+
*/
|
|
135
|
+
export function pluginHealth(source, { hostPaths }) {
|
|
136
|
+
const entry = (plugin) => hostPaths ? { name: plugin.name, source: plugin.source, path: plugin.path } : { name: plugin.name, source: plugin.source };
|
|
137
|
+
return {
|
|
138
|
+
loaded: source.loaded.map(entry),
|
|
139
|
+
failed: source.failed.map(plugin => ({ ...entry(plugin), error: PLUGIN_FAILURE_TEXT[plugin.reason] })),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/plugin/loader.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAe,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,cAAc,EAA+C,MAAM,UAAU,CAAC;AACvF,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AA+B7D,MAAM,iBAAkB,SAAQ,KAAK;IACd,MAAM;IAA3B,YAAqB,MAA2B,EAAE,OAAe;QAC/D,KAAK,CAAC,OAAO,CAAC,CAAC;sBADI,MAAM;IAE3B,CAAC;CACF;AASD,MAAM,YAAY,GAAqB,MAAM,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;AAC9F,IAAI,MAAM,GAAqB,YAAY,CAAC;AAE5C,mGAAmG;AACnG,MAAM,UAAU,gBAAgB;IAC9B,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,wEAAwE;AACxE,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,WAAW,EAAE,UAAU,CAAU,CAAC;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AAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;KACvG,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** The one public plugin entry (spec 2026-11-24-plugin-loader-and-runner-kit § 4). */
|
|
2
|
+
export declare const PLUGIN_ENTRY_SPECIFIER = "@hearsay-tools/squawk/plugin";
|
|
3
|
+
/**
|
|
4
|
+
* The running copy's plugin entry: `index.ts` next to this file under source (tsx, Node type
|
|
5
|
+
* stripping, Vitest), `index.js` next to it under the built `dist/`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function runningPluginEntryUrl(moduleUrl?: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Map `@hearsay-tools/squawk/plugin` to the running copy for every later import in this process,
|
|
10
|
+
* so a plugin outside the repository and a built-in runner share one set of module state. Any other
|
|
11
|
+
* specifier in the package (its root, a deeper subpath) is refused: it has no running copy to map
|
|
12
|
+
* to, and an installed copy would split process state. Installs once; a second call does nothing.
|
|
13
|
+
* Loads no runner code.
|
|
14
|
+
*/
|
|
15
|
+
export declare function installPluginResolveHook(): void;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { registerHooks } from 'node:module';
|
|
2
|
+
import { extname } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
/** The one public plugin entry (spec 2026-11-24-plugin-loader-and-runner-kit § 4). */
|
|
5
|
+
export const PLUGIN_ENTRY_SPECIFIER = '@hearsay-tools/squawk/plugin';
|
|
6
|
+
/**
|
|
7
|
+
* The running copy's plugin entry: `index.ts` next to this file under source (tsx, Node type
|
|
8
|
+
* stripping, Vitest), `index.js` next to it under the built `dist/`.
|
|
9
|
+
*/
|
|
10
|
+
export function runningPluginEntryUrl(moduleUrl = import.meta.url) {
|
|
11
|
+
return new URL(`./index${extname(fileURLToPath(moduleUrl))}`, moduleUrl).href;
|
|
12
|
+
}
|
|
13
|
+
let installed = false;
|
|
14
|
+
/** Squawk's own package. Any specifier in it other than the plugin entry would load a second copy. */
|
|
15
|
+
const PACKAGE_NAME = '@hearsay-tools/squawk';
|
|
16
|
+
/**
|
|
17
|
+
* Map `@hearsay-tools/squawk/plugin` to the running copy for every later import in this process,
|
|
18
|
+
* so a plugin outside the repository and a built-in runner share one set of module state. Any other
|
|
19
|
+
* specifier in the package (its root, a deeper subpath) is refused: it has no running copy to map
|
|
20
|
+
* to, and an installed copy would split process state. Installs once; a second call does nothing.
|
|
21
|
+
* Loads no runner code.
|
|
22
|
+
*/
|
|
23
|
+
export function installPluginResolveHook() {
|
|
24
|
+
if (installed)
|
|
25
|
+
return;
|
|
26
|
+
installed = true;
|
|
27
|
+
const url = runningPluginEntryUrl();
|
|
28
|
+
registerHooks({
|
|
29
|
+
resolve(specifier, context, nextResolve) {
|
|
30
|
+
if (specifier === PLUGIN_ENTRY_SPECIFIER)
|
|
31
|
+
return { url, shortCircuit: true };
|
|
32
|
+
if (specifier === PACKAGE_NAME || specifier.startsWith(`${PACKAGE_NAME}/`)) {
|
|
33
|
+
throw new Error(`Cannot import ${specifier}: a plugin imports Squawk only from ${PLUGIN_ENTRY_SPECIFIER}.`);
|
|
34
|
+
}
|
|
35
|
+
return nextResolve(specifier, context);
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=resolve-hook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-hook.js","sourceRoot":"","sources":["../../src/plugin/resolve-hook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,sFAAsF;AACtF,MAAM,CAAC,MAAM,sBAAsB,GAAG,8BAA8B,CAAC;AAErE;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,SAAS,GAAW,OAAO,IAAI,CAAC,GAAG;IACvE,OAAO,IAAI,GAAG,CAAC,UAAU,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC,IAAI,CAAC;AAChF,CAAC;AAED,IAAI,SAAS,GAAG,KAAK,CAAC;AAEtB,sGAAsG;AACtG,MAAM,YAAY,GAAG,uBAAuB,CAAC;AAE7C;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB;IACtC,IAAI,SAAS;QAAE,OAAO;IACtB,SAAS,GAAG,IAAI,CAAC;IACjB,MAAM,GAAG,GAAG,qBAAqB,EAAE,CAAC;IACpC,aAAa,CAAC;QACZ,OAAO,CAAC,SAAS,EAAE,OAAO,EAAE,WAAW;YACrC,IAAI,SAAS,KAAK,sBAAsB;gBAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;YAC7E,IAAI,SAAS,KAAK,YAAY,IAAI,SAAS,CAAC,UAAU,CAAC,GAAG,YAAY,GAAG,CAAC,EAAE,CAAC;gBAC3E,MAAM,IAAI,KAAK,CAAC,iBAAiB,SAAS,uCAAuC,sBAAsB,GAAG,CAAC,CAAC;YAC9G,CAAC;YACD,OAAO,WAAW,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACzC,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The best of `offers` for this `Accept`, or `null` for "no preference expressed" — which is what
|
|
3
|
+
* an absent header, a `*<slash>*`-only header and a header naming nothing on offer all mean, and
|
|
4
|
+
* what leaves the caller on its route's default.
|
|
5
|
+
*
|
|
6
|
+
* `offers` is the server's own preference order: an offer may itself be a wildcard (`image/*`,
|
|
7
|
+
* since the concrete image type is not known until the file is read), and equal q-values go to the
|
|
8
|
+
* EARLIER offer, so each route lists its default representation first.
|
|
9
|
+
*/
|
|
10
|
+
export declare function negotiate<O extends string>(accept: string | undefined, offers: readonly O[]): O | null;
|
|
11
|
+
/** What `GET /repo/commit/:sha` offers, DEFAULT FIRST: the legacy `text/plain` blob is what a
|
|
12
|
+
* request with no opinion has always received, so it also wins an Accept tie. */
|
|
13
|
+
export declare const COMMIT_FORMATS: readonly ['text/plain', 'application/json'];
|
|
14
|
+
/** What `GET /runs/:id/files` offers, DEFAULT FIRST. `image/*` rather than a concrete type: which
|
|
15
|
+
* image type the bytes are is only known once the path resolves, and the raw branch refuses
|
|
16
|
+
* everything that is not an image anyway. */
|
|
17
|
+
export declare const FILE_FORMATS: readonly ['application/json', 'image/*'];
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
function parseAccept(header) {
|
|
2
|
+
const ranges = [];
|
|
3
|
+
for (const part of header.split(',')) {
|
|
4
|
+
const [range = '', ...params] = part.split(';');
|
|
5
|
+
const [type = '', subtype = ''] = range.trim().toLowerCase().split('/');
|
|
6
|
+
if (type === '' || subtype === '')
|
|
7
|
+
continue;
|
|
8
|
+
const weight = params.map((p) => p.trim().toLowerCase()).find((p) => p.startsWith('q='));
|
|
9
|
+
const parsed = weight === undefined ? 1 : Number.parseFloat(weight.slice(2));
|
|
10
|
+
const q = Number.isFinite(parsed) ? Math.min(Math.max(parsed, 0), 1) : 0;
|
|
11
|
+
if (q > 0)
|
|
12
|
+
ranges.push({ type, subtype, q });
|
|
13
|
+
}
|
|
14
|
+
return ranges;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The best of `offers` for this `Accept`, or `null` for "no preference expressed" — which is what
|
|
18
|
+
* an absent header, a `*<slash>*`-only header and a header naming nothing on offer all mean, and
|
|
19
|
+
* what leaves the caller on its route's default.
|
|
20
|
+
*
|
|
21
|
+
* `offers` is the server's own preference order: an offer may itself be a wildcard (`image/*`,
|
|
22
|
+
* since the concrete image type is not known until the file is read), and equal q-values go to the
|
|
23
|
+
* EARLIER offer, so each route lists its default representation first.
|
|
24
|
+
*/
|
|
25
|
+
export function negotiate(accept, offers) {
|
|
26
|
+
if (accept === undefined)
|
|
27
|
+
return null;
|
|
28
|
+
const ranges = parseAccept(accept);
|
|
29
|
+
let best = null;
|
|
30
|
+
for (const offer of offers) {
|
|
31
|
+
const [type = '', subtype = ''] = offer.split('/');
|
|
32
|
+
let q = 0;
|
|
33
|
+
for (const range of ranges) {
|
|
34
|
+
if (range.type === '*' && range.subtype === '*')
|
|
35
|
+
continue; // "anything" is not a preference
|
|
36
|
+
const typeMatches = range.type === type || range.type === '*' || type === '*';
|
|
37
|
+
const subtypeMatches = range.subtype === subtype || range.subtype === '*' || subtype === '*';
|
|
38
|
+
if (typeMatches && subtypeMatches && range.q > q)
|
|
39
|
+
q = range.q;
|
|
40
|
+
}
|
|
41
|
+
if (q > 0 && (best === null || q > best.q))
|
|
42
|
+
best = { offer, q };
|
|
43
|
+
}
|
|
44
|
+
return best?.offer ?? null;
|
|
45
|
+
}
|
|
46
|
+
/** What `GET /repo/commit/:sha` offers, DEFAULT FIRST: the legacy `text/plain` blob is what a
|
|
47
|
+
* request with no opinion has always received, so it also wins an Accept tie. */
|
|
48
|
+
export const COMMIT_FORMATS = ['text/plain', 'application/json'];
|
|
49
|
+
/** What `GET /runs/:id/files` offers, DEFAULT FIRST. `image/*` rather than a concrete type: which
|
|
50
|
+
* image type the bytes are is only known once the path resolves, and the raw branch refuses
|
|
51
|
+
* everything that is not an image anyway. */
|
|
52
|
+
export const FILE_FORMATS = ['application/json', 'image/*'];
|
|
53
|
+
//# sourceMappingURL=accept-negotiation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accept-negotiation.js","sourceRoot":"","sources":["../../src/server/accept-negotiation.ts"],"names":[],"mappings":"AA2BA,SAAS,WAAW,CAAC,MAAc;IACjC,MAAM,MAAM,GAAiB,EAAE,CAAC;IAChC,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACrC,MAAM,CAAC,KAAK,GAAG,EAAE,EAAE,GAAG,MAAM,CAAC,GAAG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3
|
+
export declare function hostnameOfHost(host: string | undefined): string;
|
|
4
|
+
/** The `hostname:port` authority of a `Host` header, e.g. `127.0.0.1:4321`.
|
|
5
|
+
*
|
|
6
|
+
* The port is kept verbatim and is `''` when the header omits it — which is
|
|
7
|
+
* exactly when a browser also omits it from `Origin` (both drop the scheme's
|
|
8
|
+
* default port). That symmetry is what lets us compare the two without knowing
|
|
9
|
+
* our own scheme, which we cannot know behind a TLS-terminating proxy. */
|
|
10
|
+
export declare function authorityOfHost(host: string | undefined): string;
|
|
11
|
+
/** The `hostname:port` authority of an `Origin` header, or `null` when it is not
|
|
12
|
+
* a parseable http(s) URL (the opaque `"null"` origin of a sandboxed iframe, a
|
|
13
|
+
* `file://` page). `URL.port` is `''` for a scheme's default port, matching
|
|
14
|
+
* `authorityOfHost`. */
|
|
15
|
+
export declare function authorityOfOrigin(origin: string): string | null;
|
|
16
|
+
/** The hostname of an `Origin` header, or `null` when it is not a parseable URL
|
|
17
|
+
* (e.g. the opaque `"null"` origin of a sandboxed iframe). Normalized through
|
|
18
|
+
* the same path as `hostnameOfHost` so the two compare equal for IPv6 and for
|
|
19
|
+
* trailing-dot FQDNs. */
|
|
20
|
+
export declare function hostnameOfOrigin(origin: string): string | null;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { normalizeHostname } from './capabilities.js';
|
|
2
|
+
/** The bare hostname of a `Host` header — see `normalizeHostname`. `''` when the
|
|
3
|
+
* header is absent, which no allowlist matches. */
|
|
4
|
+
export function hostnameOfHost(host) {
|
|
5
|
+
return host ? normalizeHostname(host) : '';
|
|
6
|
+
}
|
|
7
|
+
/** The `hostname:port` authority of a `Host` header, e.g. `127.0.0.1:4321`.
|
|
8
|
+
*
|
|
9
|
+
* The port is kept verbatim and is `''` when the header omits it — which is
|
|
10
|
+
* exactly when a browser also omits it from `Origin` (both drop the scheme's
|
|
11
|
+
* default port). That symmetry is what lets us compare the two without knowing
|
|
12
|
+
* our own scheme, which we cannot know behind a TLS-terminating proxy. */
|
|
13
|
+
export function authorityOfHost(host) {
|
|
14
|
+
if (!host)
|
|
15
|
+
return '';
|
|
16
|
+
const port = host.match(/^\[[^\]]*\]:(\d+)$/)?.[1] ?? host.match(/^[^:]*:(\d+)$/)?.[1] ?? '';
|
|
17
|
+
return `${normalizeHostname(host)}:${port}`;
|
|
18
|
+
}
|
|
19
|
+
/** The `hostname:port` authority of an `Origin` header, or `null` when it is not
|
|
20
|
+
* a parseable http(s) URL (the opaque `"null"` origin of a sandboxed iframe, a
|
|
21
|
+
* `file://` page). `URL.port` is `''` for a scheme's default port, matching
|
|
22
|
+
* `authorityOfHost`. */
|
|
23
|
+
export function authorityOfOrigin(origin) {
|
|
24
|
+
try {
|
|
25
|
+
const u = new URL(origin);
|
|
26
|
+
if (u.protocol !== 'http:' && u.protocol !== 'https:')
|
|
27
|
+
return null;
|
|
28
|
+
return `${normalizeHostname(u.hostname)}:${u.port}`;
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** The hostname of an `Origin` header, or `null` when it is not a parseable URL
|
|
35
|
+
* (e.g. the opaque `"null"` origin of a sandboxed iframe). Normalized through
|
|
36
|
+
* the same path as `hostnameOfHost` so the two compare equal for IPv6 and for
|
|
37
|
+
* trailing-dot FQDNs. */
|
|
38
|
+
export function hostnameOfOrigin(origin) {
|
|
39
|
+
try {
|
|
40
|
+
return normalizeHostname(new URL(origin).hostname);
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=host-authority.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-authority.js","sourceRoot":"","sources":["../../src/server/host-authority.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD;oDACoD;AACpD,MAAM,UAAU,cAAc,CAAC,IA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