@hraness/sponge 0.3.2 → 0.3.3

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.
@@ -8,7 +8,7 @@ import { command, usageOf } from './commands.js';
8
8
  import { openLibrary } from '../store/index.js';
9
9
  import { defaultCapturePins } from '../acquisition/index.js';
10
10
  import { failure } from '../acquisition/errors.js';
11
- import { SpongeError, codeOf, publicCode, exitFor, hints, debugChain } from '../errors.js';
11
+ import { SpongeError, codeOf, publicCode, exitFor, hints, detailHints, debugChain, } from '../errors.js';
12
12
  /** Failures print one categorical JSON line: the public code, its specific `reason` when narrower, and a fixed hint.
13
13
  * Causes, details, paths and upstream messages appear only with --debug or SPONGE_DEBUG=1. */
14
14
  function report(error, requestId, debug) {
@@ -17,7 +17,7 @@ function report(error, requestId, debug) {
17
17
  process.stderr.write(JSON.stringify({ issues }) + '\n');
18
18
  const hint = code === 'invalid-input' && typeof usage === 'string' && command(usage)
19
19
  ? `Usage: ${usageOf(usage).replace(/\n/g, ' | ')}`
20
- : hints[code];
20
+ : (detailHints[reason] ?? hints[code]);
21
21
  process.stderr.write(JSON.stringify({ ...failure(requestId, code), ...(reason !== code ? { reason } : {}), hint }) + '\n');
22
22
  if (debug)
23
23
  process.stderr.write(debugChain(error));
@@ -610,7 +610,7 @@ export async function draftDigest(input) {
610
610
  result = await attempt(await call([...messages, { role: 'assistant', content: first }, { role: 'user', content: repairPrompt(result.issues) }], schema));
611
611
  }
612
612
  if (!result.draft)
613
- throw new SpongeError('unavailable', { issues: result.issues });
613
+ throw new SpongeError('draft-rejected', { issues: result.issues });
614
614
  let issues = result.issues;
615
615
  if (issues.length) {
616
616
  trace.dropped = prune(result.draft, issues, source, options);
@@ -618,7 +618,7 @@ export async function draftDigest(input) {
618
618
  if (result.draft.digest.ideas.length < L.minIdeas)
619
619
  issues = [...issues.filter((i) => !(i.path === 'ideas' && i.code === 'count')), { path: 'ideas', code: 'count' }];
620
620
  if (issues.length)
621
- throw new SpongeError('unavailable', { issues });
621
+ throw new SpongeError('draft-rejected', { issues });
622
622
  }
623
623
  const producer = {
624
624
  pipeline: 'sponge-digest',
@@ -16,6 +16,7 @@ declare const parents: {
16
16
  readonly 'not-digest': "unsupported";
17
17
  readonly malformed: "invalid-input";
18
18
  readonly 'no-capture': "invalid-input";
19
+ readonly 'draft-rejected': "unavailable";
19
20
  readonly 'parent-missing': "invalid-input";
20
21
  readonly 'target-exists': "invalid-input";
21
22
  };
@@ -27,6 +28,8 @@ export declare const isSpongeCode: (value: unknown) => value is SpongeCode;
27
28
  export declare const exitStatus: Readonly<Record<ErrorCode, number>>;
28
29
  /** The one code→user-facing hint table. Fixed text only: never paths, sources, credentials or upstream prose. */
29
30
  export declare const hints: Readonly<Record<ErrorCode, string>>;
31
+ /** Hints for detail codes whose public code's hint would mislead. Fixed text only, like `hints`. */
32
+ export declare const detailHints: Readonly<Partial<Record<DetailCode, string>>>;
30
33
  export interface SpongeErrorOptions {
31
34
  detail?: Record<string, unknown>;
32
35
  cause?: unknown;
@@ -30,6 +30,7 @@ const parents = {
30
30
  'not-digest': 'unsupported',
31
31
  malformed: 'invalid-input',
32
32
  'no-capture': 'invalid-input',
33
+ 'draft-rejected': 'unavailable',
33
34
  'parent-missing': 'invalid-input',
34
35
  'target-exists': 'invalid-input',
35
36
  };
@@ -77,6 +78,10 @@ export const hints = {
77
78
  'schema-newer': 'This library was written by a newer Sponge. Upgrade Sponge.',
78
79
  'owner-busy': 'Another Sponge process owns the library. Wait for it, or run `sponge queue recover` after it stops.',
79
80
  };
81
+ /** Hints for detail codes whose public code's hint would mislead. Fixed text only, like `hints`. */
82
+ export const detailHints = {
83
+ 'draft-rejected': 'The model draft failed the digest checks listed above, even after one repair. Run it again; drafts vary.',
84
+ };
80
85
  /** The one error type. `message` is the code, so bare `String(error)` never carries detail, paths or causes. */
81
86
  export class SpongeError extends Error {
82
87
  code;
@@ -27,14 +27,14 @@
27
27
  }
28
28
  ],
29
29
  "build": {
30
- "asrSourceSha256": "8bd77ebffabae786902304eacb983fc950f70c981fb1538696517d85052c9407",
30
+ "asrSourceSha256": "e2e38c4beb276bf8e625e89f4694dcf6a89526621b0a056b590325bc7fb92314",
31
31
  "clangVersion": "Apple clang version 21.0.0 (clang-2100.1.1.101)",
32
- "embeddingSourceSha256": "2b0cd2b9c52c9dee578a3be50a443d528d5204d47f3f9ba750f6a1f37a191e78",
32
+ "embeddingSourceSha256": "38ba64989463d38bf6100636a2b1569e43cc32fbe640da6cc4bf0d8b24409c8a",
33
33
  "swiftVersion": "Apple Swift version 6.3.3 (swiftlang-6.3.3.1.3 clang-2100.1.1.101)"
34
34
  },
35
35
  "minimumMacOS": "26.0",
36
- "packageVersion": "0.3.2",
36
+ "packageVersion": "0.3.3",
37
37
  "platform": "darwin",
38
38
  "schemaVersion": 1,
39
- "sourceCommit": "e9eb0613365859c5809a05e8ad909504ac6e8d66"
39
+ "sourceCommit": "b1de42fa724be73e352c34357d42a1ca3946d5b5"
40
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hraness/sponge",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "A local library for captured articles and verified offline assets.",
5
5
  "repository": {
6
6
  "type": "git",