@theoremjs/web 0.3.4-next.484.g20d8b9d → 0.3.4-next.508.geda6db0

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/README.md CHANGED
@@ -485,7 +485,7 @@ On the browser side, `@theoremjs/web/client` reads what your server sends:
485
485
  | `fetchConversation(url, body, options?)` | POSTs a conversation read, and checks the view your server answers. |
486
486
  | `fetchRewound(url, body, options?)` | POSTs a rewind, and checks the rewound conversation. |
487
487
  | `fetchStarted(url, body, options?)` | POSTs blocks to start a conversation on, and checks the started conversation. |
488
- | `failedDecisionTraces(err)` | The trace records that a failed decision left, for the trace inspector. |
488
+ | `failedTraces(err)` | The trace records that a failed decision left, for the trace inspector. |
489
489
 
490
490
  ## More documentation
491
491
 
@@ -13,11 +13,8 @@ export type DecisionQuestionView = {
13
13
  type: DecisionQuestion['type'];
14
14
  /** A choice's labels, a score's levels from 0 up; empty for a number. */
15
15
  labels: string[];
16
- /**
17
- * A box's image: the one its question gives, a reference or a state field, else the field its
18
- * instructions first name in backticks.
19
- */
20
- field?: string;
16
+ /** A box's image, as its question gives it: a reference, or the state field that holds one. */
17
+ image?: string;
21
18
  };
22
19
  /** What a decision profile shows the page. */
