@ai-sdk/harness-pi 1.0.103 → 1.0.104

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": "@ai-sdk/harness-pi",
3
- "version": "1.0.103",
3
+ "version": "1.0.104",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -26,7 +26,7 @@
26
26
  }
27
27
  },
28
28
  "dependencies": {
29
- "@ai-sdk/harness": "1.0.101",
29
+ "@ai-sdk/harness": "1.0.102",
30
30
  "@ai-sdk/provider-utils": "5.0.36",
31
31
  "@earendil-works/pi-ai": "0.74.2",
32
32
  "@earendil-works/pi-coding-agent": "^0.84.3",
@@ -37,7 +37,7 @@
37
37
  "zod": "^3.25.76 || ^4.1.8"
38
38
  },
39
39
  "devDependencies": {
40
- "@ai-sdk/sandbox-just-bash": "1.0.101",
40
+ "@ai-sdk/sandbox-just-bash": "1.0.102",
41
41
  "@types/node": "22.19.19",
42
42
  "@vercel/ai-tsconfig": "0.0.0",
43
43
  "tsup": "^8.5.1",
package/src/pi-auth.ts CHANGED
@@ -174,16 +174,19 @@ function createGatewayProviderConfig({
174
174
  apiKey,
175
175
  baseUrl,
176
176
  clientApp,
177
+ headers,
177
178
  }: {
178
179
  apiKey: string;
179
180
  baseUrl: string;
180
181
  clientApp: string;
182
+ headers?: Readonly<Record<string, string>>;
181
183
  }): ProviderConfigInput {
182
184
  return {
183
185
  apiKey,
184
186
  baseUrl,
185
187
  authHeader: true,
186
188
  headers: {
189
+ ...headers,
187
190
  'User-Agent': clientApp,
188
191
  'x-client-app': clientApp,
189
192
  },
@@ -311,11 +314,13 @@ export async function registerPiProviders({
311
314
  resolvedEnv,
312
315
  registries,
313
316
  clientApp = HARNESS_CLIENT_APP,
317
+ headers,
314
318
  }: {
315
319
  options: PiAuthenticationMode | undefined;
316
320
  resolvedEnv: Record<string, string>;
317
321
  registries: PiRegistries;
318
322
  clientApp?: string;
323
+ headers?: Readonly<Record<string, string>>;
319
324
  }): Promise<void> {
320
325
  const suppliedEnvironment = isHarnessAuthenticationEnvironment(options);
321
326
  const authenticationEnvironment = suppliedEnvironment ? options : process.env;
@@ -328,6 +333,7 @@ export async function registerPiProviders({
328
333
  customEnv: { ...pickOpenAIEnv(authenticationEnvironment), ...env },
329
334
  registries,
330
335
  clientApp,
336
+ headers,
331
337
  });
332
338
  return;
333
339
  }
@@ -337,6 +343,7 @@ export async function registerPiProviders({
337
343
  customEnv: { ...pickAnthropicEnv(authenticationEnvironment), ...env },
338
344
  registries,
339
345
  clientApp,
346
+ headers,
340
347
  });
341
348
  return;
342
349
  }
@@ -347,6 +354,7 @@ export async function registerPiProviders({
347
354
  customEnv: { ...pickProviderEnv(authenticationEnvironment), ...env },
348
355
  registries,
349
356
  clientApp,
357
+ headers,
350
358
  });
351
359
  return;
352
360
  }
@@ -367,6 +375,7 @@ export async function registerPiProviders({
367
375
  apiKey: gatewayApiKey,
368
376
  baseUrl: gatewayBaseUrl,
369
377
  clientApp,
378
+ headers,
370
379
  }),
371
380
  });
372
381
  return;
@@ -391,6 +400,7 @@ export async function registerPiProviders({
391
400
  apiKey: gatewayApiKey,
392
401
  baseUrl: gatewayBaseUrl,
393
402
  clientApp,
403
+ headers,
394
404
  }),
395
405
  });
396
406
  return;
@@ -400,6 +410,7 @@ export async function registerPiProviders({
400
410
  customEnv: { ...pickProviderEnv(authenticationEnvironment), ...env },
401
411
  registries,
402
412
  clientApp,
413
+ headers,
403
414
  });
404
415
  return;
405
416
  }
@@ -455,10 +466,12 @@ async function registerCustomProviders({
455
466
  customEnv,
456
467
  registries,
457
468
  clientApp,
469
+ headers,
458
470
  }: {
459
471
  customEnv: Record<string, string>;
460
472
  registries: PiRegistries;
461
473
  clientApp: string;
474
+ headers?: Readonly<Record<string, string>>;
462
475
  }): Promise<void> {
463
476
  const gatewayKey = customEnv.AI_GATEWAY_API_KEY;
464
477
  if (gatewayKey) {
@@ -471,6 +484,7 @@ async function registerCustomProviders({
471
484
  apiKey: gatewayKey,
472
485
  baseUrl,
473
486
  clientApp,
487
+ headers,
474
488
  }),
475
489
  });
476
490
  }
@@ -485,6 +499,7 @@ async function registerCustomProviders({
485
499
  apiKey: customEnv.OPENAI_API_KEY,
486
500
  baseUrl,
487
501
  authHeader: true,
502
+ ...(headers ? { headers } : {}),
488
503
  },
489
504
  });
490
505
  }
