@opendatalabs/personal-server-ts-server 1.14.0 → 1.16.0

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/app.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qDAAqD,CAAC;AACxF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yDAAyD,CAAC;AACvG,OAAO,KAAK,EACV,4BAA4B,EAC5B,aAAa,EACd,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAC;AAClF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0DAA0D,CAAC;AAChG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6DAA6D,CAAC;AACnG,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,2CAA2C,CAAC;AACvG,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIlE,OAAO,EAGL,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACvB,MAAM,6CAA6C,CAAC;AAWrD,OAAO,EACL,mBAAmB,EAGnB,KAAK,kBAAkB,EACvB,KAAK,0BAA0B,EAChC,MAAM,2CAA2C,CAAC;AASnD,OAAO,KAAK,EACV,oBAAoB,EACpB,WAAW,EACZ,MAAM,4CAA4C,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAC;AAClF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAC;AACxF,OAAO,KAAK,EACV,aAAa,EACb,kBAAkB,EACnB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,KAAK,EACV,eAAe,EACf,uBAAuB,EACxB,MAAM,6CA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C;IACpC;;;OAGG;IACH,iBAAiB,CAAC,EAAE;QAClB,KAAK,EAAE,aAAa,CAAC;QACrB,SAAS,EAAE,kBAAkB,CAAC;KAC/B,GAAG,IAAI,CAAC;IACT,eAAe,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAChD;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACvD;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,0BAA0B,CAAC,EAAE,0BAA0B,CAAC;IACxD,mBAAmB,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC;IAC9C,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC;;;OAGG;IACH,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;CAC/C;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAiT7C"}
package/dist/app.js CHANGED
@@ -70,13 +70,17 @@ export function createApp(deps) {
70
70
  lineageGateway: deps.lineageGateway,
71
71
  writeSessionStore,
72
72
  writeProofReplayStore,
73
- // Recompute on refresh: a new local version of a scope marks every
74
- // question that reads it stale.
73
+ // A new local version of a scope marks every question that reads it
74
+ // stale; the recompute waits for a reader.
75
75
  onDataWritten: deps.derivativeCompute
76
76
  ? (event) => deps.derivativeCompute?.scheduler.markSourceChanged(event.scope, {
77
77
  lineageSources: event.lineageSources,
78
78
  })
79
79
  : undefined,
80
+ // And an authorized read of a derived scope is that reader.
81
+ onDataRead: deps.derivativeCompute
82
+ ? (event) => deps.derivativeCompute?.scheduler.markDemand(event.scope)
83
+ : undefined,
80
84
  mountPath: "/v1/data",
81
85
  }));
82
86
  // Derivative compute: question registration + readiness for builders.