23
20
  export type DecisionInterface = {
@@ -57,7 +54,6 @@ export interface DecisionTransport {
57
54
  export declare function withFailedTraces(err: unknown, traces: readonly TraceRecord[]): unknown;
58
55
  /** The trace records a failed decision left; none when its host sent none. */
59
56
  export declare function failedTraces(err: unknown): readonly TraceRecord[];
60
- export declare const failedDecisionTraces: typeof failedTraces;
61
57
  /** POSTs `body` and reads its reply with `read`; a failure keeps the trace records its body carried. */
62
58
  export declare function postWithTraces<Reply>(url: string, body: unknown, signal: AbortSignal | undefined, options: HttpOptions, read: (raw: unknown) => Reply): Promise<Reply>;
63
59
  /** POSTs a decision and reads its reply; a failure keeps the trace records its body carried. */
@@ -14,21 +14,6 @@ function entryLabel(entry, fallback) {
14
14
  const entries = Array.isArray(entry) ? entry : Object.keys(entry);
15
15
  return entries.length ? entryLabel(entries[0], fallback) : fallback;
16
16
  }
17
- function withField(field) {
18
- return field === undefined ? {} : { field };
19
- }
20
- /** The first field an entry names in backticks, as in "the mug in `photo`". */
21
- function namedField(entry) {
22
- if (typeof entry === 'string')
23
- return /\x60([^\x60\s]+)\x60/.exec(entry)?.[1];
24
- const entries = Array.isArray(entry) ? entry : Object.values(entry);
25
- for (const each of entries) {
26
- const field = namedField(each);
27
- if (field !== undefined)
28
- return field;
29
- }
30
- return undefined;
31
- }
32
17
  /** The page's view of a decision profile, the questions its host asks, and the host's own images. */
33
18
  export function decisionInterface(profile, questions, images) {
34
19
  return {
@@ -46,9 +31,7 @@ export function decisionInterface(profile, questions, images) {
46
31
  : question.type === 'score'
47
32
  ? question.criteria.map((entry, level) => entryLabel(entry, String(level)))
48
33
  : [],
49
- ...(question.type === 'box'
50
- ? withField(question.image ?? namedField(question.instructions))
51
- : {}),
34
+ ...(question.type === 'box' && question.image !== undefined ? { image: question.image } : {}),
52
35
  })),
53
36
  ...(images && Object.keys(images).length > 0 ? { images } : {}),
54
37
  ...(profile.observability
@@ -68,10 +51,9 @@ export function decisionAssets(host, page) {
68
51
  const all = { ...host, ...page };
69
52
  return Object.keys(all).length > 0 ? all : undefined;
70
53
  }
54
+ // why: The host's kernel checks each answer against its question; the page checks only the shape it draws.
71
55
  const probability = z.number().min(0).max(1);
72
- const probabilities = z
73
- .record(z.string(), probability)
74
- .refine((record) => Math.abs(Object.values(record).reduce((sum, value) => sum + value, 0) - 1) <= 0.001);
56
+ const probabilities = z.record(z.string(), probability);
75
57
  const answerSchema = z.discriminatedUnion('type', [
76
58
  z.object({
77
59
  type: z.literal('choice'),
@@ -119,7 +101,6 @@ export function withFailedTraces(err, traces) {
119
101
  export function failedTraces(err) {
120
102
  return (typeof err === 'object' && err !== null && traceFailures.get(err)) || [];
121
103
  }
122
- export const failedDecisionTraces = failedTraces;
123
104
  const failedBody = z.object({ traces: z.array(traceRecordSchema) });
124
105
  /** POSTs `body` and reads its reply with `read`; a failure keeps the trace records its body carried. */
125
106
  export async function postWithTraces(url, body, signal, options, read) {
@@ -155,7 +136,7 @@ const describedSchema = z.object({
155
136
  id: z.string(),
156
137
  type: z.enum(['choice', 'noul', 'score', 'box']),
157
138
  labels: z.array(z.string()),
158
- field: z.string().optional(),
139
+ image: z.string().optional(),
159
140
  })),
160
141
  images: z
161
142
  .record(z.string(), z.object({ mimeType: z.enum(['image/png', 'image/jpeg']), data: z.string() }))
package/client/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export { type ChatController, type ChatOptions, type ChatSlots, type ChatState,
3
3
  export { type ComposerDrawerKind, type ComposerDrawerSummary, composerDrawerSummary, } from './composer-drawer.ts';
4
4
  export { type ComposerHint, isStashShortcut, resolveComposerHint, STASH_SHORTCUT, } from './composer-hints.ts';
5
5
  export { type ComposerActionState, composerActionState, composerHasPayload, } from './composer-primary.ts';
6
- export { createDecisionTransport, type DecisionInterface, type DecisionQuestionView, type DecisionReply, type DecisionTransport, decisionAssets, decisionInterface, failedDecisionTraces, failedTraces, postDecision, readDecisionReply, withFailedTraces, } from './decision-transport.ts';
6
+ export { createDecisionTransport, type DecisionInterface, type DecisionQuestionView, type DecisionReply, type DecisionTransport, decisionAssets, decisionInterface, failedTraces, postDecision, readDecisionReply, withFailedTraces, } from './decision-transport.ts';
7
7
  export { type ComposerDraftFields, composerFieldsFromDraft } from './decode-composer-draft.ts';
8
8
  export { addUsage, checkEmbeddingInputs, checkInputs, cosineSimilarity, type EmbeddingFields, type EmbeddingInputCheck, type EmbeddingMatch, type EmbeddingMediaPart, type EmbeddingSplit, embeddingBatches, fieldsInput, inputFields, MAX_BATCH_INPUTS, rankMatches, readEmbeddingInput, readEmbeddingInputs, readsAsText, splitText, } from './embedding-input.ts';
9
9
  export { type EmbeddingSpace, layoutSpace, layoutSpaceSoon, outlierThreshold, placeQuery, type SpaceCluster, type SpaceDocument, type SpaceLink, type SpacePoint, } from './embedding-space.ts';
package/client/index.js CHANGED
@@ -3,7 +3,7 @@ export { createChatController, } from "./chat.js";
3
3
  export { composerDrawerSummary, } from "./composer-drawer.js";
4
4
  export { isStashShortcut, resolveComposerHint, STASH_SHORTCUT, } from "./composer-hints.js";
5
5
  export { composerActionState, composerHasPayload, } from "./composer-primary.js";
6
- export { createDecisionTransport, decisionAssets, decisionInterface, failedDecisionTraces, failedTraces, postDecision, readDecisionReply, withFailedTraces, } from "./decision-transport.js";
6
+ export { createDecisionTransport, decisionAssets, decisionInterface, failedTraces, postDecision, readDecisionReply, withFailedTraces, } from "./decision-transport.js";
7
7
  export { composerFieldsFromDraft } from "./decode-composer-draft.js";
8
8
  export { addUsage, checkEmbeddingInputs, checkInputs, cosineSimilarity, embeddingBatches, fieldsInput, inputFields, MAX_BATCH_INPUTS, rankMatches, readEmbeddingInput, readEmbeddingInputs, readsAsText, splitText, } from "./embedding-input.js";
9
9
  export { layoutSpace, layoutSpaceSoon, outlierThreshold, placeQuery, } from "./embedding-space.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theoremjs/web",
3
- "version": "0.3.4-next.484.g20d8b9d",
3
+ "version": "0.3.4-next.508.geda6db0",
4
4
  "description": "Theorem on the web platform, with no UI framework: Web-standard server handlers that serve a profile, and the browser client that talks to them.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -25,6 +25,6 @@
25
25
  },
26
26
  "peerDependencies": {
27
27
  "zod": "^4.6.5",
28
- "@theoremjs/agents": "^0.3.4-next.484.g20d8b9d"
28
+ "@theoremjs/agents": "^0.3.4-next.508.geda6db0"
29
29
  }
30
30
  }