@granular-software/sdk 0.4.37 → 0.4.39

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.
@@ -1,8 +1,9 @@
1
- import { P as Prompt, f as EnvironmentSession, c as SessionHeapSnapshot, br as ManifestContent, aR as RecordObjectOptions, T as ToolWithHandler, G as Granular, C as ConnectOptions, J as CreateEnvironmentData, k as GranularOptions } from './client-eE9nTfvp.mjs';
1
+ import { a as EnvironmentSession, G as Granular } from './client-CBQFvuKf.mjs';
2
+ import { G as GranularSpendContext, h as OpenAITokenSpend, P as Prompt, c as SessionHeapSnapshot, bM as ManifestContent, ba as RecordObjectOptions, T as ToolWithHandler, C as ConnectOptions, a6 as CreateEnvironmentData, q as GranularOptions } from './spend-tAz2a16I.mjs';
2
3
  import { GranularAgentToolInfo, GeneratedJobCodeIssue, HarnessControllerBudgets } from './agent-harness.mjs';
3
- import '@granular-software/policy-engine';
4
4
  import '@automerge/automerge';
5
5
  import '@automerge/automerge/slim';
6
+ import '@granular-software/policy-engine';
6
7
 
7
8
  type EvalMatcher = string | RegExp;
8
9
  interface AgentEvalPromptInteraction {
@@ -23,6 +24,7 @@ interface AgentEvalGenerationInput {
23
24
  tools?: GranularAgentToolInfo[];
24
25
  repairIssues?: GeneratedJobCodeIssue[];
25
26
  onTextDelta?: (delta: string) => void | Promise<void>;
27
+ usageContext?: GranularSpendContext;
26
28
  }
27
29
  interface AgentEvalGenerationOutput {
28
30
  reply?: string;
@@ -51,6 +53,15 @@ interface AgentEvalTokenUsage {
51
53
  totalCostUsd: number;
52
54
  missingUsageCalls: number;
53
55
  }
56
+ interface AgentEvalOpenAIUsageEvent extends OpenAITokenSpend {
57
+ spendEventId?: string;
58
+ source: "openai";
59
+ lineItemType: "llm_tokens";
60
+ operation: "chat.completions";
61
+ requestId?: string | null;
62
+ usageContext?: GranularSpendContext;
63
+ rawUsage: unknown;
64
+ }
54
65
  type AgentEvalTurnGenerator = (input: AgentEvalGenerationInput) => Promise<AgentEvalGenerationOutput>;
55
66
  interface ScriptedPromptRule {
56
67
  type?: Prompt["type"];
@@ -278,7 +289,10 @@ declare function createOpenAIChatTurnGenerator(options: {
278
289
  baseUrl?: string;
279
290
  temperature?: number;
280
291
  headers?: Record<string, string>;
292
+ usageContext?: GranularSpendContext;
293
+ onUsage?: (usage: AgentEvalOpenAIUsageEvent) => void | Promise<void>;
281
294
  }): AgentEvalTurnGenerator;
295
+ declare function generateTurnWithRepair(generator: AgentEvalTurnGenerator, input: AgentEvalGenerationInput): Promise<AgentEvalGenerationOutput>;
282
296
  declare function runAgentEvalSuite(options: {
283
297
  harness: ReturnType<typeof createAgentEvalHarness>;
284
298
  scenarios: AgentEvalScenario[];
@@ -379,4 +393,4 @@ declare const createHumanResponder: typeof createScriptedPromptResponder;
379
393
  declare const createOpenAIGenerator: typeof createOpenAIChatTurnGenerator;
380
394
  declare const createTestArtifactsDirectory: typeof createTimestampedArtifactDirectory;
381
395
 
382
- export { type AgentEvalCheck, type AgentEvalCheckContext, type AgentEvalCompletedTurn, type AgentEvalConversation, type AgentEvalExpectations, type AgentEvalGenerationAttempt, type AgentEvalGenerationInput, type AgentEvalGenerationOutput, type AgentEvalHarnessOptions, type AgentEvalInspection, type AgentEvalPendingTurn, type AgentEvalPrepareContext, type AgentEvalPromptInteraction, type AgentEvalPromptResponder, type AgentEvalResult, type AgentEvalScenario, type AgentEvalSetup, type AgentEvalSetupContext, type AgentEvalStep, type AgentEvalStepResult, type AgentEvalSuiteResult, type AgentEvalTokenUsage, type AgentEvalTurnGenerator, type AgentTestTarget, type AgentTesterOptions, type EvalMatcher, type ScriptedPromptRule, createAgentEvalHarness, createAgentTester, createHumanResponder, createOpenAIChatTurnGenerator, createOpenAIGenerator, createScriptedPromptResponder, createTestArtifactsDirectory, createTimestampedArtifactDirectory, runAgentEvalSuite, runAgentTests };
396
+ export { type AgentEvalCheck, type AgentEvalCheckContext, type AgentEvalCompletedTurn, type AgentEvalConversation, type AgentEvalExpectations, type AgentEvalGenerationAttempt, type AgentEvalGenerationInput, type AgentEvalGenerationOutput, type AgentEvalHarnessOptions, type AgentEvalInspection, type AgentEvalOpenAIUsageEvent, type AgentEvalPendingTurn, type AgentEvalPrepareContext, type AgentEvalPromptInteraction, type AgentEvalPromptResponder, type AgentEvalResult, type AgentEvalScenario, type AgentEvalSetup, type AgentEvalSetupContext, type AgentEvalStep, type AgentEvalStepResult, type AgentEvalSuiteResult, type AgentEvalTokenUsage, type AgentEvalTurnGenerator, type AgentTestTarget, type AgentTesterOptions, type EvalMatcher, type ScriptedPromptRule, createAgentEvalHarness, createAgentTester, createHumanResponder, createOpenAIChatTurnGenerator, createOpenAIGenerator, createScriptedPromptResponder, createTestArtifactsDirectory, createTimestampedArtifactDirectory, generateTurnWithRepair, runAgentEvalSuite, runAgentTests };
@@ -1,8 +1,9 @@
1
- import { P as Prompt, f as EnvironmentSession, c as SessionHeapSnapshot, br as ManifestContent, aR as RecordObjectOptions, T as ToolWithHandler, G as Granular, C as ConnectOptions, J as CreateEnvironmentData, k as GranularOptions } from './client-eE9nTfvp.js';
1
+ import { a as EnvironmentSession, G as Granular } from './client-BZ8NuQ_e.js';
2
+ import { G as GranularSpendContext, h as OpenAITokenSpend, P as Prompt, c as SessionHeapSnapshot, bM as ManifestContent, ba as RecordObjectOptions, T as ToolWithHandler, C as ConnectOptions, a6 as CreateEnvironmentData, q as GranularOptions } from './spend-tAz2a16I.js';
2
3
  import { GranularAgentToolInfo, GeneratedJobCodeIssue, HarnessControllerBudgets } from './agent-harness.js';
3
- import '@granular-software/policy-engine';
4
4
  import '@automerge/automerge';
5
5
  import '@automerge/automerge/slim';
6
+ import '@granular-software/policy-engine';
6
7
 
7
8
  type EvalMatcher = string | RegExp;
8
9
  interface AgentEvalPromptInteraction {
@@ -23,6 +24,7 @@ interface AgentEvalGenerationInput {
23
24
  tools?: GranularAgentToolInfo[];
24
25
  repairIssues?: GeneratedJobCodeIssue[];
25
26
  onTextDelta?: (delta: string) => void | Promise<void>;
27
+ usageContext?: GranularSpendContext;
26
28
  }
27
29
  interface AgentEvalGenerationOutput {
28
30
  reply?: string;
@@ -51,6 +53,15 @@ interface AgentEvalTokenUsage {
51
53
  totalCostUsd: number;
52
54
  missingUsageCalls: number;
53
55
  }
56
+ interface AgentEvalOpenAIUsageEvent extends OpenAITokenSpend {
57
+ spendEventId?: string;
58
+ source: "openai";
59
+ lineItemType: "llm_tokens";
60
+ operation: "chat.completions";
61
+ requestId?: string | null;
62
+ usageContext?: GranularSpendContext;
63
+ rawUsage: unknown;
64
+ }
54
65
  type AgentEvalTurnGenerator = (input: AgentEvalGenerationInput) => Promise<AgentEvalGenerationOutput>;
55
66
  interface ScriptedPromptRule {
56
67
  type?: Prompt["type"];
@@ -278,7 +289,10 @@ declare function createOpenAIChatTurnGenerator(options: {
278
289
  baseUrl?: string;
279
290
  temperature?: number;
280
291
  headers?: Record<string, string>;
292
+ usageContext?: GranularSpendContext;
293
+ onUsage?: (usage: AgentEvalOpenAIUsageEvent) => void | Promise<void>;
281
294
  }): AgentEvalTurnGenerator;
295
+ declare function generateTurnWithRepair(generator: AgentEvalTurnGenerator, input: AgentEvalGenerationInput): Promise<AgentEvalGenerationOutput>;
282
296
  declare function runAgentEvalSuite(options: {
283
297
  harness: ReturnType<typeof createAgentEvalHarness>;
284
298
  scenarios: AgentEvalScenario[];
@@ -379,4 +393,4 @@ declare const createHumanResponder: typeof createScriptedPromptResponder;
379
393
  declare const createOpenAIGenerator: typeof createOpenAIChatTurnGenerator;
380
394
  declare const createTestArtifactsDirectory: typeof createTimestampedArtifactDirectory;
381
395
 
382
- export { type AgentEvalCheck, type AgentEvalCheckContext, type AgentEvalCompletedTurn, type AgentEvalConversation, type AgentEvalExpectations, type AgentEvalGenerationAttempt, type AgentEvalGenerationInput, type AgentEvalGenerationOutput, type AgentEvalHarnessOptions, type AgentEvalInspection, type AgentEvalPendingTurn, type AgentEvalPrepareContext, type AgentEvalPromptInteraction, type AgentEvalPromptResponder, type AgentEvalResult, type AgentEvalScenario, type AgentEvalSetup, type AgentEvalSetupContext, type AgentEvalStep, type AgentEvalStepResult, type AgentEvalSuiteResult, type AgentEvalTokenUsage, type AgentEvalTurnGenerator, type AgentTestTarget, type AgentTesterOptions, type EvalMatcher, type ScriptedPromptRule, createAgentEvalHarness, createAgentTester, createHumanResponder, createOpenAIChatTurnGenerator, createOpenAIGenerator, createScriptedPromptResponder, createTestArtifactsDirectory, createTimestampedArtifactDirectory, runAgentEvalSuite, runAgentTests };
396
+ export { type AgentEvalCheck, type AgentEvalCheckContext, type AgentEvalCompletedTurn, type AgentEvalConversation, type AgentEvalExpectations, type AgentEvalGenerationAttempt, type AgentEvalGenerationInput, type AgentEvalGenerationOutput, type AgentEvalHarnessOptions, type AgentEvalInspection, type AgentEvalOpenAIUsageEvent, type AgentEvalPendingTurn, type AgentEvalPrepareContext, type AgentEvalPromptInteraction, type AgentEvalPromptResponder, type AgentEvalResult, type AgentEvalScenario, type AgentEvalSetup, type AgentEvalSetupContext, type AgentEvalStep, type AgentEvalStepResult, type AgentEvalSuiteResult, type AgentEvalTokenUsage, type AgentEvalTurnGenerator, type AgentTestTarget, type AgentTesterOptions, type EvalMatcher, type ScriptedPromptRule, createAgentEvalHarness, createAgentTester, createHumanResponder, createOpenAIChatTurnGenerator, createOpenAIGenerator, createScriptedPromptResponder, createTestArtifactsDirectory, createTimestampedArtifactDirectory, generateTurnWithRepair, runAgentEvalSuite, runAgentTests };