package/dist/app.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"app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C;IACJ,CAAC,CAAC,CAAC;IAEH,eAAe;IACf,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE;QACjB,OAAO,CAAC,CAAC,IAAI,CACX;YACE,KAAK,EAAE;gBACL,IAAI,EAAE,GAAG;gBACT,SAAS,EAAE,WAAW;gBACtB,OAAO,EAAE,WAAW;aACrB;SACF,EACD,GAAG,CACJ,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC"}
package/dist/bootstrap.js CHANGED
@@ -224,7 +224,7 @@ export async function createServer(config, options) {
224
224
  serverOwner,
225
225
  logger,
226
226
  compute: (questionId) => computeQuestion(questionId, {
227
- // A -> B -> C: a question reading this derived scope recomputes.
227
+ // A -> B -> C: a question reading this derived scope goes stale.
228
228
  onDerivedWritten: (event) => derivativeScheduler.markSourceChanged(event.scope, {
229
229
  lineageSources: event.lineageSources,
230
230
  }),
@@ -73,12 +73,16 @@ export interface DataRouteDeps {
73
73
  * can only cite local scopes; lineage read / cascade answer 503 / 501.
74
74
  */
75
75
  lineageGateway?: LineageGatewayPort;
76
- /** Post-commit write hook (derivative recompute on refresh). */
76
+ /** Post-commit write hook (marks derivative questions stale). */
77
77
  onDataWritten?: (event: {
78
78
  scope: string;
79
79
  collectedAt: string;
80
80
  lineageSources?: string[];
81
81
  }) => void;
82
+ /** Post-auth read hook (runs a stale derivative question on demand). */
83
+ onDataRead?: (event: {
84
+ scope: string;
85
+ }) => void;
82
86
  mountPath?: PersonalServerApiDispatchOptions["basePath"];
83
87
  }
84
88
  export declare function dataRoutes(deps: DataRouteDeps): Hono;
@@ -1 +1 @@
1
- {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../src/routes/data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAEL,KAAK,gCAAgC,EACrC,KAAK,qCAAqC,EAC3C,MAAM,2CAA2C,CAAC;AACnD,OAAO,K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C9C;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,2EAA2E;IAC3E,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;IAC9C;;;;;OAKG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B;;;;OAIG;IACH,aAAa,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;IAC9B;;;;OAIG;IACH,cAAc,CAAC,EAAE,kBAAkB,CAAC;IACpC,iEAAiE;IACjE,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE;QACtB,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,MAAM,CAAC;QACpB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;KAC3B,KAAK,IAAI,CAAC;IACX,wEAAwE;IACxE,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAChD,SAAS,CAAC,EAAE,gCAAgC,CAAC,UAAU,CAAC,CAAC;CAC1D;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI,CAyDpD"}
@@ -40,6 +40,7 @@ export function dataRoutes(deps) {
40
40
  paymentEnabled: deps.paymentEnabled,
41
41
  lineageGateway: deps.lineageGateway,
42
42
  onDataWritten: deps.onDataWritten,
43
+ onDataRead: deps.onDataRead,
43
44
  // Network identifier for the 402 challenge body. We use the chain
44
45
  // id as the convention since the gateway is chain-scoped; clients
45
46
  // dispatch on the (scheme, chainId) pair, not the human name.
@@ -1 +1 @@
1
- {"version":3,"file":"data.js","sourceRoot":"","sources":["../../src/routes/data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EACL,+BAA+B,GAGhC,MAAM,2CAA2C,CAAC;AAwBnD,OAAO,EACL,eAAe,EACf,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,qBAAqB,EAAE,MA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AC,aAAa;YACzB,CAAC,CAAC,QAAQ,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE;YACtC,CAAC,CAAC,SAAS;QACb,MAAM,EAAE,IAAI,CAAC,MAAM;KACpB,EACD,EAAE,QAAQ,EAAE,IAAI,CAAC,SAAS,EAAE,CAC7B,CACF,CAAC;IAEF,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"question-store.d.ts","sourceRoot":"","sources":["../../src/storage/question-store.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAKL,KAAK,aAAa,EACnB,MAAM,mDAAmD,CAAC;AAgF3D,wBAAgB,yBAAyB,CACvC,EAAE,EAAE,QAAQ,CAAC,QAAQ,GACpB,aAAa,CAmGf"}
1
+ {"version":3,"file":"question-store.d.ts","sourceRoot":"","sources":["../../src/storage/question-store.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAML,KAAK,aAAa,EACnB,MAAM,mDAAmD,CAAC;AAkG3D,wBAAgB,yBAAyB,CACvC,EAAE,EAAE,QAAQ,CAAC,QAAQ,GACpB,aAAa,CAwGf"}
@@ -11,6 +11,7 @@ CREATE TABLE IF NOT EXISTS derivative_questions (
11
11
  source_scopes TEXT NOT NULL,
12
12
  question TEXT NOT NULL,
13
13
  model TEXT,
14
+ answer_shape TEXT,
14
15
  recompute TEXT NOT NULL DEFAULT 'on-change',
15
16
  registered_by TEXT NOT NULL,
16
17
  status TEXT NOT NULL,
@@ -35,6 +36,19 @@ function ensureErrorCodeColumn(db) {
35
36
  return;
36
37
  db.exec("ALTER TABLE derivative_questions ADD COLUMN error_code TEXT");
37
38
  }
39
+ /**
40
+ * Same in-place migration for the declared answer shape (stored as its
41
+ * JSON): rows written before it existed read back as null, which is the
42
+ * free-text answer the question was registered with.
43
+ */
44
+ function ensureAnswerShapeColumn(db) {
45
+ const columns = db
46
+ .prepare("PRAGMA table_info(derivative_questions)")
47
+ .all();
48
+ if (columns.some((column) => column.name === "answer_shape"))
49
+ return;
50
+ db.exec("ALTER TABLE derivative_questions ADD COLUMN answer_shape TEXT");
51
+ }
38
52
  const CREATE_INDEX_SQL = "CREATE INDEX IF NOT EXISTS idx_derivative_questions_derived_scope ON derivative_questions (derived_scope)";
39
53
  // Databases created before the recompute policy existed migrate in place;
40
54
  // their registrations keep the old follow-every-change behavior.
@@ -46,6 +60,9 @@ function toRegistration(row) {
46
60
  sourceScopes: JSON.parse(row.source_scopes),
47
61
  question: row.question,
48
62
  model: row.model,
63
+ answerShape: row.answer_shape
64
+ ? JSON.parse(row.answer_shape)
65
+ : null,
49
66
  recompute: row.recompute,
50
67
  registeredBy: JSON.parse(row.registered_by),
51
68
  status: row.status,
@@ -61,6 +78,7 @@ function toRegistration(row) {
61
78
  export function createSqliteQuestionStore(db) {
62
79
  db.exec(CREATE_TABLE_SQL);
63
80
  ensureErrorCodeColumn(db);
81
+ ensureAnswerShapeColumn(db);
64
82
  db.exec(CREATE_INDEX_SQL);
65
83
  const columns = db
66
84
  .prepare("PRAGMA table_info(derivative_questions)")
@@ -75,12 +93,13 @@ export function createSqliteQuestionStore(db) {
75
93
  const getOne = db.prepare("SELECT * FROM derivative_questions WHERE question_id = ?");
76
94
  const insertOne = db.prepare(`
77
95
  INSERT INTO derivative_questions (
78
- question_id, derived_scope, source_scopes, question, model, recompute,
79
- registered_by, status, error, error_code, created_at, updated_at,
96
+ question_id, derived_scope, source_scopes, question, model, answer_shape,
97
+ recompute, registered_by, status, error, error_code, created_at, updated_at,
80
98
  last_computed_at, derived_version, derived_collected_at
81
99
  ) VALUES (
82
100
  @question_id, @derived_scope, @source_scopes, @question, @model,
83
- @recompute, @registered_by, @status, @error, @error_code, @created_at, @updated_at,
101
+ @answer_shape, @recompute, @registered_by, @status, @error, @error_code,
102
+ @created_at, @updated_at,
84
103
  @last_computed_at, @derived_version, @derived_collected_at
85
104
  )`);
86
105
  const updateOne = db.prepare(`
@@ -114,6 +133,9 @@ export function createSqliteQuestionStore(db) {
114
133
  source_scopes: JSON.stringify(registration.sourceScopes),
115
134
  question: registration.question,
116
135
  model: registration.model,
136
+ answer_shape: registration.answerShape
137
+ ? JSON.stringify(registration.answerShape)
138
+ : null,
117
139
  recompute: registration.recompute,
118
140
  registered_by: JSON.stringify(registration.registeredBy),
119
141
  status: registration.status,
@@ -1 +1 @@
1
- {"version":3,"file":"question-store.js","sourceRoot":"","sources":["../../src/storage/question-store.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,qBAAqB,GAKtB,MAAM,mDAAmD,CAAC;AAE3D,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;;;;;EAiBvB,CAAC;AAEH;;;;GAIG;AACH,SAAS,qBAAqB,CAAC,EAAqB;IAClD,MAAM,OAAO,GAAG,EAAE;SACf,OAAO,CAAC,yCAAyC,CAAC;SAClD,GAAG,EAA6B,CAAC;IACpC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,YAAY,CAAC;QAAE,OAAO;IACnE,EAAE,CAAC,IAAI,CAAC,6DAA6D,CAAC,CAAC;AACzE,CAAC;AAED,MAAM,gBAAgB,GACpB,2GAA2G,CAAC;AAE9G,0EAA0E;AAC1E,iEAAiE;AACjE,MAAM,wBAAwB,GAC5B,yFAAyF,CAAC;AAoB5F,SAAS,cAAc,CAAC,GAAQ;IAC9B,OAAO;QACL,UAAU,EAAE,GAAG,CAAC,WAAW;QAC3B,YAAY,EAAE,GAAG,CAAC,aAAa;QAC/B,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,CAAa;QACvD,QAAQ,EAAE,GAAG,CAAC,QAAQ;QACtB,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,SAAS,EAAE,GAAG,CAAC,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AC,SAAS;gBAClC,UAAU,EAAE,YAAY,CAAC,SAAS;gBAClC,gBAAgB,EAAE,YAAY,CAAC,cAAc;gBAC7C,eAAe,EAAE,YAAY,CAAC,cAAc;gBAC5C,oBAAoB,EAAE,YAAY,CAAC,kBAAkB;aACtD,CAAC,CAAC;QACL,CAAC;QACD,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,KAAK;YAC5B,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,CAAoB,CAAC;YAC1D,IAAI,CAAC,OAAO;gBAAE,OAAO,IAAI,CAAC;YAC1B,MAAM,MAAM,GAAG,EAAE,GAAG,cAAc,CAAC,OAAO,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC;YACxD,SAAS,CAAC,GAAG,CAAC;gBACZ,WAAW,EAAE,UAAU;gBACvB,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,UAAU,EAAE,MAAM,CAAC,SAAS,IAAI,IAAI;gBACpC,UAAU,EAAE,MAAM,CAAC,SAAS;gBAC5B,gBAAgB,EAAE,MAAM,CAAC,cAAc;gBACvC,eAAe,EAAE,MAAM,CAAC,cAAc;gBACtC,oBAAoB,EAAE,MAAM,CAAC,kBAAkB;aAChD,CAAC,CAAC;YACH,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,KAAK,CAAC,MAAM,CAAC,UAAU;YACrB,OAAO,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC;QAC/C,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -61644,8 +61644,8 @@ var require_multipleOf = __commonJS({
61644
61644
  const { gen: gen2, data, schemaCode, it: it3 } = cxt;
61645
61645
  const prec = it3.opts.multipleOfPrecision;
61646
61646
  const res = gen2.let("res");
61647
- const invalid = prec ? (0, codegen_1._)`Math.abs(Math.round(${res}) - ${res}) > 1e-${prec}` : (0, codegen_1._)`${res} !== parseInt(${res})`;
61648
- cxt.fail$data((0, codegen_1._)`(${schemaCode} === 0 || (${res} = ${data}/${schemaCode}, ${invalid}))`);
61647
+ const invalid2 = prec ? (0, codegen_1._)`Math.abs(Math.round(${res}) - ${res}) > 1e-${prec}` : (0, codegen_1._)`${res} !== parseInt(${res})`;
61648
+ cxt.fail$data((0, codegen_1._)`(${schemaCode} === 0 || (${res} = ${data}/${schemaCode}, ${invalid2}))`);
61649
61649
  }
61650
61650
  };
61651
61651
  exports.default = def;
@@ -67542,8 +67542,8 @@ var require_multipleOf2 = __commonJS({
67542
67542
  const { gen: gen2, data, schemaCode, it: it3 } = cxt;
67543
67543
  const prec = it3.opts.multipleOfPrecision;
67544
67544
  const res = gen2.let("res");
67545
- const invalid = prec ? (0, codegen_1._)`Math.abs(Math.round(${res}) - ${res}) > 1e-${prec}` : (0, codegen_1._)`${res} !== parseInt(${res})`;
67546
- cxt.fail$data((0, codegen_1._)`(${schemaCode} === 0 || (${res} = ${data}/${schemaCode}, ${invalid}))`);
67545
+ const invalid2 = prec ? (0, codegen_1._)`Math.abs(Math.round(${res}) - ${res}) > 1e-${prec}` : (0, codegen_1._)`${res} !== parseInt(${res})`;
67546
+ cxt.fail$data((0, codegen_1._)`(${schemaCode} === 0 || (${res} = ${data}/${schemaCode}, ${invalid2}))`);
67547
67547
  }
67548
67548
  };
67549
67549
  exports.default = def;
@@ -111380,6 +111380,18 @@ function notifyDataWritten(deps, event) {
111380
111380
  }, "onDataWritten hook failed; record already stored");
111381
111381
  }
111382
111382
  }
111383
+ function notifyDataRead(deps, event) {
111384
+ if (!deps.onDataRead)
111385
+ return;
111386
+ try {
111387
+ deps.onDataRead(event);
111388
+ } catch (err2) {
111389
+ deps.logger?.warn?.({
111390
+ scope: event.scope,
111391
+ error: err2 instanceof Error ? err2.message : String(err2)
111392
+ }, "onDataRead hook failed; the read is unaffected");
111393
+ }
111394
+ }
111383
111395
  function notifyNewData(syncManager) {
111384
111396
  if (!syncManager)
111385
111397
  return;
@@ -111589,6 +111601,7 @@ async function handlePersonalServerDataRequest(request2, deps, options = {}) {
111589
111601
  at: url2.searchParams.get("at") ?? void 0
111590
111602
  });
111591
111603
  await assertScopeNotDeleted(deps, scopeResult.scope, selectedEntry);
111604
+ notifyDataRead(deps, { scope: scopeResult.scope });
111592
111605
  const isOwnerSignal = authResult?.grantId === "owner" || authResult?.grantId === "policy-bypass";
111593
111606
  const builder = authResult?.builder;
111594
111607
  const resolvedGrantId = !isOwnerSignal && authResult?.grantId ? authResult.grantId : void 0;
@@ -114031,6 +114044,258 @@ async function loadOrCreatePsLiteServerIdentity(params) {
114031
114044
  return { persisted, account };
114032
114045
  }
114033
114046
 
114047
+ // ../core/dist/derivatives/answer-shape.js
114048
+ var MAX_ANSWER_SHAPE_FIELDS = 16;
114049
+ var MAX_ANSWER_FIELD_NAME_CHARS = 64;
114050
+ var MAX_ANSWER_STRING_CHARS = 4e3;
114051
+ var MAX_ANSWER_ENUM_VALUES = 32;
114052
+ var MAX_ANSWER_ENUM_VALUE_CHARS = 64;
114053
+ var FIELD_NAME = /^[A-Za-z][A-Za-z0-9_]*$/;
114054
+ var FIELD_TYPES = [
114055
+ "string",
114056
+ "number",
114057
+ "integer",
114058
+ "boolean",
114059
+ "enum"
114060
+ ];
114061
+ var KEYS_BY_TYPE = {
114062
+ string: ["name", "type", "required", "maxLength"],
114063
+ number: ["name", "type", "required", "min", "max"],
114064
+ integer: ["name", "type", "required", "min", "max"],
114065
+ boolean: ["name", "type", "required"],
114066
+ enum: ["name", "type", "required", "values"]
114067
+ };
114068
+ function isRecord4(value) {
114069
+ return value !== null && typeof value === "object" && !Array.isArray(value);
114070
+ }
114071
+ function invalid(message, details) {
114072
+ throw new DerivativeQuestionInvalidError(message, {
114073
+ field: "answerShape",
114074
+ ...details
114075
+ });
114076
+ }
114077
+ function parseFieldName(value, index) {
114078
+ if (typeof value !== "string" || value === "") {
114079
+ invalid(`answerShape.fields[${index}].name must be a non-empty string`, {
114080
+ index
114081
+ });
114082
+ }
114083
+ if (value.length > MAX_ANSWER_FIELD_NAME_CHARS) {
114084
+ invalid(`answerShape.fields[${index}].name is ${value.length} characters; the maximum is ${MAX_ANSWER_FIELD_NAME_CHARS}`, { index, max: MAX_ANSWER_FIELD_NAME_CHARS });
114085
+ }
114086
+ if (!FIELD_NAME.test(value)) {
114087
+ invalid(`answerShape.fields[${index}].name must start with a letter and hold only letters, digits and underscores`, { index });
114088
+ }
114089
+ return value;
114090
+ }
114091
+ function parseBound(value, index, key, integer2) {
114092
+ if (typeof value !== "number" || !Number.isFinite(value)) {
114093
+ invalid(`answerShape.fields[${index}].${key} must be a finite number`, {
114094
+ index,
114095
+ key
114096
+ });
114097
+ }
114098
+ if (integer2 && !Number.isSafeInteger(value)) {
114099
+ invalid(`answerShape.fields[${index}].${key} must be a safe integer for an integer field`, { index, key });
114100
+ }
114101
+ return value;
114102
+ }
114103
+ function parseEnumValues(value, index) {
114104
+ if (!Array.isArray(value) || value.length === 0) {
114105
+ invalid(`answerShape.fields[${index}].values must be a non-empty array of strings`, { index });
114106
+ }
114107
+ if (value.length > MAX_ANSWER_ENUM_VALUES) {
114108
+ invalid(`answerShape.fields[${index}].values lists ${value.length} values; the maximum is ${MAX_ANSWER_ENUM_VALUES}`, { index, max: MAX_ANSWER_ENUM_VALUES });
114109
+ }
114110
+ const values = [];
114111
+ for (const entry of value) {
114112
+ if (typeof entry !== "string" || entry === "") {
114113
+ invalid(`answerShape.fields[${index}].values must hold non-empty strings`, { index });
114114
+ }
114115
+ if (entry.length > MAX_ANSWER_ENUM_VALUE_CHARS) {
114116
+ invalid(`answerShape.fields[${index}].values holds a ${entry.length} character value; the maximum is ${MAX_ANSWER_ENUM_VALUE_CHARS}`, { index, max: MAX_ANSWER_ENUM_VALUE_CHARS });
114117
+ }
114118
+ if (/[\n\r\t]/.test(entry)) {
114119
+ invalid(`answerShape.fields[${index}].values must not hold line breaks or tabs`, { index });
114120
+ }
114121
+ if (values.includes(entry)) {
114122
+ invalid(`answerShape.fields[${index}].values lists the same value twice`, { index });
114123
+ }
114124
+ values.push(entry);
114125
+ }
114126
+ return values;
114127
+ }
114128
+ function parseField(value, index) {
114129
+ if (!isRecord4(value)) {
114130
+ invalid(`answerShape.fields[${index}] must be an object`, { index });
114131
+ }
114132
+ const name = parseFieldName(value.name, index);
114133
+ if (typeof value.type !== "string" || !FIELD_TYPES.includes(value.type)) {
114134
+ invalid(`answerShape.fields[${index}].type must be one of ${FIELD_TYPES.join(", ")}`, { index });
114135
+ }
114136
+ const type = value.type;
114137
+ const allowed = KEYS_BY_TYPE[type];
114138
+ for (const key of Object.keys(value)) {
114139
+ if (!allowed.includes(key)) {
114140
+ invalid(`answerShape.fields[${index}] does not accept "${key}" on a ${type} field`, { index, key: key.slice(0, MAX_ANSWER_FIELD_NAME_CHARS) });
114141
+ }
114142
+ }
114143
+ let required2 = true;
114144
+ if (value.required !== void 0 && value.required !== null) {
114145
+ if (typeof value.required !== "boolean") {
114146
+ invalid(`answerShape.fields[${index}].required must be a boolean`, {
114147
+ index
114148
+ });
114149
+ }
114150
+ required2 = value.required;
114151
+ }
114152
+ const field = { name, type, required: required2 };
114153
+ if (type === "string") {
114154
+ let maxLength = MAX_ANSWER_STRING_CHARS;
114155
+ if (value.maxLength !== void 0 && value.maxLength !== null) {
114156
+ if (typeof value.maxLength !== "number" || !Number.isSafeInteger(value.maxLength) || value.maxLength < 1 || value.maxLength > MAX_ANSWER_STRING_CHARS) {
114157
+ invalid(`answerShape.fields[${index}].maxLength must be an integer between 1 and ${MAX_ANSWER_STRING_CHARS}`, { index, max: MAX_ANSWER_STRING_CHARS });
114158
+ }
114159
+ maxLength = value.maxLength;
114160
+ }
114161
+ field.maxLength = maxLength;
114162
+ }
114163
+ if (type === "number" || type === "integer") {
114164
+ const integer2 = type === "integer";
114165
+ if (value.min !== void 0 && value.min !== null) {
114166
+ field.min = parseBound(value.min, index, "min", integer2);
114167
+ }
114168
+ if (value.max !== void 0 && value.max !== null) {
114169
+ field.max = parseBound(value.max, index, "max", integer2);
114170
+ }
114171
+ if (field.min !== void 0 && field.max !== void 0 && field.min > field.max) {
114172
+ invalid(`answerShape.fields[${index}].min is greater than its max`, {
114173
+ index
114174
+ });
114175
+ }
114176
+ }
114177
+ if (type === "enum") {
114178
+ field.values = parseEnumValues(value.values, index);
114179
+ }
114180
+ return field;
114181
+ }
114182
+ function parseAnswerShapeInput(value) {
114183
+ if (value === void 0 || value === null)
114184
+ return null;
114185
+ if (!isRecord4(value)) {
114186
+ invalid("answerShape must be an object with a fields array", {});
114187
+ }
114188
+ for (const key of Object.keys(value)) {
114189
+ if (key !== "fields") {
114190
+ invalid(`answerShape does not accept "${key}"`, {
114191
+ key: key.slice(0, MAX_ANSWER_FIELD_NAME_CHARS)
114192
+ });
114193
+ }
114194
+ }
114195
+ if (!Array.isArray(value.fields) || value.fields.length === 0) {
114196
+ invalid("answerShape.fields must be a non-empty array", {});
114197
+ }
114198
+ if (value.fields.length > MAX_ANSWER_SHAPE_FIELDS) {
114199
+ invalid(`answerShape.fields lists ${value.fields.length} fields; the maximum is ${MAX_ANSWER_SHAPE_FIELDS}`, { max: MAX_ANSWER_SHAPE_FIELDS });
114200
+ }
114201
+ const fields = [];
114202
+ const names = /* @__PURE__ */ new Set();
114203
+ value.fields.forEach((entry, index) => {
114204
+ const field = parseField(entry, index);
114205
+ if (names.has(field.name)) {
114206
+ invalid(`answerShape.fields names "${field.name}" twice`, { index });
114207
+ }
114208
+ names.add(field.name);
114209
+ fields.push(field);
114210
+ });
114211
+ return { fields };
114212
+ }
114213
+ function compileAnswerShape(shape) {
114214
+ const entries = {};
114215
+ for (const field of shape.fields) {
114216
+ let schema;
114217
+ switch (field.type) {
114218
+ case "string":
114219
+ schema = external_exports.string().max(field.maxLength ?? MAX_ANSWER_STRING_CHARS);
114220
+ break;
114221
+ case "number":
114222
+ case "integer": {
114223
+ let numeric = field.type === "integer" ? external_exports.int() : external_exports.number();
114224
+ if (field.min !== void 0)
114225
+ numeric = numeric.min(field.min);
114226
+ if (field.max !== void 0)
114227
+ numeric = numeric.max(field.max);
114228
+ schema = numeric;
114229
+ break;
114230
+ }
114231
+ case "boolean":
114232
+ schema = external_exports.boolean();
114233
+ break;
114234
+ case "enum":
114235
+ schema = external_exports.enum(field.values ?? []);
114236
+ break;
114237
+ }
114238
+ entries[field.name] = field.required ? schema : schema.nullish();
114239
+ }
114240
+ return external_exports.object(entries);
114241
+ }
114242
+ function validateAnswerShape(shape, compiled, candidate) {
114243
+ const parsed = compiled.safeParse(candidate);
114244
+ if (!parsed.success) {
114245
+ return {
114246
+ ok: false,
114247
+ // zod's messages state the constraint ("expected int", "<=5") and
114248
+ // never echo the received value, so they are safe to hand back to
114249
+ // the model in the corrective turn.
114250
+ issues: parsed.error.issues.map((issue2) => {
114251
+ const path = issue2.path.join(".");
114252
+ return path ? `${path}: ${issue2.message}` : issue2.message;
114253
+ })
114254
+ };
114255
+ }
114256
+ const value = {};
114257
+ for (const field of shape.fields) {
114258
+ const entry = parsed.data[field.name];
114259
+ if (entry === void 0 || entry === null)
114260
+ continue;
114261
+ value[field.name] = entry;
114262
+ }
114263
+ return { ok: true, value };
114264
+ }
114265
+ function describeField(field) {
114266
+ const requirement = field.required ? "required" : "optional";
114267
+ switch (field.type) {
114268
+ case "string":
114269
+ return `"${field.name}": string, at most ${field.maxLength ?? MAX_ANSWER_STRING_CHARS} characters (${requirement})`;
114270
+ case "number":
114271
+ case "integer": {
114272
+ const kind = field.type === "integer" ? "integer" : "number";
114273
+ const range = field.min !== void 0 && field.max !== void 0 ? ` between ${field.min} and ${field.max}` : field.min !== void 0 ? ` of at least ${field.min}` : field.max !== void 0 ? ` of at most ${field.max}` : "";
114274
+ return `"${field.name}": ${kind}${range} (${requirement})`;
114275
+ }
114276
+ case "boolean":
114277
+ return `"${field.name}": true or false (${requirement})`;
114278
+ case "enum":
114279
+ return `"${field.name}": exactly one of ${(field.values ?? []).map((entry) => JSON.stringify(entry)).join(", ")} (${requirement})`;
114280
+ }
114281
+ }
114282
+ function describeAnswerShape(shape) {
114283
+ return shape.fields.map((field) => ` ${describeField(field)}`);
114284
+ }
114285
+ function renderShapedAnswer(shape, value) {
114286
+ return shape.fields.filter((field) => value[field.name] !== void 0).map((field) => `${field.name}: ${String(value[field.name])}`).join("\n");
114287
+ }
114288
+ function cloneAnswerShape(shape) {
114289
+ if (!shape)
114290
+ return null;
114291
+ return {
114292
+ fields: shape.fields.map((field) => ({
114293
+ ...field,
114294
+ ...field.values ? { values: [...field.values] } : {}
114295
+ }))
114296
+ };
114297
+ }
114298
+
114034
114299
  // ../core/dist/derivatives/types.js
114035
114300
  function questionRegistrationView(registration) {
114036
114301
  return {
@@ -114039,6 +114304,7 @@ function questionRegistrationView(registration) {
114039
114304
  sourceScopes: [...registration.sourceScopes],
114040
114305
  question: registration.question,
114041
114306
  model: registration.model,
114307
+ answerShape: cloneAnswerShape(registration.answerShape),
114042
114308
  recompute: registration.recompute,
114043
114309
  registeredBy: registration.registeredBy,
114044
114310
  status: registration.status,
@@ -114058,6 +114324,7 @@ function clone2(registration) {
114058
114324
  ...registration,
114059
114325
  // Registrations persisted before the field existed load as null.
114060
114326
  errorCode: registration.errorCode ?? null,
114327
+ answerShape: cloneAnswerShape(registration.answerShape ?? null),
114061
114328
  sourceScopes: [...registration.sourceScopes],
114062
114329
  registeredBy: { ...registration.registeredBy }
114063
114330
  };
@@ -114128,7 +114395,7 @@ var MAX_QUESTION_CHARS = 8e3;
114128
114395
  var MAX_MODEL_CHARS = 128;
114129
114396
  var MAX_ECHOED_SCOPE_CHARS = 128;
114130
114397
  var MODEL_ID = /^[A-Za-z0-9][A-Za-z0-9._:/-]*$/;
114131
- function isRecord4(value) {
114398
+ function isRecord5(value) {
114132
114399
  return value !== null && typeof value === "object" && !Array.isArray(value);
114133
114400
  }
114134
114401
  function parseScope(value, field) {
@@ -114144,7 +114411,7 @@ function parseScope(value, field) {
114144
114411
  return parsed.scope;
114145
114412
  }
114146
114413
  function parseQuestionInput(body) {
114147
- if (!isRecord4(body)) {
114414
+ if (!isRecord5(body)) {
114148
114415
  throw new DerivativeQuestionInvalidError("Body must be a JSON object");
114149
114416
  }
114150
114417
  const derivedScope = parseScope(body.derivedScope, "derivedScope");
@@ -114178,6 +114445,7 @@ function parseQuestionInput(body) {
114178
114445
  }
114179
114446
  model = body.model;
114180
114447
  }
114448
+ const answerShape = parseAnswerShapeInput(body.answerShape);
114181
114449
  let recompute = "on-change";
114182
114450
  if (body.recompute !== void 0 && body.recompute !== null) {
114183
114451
  if (body.recompute !== "snapshot" && body.recompute !== "on-change") {
@@ -114191,6 +114459,7 @@ function parseQuestionInput(body) {
114191
114459
  sourceScopes,
114192
114460
  question: body.question,
114193
114461
  model,
114462
+ answerShape,
114194
114463
  recompute
114195
114464
  };
114196
114465
  }
@@ -114240,6 +114509,7 @@ async function createQuestionRegistration(input) {
114240
114509
  sourceScopes: parsed.sourceScopes,
114241
114510
  question: parsed.question,
114242
114511
  model: parsed.model,
114512
+ answerShape: parsed.answerShape,
114243
114513
  recompute: parsed.recompute,
114244
114514
  registeredBy: input.registeredBy,
114245
114515
  status: "pending",
@@ -114277,11 +114547,11 @@ var TIMESTAMP_KEYS = [
114277
114547
  "published_at"
114278
114548
  ];
114279
114549
  var RESERVED_KEYS = /* @__PURE__ */ new Set(["$lineage", "$writtenBy", "$binary"]);
114280
- function isRecord5(value) {
114550
+ function isRecord6(value) {
114281
114551
  return value !== null && typeof value === "object" && !Array.isArray(value);
114282
114552
  }
114283
114553
  function timestampOf(item) {
114284
- if (!isRecord5(item))
114554
+ if (!isRecord6(item))
114285
114555
  return null;
114286
114556
  for (const key of TIMESTAMP_KEYS) {
114287
114557
  const value = item[key];
@@ -114322,7 +114592,7 @@ function trimSourceData(data, options = {}) {
114322
114592
  total = 0;
114323
114593
  if (Array.isArray(data))
114324
114594
  return trimArray(data, limit2);
114325
- if (isRecord5(data)) {
114595
+ if (isRecord6(data)) {
114326
114596
  const stamped = "$lineage" in data;
114327
114597
  const out = {};
114328
114598
  for (const [key, value] of Object.entries(data)) {
@@ -114354,13 +114624,28 @@ function trimSourceData(data, options = {}) {
114354
114624
  }
114355
114625
  return { data: result, kept, total, truncated: false };
114356
114626
  }
114357
- var SYSTEM_PROMPT = [
114627
+ var GROUNDING = [
114358
114628
  "You answer a question about a person using ONLY the user data provided in the message.",
114359
- "Do not use outside knowledge and do not guess; if the data does not support an answer, say so in the answer.",
114629
+ "Do not use outside knowledge and do not guess; if the data does not support an answer, say so in the answer."
114630
+ ];
114631
+ var SYSTEM_PROMPT = [
114632
+ ...GROUNDING,
114360
114633
  "Respond with a single JSON object and nothing else, with exactly these fields:",
114361
114634
  ' "answer": string, the answer to the question, written for the person the data belongs to;',
114362
114635
  ' "evidence": string, a short summary of which parts of the data support the answer.'
114363
114636
  ].join("\n");
114637
+ function shapedSystemPrompt(shape) {
114638
+ return [
114639
+ ...GROUNDING,
114640
+ "Respond with a single JSON object and nothing else, with exactly these fields:",
114641
+ ' "answer": object, holding exactly the fields listed below and no others;',
114642
+ ' "evidence": string, a short summary of which parts of the data support the answer.',
114643
+ 'The "answer" object holds:',
114644
+ ...describeAnswerShape(shape),
114645
+ "Use the declared type for every field: a number field is a JSON number, not a string.",
114646
+ "Do not add fields, do not rename them and do not put prose outside them."
114647
+ ].join("\n");
114648
+ }
114364
114649
  function buildQuestionMessages(input) {
114365
114650
  const sections = input.sources.map((source) => {
114366
114651
  const note = source.total > source.kept ? ` (newest ${source.kept} of ${source.total} items)` : "";
@@ -114378,14 +114663,34 @@ function buildQuestionMessages(input) {
114378
114663
  "## User data",
114379
114664
  ...sections,
114380
114665
  "",
114381
- "Answer the question as a JSON object with the fields answer and evidence."
114666
+ input.answerShape ? "Answer the question as a JSON object with the fields answer and evidence, where answer holds exactly the declared fields." : "Answer the question as a JSON object with the fields answer and evidence."
114382
114667
  ].join("\n");
114383
114668
  return [
114384
- { role: "system", content: SYSTEM_PROMPT },
114669
+ {
114670
+ role: "system",
114671
+ content: input.answerShape ? shapedSystemPrompt(input.answerShape) : SYSTEM_PROMPT
114672
+ },
114385
114673
  { role: "user", content: user }
114386
114674
  ];
114387
114675
  }
114388
- function parseAnswer(content) {
114676
+ function buildShapeRetryMessages(input) {
114677
+ return [
114678
+ ...input.messages,
114679
+ { role: "assistant", content: input.reply },
114680
+ {
114681
+ role: "user",
114682
+ content: [
114683
+ "That reply did not match the required answer shape:",
114684
+ ...input.issues.map((issue2) => `- ${issue2}`),
114685
+ "",
114686
+ 'Answer again as a single JSON object with the fields answer and evidence, where "answer" holds:',
114687
+ ...describeAnswerShape(input.answerShape),
114688
+ "Return the JSON object and nothing else."
114689
+ ].join("\n")
114690
+ }
114691
+ ];
114692
+ }
114693
+ function jsonFramings(content) {
114389
114694
  const candidates = [content.trim()];
114390
114695
  const fenced = /```(?:json)?\s*([\s\S]*?)```/i.exec(content);
114391
114696
  if (fenced?.[1])
@@ -114395,10 +114700,13 @@ function parseAnswer(content) {
114395
114700
  if (first !== -1 && last2 > first) {
114396
114701
  candidates.push(content.slice(first, last2 + 1));
114397
114702
  }
114398
- for (const candidate of candidates) {
114703
+ return [...new Set(candidates)];
114704
+ }
114705
+ function parseAnswer(content) {
114706
+ for (const candidate of jsonFramings(content)) {
114399
114707
  try {
114400
114708
  const parsed = JSON.parse(candidate);
114401
- if (isRecord5(parsed) && typeof parsed.answer === "string") {
114709
+ if (isRecord6(parsed) && typeof parsed.answer === "string") {
114402
114710
  return {
114403
114711
  answer: parsed.answer,
114404
114712
  evidence: typeof parsed.evidence === "string" ? parsed.evidence : null
@@ -114409,6 +114717,25 @@ function parseAnswer(content) {
114409
114717
  }
114410
114718
  return { answer: content.trim(), evidence: null };
114411
114719
  }
114720
+ function parseShapedAnswer(content) {
114721
+ const found = [];
114722
+ for (const candidate of jsonFramings(content)) {
114723
+ let parsed;
114724
+ try {
114725
+ parsed = JSON.parse(candidate);
114726
+ } catch {
114727
+ continue;
114728
+ }
114729
+ if (!isRecord6(parsed))
114730
+ continue;
114731
+ const evidence = typeof parsed.evidence === "string" ? parsed.evidence : null;
114732
+ if (isRecord6(parsed.answer)) {
114733
+ found.push({ answer: parsed.answer, evidence });
114734
+ }
114735
+ found.push({ answer: parsed, evidence });
114736
+ }
114737
+ return found;
114738
+ }
114412
114739
 
114413
114740
  // ../core/dist/derivatives/inference.js
114414
114741
  var DEFAULT_INFERENCE_BASE_URL = "https://inference.phala.com/v1";
@@ -114435,11 +114762,11 @@ var InferenceRequestError = class extends Error {
114435
114762
  this.retryable = options.retryable;
114436
114763
  }
114437
114764
  };
114438
- function isRecord6(value) {
114765
+ function isRecord7(value) {
114439
114766
  return value !== null && typeof value === "object" && !Array.isArray(value);
114440
114767
  }
114441
114768
  function readUsage(value) {
114442
- if (!isRecord6(value))
114769
+ if (!isRecord7(value))
114443
114770
  return void 0;
114444
114771
  const num2 = (v10) => typeof v10 === "number" ? v10 : void 0;
114445
114772
  const usage = {
@@ -114450,10 +114777,10 @@ function readUsage(value) {
114450
114777
  return usage;
114451
114778
  }
114452
114779
  function readContent(body) {
114453
- if (!isRecord6(body) || !Array.isArray(body.choices))
114780
+ if (!isRecord7(body) || !Array.isArray(body.choices))
114454
114781
  return null;
114455
114782
  const first = body.choices[0];
114456
- if (!isRecord6(first) || !isRecord6(first.message))
114783
+ if (!isRecord7(first) || !isRecord7(first.message))
114457
114784
  return null;
114458
114785
  const index = typeof first.index === "number" ? first.index : 0;
114459
114786
  const field = `choices.${index}.message.content`;
@@ -114462,7 +114789,7 @@ function readContent(body) {
114462
114789
  if (typeof content === "string")
114463
114790
  return { content, field, id: id2 };
114464
114791
  if (Array.isArray(content)) {
114465
- const text = content.map((part) => isRecord6(part) && typeof part.text === "string" ? part.text : "").join("");
114792
+ const text = content.map((part) => isRecord7(part) && typeof part.text === "string" ? part.text : "").join("");
114466
114793
  return { content: text, field, id: id2 };
114467
114794
  }
114468
114795
  return null;
@@ -114470,7 +114797,7 @@ function readContent(body) {
114470
114797
  async function readErrorType(response) {
114471
114798
  try {
114472
114799
  const body = await response.json();
114473
- if (isRecord6(body) && isRecord6(body.error)) {
114800
+ if (isRecord7(body) && isRecord7(body.error)) {
114474
114801
  return typeof body.error.type === "string" ? body.error.type : null;
114475
114802
  }
114476
114803
  } catch {
@@ -114578,7 +114905,7 @@ function createOpenAiCompatibleInferenceProvider(options = {}) {
114578
114905
  ok: true,
114579
114906
  result: {
114580
114907
  content,
114581
- usage: readUsage(isRecord6(parsed) ? parsed.usage : void 0),
114908
+ usage: readUsage(isRecord7(parsed) ? parsed.usage : void 0),
114582
114909
  ...receiptId ? { receiptId } : {},
114583
114910
  ...aciIdentity ? { aciIdentity } : {}
114584
114911
  }
@@ -114651,6 +114978,53 @@ function shortError(err2) {
114651
114978
  return `${err2.errorCode}: ${err2.message}`;
114652
114979
  return `compute failed (${err2 instanceof Error ? err2.name : "Error"})`;
114653
114980
  }
114981
+ async function produceAnswer(deps, registration, model, messages) {
114982
+ const ask = (turns2) => withRetries(deps, () => deps.provider.chat({
114983
+ model,
114984
+ messages: turns2,
114985
+ maxTokens: deps.maxTokens
114986
+ }), isRetryableInferenceError);
114987
+ const shape = registration.answerShape;
114988
+ if (!shape) {
114989
+ const reply = await ask(messages);
114990
+ const parsed = parseAnswer(reply.content);
114991
+ return {
114992
+ reply,
114993
+ answer: parsed.answer,
114994
+ evidence: parsed.evidence,
114995
+ answerData: null
114996
+ };
114997
+ }
114998
+ const compiled = compileAnswerShape(shape);
114999
+ let turns = messages;
115000
+ for (let attempt = 0; ; attempt += 1) {
115001
+ const reply = await ask(turns);
115002
+ const candidates = parseShapedAnswer(reply.content);
115003
+ let issues = ["the reply was not a JSON object"];
115004
+ for (const [index, candidate] of candidates.entries()) {
115005
+ const checked = validateAnswerShape(shape, compiled, candidate.answer);
115006
+ if (checked.ok) {
115007
+ return {
115008
+ reply,
115009
+ answer: renderShapedAnswer(shape, checked.value),
115010
+ evidence: candidate.evidence,
115011
+ answerData: checked.value
115012
+ };
115013
+ }
115014
+ if (index === 0)
115015
+ issues = checked.issues;
115016
+ }
115017
+ if (attempt >= 1)
115018
+ break;
115019
+ turns = buildShapeRetryMessages({
115020
+ messages,
115021
+ reply: reply.content,
115022
+ issues,
115023
+ answerShape: shape
115024
+ });
115025
+ }
115026
+ throw new ComputeFailure(`answer did not match the declared shape (fields: ${shape.fields.map((field) => field.name).join(", ")})`, "internal");
115027
+ }
114654
115028
  function collectedAtStamp(now, isTaken) {
114655
115029
  const base = now();
114656
115030
  base.setUTCMilliseconds(0);
@@ -114811,18 +115185,20 @@ async function computeQuestion(questionId, deps) {
114811
115185
  await assertNoLineageCycle(deps, registration, serverOwner, sourceLineage);
114812
115186
  const messages = buildQuestionMessages({
114813
115187
  question: registration.question,
114814
- sources
115188
+ sources,
115189
+ answerShape: registration.answerShape
114815
115190
  });
114816
115191
  const model = registration.model ?? deps.provider.defaultModel;
114817
- const reply = await withRetries(deps, () => deps.provider.chat({ model, messages, maxTokens: deps.maxTokens }), isRetryableInferenceError);
114818
- const parsed = parseAnswer(reply.content);
115192
+ const produced = await produceAnswer(deps, registration, model, messages);
115193
+ const reply = produced.reply;
114819
115194
  const computedAt = now().toISOString();
114820
115195
  const lineageIds = registration.sourceScopes.map((scope) => computeDataPointId(serverOwner, scope));
114821
115196
  const record2 = {
114822
115197
  questionId: registration.questionId,
114823
115198
  question: registration.question,
114824
- answer: parsed.answer,
114825
- evidence: parsed.evidence,
115199
+ answer: produced.answer,
115200
+ ...produced.answerData ? { answerData: produced.answerData } : {},
115201
+ evidence: produced.evidence,
114826
115202
  model,
114827
115203
  computedAt,
114828
115204
  sources: sources.map((source) => ({
@@ -114971,7 +115347,8 @@ function createRecomputeScheduler(options) {
114971
115347
  retryAttempts: 0,
114972
115348
  retryAtMs: null,
114973
115349
  retryScheduled: false,
114974
- retryRunning: false
115350
+ retryRunning: false,
115351
+ sourceChangedDuringRun: false
114975
115352
  };
114976
115353
  states.set(questionId, state);
114977
115354
  }
@@ -114995,6 +115372,8 @@ function createRecomputeScheduler(options) {
114995
115372
  state.running = null;
114996
115373
  state.retryAtMs = null;
114997
115374
  state.retryRunning = false;
115375
+ const sourceChangedDuringRun = state.sourceChangedDuringRun;
115376
+ state.sourceChangedDuringRun = false;
114998
115377
  const retryable = isTransientFailureOutcome(outcome) || // A runtime-unavailable skip DURING a chain consumes an attempt
114999
115378
  // instead of ending the chain; on a fresh compute it keeps the
115000
115379
  // pre-retry behavior (pending/stale, reswept by start()).
@@ -115018,6 +115397,9 @@ function createRecomputeScheduler(options) {
115018
115397
  state.retryScheduled = true;
115019
115398
  } else {
115020
115399
  state.retryAttempts = 0;
115400
+ if (sourceChangedDuringRun) {
115401
+ await markStale(questionId);
115402
+ }
115021
115403
  if (!states.get(questionId)?.timer) {
115022
115404
  states.delete(questionId);
115023
115405
  }
@@ -115038,6 +115420,15 @@ function createRecomputeScheduler(options) {
115038
115420
  run(questionId);
115039
115421
  }, delayMs);
115040
115422
  }
115423
+ function scheduleDemand(questionId) {
115424
+ const state = stateFor(questionId);
115425
+ if (state.running !== null)
115426
+ return;
115427
+ if (state.timer !== null && !state.retryScheduled)
115428
+ return;
115429
+ schedule(questionId, 0);
115430
+ state.retryScheduled = false;
115431
+ }
115041
115432
  async function markStale(questionId) {
115042
115433
  const registration = await options.store.get(questionId);
115043
115434
  if (!registration)
@@ -115081,12 +115472,34 @@ function createRecomputeScheduler(options) {
115081
115472
  if (options.serverOwner && lineage.has(computeDataPointId(options.serverOwner, registration.derivedScope))) {
115082
115473
  continue;
115083
115474
  }
115475
+ const state = states.get(registration.questionId);
115476
+ const runningBefore = state?.running != null;
115084
115477
  await markStale(registration.questionId);
115085
- resetRetry(registration.questionId);
115086
- schedule(registration.questionId, debounceMs);
115478
+ if (state && (runningBefore || state.running !== null)) {
115479
+ state.sourceChangedDuringRun = true;
115480
+ }
115087
115481
  }
115088
115482
  })().catch((err2) => warn({ scope, error: err2 instanceof Error ? err2.name : String(err2) }, "Could not mark derivative questions stale")));
115089
115483
  },
115484
+ markDemand(derivedScope) {
115485
+ if (stopped)
115486
+ return;
115487
+ void track((async () => {
115488
+ const affected = await options.store.list({ derivedScope });
115489
+ for (const registration of affected) {
115490
+ if (registration.recompute === "snapshot") {
115491
+ continue;
115492
+ }
115493
+ if (registration.status !== "stale" && registration.status !== "pending") {
115494
+ continue;
115495
+ }
115496
+ scheduleDemand(registration.questionId);
115497
+ }
115498
+ })().catch((err2) => warn({
115499
+ derivedScope,
115500
+ error: err2 instanceof Error ? err2.name : String(err2)
115501
+ }, "Could not schedule derivative questions on demand")));
115502
+ },
115090
115503
  requestRecompute(questionId, opts) {
115091
115504
  if (stopped)
115092
115505
  return;
@@ -115128,7 +115541,7 @@ function createRecomputeScheduler(options) {
115128
115541
  stopped = false;
115129
115542
  void track((async () => {
115130
115543
  for (const registration of await options.store.list()) {
115131
- if (registration.status === "pending" || registration.status === "stale") {
115544
+ if (registration.status === "pending") {
115132
115545
  schedule(registration.questionId, 0);
115133
115546
  }
115134
115547
  }
@@ -115214,6 +115627,7 @@ async function handleStatusRoute(request2, url2, deps, store, scheduler, now) {
115214
115627
  if (registrations.length === 0) {
115215
115628
  throw new DerivativeQuestionNotFoundError({ derivedScope });
115216
115629
  }
115630
+ scheduler.markDemand(derivedScope);
115217
115631
  const STATUS_PRECEDENCE = {
115218
115632
  ready: 0,
115219
115633
  stale: 1,
@@ -115583,7 +115997,7 @@ var E2eeAttestationError = class extends Error {
115583
115997
  this.name = "E2eeAttestationError";
115584
115998
  }
115585
115999
  };
115586
- function isRecord7(value) {
116000
+ function isRecord8(value) {
115587
116001
  return value !== null && typeof value === "object" && !Array.isArray(value);
115588
116002
  }
115589
116003
  async function sha256Hex2(bytes2) {
@@ -115601,7 +116015,7 @@ async function reportDataFor(keysetDigest, nonce) {
115601
116015
  return sha256Hex2(new TextEncoder().encode(statement));
115602
116016
  }
115603
116017
  function parseReport(body) {
115604
- if (!isRecord7(body) || typeof body.api_version !== "string" || typeof body.workload_keyset_digest !== "string" || !isRecord7(body.attestation) || typeof body.attestation.tee_type !== "string" || typeof body.attestation.report_data !== "string" || !isRecord7(body.attestation.workload_keyset)) {
116018
+ if (!isRecord8(body) || typeof body.api_version !== "string" || typeof body.workload_keyset_digest !== "string" || !isRecord8(body.attestation) || typeof body.attestation.tee_type !== "string" || typeof body.attestation.report_data !== "string" || !isRecord8(body.attestation.workload_keyset)) {
115605
116019
  throw new E2eeAttestationError("malformed_report", "attestation report is missing required fields");
115606
116020
  }
115607
116021
  const keyset = body.attestation.workload_keyset;
@@ -115648,7 +116062,7 @@ async function verifyAciReportBinding(report, nonce, nowSeconds) {
115648
116062
  }
115649
116063
  function selectX25519Key(keyset, expectedKeyId) {
115650
116064
  for (const entry of keyset.e2ee_public_keys) {
115651
- if (!isRecord7(entry) || entry.algo !== E2EE_ALGO_X25519)
116065
+ if (!isRecord8(entry) || entry.algo !== E2EE_ALGO_X25519)
115652
116066
  continue;
115653
116067
  if (typeof entry.public_key !== "string")
115654
116068
  continue;
@@ -130993,9 +131407,11 @@ function createPsLiteRuntime(options) {
130993
131407
  serverOwner: options.serverOwner,
130994
131408
  serverSigner: x402ServerSigner,
130995
131409
  lineageGateway: options.lineageGateway,
130996
- // Recompute on refresh: a new local version marks every
130997
- // question that reads the scope stale.
130998
- onDataWritten: options.derivatives ? (event) => options.derivatives?.scheduler.markSourceChanged(event.scope, { lineageSources: event.lineageSources }) : void 0
131410
+ // A new local version marks every question that reads the
131411
+ // scope stale; the recompute waits for a reader.
131412
+ onDataWritten: options.derivatives ? (event) => options.derivatives?.scheduler.markSourceChanged(event.scope, { lineageSources: event.lineageSources }) : void 0,
131413
+ // And an authorized read of a derived scope is that reader.
131414
+ onDataRead: options.derivatives ? (event) => options.derivatives?.scheduler.markDemand(event.scope) : void 0
130999
131415
  }, { basePath: dataPrefix });
131000
131416
  }
131001
131417
  if (url2.pathname === "/v1/write/session") {
@@ -133246,7 +133662,8 @@ async function createPsLiteQuestionStore(stateStore) {
133246
133662
  const saved = await stateStore.get(QUESTIONS_KEY);
133247
133663
  const initial = (saved?.version === 1 ? saved.questions : []).map((question) => ({
133248
133664
  ...question,
133249
- recompute: question.recompute ?? "on-change"
133665
+ recompute: question.recompute ?? "on-change",
133666
+ answerShape: question.answerShape ?? null
133250
133667
  }));
133251
133668
  return createInMemoryQuestionStore({
133252
133669
  initial,
@@ -133286,7 +133703,7 @@ function createPsLiteDerivativeCompute(options) {
133286
133703
  now: options.now,
133287
133704
  logger,
133288
133705
  compute: (questionId) => computeQuestion(questionId, {
133289
- // A -> B -> C: a question reading this derived scope recomputes.
133706
+ // A -> B -> C: a question reading this derived scope goes stale.
133290
133707
  onDerivedWritten: (event) => scheduler.markSourceChanged(event.scope, {
133291
133708
  lineageSources: event.lineageSources
133292
133709
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opendatalabs/personal-server-ts-server",
3
- "version": "1.14.0",
3
+ "version": "1.16.0",
4
4
  "description": "Hono HTTP server for the Vana Personal Server — routes, middleware, composition root",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -44,8 +44,8 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@hono/node-server": "^1.19.13",
47
- "@opendatalabs/personal-server-ts-core": "1.14.0",
48
- "@opendatalabs/personal-server-ts-lite": "1.14.0",
47
+ "@opendatalabs/personal-server-ts-core": "1.16.0",
48
+ "@opendatalabs/personal-server-ts-lite": "1.16.0",
49
49
  "@opendatalabs/vana-sdk": "3.14.0",
50
50
  "better-sqlite3": "^12.11.1",
51
51
  "hono": "^4.12.27",