@ai-sdk/harness-acp 1.0.30 → 1.0.32
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 +25 -0
- package/README.md +11 -0
- package/dist/bridge/host-tool-mcp.mjs +1 -1
- package/dist/bridge/index.mjs +94 -30
- 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 +26 -2
- package/dist/index.js +121 -104
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/acp-harness.ts +9 -2
- package/src/index.ts +1 -0
- package/src/v1/acp-v1-bridge-protocol.ts +27 -6
- package/src/v1/acp-v1-harness.ts +85 -47
- 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 +20 -1
- package/src/v1/acp-v1-skills.ts +15 -56
- package/src/v1/acp-v1-turn-start-config.ts +7 -3
- package/src/v1/bridge/acp-v1-bridge-environment.ts +4 -0
- package/src/v1/bridge/index.ts +16 -5
- package/src/v1/bridge/model-mapping.ts +35 -0
- package/src/v1/bridge/package.json +2 -2
- package/src/v1/bridge/pnpm-lock.yaml +57 -55
- package/src/v1/bridge/protocol-configuration.ts +6 -2
- package/src/v1/implementation.ts +8 -0
- package/src/v1/index.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -311,6 +311,8 @@ function createImplementationIdentity({
|
|
|
311
311
|
acpVersion,
|
|
312
312
|
implementation,
|
|
313
313
|
clientApp,
|
|
314
|
+
clientCapabilities,
|
|
315
|
+
modelMapping,
|
|
314
316
|
providerAuthentication,
|
|
315
317
|
permissionModeMapping
|
|
316
318
|
}) {
|
|
@@ -344,6 +346,8 @@ function createImplementationIdentity({
|
|
|
344
346
|
executable: implementation.executable,
|
|
345
347
|
args: implementation.args ?? [],
|
|
346
348
|
clientApp,
|
|
349
|
+
clientCapabilities: clientCapabilities ?? null,
|
|
350
|
+
modelMapping,
|
|
347
351
|
environment: {
|
|
348
352
|
forwarded: forwardedEnvironment,
|
|
349
353
|
credential: credentialEnvironment,
|
|
@@ -659,7 +663,7 @@ function convertHarnessPromptToACPTextBlocks({
|
|
|
659
663
|
}
|
|
660
664
|
return content;
|
|
661
665
|
}
|
|
662
|
-
function
|
|
666
|
+
function prependACPInstructionGuidance({
|
|
663
667
|
prompt,
|
|
664
668
|
instructions
|
|
665
669
|
}) {
|
|
@@ -729,6 +733,19 @@ var outputSchemaMappingSchema = z2.object({
|
|
|
729
733
|
type: z2.literal("session-prompt-meta"),
|
|
730
734
|
path: z2.array(z2.string().min(1)).min(1)
|
|
731
735
|
});
|
|
736
|
+
var modelMappingSchema = z2.discriminatedUnion(
|
|
737
|
+
"type",
|
|
738
|
+
[
|
|
739
|
+
z2.object({
|
|
740
|
+
type: z2.literal("session-config-option"),
|
|
741
|
+
path: z2.string().min(1)
|
|
742
|
+
}),
|
|
743
|
+
z2.object({
|
|
744
|
+
type: z2.literal("session-model"),
|
|
745
|
+
path: z2.string().min(1)
|
|
746
|
+
})
|
|
747
|
+
]
|
|
748
|
+
);
|
|
732
749
|
var acpTurnStartConfigSchema = z2.object({
|
|
733
750
|
version: z2.literal(1),
|
|
734
751
|
configurationFingerprint: z2.string(),
|
|
@@ -737,12 +754,17 @@ var acpTurnStartConfigSchema = z2.object({
|
|
|
737
754
|
builtinTools: z2.array(builtinToolSchema).default([]),
|
|
738
755
|
permissionMode: harnessV1BridgeStartBaseSchema.shape.permissionMode.unwrap(),
|
|
739
756
|
permissionModeMapping: permissionModeMappingSchema.optional(),
|
|
757
|
+
model: harnessV1BridgeStartBaseSchema.shape.model.optional(),
|
|
758
|
+
modelMapping: modelMappingSchema.optional(),
|
|
740
759
|
debug: harnessV1BridgeStartBaseSchema.shape.debug.optional(),
|
|
741
760
|
responseFormat: harnessV1BridgeStartBaseSchema.shape.responseFormat.optional(),
|
|
742
761
|
outputSchemaMapping: outputSchemaMappingSchema.optional()
|
|
743
762
|
});
|
|
744
|
-
var acpColdSessionStateSchema = acpTurnStartConfigSchema.omit({
|
|
745
|
-
|
|
763
|
+
var acpColdSessionStateSchema = acpTurnStartConfigSchema.omit({
|
|
764
|
+
prompt: true,
|
|
765
|
+
debug: true,
|
|
766
|
+
model: true,
|
|
767
|
+
modelMapping: true
|
|
746
768
|
});
|
|
747
769
|
var lossyRecoverySchema = z2.object({
|
|
748
770
|
type: z2.literal("lossy-rerun"),
|
|
@@ -772,6 +794,7 @@ var startMessageSchema = harnessV1BridgeStartBaseSchema.extend({
|
|
|
772
794
|
tools: z2.array(acpSerializableToolSpecSchema).optional(),
|
|
773
795
|
builtinTools: z2.array(builtinToolSchema).readonly().default([]),
|
|
774
796
|
permissionModeMapping: permissionModeMappingSchema.optional(),
|
|
797
|
+
modelMapping: modelMappingSchema.optional(),
|
|
775
798
|
turnStartConfig: acpTurnStartConfigSchema,
|
|
776
799
|
recoveryMode: z2.discriminatedUnion("type", [lossyRecoverySchema, coldRestoreSchema]).optional()
|
|
777
800
|
});
|
|
@@ -825,20 +848,23 @@ var bridgeConfigurationSchema = z3.object({
|
|
|
825
848
|
authentication: authenticationSchema.optional(),
|
|
826
849
|
providerAuthentication: providerAuthenticationSchema.optional(),
|
|
827
850
|
providerEnvironment: z3.record(z3.string(), z3.string()).optional(),
|
|
828
|
-
sessionMeta: serializableRecordSchema.optional()
|
|
851
|
+
sessionMeta: serializableRecordSchema.optional(),
|
|
852
|
+
clientCapabilities: serializableRecordSchema.optional()
|
|
829
853
|
});
|
|
830
854
|
function createACPBridgeEnvironment({
|
|
831
855
|
authentication,
|
|
832
856
|
providerAuthentication,
|
|
833
857
|
providerEnvironment,
|
|
834
|
-
sessionMeta
|
|
858
|
+
sessionMeta,
|
|
859
|
+
clientCapabilities
|
|
835
860
|
}) {
|
|
836
861
|
return {
|
|
837
862
|
[ACP_BRIDGE_CONFIGURATION_ENV]: JSON.stringify({
|
|
838
863
|
...authentication == null ? {} : { authentication },
|
|
839
864
|
...providerAuthentication == null ? {} : { providerAuthentication },
|
|
840
865
|
...providerEnvironment == null ? {} : { providerEnvironment },
|
|
841
|
-
...sessionMeta == null ? {} : { sessionMeta }
|
|
866
|
+
...sessionMeta == null ? {} : { sessionMeta },
|
|
867
|
+
...clientCapabilities == null ? {} : { clientCapabilities }
|
|
842
868
|
})
|
|
843
869
|
};
|
|
844
870
|
}
|
|
@@ -952,7 +978,9 @@ function createACPTurnStartConfig({
|
|
|
952
978
|
sessionMeta,
|
|
953
979
|
instructionMapping,
|
|
954
980
|
responseFormat,
|
|
955
|
-
outputSchemaMapping
|
|
981
|
+
outputSchemaMapping,
|
|
982
|
+
model,
|
|
983
|
+
modelMapping
|
|
956
984
|
}) {
|
|
957
985
|
return {
|
|
958
986
|
version: 1,
|
|
@@ -962,6 +990,7 @@ function createACPTurnStartConfig({
|
|
|
962
990
|
sessionMeta: sessionMeta ?? null,
|
|
963
991
|
...instructionMapping == null ? {} : { instructionMapping },
|
|
964
992
|
...outputSchemaMapping == null ? {} : { outputSchemaMapping },
|
|
993
|
+
modelMapping,
|
|
965
994
|
builtinTools,
|
|
966
995
|
permissionModeMapping: permissionModeMapping ?? null,
|
|
967
996
|
mcpServers: mcpServers ?? null
|
|
@@ -971,6 +1000,7 @@ function createACPTurnStartConfig({
|
|
|
971
1000
|
tools: tools.map((tool) => acpSerializableToolSpecSchema.parse(tool)),
|
|
972
1001
|
builtinTools: [...builtinTools],
|
|
973
1002
|
permissionMode,
|
|
1003
|
+
...model == null ? {} : { model, modelMapping },
|
|
974
1004
|
...responseFormat == null ? {} : { responseFormat },
|
|
975
1005
|
...outputSchemaMapping == null ? {} : {
|
|
976
1006
|
outputSchemaMapping: {
|
|
@@ -983,8 +1013,7 @@ function createACPTurnStartConfig({
|
|
|
983
1013
|
};
|
|
984
1014
|
}
|
|
985
1015
|
function createACPColdSessionState({
|
|
986
|
-
turnStartConfig
|
|
987
|
-
modelId
|
|
1016
|
+
turnStartConfig
|
|
988
1017
|
}) {
|
|
989
1018
|
return {
|
|
990
1019
|
version: turnStartConfig.version,
|
|
@@ -994,8 +1023,7 @@ function createACPColdSessionState({
|
|
|
994
1023
|
permissionMode: turnStartConfig.permissionMode,
|
|
995
1024
|
...turnStartConfig.responseFormat == null ? {} : { responseFormat: turnStartConfig.responseFormat },
|
|
996
1025
|
...turnStartConfig.outputSchemaMapping == null ? {} : { outputSchemaMapping: turnStartConfig.outputSchemaMapping },
|
|
997
|
-
...turnStartConfig.permissionModeMapping == null ? {} : { permissionModeMapping: turnStartConfig.permissionModeMapping }
|
|
998
|
-
...modelId == null ? {} : { modelId }
|
|
1026
|
+
...turnStartConfig.permissionModeMapping == null ? {} : { permissionModeMapping: turnStartConfig.permissionModeMapping }
|
|
999
1027
|
};
|
|
1000
1028
|
}
|
|
1001
1029
|
function stableStringify3(value) {
|
|
@@ -1021,19 +1049,6 @@ function resolveACPInitialGuidanceApplied({
|
|
|
1021
1049
|
if (!isResume) return false;
|
|
1022
1050
|
return lifecycleState?.initialGuidanceApplied ?? true;
|
|
1023
1051
|
}
|
|
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
1052
|
function validateACPLifecycleCompatibility({
|
|
1038
1053
|
harnessId,
|
|
1039
1054
|
lifecycleHarnessId,
|
|
@@ -1075,24 +1090,6 @@ import path from "path";
|
|
|
1075
1090
|
import { writeSkills } from "@ai-sdk/harness/utils";
|
|
1076
1091
|
var ACP_SKILL_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
1077
1092
|
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
1093
|
function resolveACPPrivateSessionDirectory({
|
|
1097
1094
|
sandboxHomeDir,
|
|
1098
1095
|
sessionWorkDir,
|
|
@@ -1115,24 +1112,21 @@ async function materializeACPSkills({
|
|
|
1115
1112
|
rootDir,
|
|
1116
1113
|
sessionWorkDir,
|
|
1117
1114
|
skills,
|
|
1118
|
-
shouldMaterialize,
|
|
1119
1115
|
abortSignal
|
|
1120
1116
|
}) {
|
|
1121
1117
|
validateACPSkills({ skills });
|
|
1122
1118
|
assertOutsideSessionWorkDir({ rootDir, sessionWorkDir });
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
});
|
|
1135
|
-
}
|
|
1119
|
+
return writeSkills({
|
|
1120
|
+
sandbox,
|
|
1121
|
+
rootDir,
|
|
1122
|
+
skills,
|
|
1123
|
+
abortSignal,
|
|
1124
|
+
skillNamePattern: ACP_SKILL_NAME_PATTERN,
|
|
1125
|
+
invalidSkillNameMessage: ({ name }) => `Invalid ACP skill name ${JSON.stringify(name)}: expected a kebab-case slug.`,
|
|
1126
|
+
invalidSkillFilePathMessage: ({ skillName, filePath }) => `Invalid ACP skill file path ${JSON.stringify(filePath)} for skill ${JSON.stringify(
|
|
1127
|
+
skillName
|
|
1128
|
+
)}: expected a relative POSIX path without traversal.`
|
|
1129
|
+
});
|
|
1136
1130
|
}
|
|
1137
1131
|
function resolveACPSkillsDirectory({
|
|
1138
1132
|
implementationHomeDir,
|
|
@@ -1220,12 +1214,6 @@ function assertOutsideSessionWorkDir({
|
|
|
1220
1214
|
);
|
|
1221
1215
|
}
|
|
1222
1216
|
}
|
|
1223
|
-
function compareCanonicalStrings({
|
|
1224
|
-
left,
|
|
1225
|
-
right
|
|
1226
|
-
}) {
|
|
1227
|
-
return left < right ? -1 : left > right ? 1 : 0;
|
|
1228
|
-
}
|
|
1229
1217
|
|
|
1230
1218
|
// src/v1/acp-v1-harness.ts
|
|
1231
1219
|
var HARNESS_ID_REGEXP = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
@@ -1296,6 +1284,8 @@ function createACPV1({
|
|
|
1296
1284
|
acpVersion: "v1",
|
|
1297
1285
|
implementation,
|
|
1298
1286
|
clientApp,
|
|
1287
|
+
clientCapabilities: settings.clientCapabilities,
|
|
1288
|
+
modelMapping: settings.modelMapping,
|
|
1299
1289
|
providerAuthentication: providerAuthenticationCompatibility,
|
|
1300
1290
|
permissionModeMapping: settings.permissionModeMapping
|
|
1301
1291
|
});
|
|
@@ -1440,24 +1430,6 @@ function createACPV1({
|
|
|
1440
1430
|
sessionWorkDir: workDir
|
|
1441
1431
|
});
|
|
1442
1432
|
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
1433
|
const report = startOptions.observability?.report;
|
|
1462
1434
|
const onDiagnostic = report ? (frame) => report(
|
|
1463
1435
|
harnessV1DiagnosticFromBridgeFrame(frame, {
|
|
@@ -1507,7 +1479,8 @@ function createACPV1({
|
|
|
1507
1479
|
harnessId: settings.harnessId,
|
|
1508
1480
|
channel: attachChannel,
|
|
1509
1481
|
proc: void 0,
|
|
1510
|
-
|
|
1482
|
+
modelMapping: settings.modelMapping,
|
|
1483
|
+
defaultModelId: settings.modelId,
|
|
1511
1484
|
sessionMeta: settings.session?.meta,
|
|
1512
1485
|
instructionMapping: settings.instructionMapping,
|
|
1513
1486
|
outputSchemaMapping: settings.outputSchemaMapping,
|
|
@@ -1523,7 +1496,9 @@ function createACPV1({
|
|
|
1523
1496
|
isResume: true,
|
|
1524
1497
|
lifecycleState: lifecycleData
|
|
1525
1498
|
}),
|
|
1526
|
-
|
|
1499
|
+
instructionsFingerprint: lifecycleData.instructionsFingerprint,
|
|
1500
|
+
sandbox: toolSafeSandboxSession,
|
|
1501
|
+
sessionWorkDir: workDir,
|
|
1527
1502
|
skillsDirectory,
|
|
1528
1503
|
acpSessionId: lifecycleData.acpSessionId,
|
|
1529
1504
|
bridgePort: coords.port,
|
|
@@ -1570,6 +1545,7 @@ function createACPV1({
|
|
|
1570
1545
|
sessionMeta: settings.session?.meta,
|
|
1571
1546
|
instructionMapping: settings.instructionMapping,
|
|
1572
1547
|
outputSchemaMapping: settings.outputSchemaMapping,
|
|
1548
|
+
modelMapping: settings.modelMapping,
|
|
1573
1549
|
builtinTools: builtinToolCatalog,
|
|
1574
1550
|
permissionModeMapping,
|
|
1575
1551
|
mcpServers: settings.mcpServers
|
|
@@ -1595,12 +1571,12 @@ function createACPV1({
|
|
|
1595
1571
|
}
|
|
1596
1572
|
const turnStartConfig = validateACPColdSessionConfiguration({
|
|
1597
1573
|
coldSession,
|
|
1598
|
-
modelId: settings.modelId,
|
|
1599
1574
|
permissionMode,
|
|
1600
1575
|
authenticationProfile,
|
|
1601
1576
|
sessionMeta: settings.session?.meta,
|
|
1602
1577
|
instructionMapping: settings.instructionMapping,
|
|
1603
1578
|
outputSchemaMapping: settings.outputSchemaMapping,
|
|
1579
|
+
modelMapping: settings.modelMapping,
|
|
1604
1580
|
builtinTools: builtinToolCatalog,
|
|
1605
1581
|
permissionModeMapping,
|
|
1606
1582
|
mcpServers: settings.mcpServers,
|
|
@@ -1642,7 +1618,8 @@ function createACPV1({
|
|
|
1642
1618
|
authentication: settings.authentication,
|
|
1643
1619
|
providerAuthentication: resolvedProviderAuthentication.providerAuthentication,
|
|
1644
1620
|
providerEnvironment: sandboxProviderEnvironment == null ? void 0 : {},
|
|
1645
|
-
sessionMeta: settings.session?.meta
|
|
1621
|
+
sessionMeta: settings.session?.meta,
|
|
1622
|
+
clientCapabilities: settings.clientCapabilities
|
|
1646
1623
|
}),
|
|
1647
1624
|
...sandboxProviderAuthenticationEnvironment,
|
|
1648
1625
|
BRIDGE_CHANNEL_TOKEN: token,
|
|
@@ -1745,7 +1722,8 @@ function createACPV1({
|
|
|
1745
1722
|
harnessId: settings.harnessId,
|
|
1746
1723
|
channel,
|
|
1747
1724
|
proc,
|
|
1748
|
-
|
|
1725
|
+
modelMapping: settings.modelMapping,
|
|
1726
|
+
defaultModelId: settings.modelId,
|
|
1749
1727
|
sessionMeta: settings.session?.meta,
|
|
1750
1728
|
instructionMapping: settings.instructionMapping,
|
|
1751
1729
|
outputSchemaMapping: settings.outputSchemaMapping,
|
|
@@ -1761,7 +1739,9 @@ function createACPV1({
|
|
|
1761
1739
|
isResume,
|
|
1762
1740
|
lifecycleState: lifecycleData
|
|
1763
1741
|
}),
|
|
1764
|
-
|
|
1742
|
+
instructionsFingerprint: lifecycleData?.instructionsFingerprint,
|
|
1743
|
+
sandbox: toolSafeSandboxSession,
|
|
1744
|
+
sessionWorkDir: workDir,
|
|
1765
1745
|
skillsDirectory,
|
|
1766
1746
|
acpSessionId: lifecycleData?.acpSessionId,
|
|
1767
1747
|
bridgePort: boundPort,
|
|
@@ -1987,7 +1967,8 @@ function createSession({
|
|
|
1987
1967
|
harnessId,
|
|
1988
1968
|
channel,
|
|
1989
1969
|
proc,
|
|
1990
|
-
|
|
1970
|
+
modelMapping,
|
|
1971
|
+
defaultModelId,
|
|
1991
1972
|
sessionMeta,
|
|
1992
1973
|
instructionMapping,
|
|
1993
1974
|
outputSchemaMapping,
|
|
@@ -2000,7 +1981,9 @@ function createSession({
|
|
|
2000
1981
|
mcpServers,
|
|
2001
1982
|
isMcpToolCall,
|
|
2002
1983
|
initialGuidanceApplied: initialGuidanceAppliedAtStart,
|
|
2003
|
-
|
|
1984
|
+
instructionsFingerprint: instructionsFingerprintAtStart,
|
|
1985
|
+
sandbox,
|
|
1986
|
+
sessionWorkDir,
|
|
2004
1987
|
skillsDirectory,
|
|
2005
1988
|
acpSessionId: acpSessionIdAtStart,
|
|
2006
1989
|
bridgePort,
|
|
@@ -2019,6 +2002,7 @@ function createSession({
|
|
|
2019
2002
|
let stopped = false;
|
|
2020
2003
|
let turnInFlight = turnInFlightAtStart;
|
|
2021
2004
|
let initialGuidanceApplied = initialGuidanceAppliedAtStart;
|
|
2005
|
+
let instructionsFingerprint = instructionsFingerprintAtStart;
|
|
2022
2006
|
let latestACPSessionId = acpSessionIdAtStart;
|
|
2023
2007
|
let latestTurnStartConfig = turnStartConfigAtStart;
|
|
2024
2008
|
const markTurnFinished = () => {
|
|
@@ -2253,23 +2237,36 @@ function createSession({
|
|
|
2253
2237
|
...bridge == null ? {} : { bridge },
|
|
2254
2238
|
...latestTurnStartConfig == null ? {} : {
|
|
2255
2239
|
coldSession: createACPColdSessionState({
|
|
2256
|
-
turnStartConfig: latestTurnStartConfig
|
|
2257
|
-
modelId
|
|
2240
|
+
turnStartConfig: latestTurnStartConfig
|
|
2258
2241
|
})
|
|
2259
2242
|
},
|
|
2260
2243
|
...!includeTurnStartConfig || latestTurnStartConfig == null ? {} : { turnStartConfig: latestTurnStartConfig },
|
|
2261
2244
|
...recoveryStatus == null ? {} : { recovery: recoveryStatus },
|
|
2262
2245
|
...restoration == null ? {} : { restoration },
|
|
2263
2246
|
initialGuidanceApplied,
|
|
2264
|
-
|
|
2265
|
-
skillsFingerprint,
|
|
2247
|
+
...instructionsFingerprint == null ? {} : { instructionsFingerprint },
|
|
2266
2248
|
skillsDirectory
|
|
2267
2249
|
});
|
|
2250
|
+
const synchronizeSkills = async ({
|
|
2251
|
+
skills,
|
|
2252
|
+
abortSignal
|
|
2253
|
+
}) => {
|
|
2254
|
+
await materializeACPSkills({
|
|
2255
|
+
sandbox,
|
|
2256
|
+
rootDir: skillsDirectory,
|
|
2257
|
+
sessionWorkDir,
|
|
2258
|
+
skills,
|
|
2259
|
+
abortSignal
|
|
2260
|
+
});
|
|
2261
|
+
};
|
|
2268
2262
|
return {
|
|
2269
2263
|
sessionId,
|
|
2270
2264
|
isResume,
|
|
2271
|
-
...modelId == null ? {} : { modelId },
|
|
2272
2265
|
doPromptTurn: async (options) => {
|
|
2266
|
+
await synchronizeSkills({
|
|
2267
|
+
skills: options.skills,
|
|
2268
|
+
abortSignal: options.abortSignal
|
|
2269
|
+
});
|
|
2273
2270
|
if (options.responseFormat?.type === "json") {
|
|
2274
2271
|
if (options.responseFormat.schema == null) {
|
|
2275
2272
|
throw unsupported({
|
|
@@ -2296,6 +2293,7 @@ function createSession({
|
|
|
2296
2293
|
prompt: options.prompt,
|
|
2297
2294
|
harnessId
|
|
2298
2295
|
});
|
|
2296
|
+
const model = options.model ?? defaultModelId;
|
|
2299
2297
|
const turnStartConfig = createACPTurnStartConfig({
|
|
2300
2298
|
prompt,
|
|
2301
2299
|
tools: options.tools ?? [],
|
|
@@ -2308,7 +2306,12 @@ function createSession({
|
|
|
2308
2306
|
sessionMeta,
|
|
2309
2307
|
instructionMapping,
|
|
2310
2308
|
responseFormat: options.responseFormat,
|
|
2311
|
-
outputSchemaMapping
|
|
2309
|
+
outputSchemaMapping,
|
|
2310
|
+
model,
|
|
2311
|
+
modelMapping
|
|
2312
|
+
});
|
|
2313
|
+
const nextInstructionsFingerprint = fingerprintValue({
|
|
2314
|
+
value: options.instructions ?? null
|
|
2312
2315
|
});
|
|
2313
2316
|
const control = wireTurn({
|
|
2314
2317
|
emit: options.emit,
|
|
@@ -2322,10 +2325,10 @@ function createSession({
|
|
|
2322
2325
|
turnInFlight = true;
|
|
2323
2326
|
channel.send({
|
|
2324
2327
|
type: "start",
|
|
2325
|
-
prompt:
|
|
2328
|
+
prompt: instructionsFingerprint !== nextInstructionsFingerprint && (instructionMapping == null || initialGuidanceApplied) ? prependACPInstructionGuidance({
|
|
2326
2329
|
prompt,
|
|
2327
|
-
instructions:
|
|
2328
|
-
}),
|
|
2330
|
+
instructions: options.instructions
|
|
2331
|
+
}) : prompt,
|
|
2329
2332
|
...instructionMapping == null ? {} : {
|
|
2330
2333
|
instructionMapping,
|
|
2331
2334
|
...options.instructions == null ? {} : { instructions: options.instructions }
|
|
@@ -2334,6 +2337,7 @@ function createSession({
|
|
|
2334
2337
|
builtinTools,
|
|
2335
2338
|
permissionMode,
|
|
2336
2339
|
permissionModeMapping,
|
|
2340
|
+
...model == null ? {} : { model, modelMapping },
|
|
2337
2341
|
...options.responseFormat == null ? {} : { responseFormat: options.responseFormat },
|
|
2338
2342
|
...turnStartConfig.outputSchemaMapping == null ? {} : { outputSchemaMapping: turnStartConfig.outputSchemaMapping },
|
|
2339
2343
|
...mcpServers == null ? {} : { mcpServers },
|
|
@@ -2342,11 +2346,16 @@ function createSession({
|
|
|
2342
2346
|
});
|
|
2343
2347
|
latestTurnStartConfig = turnStartConfig;
|
|
2344
2348
|
initialGuidanceApplied = true;
|
|
2349
|
+
instructionsFingerprint = nextInstructionsFingerprint;
|
|
2345
2350
|
}
|
|
2346
2351
|
});
|
|
2347
2352
|
return control;
|
|
2348
2353
|
},
|
|
2349
2354
|
doContinueTurn: async (options) => {
|
|
2355
|
+
await synchronizeSkills({
|
|
2356
|
+
skills: options.skills,
|
|
2357
|
+
abortSignal: options.abortSignal
|
|
2358
|
+
});
|
|
2350
2359
|
if (options.responseFormat?.type === "json") {
|
|
2351
2360
|
if (options.responseFormat.schema == null) {
|
|
2352
2361
|
throw unsupported({
|
|
@@ -2388,6 +2397,10 @@ function createSession({
|
|
|
2388
2397
|
builtinTools: turnStartConfig.builtinTools,
|
|
2389
2398
|
permissionMode: turnStartConfig.permissionMode,
|
|
2390
2399
|
permissionModeMapping: turnStartConfig.permissionModeMapping,
|
|
2400
|
+
...turnStartConfig.model == null ? {} : {
|
|
2401
|
+
model: turnStartConfig.model,
|
|
2402
|
+
modelMapping: turnStartConfig.modelMapping
|
|
2403
|
+
},
|
|
2391
2404
|
...turnStartConfig.responseFormat == null ? {} : { responseFormat: turnStartConfig.responseFormat },
|
|
2392
2405
|
...turnStartConfig.outputSchemaMapping == null ? {} : { outputSchemaMapping: turnStartConfig.outputSchemaMapping },
|
|
2393
2406
|
...instructionMapping == null ? {} : {
|
|
@@ -2532,6 +2545,7 @@ function validateACPTurnStartConfig({
|
|
|
2532
2545
|
sessionMeta,
|
|
2533
2546
|
instructionMapping,
|
|
2534
2547
|
outputSchemaMapping,
|
|
2548
|
+
modelMapping,
|
|
2535
2549
|
builtinTools,
|
|
2536
2550
|
permissionModeMapping,
|
|
2537
2551
|
mcpServers
|
|
@@ -2548,7 +2562,9 @@ function validateACPTurnStartConfig({
|
|
|
2548
2562
|
sessionMeta,
|
|
2549
2563
|
instructionMapping,
|
|
2550
2564
|
responseFormat: turnStartConfig.responseFormat,
|
|
2551
|
-
outputSchemaMapping
|
|
2565
|
+
outputSchemaMapping,
|
|
2566
|
+
model: turnStartConfig.model,
|
|
2567
|
+
modelMapping
|
|
2552
2568
|
});
|
|
2553
2569
|
if (current.configurationFingerprint !== turnStartConfig.configurationFingerprint) {
|
|
2554
2570
|
throw new Error(
|
|
@@ -2558,12 +2574,12 @@ function validateACPTurnStartConfig({
|
|
|
2558
2574
|
}
|
|
2559
2575
|
function validateACPColdSessionConfiguration({
|
|
2560
2576
|
coldSession,
|
|
2561
|
-
modelId,
|
|
2562
2577
|
permissionMode,
|
|
2563
2578
|
authenticationProfile,
|
|
2564
2579
|
sessionMeta,
|
|
2565
2580
|
instructionMapping,
|
|
2566
2581
|
outputSchemaMapping,
|
|
2582
|
+
modelMapping,
|
|
2567
2583
|
builtinTools,
|
|
2568
2584
|
permissionModeMapping,
|
|
2569
2585
|
mcpServers,
|
|
@@ -2581,9 +2597,11 @@ function validateACPColdSessionConfiguration({
|
|
|
2581
2597
|
sessionMeta,
|
|
2582
2598
|
instructionMapping,
|
|
2583
2599
|
responseFormat: coldSession.responseFormat,
|
|
2584
|
-
outputSchemaMapping
|
|
2600
|
+
outputSchemaMapping,
|
|
2601
|
+
model: void 0,
|
|
2602
|
+
modelMapping
|
|
2585
2603
|
});
|
|
2586
|
-
if (current.configurationFingerprint !== coldSession.configurationFingerprint || coldSession.permissionMode !== permissionMode
|
|
2604
|
+
if (current.configurationFingerprint !== coldSession.configurationFingerprint || coldSession.permissionMode !== permissionMode) {
|
|
2587
2605
|
throw new Error(
|
|
2588
2606
|
"ACP cold-session state is incompatible with the current non-secret session configuration."
|
|
2589
2607
|
);
|
|
@@ -2628,7 +2646,7 @@ function deserializeBridgeError({
|
|
|
2628
2646
|
}
|
|
2629
2647
|
|
|
2630
2648
|
// src/version.ts
|
|
2631
|
-
var VERSION = true ? "1.0.
|
|
2649
|
+
var VERSION = true ? "1.0.32" : "0.0.0-test";
|
|
2632
2650
|
|
|
2633
2651
|
// src/acp-harness.ts
|
|
2634
2652
|
var ACP_CLIENT_APP = {
|
|
@@ -2667,8 +2685,7 @@ var acpResumeStateSchema = z4.object({
|
|
|
2667
2685
|
method: z4.enum(["resume", "load"])
|
|
2668
2686
|
}).optional(),
|
|
2669
2687
|
initialGuidanceApplied: z4.boolean().optional(),
|
|
2670
|
-
|
|
2671
|
-
skillsFingerprint: z4.string().optional(),
|
|
2688
|
+
instructionsFingerprint: z4.string().optional(),
|
|
2672
2689
|
skillsDirectory: z4.string().optional()
|
|
2673
2690
|
});
|
|
2674
2691
|
function createACP(settings) {
|