@bluecopa/harness 0.1.0-snapshot.59 → 0.1.0-snapshot.60

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluecopa/harness",
3
- "version": "0.1.0-snapshot.59",
3
+ "version": "0.1.0-snapshot.60",
4
4
  "description": "Provider-agnostic TypeScript agent framework",
5
5
  "license": "UNLICENSED",
6
6
  "scripts": {
@@ -70,7 +70,7 @@ export class ArcLoop {
70
70
  private readonly memory: MemoryManager;
71
71
  private readonly modelMap: Record<ModelTier, string>;
72
72
  private readonly orchestratorModel: string;
73
- private readonly systemPrompt: string;
73
+ private readonly systemPrompt: string | Array<{ text: string; cacheControl?: { type: 'ephemeral' } }>;
74
74
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
75
75
  private readonly cachedSystem: any;
76
76
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -102,9 +102,9 @@ export class ArcLoop {
102
102
  this.systemPrompt = config.systemPrompt ?? DEFAULT_ORCHESTRATOR_PROMPT;
103
103
 
104
104
  // AI SDK v6 `system` parameter expects a string or Array<{ type: 'text', text: string }>.
105
- // Passing [{ role: 'system', content }] causes 'system.0.text: Input should be a valid string'
106
- // from the Anthropic API because the SDK reads `.text` (undefined) instead of `.content`.
107
- this.cachedSystem = this.systemPrompt;
105
+ // Build system param: supports both string and structured blocks with cache control.
106
+ // Structured blocks are converted to AI SDK v6 SystemModelMessage format.
107
+ this.cachedSystem = this.buildSystemParam();
108
108
 
109
109
  this.tools = {
110
110
  ...orchestratorTools,
@@ -124,7 +124,9 @@ export class ArcLoop {
124
124
  this.ctx = new ContextWindow({
125
125
  contextWindowSize: config.contextWindowSize ?? 200_000,
126
126
  outputReserve: config.outputReserve ?? 20_000,
127
- systemPrompt: this.systemPrompt,
127
+ systemPrompt: typeof this.systemPrompt === 'string'
128
+ ? this.systemPrompt
129
+ : this.systemPrompt.map(b => b.text).join('\n\n'),
128
130
  episodeStore: config.episodeStore,
129
131
  memory: this.memory,
130
132
  taskId: config.taskId,
@@ -144,6 +146,20 @@ export class ArcLoop {
144
146
  this.traceWriter?.({ ts: Date.now(), kind });
145
147
  }
146
148
 
149
+ /** Build the `system` parameter for streamText. Handles string and structured blocks with cache control. */
150
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
151
+ private buildSystemParam(): any {
152
+ if (typeof this.systemPrompt === 'string') return this.systemPrompt;
153
+ // Structured blocks → AI SDK v6 SystemModelMessage format
154
+ return this.systemPrompt.map(block => ({
155
+ role: 'system' as const,
156
+ content: block.text,
157
+ ...(block.cacheControl
158
+ ? { providerOptions: { anthropic: { cacheControl: block.cacheControl } } }
159
+ : {}),
160
+ }));
161
+ }
162
+
147
163
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
148
164
  private static extractUsage(usage: any): { inputTokens: number; outputTokens: number; cacheReadTokens?: number; cacheWriteTokens?: number; reasoningTokens?: number } | undefined {
149
165
  if (!usage) return undefined;
package/src/arc/types.ts CHANGED
@@ -57,7 +57,8 @@ export interface ArcLoopConfig {
57
57
  /** @deprecated Use createModel instead. Anthropic API key (set via ANTHROPIC_API_KEY env var). */
58
58
  apiKey?: string;
59
59
  /** Custom orchestrator system prompt */
60
- systemPrompt?: string;
60
+ /** System prompt — string or structured blocks with Anthropic cache control markers. */
61
+ systemPrompt?: string | Array<{ text: string; cacheControl?: { type: 'ephemeral' } }>;
61
62
  /** Max orchestrator turns before stopping (default: 30) */
62
63
  maxTurns?: number;
63
64
  /** Extra orchestrator tools beyond Thread/Check/Cancel/Remember */