@modelprofile.com/flexharness 1.0.1 → 2.0.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/ts/errors.ts CHANGED
@@ -52,6 +52,13 @@ export class FlexHarnessCallbackOverflowError extends FlexHarnessError {
52
52
  }
53
53
  }
54
54
 
55
+ export class FlexHarnessExternalError extends FlexHarnessError {
56
+ constructor(info: IFlexErrorInfo) {
57
+ super(info.code ?? 'FLEX_EXTERNAL_ERROR', info.message);
58
+ this.name = info.name;
59
+ }
60
+ }
61
+
55
62
  export class FlexHarnessPermissionRejectedError extends FlexHarnessError {
56
63
  constructor(permissionId: string, options?: ErrorOptions) {
57
64
  super('FLEX_PERMISSION_REJECTED', `Permission "${permissionId}" was rejected.`, options);
package/ts/interfaces.ts CHANGED
@@ -55,6 +55,7 @@ export interface IFlexModelIdentity {
55
55
  provider: string;
56
56
  model: string;
57
57
  displayName?: string;
58
+ variant?: string;
58
59
  }
59
60
 
60
61
  export type TFlexActivityStatus =
@@ -167,6 +168,21 @@ export interface IFlexPromptResult {
167
168
  steps: number;
168
169
  }
169
170
 
171
+ export interface IFlexPromptAdmission {
172
+ runId: string;
173
+ completion: Promise<IFlexPromptResult>;
174
+ }
175
+
176
+ export interface IFlexMessagePageOptions {
177
+ limit?: number;
178
+ before?: string;
179
+ }
180
+
181
+ export interface IFlexMessagePage {
182
+ messages: IFlexMessage[];
183
+ nextCursor?: string;
184
+ }
185
+
170
186
  export interface IFlexResolvedScope<TScope> {
171
187
  storageKey: string;
172
188
  scope: TScope;
@@ -271,6 +287,27 @@ export interface IFlexCallbackLimits {
271
287
  maxParts?: number;
272
288
  }
273
289
 
290
+ export type TFlexExternalErrorSource =
291
+ | 'modelResolver'
292
+ | 'toolProvider'
293
+ | 'runner'
294
+ | 'toolExecution'
295
+ | 'toolCallback'
296
+ | 'toolCleanup'
297
+ | 'persistence';
298
+
299
+ export interface IFlexExternalErrorContext {
300
+ source: TFlexExternalErrorSource;
301
+ scopeId: string;
302
+ sessionId: string;
303
+ runId: string;
304
+ }
305
+
306
+ export type TFlexExternalErrorProjector = (
307
+ error: unknown,
308
+ context: IFlexExternalErrorContext,
309
+ ) => IFlexErrorInfo;
310
+
274
311
  export interface IFlexHarnessOptions<TScope> {
275
312
  scopeResolver: IFlexScopeResolver<TScope>;
276
313
  modelResolver: IFlexModelResolver<TScope>;
@@ -279,6 +316,7 @@ export interface IFlexHarnessOptions<TScope> {
279
316
  runner?: TFlexAgentRunner;
280
317
  toolOutputLimits?: IFlexJsonLimits;
281
318
  callbackLimits?: IFlexCallbackLimits;
319
+ externalErrorProjector?: TFlexExternalErrorProjector;
282
320
  }
283
321
 
284
322
  export interface IFlexEventBase {
package/ts/utils.json.ts CHANGED
@@ -166,7 +166,7 @@ export function normalizeJsonValue(value: unknown, limits: IFlexJsonLimits = {})
166
166
  if (current instanceof Error) {
167
167
  return description(
168
168
  'error',
169
- { name: shortString(current.name), message: shortString(current.message) },
169
+ { description: 'An error value was returned.' },
170
170
  allowance,
171
171
  );
172
172
  }
@@ -200,9 +200,9 @@ export function normalizeJsonValue(value: unknown, limits: IFlexJsonLimits = {})
200
200
  let entry: unknown;
201
201
  try {
202
202
  entry = current[index];
203
- } catch (error) {
203
+ } catch {
204
204
  entry = makeDescription('unreadable', {
205
- description: shortString(error instanceof Error ? error.message : String(error)),
205
+ description: 'The array entry could not be read.',
206
206
  });
207
207
  }
208
208
  const child = visit(
@@ -266,9 +266,9 @@ export function normalizeJsonValue(value: unknown, limits: IFlexJsonLimits = {})
266
266
  let entry: unknown;
267
267
  try {
268
268
  entry = (current as Record<string, unknown>)[key];
269
- } catch (error) {
269
+ } catch {
270
270
  entry = makeDescription('unreadable', {
271
- description: shortString(error instanceof Error ? error.message : String(error)),
271
+ description: 'The object property could not be read.',
272
272
  });
273
273
  }
274
274
  const child = visit(
@@ -448,6 +448,7 @@ function validateSessionSnapshot(value: unknown, path: string): string {
448
448
  requireString(model.provider, `${messagePath}.model.provider`);
449
449
  requireString(model.model, `${messagePath}.model.model`);
450
450
  requireOptionalString(model.displayName, `${messagePath}.model.displayName`);
451
+ requireOptionalString(model.variant, `${messagePath}.model.variant`);
451
452
  }
452
453
  if (message.usage !== undefined) {
453
454
  const usage = requireRecord(message.usage, `${messagePath}.usage`);