@modelprofile.com/flexharness-agent 10.10.0 → 10.12.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_ts_agent/classes.sessionengine.d.ts +1 -0
- package/dist_ts_agent/classes.sessionengine.js +194 -41
- package/dist_ts_agent/index.d.ts +1 -1
- package/dist_ts_agent/index.js +1 -1
- package/dist_ts_agent/plugins.d.ts +3 -3
- package/dist_ts_agent/plugins.js +3 -3
- package/dist_ts_agent/smartagent.interfaces.d.ts +20 -3
- package/dist_ts_agent/smartagent.interfaces.js +1 -1
- package/dist_ts_agent/smartagent.pendinginput.d.ts +3 -0
- package/dist_ts_agent/smartagent.pendinginput.js +31 -1
- package/dist_ts_agent/smartagent.usage.d.ts +1 -1
- package/dist_ts_agent/smartagent.usage.js +4 -2
- package/package.json +2 -2
- package/readme.md +8 -0
- package/ts_agent/classes.sessionengine.ts +203 -40
- package/ts_agent/index.ts +1 -0
- package/ts_agent/plugins.ts +7 -0
- package/ts_agent/readme.md +8 -0
- package/ts_agent/smartagent.interfaces.ts +24 -3
- package/ts_agent/smartagent.pendinginput.ts +26 -0
- package/ts_agent/smartagent.usage.ts +3 -1
package/dist_ts_agent/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export { AgentModelCallUsageRecorder } from './smartagent.usage.js';
|
|
|
10
10
|
export type { IAgentModelCallUsageRecorderModel } from './smartagent.usage.js';
|
|
11
11
|
export { AgentGenerationLeaseCleanupError, ContextOverflowError, } from './smartagent.interfaces.js';
|
|
12
12
|
export { AGENT_TOOL_RESULT_FILE_MAX_BYTES, AgentEventStoreConflictError, InMemoryAgentEventStore, isAgentEventStoreV2, validateAgentEventArchiveV2, validateAgentEventSnapshotV2, } from './smartagent.persistence.js';
|
|
13
|
-
export type { IAgentCacheOptions, IAgentContextOverflowInvocationOptions, IAgentContextBuildOptions, IAgentContextCompactionOptions, IAgentCompactOptions, IAgentEventRetentionOptions, IAgentBeginGenerationOptions, IAgentFinalizeGenerationOptions, IAgentGenerateOptions, IAgentGenerateResult, IAgentGenerationHandle, IAgentGenerationLease, IAgentGenerationPreparationContext, IAgentRunOptions, IAgentRunResult, IAgentSession, IAgentSessionAbortOptions, IAgentSessionChange, IAgentSessionOptions, IAgentScheduleGenerateOptions, IAgentToolCallRecord, IAgentToolCallStartEvent, IAgentToolCallUpdateEvent, IAgentUsage, ProviderOptions, TAgentCacheRetention, TAgentCacheSetting, TAgentPrompt, TAgentContextBuilder, TAgentContextCompactor, TAgentGenerationPrepare, TAgentModelCallUnreportedReason, TAgentModelCallUsage, TAgentModelCallUsageEvent, TAgentModelCallUsageReporter, TAgentSessionChangeListener, TAgentToolCallFinishEvent, TAgentToolExecutionReconciliationOptions, } from './smartagent.interfaces.js';
|
|
13
|
+
export type { IAgentCacheOptions, ISmartAiCacheDispatch, IAgentContextOverflowInvocationOptions, IAgentContextBuildOptions, IAgentContextCompactionOptions, IAgentCompactOptions, IAgentEventRetentionOptions, IAgentBeginGenerationOptions, IAgentFinalizeGenerationOptions, IAgentGenerateOptions, IAgentGenerateResult, IAgentGenerationHandle, IAgentGenerationLease, IAgentGenerationPreparationContext, IAgentRunOptions, IAgentRunResult, IAgentSession, IAgentSessionAbortOptions, IAgentSessionChange, IAgentSessionOptions, IAgentScheduleGenerateOptions, IAgentToolCallRecord, IAgentToolCallStartEvent, IAgentToolCallUpdateEvent, IAgentUsage, ProviderOptions, TAgentCacheRetention, TAgentCacheSetting, TAgentPrompt, TAgentContextBuilder, TAgentContextCompactor, TAgentGenerationPrepare, TAgentModelCallUnreportedReason, TAgentModelCallUsage, TAgentModelCallUsageEvent, TAgentModelCallUsageReporter, TAgentSessionChangeListener, TAgentToolCallFinishEvent, TAgentToolExecutionReconciliationOptions, } from './smartagent.interfaces.js';
|
|
14
14
|
export type { IAgentEventArchive, IAgentEventArchiveV2, IAgentEventSnapshot, IAgentEventSnapshotV2, IAgentEventStore, IAgentEventStoreV2, TAgentEventArchive, TAgentEventSnapshot, TAgentEventStore, } from './smartagent.persistence.js';
|
|
15
15
|
export type { IAgentEventBase, IAgentRuntimeEventPayload, IArchivedAgentGenerationTransaction, IAssistantMessageEvent, IContextCompactionEvent, IGenerationBegunEvent, IGenerationExecutionCompletedEvent, IGenerationExecutionStartedEvent, IGenerationOutcomeEvent, IModelMessageEvent, IModelMessagesToEventsOptions, IModelMessageEventIdentityCoordinates, IRuntimeEvent, ISystemMessageEvent, IToolCallEvent, IToolExecutionIntentEvent, IToolExecutionReconciliationEvent, IToolResultEvent, IUserMessageEvent, TAgentAssistantMessage, TAgentConversationEvent, TAgentControlEvent, TAgentEvent, TAgentEventInput, TAgentSystemMessage, TAgentGenerationOutcome, TAgentToolCallPart, TAgentToolMessage, TAgentToolResultOutput, TAgentToolResultPart, TAgentUserMessage, TModelMessageEmittedEventKind, TModelMessageEventIdentityFactory, TToolExecutionReconciliation, } from './smartagent.events.js';
|
|
16
16
|
export type { IAgentGenerationTransaction, TAgentGenerationTransactionState, } from './smartagent.transactions.js';
|
package/dist_ts_agent/index.js
CHANGED
|
@@ -13,4 +13,4 @@ export * from './tool.persistence.js';
|
|
|
13
13
|
export * from './tool.adapter.js';
|
|
14
14
|
export { tool, jsonSchema, stepCountIs, z } from './plugins.js';
|
|
15
15
|
export { FileAgentEventStore } from './persistence.file.js';
|
|
16
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
16
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90c19hZ2VudC9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0sK0JBQStCLENBQUM7QUFDekQsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQy9ELE9BQU8sRUFBRSxrQkFBa0IsRUFBRSxNQUF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LanguageModel };
|
|
3
3
|
export type { AssistantModelMessage, LanguageModelUsage, ModelMessage, StepResult, SystemModelMessage, ToolSet, ToolModelMessage, ToolExecutionOptions, StreamTextResult, UserModelMessage, } from 'ai';
|
|
4
|
-
import { applySmartAiCacheProviderOptions, createModelLimitInfo, createSmartAiCachingMiddleware, isModelLimitError, isModelLimitInfo, jsonSchema, ModelLimitError, readRetryAfterMs, resolveSmartAiCacheProvider, tool } from '@modelprofile.com/flexharness-models';
|
|
5
|
-
export { applySmartAiCacheProviderOptions, createModelLimitInfo, createSmartAiCachingMiddleware, isModelLimitError, isModelLimitInfo, ModelLimitError, readRetryAfterMs, resolveSmartAiCacheProvider, tool, jsonSchema, };
|
|
6
|
-
export type { ISmartAiCacheOptions, TSmartAiLanguageModel, TSmartAiCacheRetention, TSmartAiCacheSetting, TSmartAiProviderOptions as ProviderOptions, } from '@modelprofile.com/flexharness-models';
|
|
4
|
+
import { applySmartAiCacheProviderOptions, bindSmartAiCachePolicyObserver, createModelLimitInfo, createSmartAiCachingMiddleware, getSmartAiCacheWaitMs, observeSmartAiCacheDispatch, isModelLimitError, isModelLimitInfo, jsonSchema, ModelLimitError, readRetryAfterMs, resolveSmartAiCacheProvider, tool } from '@modelprofile.com/flexharness-models';
|
|
5
|
+
export { applySmartAiCacheProviderOptions, bindSmartAiCachePolicyObserver, createModelLimitInfo, createSmartAiCachingMiddleware, getSmartAiCacheWaitMs, observeSmartAiCacheDispatch, isModelLimitError, isModelLimitInfo, ModelLimitError, readRetryAfterMs, resolveSmartAiCacheProvider, tool, jsonSchema, };
|
|
6
|
+
export type { ISmartAiCacheOptions, ISmartAiCacheDispatch, TSmartAiLanguageModel, TSmartAiCacheRetention, TSmartAiCacheSetting, TSmartAiProviderOptions as ProviderOptions, } from '@modelprofile.com/flexharness-models';
|
|
7
7
|
export type { IToolExecutionContext, IToolJobState, } from './tool.contracts.js';
|
|
8
8
|
import { z } from 'zod';
|
|
9
9
|
export { z };
|
package/dist_ts_agent/plugins.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { streamText, generateText, stepCountIs, wrapLanguageModel } from 'ai';
|
|
3
3
|
export { streamText, generateText, stepCountIs, wrapLanguageModel };
|
|
4
4
|
// model contracts and AI SDK
|
|
5
|
-
import { applySmartAiCacheProviderOptions, createModelLimitInfo, createSmartAiCachingMiddleware, isModelLimitError, isModelLimitInfo, jsonSchema, ModelLimitError, readRetryAfterMs, resolveSmartAiCacheProvider, tool, } from '@modelprofile.com/flexharness-models';
|
|
6
|
-
export { applySmartAiCacheProviderOptions, createModelLimitInfo, createSmartAiCachingMiddleware, isModelLimitError, isModelLimitInfo, ModelLimitError, readRetryAfterMs, resolveSmartAiCacheProvider, tool, jsonSchema, };
|
|
5
|
+
import { applySmartAiCacheProviderOptions, bindSmartAiCachePolicyObserver, createModelLimitInfo, createSmartAiCachingMiddleware, getSmartAiCacheWaitMs, observeSmartAiCacheDispatch, isModelLimitError, isModelLimitInfo, jsonSchema, ModelLimitError, readRetryAfterMs, resolveSmartAiCacheProvider, tool, } from '@modelprofile.com/flexharness-models';
|
|
6
|
+
export { applySmartAiCacheProviderOptions, bindSmartAiCachePolicyObserver, createModelLimitInfo, createSmartAiCachingMiddleware, getSmartAiCacheWaitMs, observeSmartAiCacheDispatch, isModelLimitError, isModelLimitInfo, ModelLimitError, readRetryAfterMs, resolveSmartAiCacheProvider, tool, jsonSchema, };
|
|
7
7
|
// zod
|
|
8
8
|
import { z } from 'zod';
|
|
9
9
|
export { z };
|
|
10
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
10
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzX2FnZW50L3BsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYztBQUNkLE9BQU8sRUFBRSxVQUFVLEVBQUUsWUFBWSxFQUFFLFdBQVcsRUFBRSxpQkFBaUIsRUFBRSxNQUFNLElBQUksQ0FBQztBQUU5RSxPQUFPLEVBQUUsVUFBVSxFQUFFLFlBQVksRUFBRSxXQUFXLEVBQUUsaUJBQWlCLEVBQUUsQ0FBQztBQWVwRSw2QkFBNkI7QUFDN0IsT0FBTyxFQUNMLGdDQUFnQyxFQUNoQyw4QkFBOEIsRUFDOUIsb0JBQW9CLEVBQ3BCLDhCQUE4QixFQUM5QixxQkFBcUIsRUFDckIsMkJBQTJCLEVBQzNCLGlCQUFpQixFQUNqQixnQkFBZ0IsRUFDaEIsVUFBVSxFQUNWLGVBQWUsRUFDZixnQkFBZ0IsRUFDaEIsMkJBQTJCLEVBQzNCLElBQUksR0FDTCxNQUFNLHNDQUFzQyxDQUFDO0FBRTlDLE9BQU8sRUFDTCxnQ0FBZ0MsRUFDaEMsOEJBQThCLEVBQzlCLG9CQUFvQixFQUNwQiw4QkFBOEIsRUFDOUIscUJBQXFCLEVBQ3JCLDJCQUEyQixFQUMzQixpQkFBaUIsRUFDakIsZ0JBQWdCLEVBQ2hCLGVBQWUsRUFDZixnQkFBZ0IsRUFDaEIsMkJBQTJCLEVBQzNCLElBQUksRUFDSixVQUFVLEdBQ1gsQ0FBQztBQWlCRixNQUFNO0FBQ04sT0FBTyxFQUFFLENBQUMsRUFBRSxNQUFNLEtBQUssQ0FBQztBQUV4QixPQUFPLEVBQUUsQ0FBQyxFQUFFLENBQUMifQ==
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { ISmartAiCacheOptions, ToolSet, ModelMessage, TSmartAiLanguageModel, ProviderOptions, IToolExecutionContext, IToolJobState, TSmartAiCacheRetention, TSmartAiCacheSetting } from './plugins.js';
|
|
1
|
+
import type { ISmartAiCacheOptions, ISmartAiCacheDispatch, ToolSet, ModelMessage, TSmartAiLanguageModel, ProviderOptions, IToolExecutionContext, IToolJobState, TSmartAiCacheRetention, TSmartAiCacheSetting } from './plugins.js';
|
|
2
2
|
import type { IAgentRuntimeEventPayload, IToolExecutionIntentEvent, TAgentEvent, TAgentGenerationOutcome, TAgentToolResultOutput } from './smartagent.events.js';
|
|
3
3
|
import type { TAgentEventArchive, TAgentEventStore } from './smartagent.persistence.js';
|
|
4
4
|
import type { AgentPendingInputQueue, IAgentAppliedInput } from './smartagent.pendinginput.js';
|
|
5
5
|
import type { IAgentRetryEvent } from './smartagent.retry.js';
|
|
6
|
-
export type { ProviderOptions };
|
|
6
|
+
export type { ProviderOptions, ISmartAiCacheDispatch };
|
|
7
7
|
export interface IAgentCacheOptions extends ISmartAiCacheOptions {
|
|
8
8
|
}
|
|
9
9
|
export type TAgentCacheRetention = TSmartAiCacheRetention;
|
|
@@ -62,6 +62,7 @@ export type TAgentModelCallUnreportedReason = 'aborted' | 'failed' | 'missing';
|
|
|
62
62
|
* The usage outcome of one model call, as the component that made the call reports it.
|
|
63
63
|
* `reported`: the provider reported the call's usage. `responseModelId` is the model id the
|
|
64
64
|
* provider's response named, or `requestedModelId` when the response named none.
|
|
65
|
+
* `usageComplete: false` preserves partial counts without certifying missing totals as zero.
|
|
65
66
|
* `unreported`: the call ended before the provider reported its usage: `aborted` (the call was
|
|
66
67
|
* aborted), `failed` (the call or its response failed) or `missing` (the response carried no usage).
|
|
67
68
|
* The provider may still have consumed tokens for it; their number is unknown.
|
|
@@ -70,6 +71,8 @@ export type TAgentModelCallUsage = (IAgentModelCallIdentity & {
|
|
|
70
71
|
status: 'reported';
|
|
71
72
|
responseModelId: string;
|
|
72
73
|
usage: IAgentUsage;
|
|
74
|
+
/** False when input/output totals were missing; zero-filled usage is only a lower bound. */
|
|
75
|
+
usageComplete?: false;
|
|
73
76
|
}) | (IAgentModelCallIdentity & {
|
|
74
77
|
status: 'unreported';
|
|
75
78
|
reason: TAgentModelCallUnreportedReason;
|
|
@@ -324,12 +327,24 @@ export interface IAgentGenerateOptions {
|
|
|
324
327
|
* Called when the model ends the generation while steps remain. Resolve once the input this
|
|
325
328
|
* generation should still take in is committed, for example the result of background work it
|
|
326
329
|
* started; reject to fail the generation. A generation does not end while a user message of its
|
|
327
|
-
* own is committed that its model has not seen: it runs another step instead.
|
|
330
|
+
* own is committed that its model has not seen: it runs another step instead. The callback
|
|
331
|
+
* must honor its abort signal: pending user input aborts this scoped wait (not the generation)
|
|
332
|
+
* so the input can be taken in at the next step boundary.
|
|
328
333
|
*/
|
|
329
334
|
beforeFinish?: (context: {
|
|
330
335
|
generationId: string;
|
|
331
336
|
abortSignal: AbortSignal;
|
|
337
|
+
cacheDispatch?: ISmartAiCacheDispatch;
|
|
332
338
|
}) => Promise<void>;
|
|
339
|
+
/** Selected-model invocation after runtime cache transforms, not opaque inner adapter dispatch. Must not throw. */
|
|
340
|
+
onCacheDispatch?: (dispatch: ISmartAiCacheDispatch) => void;
|
|
341
|
+
/**
|
|
342
|
+
* Take in terminal job events only for jobs whose started event names the metadata.toolCallId
|
|
343
|
+
* of a currently executing, prepared local tool of this generation. Requires jobs.subscribe;
|
|
344
|
+
* independent jobs are not cancelled on finish.
|
|
345
|
+
* At most 256 jobs are tracked per generation; exceeding the bound fails the generation.
|
|
346
|
+
*/
|
|
347
|
+
activateOnBackgroundJobs?: boolean;
|
|
333
348
|
}
|
|
334
349
|
export interface IAgentScheduleGenerateOptions extends IAgentGenerateOptions {
|
|
335
350
|
/** Coalescing identity for this scheduled generation. */
|
|
@@ -367,6 +382,8 @@ export interface IAgentRunResult {
|
|
|
367
382
|
toolCalls: IAgentToolCallRecord[];
|
|
368
383
|
}
|
|
369
384
|
export interface IAgentGenerateResult extends IAgentRunResult {
|
|
385
|
+
/** Why the session loop stopped. Tool-only step exhaustion still resolves for direct callers. */
|
|
386
|
+
terminationReason: 'model' | 'step-limit';
|
|
370
387
|
/** Raw canonical events remain available independently from model messages. */
|
|
371
388
|
events: readonly TAgentEvent[];
|
|
372
389
|
}
|
|
@@ -21,4 +21,4 @@ export class ContextOverflowError extends Error {
|
|
|
21
21
|
this.name = 'ContextOverflowError';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csc0JBQXNCLENBQUM7SUFDckMsQ0FBQztDQUNGIn0=
|
|
@@ -40,11 +40,14 @@ export declare class AgentPendingInputQueue {
|
|
|
40
40
|
private readonly waiting;
|
|
41
41
|
private readonly inputIds;
|
|
42
42
|
private isClosed;
|
|
43
|
+
private readonly changeListeners;
|
|
43
44
|
/** True once `close()` ended intake. */
|
|
44
45
|
get closed(): boolean;
|
|
45
46
|
/** Inputs waiting for the next step boundary. */
|
|
46
47
|
get size(): number;
|
|
47
48
|
add(input: IAgentPendingInput): void;
|
|
49
|
+
/** Resolves on pending input (true) or closure (false); abort removes the event listener. */
|
|
50
|
+
waitForInput(signal: AbortSignal): Promise<boolean>;
|
|
48
51
|
/** Takes every waiting input in arrival order; a closed queue has none left to take. */
|
|
49
52
|
drain(): IAgentPendingInput[];
|
|
50
53
|
/**
|
|
@@ -40,6 +40,7 @@ export class AgentPendingInputQueue {
|
|
|
40
40
|
waiting = [];
|
|
41
41
|
inputIds = new Set();
|
|
42
42
|
isClosed = false;
|
|
43
|
+
changeListeners = new Set();
|
|
43
44
|
/** True once `close()` ended intake. */
|
|
44
45
|
get closed() {
|
|
45
46
|
return this.isClosed;
|
|
@@ -60,6 +61,30 @@ export class AgentPendingInputQueue {
|
|
|
60
61
|
throw new AgentPendingInputRejectedError('closed', input.inputId);
|
|
61
62
|
this.inputIds.add(input.inputId);
|
|
62
63
|
this.waiting.push({ inputId: input.inputId, content: structuredClone(input.content) });
|
|
64
|
+
for (const listener of this.changeListeners)
|
|
65
|
+
listener();
|
|
66
|
+
}
|
|
67
|
+
/** Resolves on pending input (true) or closure (false); abort removes the event listener. */
|
|
68
|
+
async waitForInput(signal) {
|
|
69
|
+
signal.throwIfAborted();
|
|
70
|
+
if (this.isClosed || this.waiting.length > 0)
|
|
71
|
+
return Promise.resolve(!this.isClosed);
|
|
72
|
+
return new Promise((resolve, reject) => {
|
|
73
|
+
const cleanup = () => {
|
|
74
|
+
this.changeListeners.delete(onChange);
|
|
75
|
+
signal.removeEventListener('abort', onAbort);
|
|
76
|
+
};
|
|
77
|
+
const onChange = () => {
|
|
78
|
+
cleanup();
|
|
79
|
+
resolve(!this.isClosed);
|
|
80
|
+
};
|
|
81
|
+
const onAbort = () => {
|
|
82
|
+
cleanup();
|
|
83
|
+
reject(signal.reason);
|
|
84
|
+
};
|
|
85
|
+
this.changeListeners.add(onChange);
|
|
86
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
87
|
+
});
|
|
63
88
|
}
|
|
64
89
|
/** Takes every waiting input in arrival order; a closed queue has none left to take. */
|
|
65
90
|
drain() {
|
|
@@ -82,11 +107,16 @@ export class AgentPendingInputQueue {
|
|
|
82
107
|
}
|
|
83
108
|
}
|
|
84
109
|
this.waiting.unshift(...inputs);
|
|
110
|
+
if (inputs.length > 0)
|
|
111
|
+
for (const listener of this.changeListeners)
|
|
112
|
+
listener();
|
|
85
113
|
}
|
|
86
114
|
/** Ends intake and returns the inputs that were never taken in, in arrival order. */
|
|
87
115
|
close() {
|
|
88
116
|
this.isClosed = true;
|
|
117
|
+
for (const listener of this.changeListeners)
|
|
118
|
+
listener();
|
|
89
119
|
return Object.freeze([...this.waiting]);
|
|
90
120
|
}
|
|
91
121
|
}
|
|
92
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
122
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhZ2VudC5wZW5kaW5naW5wdXQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90c19hZ2VudC9zbWFydGFnZW50LnBlbmRpbmdpbnB1dC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFxQkEsdUZBQXVGO0FBQ3ZGLE1BQU0sT0FBTyw4QkFBK0IsU0FBUSxLQUFLO0lBRXJDO0lBQ0E7SUFGbEIsWUFDa0IsTUFBbUMsRUFDbkMsT0FBZTtRQUUvQixLQUFLLENBQUMsTUFBTSxLQUFLLFdBQVc7WUFDMUI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Q0FBQztJQUNqRixDQUFDO0lBRUQscUZBQXFGO0lBQzlFLEtBQUs7UUFDVixJQUFJLENBQUMsUUFBUSxHQUFHLElBQUksQ0FBQztRQUNyQixLQUFLLE1BQU0sUUFBUSxJQUFJLElBQUksQ0FBQyxlQUFlO1lBQUUsUUFBUSxFQUFFLENBQUM7UUFDeEQsT0FBTyxNQUFNLENBQUMsTUFBTSxDQUFDLENBQUMsR0FBRyxJQUFJLENBQUMsT0FBTyxDQUFDLENBQUMsQ0FBQztJQUMxQyxDQUFDO0NBQ0YifQ==
|
|
@@ -18,7 +18,7 @@ export declare class AgentModelCallUsageRecorder {
|
|
|
18
18
|
constructor(model: IAgentModelCallUsageRecorderModel, report: TAgentModelCallUsageReporter);
|
|
19
19
|
/** A model call begins. */
|
|
20
20
|
start(): void;
|
|
21
|
-
/**
|
|
21
|
+
/** Missing input/output totals are zero-filled for aggregation but explicitly incomplete. */
|
|
22
22
|
end(responseModelId: string, providerUsage: LanguageModelUsage): void;
|
|
23
23
|
/** The current call ended without usage. Does nothing when no call is open. */
|
|
24
24
|
settle(reason: TAgentModelCallUnreportedReason): void;
|
|
@@ -17,7 +17,7 @@ export class AgentModelCallUsageRecorder {
|
|
|
17
17
|
this.settle('missing');
|
|
18
18
|
this.open = true;
|
|
19
19
|
}
|
|
20
|
-
/**
|
|
20
|
+
/** Missing input/output totals are zero-filled for aggregation but explicitly incomplete. */
|
|
21
21
|
end(responseModelId, providerUsage) {
|
|
22
22
|
this.open = false;
|
|
23
23
|
const inputTokens = providerUsage.inputTokens ?? 0;
|
|
@@ -35,6 +35,8 @@ export class AgentModelCallUsageRecorder {
|
|
|
35
35
|
requestedModelId: this.model.modelId,
|
|
36
36
|
responseModelId,
|
|
37
37
|
usage,
|
|
38
|
+
...(providerUsage.inputTokens === undefined || providerUsage.outputTokens === undefined
|
|
39
|
+
? { usageComplete: false } : {}),
|
|
38
40
|
});
|
|
39
41
|
}
|
|
40
42
|
/** The current call ended without usage. Does nothing when no call is open. */
|
|
@@ -50,4 +52,4 @@ export class AgentModelCallUsageRecorder {
|
|
|
50
52
|
});
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
55
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhZ2VudC51c2FnZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzX2FnZW50L3NtYXJ0YWdlbnQudXNhZ2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBYUE7Ozs7O0dBS0c7QUFDSCxNQUFNLE9BQU8sMkJBQTJCO0lBSW5CO0lBQ0E7SUFKWCxJQUFJLEdBQUcsS0FBSyxDQUFDO0lBRXJCLFlBQ21CLEtBQXdDLEVBQ3hDLE1BQW9DO1FBRHBDLFVBQUssR0FBTCxLQUFLLENBQW1DO1FBQ3hDLFdBQU0sR0FBTixNQUFNLENBQThCO0lBQ3BELENBQUM7SUFFSiwyQkFBMkI7SUFDcEIsS0FBSztRQUNWLElBQUksQ0FBQyxNQUFNLENBQUMsU0FBUyxDQUFDLENBQUM7UUFDdkIsSUFBSSxDQUFDLElBQUksR0FBRyxJQUFJLENBQUM7SUFDbkIsQ0FBQztJQUVELDZGQUE2RjtJQUN0RixHQUFHLENBQUMsZUFBdUIsRUFBRSxhQUFpQztRQUNuRSxJQUFJLENBQUMsSUFBSSxHQUFHLEtBQUssQ0FBQztRQUNsQixNQUFNLFdBQVcsR0FBRyxhQUFhLENBQUMsV0FBVyxJQUFJLENBQUMsQ0FBQztRQUNuRCxNQUFNLFlBQVksR0FBRyxhQUFhLENBQUMsWUFBWSxJQUFJLENBQUMsQ0FBQztRQUNyRCxNQUFNLEtBQUssR0FBZ0I7WUFDekIsV0FBVztZQUNYLFlBQVk7WUFDWixXQUFXLEVBQUUsV0FBVyxHQUFHLFlBQVk7WUFDdkMsZUFBZSxFQUFFLGFBQWEsQ0FB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
|
|
5
|
-
"version": "10.
|
|
5
|
+
"version": "10.12.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"description": "Standalone event-driven agent runtime with generation transactions, context and tool execution contracts.",
|
|
8
8
|
"main": "./dist_ts_agent/index.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@modelprofile.com/flexharness-models": "10.
|
|
21
|
+
"@modelprofile.com/flexharness-models": "10.12.0",
|
|
22
22
|
"ai": "^7.0.111",
|
|
23
23
|
"zod": "^4.6.5",
|
|
24
24
|
"@noble/hashes": "^2.4.0",
|
package/readme.md
CHANGED
|
@@ -178,6 +178,7 @@ try {
|
|
|
178
178
|
usageComplete = false;
|
|
179
179
|
return;
|
|
180
180
|
}
|
|
181
|
+
if (event.usageComplete === false) usageComplete = false;
|
|
181
182
|
for (const key of Object.keys(used) as (keyof IAgentUsage)[]) used[key] += event.usage[key];
|
|
182
183
|
},
|
|
183
184
|
});
|
|
@@ -192,6 +193,7 @@ try {
|
|
|
192
193
|
| `generationId` | The generation the call belongs to. A compaction carries the generation whose context overflow caused it; a compaction by `compact()` or event retention has none. |
|
|
193
194
|
| `provider`, `requestedModelId` | The model the call was made with: the language model's `provider` and `modelId`. Every event carries both, whatever its status, so key usage caps on them. |
|
|
194
195
|
| `status: 'reported'`, `usage`, `responseModelId` | The provider reported the call's usage. A count the provider leaves out is zero. `responseModelId` is the model id the provider's response named (a provider may answer with a dated model version), or `requestedModelId` when it named none. |
|
|
196
|
+
| `usageComplete: false` | A reported call omitted its input or output total. The zero-filled aggregate preserves the known counts as a lower bound, not proof that missing counts were zero. Absence of cache-detail counts alone does not make the input/output total incomplete. |
|
|
195
197
|
| `status: 'unreported'`, `reason` | The call ended before the provider reported its usage: `aborted` (the call was aborted), `failed` (the call or its response failed) or `missing` (the response carried no usage). The provider may still have consumed tokens for it; their number is unknown. |
|
|
196
198
|
|
|
197
199
|
When a run returns, its reported calls sum to `result.usage`; count one or the other, not both. A call is reported when the provider's response ends, before its tool calls run, so a run aborted during a tool call still reports the call that requested it. Retried calls and validation retries are included. `onUsage` must not throw; an error it throws is reported like a session listener error and does not change the run's outcome. `runAgent` delivers every event of the run before its promise settles. `AgentSession.create()` accepts the same callback for every generation and compaction of the session; `generate()` and `scheduleGenerate()` without a `transaction` reject as soon as their abort signal fires and may report the interrupted call afterwards; `close()` waits for that report. With a `transaction`, they settle only after every call of the generation has been reported.
|
|
@@ -411,3 +413,9 @@ Registered at District Court Bremen HRB 35230 HB, Germany
|
|
|
411
413
|
For any legal inquiries or further information, please contact us via email at hello@task.vc.
|
|
412
414
|
|
|
413
415
|
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
|
416
|
+
|
|
417
|
+
### Generation finish waits and termination
|
|
418
|
+
|
|
419
|
+
`AgentSession.generate()` returns `terminationReason: 'model' | 'step-limit'` separately from the provider's `finishReason`. A final answer on the last allowed step is a model completion; a tool-only final step or unseen generation input with no steps left is step exhaustion. Direct callers can deliberately use a one-step tool-only generation: it still resolves, and they can inspect the termination reason.
|
|
420
|
+
|
|
421
|
+
A `beforeFinish` hook must honor its scoped abort signal. Pending user input preempts that wait, without cancelling the generation or its tools, so the generation records the input durably at its next step boundary. Hook cleanup is joined; failures other than the exact input-preemption reason still fail the generation.
|