@hearsay-tools/squawk 0.18.0-pr4108.7872 → 0.18.0-pr4110.7877
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/autosave-commit.js +46 -15
- package/dist/autosave-commit.js.map +1 -1
- package/dist/runners/acp/events.d.ts +7 -1
- package/dist/runners/acp/events.js +38 -3
- package/dist/runners/acp/events.js.map +1 -1
- package/dist/runners/acp/session.js +2 -2
- package/dist/runners/acp/session.js.map +1 -1
- package/dist/server/brand-file-routes.d.ts +1 -1
- package/dist/server/server.d.ts +477 -477
- package/dist/server/server.js +28 -26
- package/dist/server/server.js.map +1 -1
- package/dist/workflows/attachment-path.d.ts +0 -2
- package/dist/workflows/attachment-path.js +0 -21
- package/dist/workflows/attachment-path.js.map +1 -1
- package/package.json +4 -4
- package/dist/server/static-assets.d.ts +0 -5
- package/dist/server/static-assets.js +0 -109
- package/dist/server/static-assets.js.map +0 -1
package/dist/server/server.js
CHANGED
|
@@ -54,7 +54,7 @@ import { runRelationships } from './run-relationships.js';
|
|
|
54
54
|
import { delegationFailure } from '../delegation/routes.js';
|
|
55
55
|
import { githubItemParamsSchema } from '../contract/index.js';
|
|
56
56
|
import { workerDestroyRequestSchema, workerEmptyRequestSchema, runRelationshipsSchema } from '../contract/index.js';
|
|
57
|
-
import { existsSync } from 'node:fs';
|
|
57
|
+
import { existsSync, readFileSync, statSync } from 'node:fs';
|
|
58
58
|
import { randomUUID } from 'node:crypto';
|
|
59
59
|
import { createAutomationService, onceCreateAnswer } from '../automations/service.js';
|
|
60
60
|
import { createAutomationToolService } from '../automations/tool-adapter.js';
|
|
@@ -105,7 +105,7 @@ import { ownPullRequestNumbers } from '../runs/pull-requests.js';
|
|
|
105
105
|
import { ColdRepoHandles } from './cold-repo-handles.js';
|
|
106
106
|
import { isV2WireEventType } from '../runs/ui-event-sink.js';
|
|
107
107
|
import { runEventsQuerySchema, runHistoryQuerySchema, runIdParamSchema, } from '../contract/index.js';
|
|
108
|
-
import {
|
|
108
|
+
import { resolveAttachmentPath } from '../workflows/attachment-path.js';
|
|
109
109
|
import { artifactParamsSchema, fileLinkQuerySchema } from '../contract/index.js';
|
|
110
110
|
import { listArtifacts, readArtifact, readArtifactMetadata } from '../artifacts/store.js';
|
|
111
111
|
import { artifactPreview, loadFileLink, rasterMime } from '../artifacts/resolve.js';
|
|
@@ -153,7 +153,6 @@ import { providerForExistingRun, providersRequiredByWorkflow, } from './provider
|
|
|
153
153
|
import { attachProjectWebhooks, createBootContext, createProviderStatus, emitProviderRow, resolveServerDeps, watchProviderRuntimeAuth, } from './server-deps.js';
|
|
154
154
|
import { NO_WEBHOOK_ERROR, agentProfileRefusal, clientRequestOf, launchRun, modelLockRefusal, notifyRefusal, providerGateRefusal, replayedRun, resolveStartWorkflow, startRunInput, } from './start-run-options.js';
|
|
155
155
|
import { ASSET_CACHE_CONTROL, BUILD_HINT_HTML, assetContentType, isSafeAssetFilename, resolveGetRequest, } from './static-ui.js';
|
|
156
|
-
import { compression, createStaticAssets, isFile } from './static-assets.js';
|
|
157
156
|
import { registerBrandFileRoutes } from './brand-file-routes.js';
|
|
158
157
|
/** The hosted-mode refusal, worded like the agent-config one it mirrors. */
|
|
159
158
|
const HOSTED_GITHUB_CREATE_REFUSAL = 'Creating GitHub repositories is available from a local cockpit only';
|
|
@@ -482,11 +481,6 @@ export function createApp(deps) {
|
|
|
482
481
|
};
|
|
483
482
|
};
|
|
484
483
|
const app = new Hono();
|
|
485
|
-
app.use('*', compression);
|
|
486
|
-
// One cache per app: immutable bundle bytes and their negotiated encodings share a cap.
|
|
487
|
-
// Live shell and worker files bypass it so a rebuild appears on the next request.
|
|
488
|
-
// Compression runs outside route families and leaves live event streams untouched.
|
|
489
|
-
const staticResponse = createStaticAssets();
|
|
490
484
|
// Reject oversized request bodies before they reach any handler (#429). GETs
|
|
491
485
|
// and SSE carry no body, so this only ever gates the mutating routes.
|
|
492
486
|
app.use('*', bodyLimit({ maxSize: GLOBAL_BODY_LIMIT }));
|
|
@@ -580,7 +574,7 @@ export function createApp(deps) {
|
|
|
580
574
|
const webDir = resolveWebDir();
|
|
581
575
|
const distDir = join(webDir, 'dist');
|
|
582
576
|
const HTML_TYPE = 'text/html; charset=utf-8';
|
|
583
|
-
const staticFile = (name, type) =>
|
|
577
|
+
const staticFile = (name, type) => (c) => {
|
|
584
578
|
// Read per request — the files are tiny and this keeps dev iteration live.
|
|
585
579
|
//
|
|
586
580
|
// Served out of the Vite build: the files are `public/` assets of the web package, which the
|
|
@@ -589,22 +583,24 @@ export function createApp(deps) {
|
|
|
589
583
|
// paths. Without a build there is nothing to serve, which is a 404 rather than a crash (the
|
|
590
584
|
// shell route answers the same dev-only state with its build hint).
|
|
591
585
|
const path = join(distDir, name);
|
|
592
|
-
|
|
586
|
+
if (!existsSync(path))
|
|
587
|
+
return c.json({ error: 'not found' }, 404);
|
|
588
|
+
return new Response(readFileSync(path), { headers: { 'content-type': type } });
|
|
593
589
|
};
|
|
594
590
|
// Stable SharedWorker identity across same-origin tabs; its imported chunks stay hashed.
|
|
595
|
-
app.get('/live-worker.js',
|
|
596
|
-
const response =
|
|
591
|
+
app.get('/live-worker.js', (c) => {
|
|
592
|
+
const response = staticFile('live-worker.js', 'text/javascript; charset=utf-8')(c);
|
|
597
593
|
response.headers.set('Cache-Control', 'no-cache');
|
|
598
594
|
return response;
|
|
599
595
|
});
|
|
600
596
|
let hintLogged = false;
|
|
601
|
-
const serveShell =
|
|
597
|
+
const serveShell = (c) => {
|
|
602
598
|
const distIndex = join(distDir, 'index.html');
|
|
603
|
-
//
|
|
599
|
+
// existsSync per request, like the reads below: `npm run build:web` in a
|
|
604
600
|
// running cockpit takes effect on the next reload, no restart.
|
|
605
601
|
const target = resolveGetRequest({
|
|
606
602
|
path: c.req.path,
|
|
607
|
-
distExists:
|
|
603
|
+
distExists: existsSync(distIndex),
|
|
608
604
|
});
|
|
609
605
|
if (target === 'passthrough')
|
|
610
606
|
return undefined;
|
|
@@ -619,22 +615,28 @@ export function createApp(deps) {
|
|
|
619
615
|
headers: { 'content-type': HTML_TYPE },
|
|
620
616
|
});
|
|
621
617
|
}
|
|
622
|
-
return
|
|
618
|
+
return new Response(readFileSync(distIndex), {
|
|
619
|
+
headers: { 'content-type': HTML_TYPE },
|
|
620
|
+
});
|
|
623
621
|
};
|
|
624
622
|
// Hashed bundles/fonts of the built app. Vite fingerprints every name, so
|
|
625
623
|
// the bytes behind a URL never change — cache them hard. Only plain
|
|
626
624
|
// filenames are served: `basename('..')` is `'..'` (it resolves to the
|
|
627
|
-
// assets dir itself and
|
|
625
|
+
// assets dir itself and readFileSync would throw EISDIR), so dot-segments
|
|
628
626
|
// and separator-bearing params get a 404, not a 500.
|
|
629
|
-
app.get('/assets/:file',
|
|
627
|
+
app.get('/assets/:file', (c) => {
|
|
630
628
|
const file = c.req.param('file');
|
|
631
629
|
if (!isSafeAssetFilename(file))
|
|
632
630
|
return c.json({ error: 'not found' }, 404);
|
|
633
631
|
const path = join(distDir, 'assets', file);
|
|
634
|
-
|
|
635
|
-
'
|
|
636
|
-
|
|
637
|
-
|
|
632
|
+
if (!existsSync(path) || !statSync(path).isFile())
|
|
633
|
+
return c.json({ error: 'not found' }, 404);
|
|
634
|
+
return new Response(readFileSync(path), {
|
|
635
|
+
headers: {
|
|
636
|
+
'content-type': assetContentType(file),
|
|
637
|
+
'cache-control': ASSET_CACHE_CONTROL,
|
|
638
|
+
},
|
|
639
|
+
});
|
|
638
640
|
});
|
|
639
641
|
registerBrandFileRoutes(app, staticFile);
|
|
640
642
|
// ---- meta ----------------------------------------------------------------
|
|
@@ -2870,13 +2872,13 @@ export function createApp(deps) {
|
|
|
2870
2872
|
'content-type': 'text/markdown; charset=utf-8',
|
|
2871
2873
|
});
|
|
2872
2874
|
})
|
|
2873
|
-
.get('/runs/:id/images/:file', paramZodValidator(attachmentFileParamSchema),
|
|
2875
|
+
.get('/runs/:id/images/:file', paramZodValidator(attachmentFileParamSchema), (c) => {
|
|
2874
2876
|
const { store } = c.get('project');
|
|
2875
2877
|
const run = store.getRun(c.req.param('id'));
|
|
2876
2878
|
if (!run)
|
|
2877
2879
|
return c.json({ error: 'not found' }, 404);
|
|
2878
2880
|
const file = c.req.valid('param').file;
|
|
2879
|
-
const path =
|
|
2881
|
+
const path = resolveAttachmentPath(store.claims.sourceDataDir(run.id), run.id, file);
|
|
2880
2882
|
if (!path)
|
|
2881
2883
|
return c.json({ error: 'not found' }, 404);
|
|
2882
2884
|
const ext = file.split('.').pop() ?? '';
|
|
@@ -2884,7 +2886,7 @@ export function createApp(deps) {
|
|
|
2884
2886
|
// An image answers exactly as it always has — the cockpit renders it in an `<img>`.
|
|
2885
2887
|
// Everything else is a user-supplied file (#950) and leaves under the download headers.
|
|
2886
2888
|
const type = image ?? FILE_TYPES[ext] ?? 'application/octet-stream';
|
|
2887
|
-
return new Response(
|
|
2889
|
+
return new Response(readFileSync(path), {
|
|
2888
2890
|
headers: {
|
|
2889
2891
|
'content-type': type,
|
|
2890
2892
|
'cache-control': 'private, max-age=31536000, immutable',
|
|
@@ -4154,7 +4156,7 @@ export function createApp(deps) {
|
|
|
4154
4156
|
// an unknown API path must never answer with HTML.
|
|
4155
4157
|
// Without a web/dist build this serves the built-in build-hint page (dev-only
|
|
4156
4158
|
// state — the published tarball ships web/dist), never a 404.
|
|
4157
|
-
routed.get('*',
|
|
4159
|
+
routed.get('*', (c) => serveShell(c) ?? c.notFound());
|
|
4158
4160
|
return routed;
|
|
4159
4161
|
}
|
|
4160
4162
|
/** The host a thread link names (#589): the bound one, or loopback for a wildcard bind. */
|