@ai-sdk/harness-acp 1.0.30 → 1.0.31
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/CHANGELOG.md +15 -0
- package/README.md +10 -0
- package/dist/bridge/host-tool-mcp.mjs +1 -1
- package/dist/bridge/index.mjs +41 -12
- package/dist/bridge/index.mjs.map +1 -1
- package/dist/bridge/package.json +2 -2
- package/dist/bridge/pnpm-lock.yaml +57 -55
- package/dist/index.d.ts +30 -2
- package/dist/index.js +83 -91
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/acp-harness.ts +8 -2
- package/src/index.ts +2 -0
- package/src/v1/acp-v1-harness.ts +78 -42
- package/src/v1/acp-v1-lifecycle.ts +1 -29
- package/src/v1/acp-v1-prompt.ts +1 -1
- package/src/v1/acp-v1-settings.ts +24 -1
- package/src/v1/acp-v1-skills.ts +15 -56
- package/src/v1/bridge/acp-v1-bridge-environment.ts +8 -0
- package/src/v1/bridge/index.ts +9 -6
- package/src/v1/bridge/package.json +2 -2
- package/src/v1/bridge/pnpm-lock.yaml +57 -55
- package/src/v1/index.ts +2 -0
package/dist/index.js
CHANGED
|
@@ -659,7 +659,7 @@ function convertHarnessPromptToACPTextBlocks({
|
|
|
659
659
|
}
|
|
660
660
|
return content;
|
|
661
661
|
}
|
|
662
|
-
function
|
|
662
|
+
function prependACPInstructionGuidance({
|
|
663
663
|
prompt,
|
|
664
664
|
instructions
|
|
665
665
|
}) {
|
|
@@ -825,20 +825,26 @@ var bridgeConfigurationSchema = z3.object({
|
|
|
825
825
|
authentication: authenticationSchema.optional(),
|
|
826
826
|
providerAuthentication: providerAuthenticationSchema.optional(),
|
|
827
827
|
providerEnvironment: z3.record(z3.string(), z3.string()).optional(),
|
|
828
|
-
sessionMeta: serializableRecordSchema.optional()
|
|
828
|
+
sessionMeta: serializableRecordSchema.optional(),
|
|
829
|
+
implementationArgs: z3.array(z3.string()).optional(),
|
|
830
|
+
implementationEnv: z3.record(z3.string(), z3.string()).optional()
|
|
829
831
|
});
|
|
830
832
|
function createACPBridgeEnvironment({
|
|
831
833
|
authentication,
|
|
832
834
|
providerAuthentication,
|
|
833
835
|
providerEnvironment,
|
|
834
|
-
sessionMeta
|
|
836
|
+
sessionMeta,
|
|
837
|
+
implementationArgs,
|
|
838
|
+
implementationEnv
|
|
835
839
|
}) {
|
|
836
840
|
return {
|
|
837
841
|
[ACP_BRIDGE_CONFIGURATION_ENV]: JSON.stringify({
|
|
838
842
|
...authentication == null ? {} : { authentication },
|
|
839
843
|
...providerAuthentication == null ? {} : { providerAuthentication },
|
|
840
844
|
...providerEnvironment == null ? {} : { providerEnvironment },
|
|
841
|
-
...sessionMeta == null ? {} : { sessionMeta }
|
|
845
|
+
...sessionMeta == null ? {} : { sessionMeta },
|
|
846
|
+
...implementationArgs == null ? {} : { implementationArgs },
|
|
847
|
+
...implementationEnv == null ? {} : { implementationEnv }
|
|
842
848
|
})
|
|
843
849
|
};
|
|
844
850
|
}
|
|
@@ -1021,19 +1027,6 @@ function resolveACPInitialGuidanceApplied({
|
|
|
1021
1027
|
if (!isResume) return false;
|
|
1022
1028
|
return lifecycleState?.initialGuidanceApplied ?? true;
|
|
1023
1029
|
}
|
|
1024
|
-
function shouldMaterializeACPSkills({
|
|
1025
|
-
isResume,
|
|
1026
|
-
lifecycleState,
|
|
1027
|
-
skillsFingerprint,
|
|
1028
|
-
skillsDirectory
|
|
1029
|
-
}) {
|
|
1030
|
-
if (isResume && lifecycleState?.skillsFingerprint != null && lifecycleState.skillsFingerprint !== skillsFingerprint) {
|
|
1031
|
-
throw new Error(
|
|
1032
|
-
"ACP lifecycle state was created with a different set of skills."
|
|
1033
|
-
);
|
|
1034
|
-
}
|
|
1035
|
-
return !isResume || lifecycleState?.skillsMaterialized !== true || lifecycleState.skillsDirectory !== skillsDirectory;
|
|
1036
|
-
}
|
|
1037
1030
|
function validateACPLifecycleCompatibility({
|
|
1038
1031
|
harnessId,
|
|
1039
1032
|
lifecycleHarnessId,
|
|
@@ -1075,24 +1068,6 @@ import path from "path";
|
|
|
1075
1068
|
import { writeSkills } from "@ai-sdk/harness/utils";
|
|
1076
1069
|
var ACP_SKILL_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
1077
1070
|
var DEFAULT_ACP_SKILLS_DIRECTORY = ".agents/skills";
|
|
1078
|
-
function createACPSkillsFingerprint({
|
|
1079
|
-
skills
|
|
1080
|
-
}) {
|
|
1081
|
-
const canonicalSkills = skills.map((skill) => ({
|
|
1082
|
-
name: skill.name,
|
|
1083
|
-
description: skill.description,
|
|
1084
|
-
content: skill.content,
|
|
1085
|
-
files: [...skill.files ?? []].map((file) => ({
|
|
1086
|
-
path: path.posix.normalize(file.path),
|
|
1087
|
-
content: file.content
|
|
1088
|
-
})).sort(
|
|
1089
|
-
(left, right) => compareCanonicalStrings({ left: left.path, right: right.path })
|
|
1090
|
-
)
|
|
1091
|
-
})).sort(
|
|
1092
|
-
(left, right) => compareCanonicalStrings({ left: left.name, right: right.name })
|
|
1093
|
-
);
|
|
1094
|
-
return createHash4("sha256").update(JSON.stringify(canonicalSkills)).digest("hex");
|
|
1095
|
-
}
|
|
1096
1071
|
function resolveACPPrivateSessionDirectory({
|
|
1097
1072
|
sandboxHomeDir,
|
|
1098
1073
|
sessionWorkDir,
|
|
@@ -1115,24 +1090,21 @@ async function materializeACPSkills({
|
|
|
1115
1090
|
rootDir,
|
|
1116
1091
|
sessionWorkDir,
|
|
1117
1092
|
skills,
|
|
1118
|
-
shouldMaterialize,
|
|
1119
1093
|
abortSignal
|
|
1120
1094
|
}) {
|
|
1121
1095
|
validateACPSkills({ skills });
|
|
1122
1096
|
assertOutsideSessionWorkDir({ rootDir, sessionWorkDir });
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
});
|
|
1135
|
-
}
|
|
1097
|
+
return writeSkills({
|
|
1098
|
+
sandbox,
|
|
1099
|
+
rootDir,
|
|
1100
|
+
skills,
|
|
1101
|
+
abortSignal,
|
|
1102
|
+
skillNamePattern: ACP_SKILL_NAME_PATTERN,
|
|
1103
|
+
invalidSkillNameMessage: ({ name }) => `Invalid ACP skill name ${JSON.stringify(name)}: expected a kebab-case slug.`,
|
|
1104
|
+
invalidSkillFilePathMessage: ({ skillName, filePath }) => `Invalid ACP skill file path ${JSON.stringify(filePath)} for skill ${JSON.stringify(
|
|
1105
|
+
skillName
|
|
1106
|
+
)}: expected a relative POSIX path without traversal.`
|
|
1107
|
+
});
|
|
1136
1108
|
}
|
|
1137
1109
|
function resolveACPSkillsDirectory({
|
|
1138
1110
|
implementationHomeDir,
|
|
@@ -1220,12 +1192,6 @@ function assertOutsideSessionWorkDir({
|
|
|
1220
1192
|
);
|
|
1221
1193
|
}
|
|
1222
1194
|
}
|
|
1223
|
-
function compareCanonicalStrings({
|
|
1224
|
-
left,
|
|
1225
|
-
right
|
|
1226
|
-
}) {
|
|
1227
|
-
return left < right ? -1 : left > right ? 1 : 0;
|
|
1228
|
-
}
|
|
1229
1195
|
|
|
1230
1196
|
// src/v1/acp-v1-harness.ts
|
|
1231
1197
|
var HARNESS_ID_REGEXP = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
@@ -1256,11 +1222,11 @@ function createACPV1({
|
|
|
1256
1222
|
`ACP harnessId must be a stable kebab-case identifier; received ${JSON.stringify(settings.harnessId)}.`
|
|
1257
1223
|
);
|
|
1258
1224
|
}
|
|
1259
|
-
const
|
|
1260
|
-
validateACPV1Implementation(
|
|
1225
|
+
const baseImplementation = createACPV1Implementation({ settings });
|
|
1226
|
+
validateACPV1Implementation(baseImplementation);
|
|
1261
1227
|
const bootstrap = createACPBootstrap({
|
|
1262
1228
|
harnessId: settings.harnessId,
|
|
1263
|
-
implementation
|
|
1229
|
+
implementation: baseImplementation
|
|
1264
1230
|
});
|
|
1265
1231
|
const permissionModeMapping = isCompletePermissionModeMapping({
|
|
1266
1232
|
value: settings.permissionModeMapping
|
|
@@ -1280,6 +1246,19 @@ function createACPV1({
|
|
|
1280
1246
|
message: "ACP built-in tool filtering is not available in this initial ACP v1 implementation."
|
|
1281
1247
|
});
|
|
1282
1248
|
}
|
|
1249
|
+
const modelId = startOptions.model ?? settings.modelId;
|
|
1250
|
+
const modelConfiguration = modelId == null ? void 0 : settings.resolveModel({ model: modelId });
|
|
1251
|
+
const implementation = {
|
|
1252
|
+
...baseImplementation,
|
|
1253
|
+
...modelConfiguration?.args == null ? {} : { args: modelConfiguration.args },
|
|
1254
|
+
...modelConfiguration?.env == null ? {} : {
|
|
1255
|
+
env: {
|
|
1256
|
+
...baseImplementation.env,
|
|
1257
|
+
...modelConfiguration.env
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
};
|
|
1261
|
+
validateACPV1Implementation(implementation);
|
|
1283
1262
|
const permissionMode = startOptions.permissionMode ?? "allow-all";
|
|
1284
1263
|
const env = { ...process.env };
|
|
1285
1264
|
const authenticationEnvironment = resolveACPAuthenticationEnvironment({
|
|
@@ -1440,24 +1419,6 @@ function createACPV1({
|
|
|
1440
1419
|
sessionWorkDir: workDir
|
|
1441
1420
|
});
|
|
1442
1421
|
const bridgeStateDir = `${privateSessionDir}/bridge`;
|
|
1443
|
-
const skills = startOptions.skills ?? [];
|
|
1444
|
-
const skillsFingerprint = createACPSkillsFingerprint({ skills });
|
|
1445
|
-
const shouldMaterializeSkills = shouldMaterializeACPSkills({
|
|
1446
|
-
isResume,
|
|
1447
|
-
lifecycleState: lifecycleData,
|
|
1448
|
-
skillsFingerprint,
|
|
1449
|
-
skillsDirectory
|
|
1450
|
-
});
|
|
1451
|
-
if (skills.length > 0) {
|
|
1452
|
-
await materializeACPSkills({
|
|
1453
|
-
sandbox: toolSafeSandboxSession,
|
|
1454
|
-
rootDir: skillsDirectory,
|
|
1455
|
-
sessionWorkDir: workDir,
|
|
1456
|
-
skills,
|
|
1457
|
-
shouldMaterialize: shouldMaterializeSkills,
|
|
1458
|
-
abortSignal: startOptions.abortSignal
|
|
1459
|
-
});
|
|
1460
|
-
}
|
|
1461
1422
|
const report = startOptions.observability?.report;
|
|
1462
1423
|
const onDiagnostic = report ? (frame) => report(
|
|
1463
1424
|
harnessV1DiagnosticFromBridgeFrame(frame, {
|
|
@@ -1507,7 +1468,7 @@ function createACPV1({
|
|
|
1507
1468
|
harnessId: settings.harnessId,
|
|
1508
1469
|
channel: attachChannel,
|
|
1509
1470
|
proc: void 0,
|
|
1510
|
-
modelId
|
|
1471
|
+
modelId,
|
|
1511
1472
|
sessionMeta: settings.session?.meta,
|
|
1512
1473
|
instructionMapping: settings.instructionMapping,
|
|
1513
1474
|
outputSchemaMapping: settings.outputSchemaMapping,
|
|
@@ -1523,7 +1484,9 @@ function createACPV1({
|
|
|
1523
1484
|
isResume: true,
|
|
1524
1485
|
lifecycleState: lifecycleData
|
|
1525
1486
|
}),
|
|
1526
|
-
|
|
1487
|
+
instructionsFingerprint: lifecycleData.instructionsFingerprint,
|
|
1488
|
+
sandbox: toolSafeSandboxSession,
|
|
1489
|
+
sessionWorkDir: workDir,
|
|
1527
1490
|
skillsDirectory,
|
|
1528
1491
|
acpSessionId: lifecycleData.acpSessionId,
|
|
1529
1492
|
bridgePort: coords.port,
|
|
@@ -1595,7 +1558,7 @@ function createACPV1({
|
|
|
1595
1558
|
}
|
|
1596
1559
|
const turnStartConfig = validateACPColdSessionConfiguration({
|
|
1597
1560
|
coldSession,
|
|
1598
|
-
modelId
|
|
1561
|
+
modelId,
|
|
1599
1562
|
permissionMode,
|
|
1600
1563
|
authenticationProfile,
|
|
1601
1564
|
sessionMeta: settings.session?.meta,
|
|
@@ -1642,7 +1605,9 @@ function createACPV1({
|
|
|
1642
1605
|
authentication: settings.authentication,
|
|
1643
1606
|
providerAuthentication: resolvedProviderAuthentication.providerAuthentication,
|
|
1644
1607
|
providerEnvironment: sandboxProviderEnvironment == null ? void 0 : {},
|
|
1645
|
-
sessionMeta: settings.session?.meta
|
|
1608
|
+
sessionMeta: settings.session?.meta,
|
|
1609
|
+
implementationArgs: modelConfiguration?.args,
|
|
1610
|
+
implementationEnv: modelConfiguration?.env
|
|
1646
1611
|
}),
|
|
1647
1612
|
...sandboxProviderAuthenticationEnvironment,
|
|
1648
1613
|
BRIDGE_CHANNEL_TOKEN: token,
|
|
@@ -1745,7 +1710,7 @@ function createACPV1({
|
|
|
1745
1710
|
harnessId: settings.harnessId,
|
|
1746
1711
|
channel,
|
|
1747
1712
|
proc,
|
|
1748
|
-
modelId
|
|
1713
|
+
modelId,
|
|
1749
1714
|
sessionMeta: settings.session?.meta,
|
|
1750
1715
|
instructionMapping: settings.instructionMapping,
|
|
1751
1716
|
outputSchemaMapping: settings.outputSchemaMapping,
|
|
@@ -1761,7 +1726,9 @@ function createACPV1({
|
|
|
1761
1726
|
isResume,
|
|
1762
1727
|
lifecycleState: lifecycleData
|
|
1763
1728
|
}),
|
|
1764
|
-
|
|
1729
|
+
instructionsFingerprint: lifecycleData?.instructionsFingerprint,
|
|
1730
|
+
sandbox: toolSafeSandboxSession,
|
|
1731
|
+
sessionWorkDir: workDir,
|
|
1765
1732
|
skillsDirectory,
|
|
1766
1733
|
acpSessionId: lifecycleData?.acpSessionId,
|
|
1767
1734
|
bridgePort: boundPort,
|
|
@@ -2000,7 +1967,9 @@ function createSession({
|
|
|
2000
1967
|
mcpServers,
|
|
2001
1968
|
isMcpToolCall,
|
|
2002
1969
|
initialGuidanceApplied: initialGuidanceAppliedAtStart,
|
|
2003
|
-
|
|
1970
|
+
instructionsFingerprint: instructionsFingerprintAtStart,
|
|
1971
|
+
sandbox,
|
|
1972
|
+
sessionWorkDir,
|
|
2004
1973
|
skillsDirectory,
|
|
2005
1974
|
acpSessionId: acpSessionIdAtStart,
|
|
2006
1975
|
bridgePort,
|
|
@@ -2019,6 +1988,7 @@ function createSession({
|
|
|
2019
1988
|
let stopped = false;
|
|
2020
1989
|
let turnInFlight = turnInFlightAtStart;
|
|
2021
1990
|
let initialGuidanceApplied = initialGuidanceAppliedAtStart;
|
|
1991
|
+
let instructionsFingerprint = instructionsFingerprintAtStart;
|
|
2022
1992
|
let latestACPSessionId = acpSessionIdAtStart;
|
|
2023
1993
|
let latestTurnStartConfig = turnStartConfigAtStart;
|
|
2024
1994
|
const markTurnFinished = () => {
|
|
@@ -2261,15 +2231,30 @@ function createSession({
|
|
|
2261
2231
|
...recoveryStatus == null ? {} : { recovery: recoveryStatus },
|
|
2262
2232
|
...restoration == null ? {} : { restoration },
|
|
2263
2233
|
initialGuidanceApplied,
|
|
2264
|
-
|
|
2265
|
-
skillsFingerprint,
|
|
2234
|
+
...instructionsFingerprint == null ? {} : { instructionsFingerprint },
|
|
2266
2235
|
skillsDirectory
|
|
2267
2236
|
});
|
|
2237
|
+
const synchronizeSkills = async ({
|
|
2238
|
+
skills,
|
|
2239
|
+
abortSignal
|
|
2240
|
+
}) => {
|
|
2241
|
+
await materializeACPSkills({
|
|
2242
|
+
sandbox,
|
|
2243
|
+
rootDir: skillsDirectory,
|
|
2244
|
+
sessionWorkDir,
|
|
2245
|
+
skills,
|
|
2246
|
+
abortSignal
|
|
2247
|
+
});
|
|
2248
|
+
};
|
|
2268
2249
|
return {
|
|
2269
2250
|
sessionId,
|
|
2270
2251
|
isResume,
|
|
2271
2252
|
...modelId == null ? {} : { modelId },
|
|
2272
2253
|
doPromptTurn: async (options) => {
|
|
2254
|
+
await synchronizeSkills({
|
|
2255
|
+
skills: options.skills,
|
|
2256
|
+
abortSignal: options.abortSignal
|
|
2257
|
+
});
|
|
2273
2258
|
if (options.responseFormat?.type === "json") {
|
|
2274
2259
|
if (options.responseFormat.schema == null) {
|
|
2275
2260
|
throw unsupported({
|
|
@@ -2310,6 +2295,9 @@ function createSession({
|
|
|
2310
2295
|
responseFormat: options.responseFormat,
|
|
2311
2296
|
outputSchemaMapping
|
|
2312
2297
|
});
|
|
2298
|
+
const nextInstructionsFingerprint = fingerprintValue({
|
|
2299
|
+
value: options.instructions ?? null
|
|
2300
|
+
});
|
|
2313
2301
|
const control = wireTurn({
|
|
2314
2302
|
emit: options.emit,
|
|
2315
2303
|
abortSignal: options.abortSignal,
|
|
@@ -2322,10 +2310,10 @@ function createSession({
|
|
|
2322
2310
|
turnInFlight = true;
|
|
2323
2311
|
channel.send({
|
|
2324
2312
|
type: "start",
|
|
2325
|
-
prompt:
|
|
2313
|
+
prompt: instructionsFingerprint !== nextInstructionsFingerprint && (instructionMapping == null || initialGuidanceApplied) ? prependACPInstructionGuidance({
|
|
2326
2314
|
prompt,
|
|
2327
|
-
instructions:
|
|
2328
|
-
}),
|
|
2315
|
+
instructions: options.instructions
|
|
2316
|
+
}) : prompt,
|
|
2329
2317
|
...instructionMapping == null ? {} : {
|
|
2330
2318
|
instructionMapping,
|
|
2331
2319
|
...options.instructions == null ? {} : { instructions: options.instructions }
|
|
@@ -2342,11 +2330,16 @@ function createSession({
|
|
|
2342
2330
|
});
|
|
2343
2331
|
latestTurnStartConfig = turnStartConfig;
|
|
2344
2332
|
initialGuidanceApplied = true;
|
|
2333
|
+
instructionsFingerprint = nextInstructionsFingerprint;
|
|
2345
2334
|
}
|
|
2346
2335
|
});
|
|
2347
2336
|
return control;
|
|
2348
2337
|
},
|
|
2349
2338
|
doContinueTurn: async (options) => {
|
|
2339
|
+
await synchronizeSkills({
|
|
2340
|
+
skills: options.skills,
|
|
2341
|
+
abortSignal: options.abortSignal
|
|
2342
|
+
});
|
|
2350
2343
|
if (options.responseFormat?.type === "json") {
|
|
2351
2344
|
if (options.responseFormat.schema == null) {
|
|
2352
2345
|
throw unsupported({
|
|
@@ -2628,7 +2621,7 @@ function deserializeBridgeError({
|
|
|
2628
2621
|
}
|
|
2629
2622
|
|
|
2630
2623
|
// src/version.ts
|
|
2631
|
-
var VERSION = true ? "1.0.
|
|
2624
|
+
var VERSION = true ? "1.0.31" : "0.0.0-test";
|
|
2632
2625
|
|
|
2633
2626
|
// src/acp-harness.ts
|
|
2634
2627
|
var ACP_CLIENT_APP = {
|
|
@@ -2667,8 +2660,7 @@ var acpResumeStateSchema = z4.object({
|
|
|
2667
2660
|
method: z4.enum(["resume", "load"])
|
|
2668
2661
|
}).optional(),
|
|
2669
2662
|
initialGuidanceApplied: z4.boolean().optional(),
|
|
2670
|
-
|
|
2671
|
-
skillsFingerprint: z4.string().optional(),
|
|
2663
|
+
instructionsFingerprint: z4.string().optional(),
|
|
2672
2664
|
skillsDirectory: z4.string().optional()
|
|
2673
2665
|
});
|
|
2674
2666
|
function createACP(settings) {
|