@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.
@@ -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 { resolveAttachmentPathAsync } from '../workflows/attachment-path.js';
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) => async (c) => {
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
- return staticResponse(c.req.raw, path, { 'content-type': type });
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', async (c) => {
596
- const response = await staticFile('live-worker.js', 'text/javascript; charset=utf-8')(c);
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 = async (c) => {
597
+ const serveShell = (c) => {
602
598
  const distIndex = join(distDir, 'index.html');
603
- // Async stat per request, like the reads below: `npm run build:web` in a
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: await isFile(distIndex),
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 staticResponse(c.req.raw, distIndex, { 'content-type': HTML_TYPE });
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 readFile would throw EISDIR), so dot-segments
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', async (c) => {
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
- return staticResponse(c.req.raw, path, {
635
- 'content-type': assetContentType(file),
636
- 'cache-control': ASSET_CACHE_CONTROL,
637
- }, true);
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), async (c) => {
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 = await resolveAttachmentPathAsync(store.claims.sourceDataDir(run.id), run.id, file);
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(await readFile(path), {
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('*', async (c) => await serveShell(c) ?? c.notFound());
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. */