@@ -498,10 +513,15 @@ async function registerCustomProviders({
498
513
  config: {
499
514
  apiKey: customEnv.ANTHROPIC_API_KEY,
500
515
  baseUrl,
501
- ...(customEnv.ANTHROPIC_AUTH_TOKEN
516
+ ...(headers || customEnv.ANTHROPIC_AUTH_TOKEN
502
517
  ? {
503
518
  headers: {
504
- authorization: `Bearer ${customEnv.ANTHROPIC_AUTH_TOKEN}`,
519
+ ...headers,
520
+ ...(customEnv.ANTHROPIC_AUTH_TOKEN
521
+ ? {
522
+ authorization: `Bearer ${customEnv.ANTHROPIC_AUTH_TOKEN}`,
523
+ }
524
+ : {}),
505
525
  },
506
526
  }
507
527
  : {}),
@@ -534,6 +554,7 @@ async function registerCustomProviders({
534
554
  apiKey,
535
555
  baseUrl,
536
556
  authHeader: true,
557
+ ...(headers ? { headers } : {}),
537
558
  },
538
559
  });
539
560
  }
package/src/pi-harness.ts CHANGED
@@ -161,6 +161,7 @@ export function createPi(
161
161
  ...(settings.extensionFactories
162
162
  ? { extensionFactories: settings.extensionFactories }
163
163
  : {}),
164
+ ...(startOpts.headers ? { headers: startOpts.headers } : {}),
164
165
  },
165
166
  clientApp: PI_CLIENT_APP,
166
167
  isResume: lifecycleState != null,
package/src/pi-session.ts CHANGED
@@ -33,6 +33,7 @@ import {
33
33
  import {
34
34
  getRestrictedSandboxSession,
35
35
  resolveSandboxHomeDir,
36
+ writeSkills,
36
37
  } from '@ai-sdk/harness/utils';
37
38
  import type { Experimental_SandboxSession as SandboxSession } from '@ai-sdk/provider-utils';
38
39
  import {
@@ -45,7 +46,7 @@ import { getPiTerminalError, parseNativeEvent } from './pi-events';
45
46
  import { createPiModelResolver } from './pi-model-resolver';
46
47
  import { createPiPathMapper } from './pi-paths';
47
48
  import { createPiRemoteOps, type PiRemoteOps } from './pi-remote-ops';
48
- import { writePiSkills } from './pi-skills';
49
+
49
50
  import {
50
51
  persistSessionFileToSandbox,
51
52
  pullSessionFileFromSandbox,
@@ -217,6 +218,7 @@ export type PiThinkingLevel =
217
218
 
218
219
  export interface PiSessionSettings {
219
220
  readonly auth?: PiAuthenticationMode;
221
+ readonly headers?: Readonly<Record<string, string>>;
220
222
  readonly model?: string;
221
223
  readonly thinkingLevel?: PiThinkingLevel;
222
224
  readonly mcpServers?: Record<string, unknown>;
@@ -410,6 +412,7 @@ export async function createPiSession(
410
412
  modelRuntime,
411
413
  },
412
414
  clientApp: input.clientApp,
415
+ headers: input.settings.headers,
413
416
  });
414
417
  const resolveModel = createPiModelResolver({
415
418
  modelRegistry,
@@ -1071,11 +1074,15 @@ export async function createPiSession(
1071
1074
  throw new Error('Pi session has been stopped.');
1072
1075
  }
1073
1076
 
1074
- const skillWriteResult = await writePiSkills({
1077
+ const skillWriteResult = await writeSkills({
1075
1078
  sandbox: toolSafeSandboxSession,
1076
- sandboxHomeDir,
1079
+ homePath: sandboxHomeDir,
1080
+ skillsDir: '.agents/skills',
1077
1081
  skills: turnOpts.skills,
1078
1082
  abortSignal: turnOpts.abortSignal,
1083
+ invalidSkillNameMessage: ({ name }) => `Invalid Pi skill name: ${name}`,
1084
+ invalidSkillFilePathMessage: ({ skillName, filePath }) =>
1085
+ `Invalid Pi skill file path for ${skillName}: ${filePath}`,
1079
1086
  });
1080
1087
  harnessSkills = createHarnessPiSkills({
1081
1088
  skills: turnOpts.skills,
package/src/pi-skills.ts DELETED
@@ -1,25 +0,0 @@
1
- import path from 'node:path';
2
- import type { HarnessV1Skill } from '@ai-sdk/harness';
3
- import { writeSkills, type WriteSkillsResult } from '@ai-sdk/harness/utils';
4
- import type { Experimental_SandboxSession } from '@ai-sdk/provider-utils';
5
-
6
- /**
7
- * Materialize Pi skills as files under
8
- * `$HOME/.agents/skills/<name>/SKILL.md` inside the sandbox.
9
- */
10
- export async function writePiSkills(args: {
11
- readonly sandbox: Experimental_SandboxSession;
12
- readonly sandboxHomeDir: string;
13
- readonly skills: ReadonlyArray<HarnessV1Skill>;
14
- readonly abortSignal?: AbortSignal;
15
- }): Promise<WriteSkillsResult> {
16
- return writeSkills({
17
- sandbox: args.sandbox,
18
- rootDir: path.posix.join(args.sandboxHomeDir, '.agents', 'skills'),
19
- skills: args.skills,
20
- abortSignal: args.abortSignal,
21
- invalidSkillNameMessage: ({ name }) => `Invalid Pi skill name: ${name}`,
22
- invalidSkillFilePathMessage: ({ skillName, filePath }) =>
23
- `Invalid Pi skill file path for ${skillName}: ${filePath}`,
24
- });
25
- }