@@ -2,6 +2,7 @@ import { describe, expect, it, vi } from "vitest";
22import type {
33 BundleLocalSkill ,
44 CloudArtifactClient ,
5+ ResolveSkillBundleDependencies ,
56} from "./cloudArtifactIdentifiers" ;
67import {
78 CLOUD_ATTACHMENT_MAX_SIZE_BYTES ,
@@ -18,6 +19,8 @@ function makeClient(): CloudArtifactClient {
1819 } ;
1920}
2021
22+ const passthroughDeps : ResolveSkillBundleDependencies = async ( refs ) => refs ;
23+
2124const bundleLocalSkill : BundleLocalSkill = vi . fn ( async ( skillBundleRef ) => {
2225 const contentBase64 = btoa ( "skill-bundle" ) ;
2326 return {
@@ -34,7 +37,11 @@ const bundleLocalSkill: BundleLocalSkill = vi.fn(async (skillBundleRef) => {
3437
3538describe ( "CloudArtifactService" , ( ) => {
3639 it ( "returns empty ids when no file paths are provided" , async ( ) => {
37- const service = new CloudArtifactService ( vi . fn ( ) , bundleLocalSkill ) ;
40+ const service = new CloudArtifactService (
41+ vi . fn ( ) ,
42+ bundleLocalSkill ,
43+ passthroughDeps ,
44+ ) ;
3845 expect (
3946 await service . uploadRunAttachments ( makeClient ( ) , "t" , "r" , [ ] ) ,
4047 ) . toEqual ( [ ] ) ;
@@ -46,6 +53,7 @@ describe("CloudArtifactService", () => {
4653 const service = new CloudArtifactService (
4754 vi . fn ( ) . mockResolvedValue ( base64 ) ,
4855 bundleLocalSkill ,
56+ passthroughDeps ,
4957 ) ;
5058
5159 await expect (
@@ -61,6 +69,7 @@ describe("CloudArtifactService", () => {
6169 const service = new CloudArtifactService (
6270 vi . fn ( ) . mockResolvedValue ( base64 ) ,
6371 bundleLocalSkill ,
72+ passthroughDeps ,
6473 ) ;
6574
6675 await expect (
@@ -76,6 +85,7 @@ describe("CloudArtifactService", () => {
7685 const service = new CloudArtifactService (
7786 vi . fn ( ) . mockResolvedValue ( null ) ,
7887 bundleLocalSkill ,
88+ passthroughDeps ,
7989 ) ;
8090
8191 await expect (
@@ -93,6 +103,7 @@ describe("CloudArtifactService", () => {
93103 const service = new CloudArtifactService (
94104 vi . fn ( ) . mockResolvedValue ( base64 ) ,
95105 bundleLocalSkill ,
106+ passthroughDeps ,
96107 ) ;
97108
98109 const client = makeClient ( ) ;
@@ -127,7 +138,11 @@ describe("CloudArtifactService", () => {
127138 const fetchMock = vi
128139 . spyOn ( globalThis , "fetch" )
129140 . mockResolvedValue ( { ok : true } as Response ) ;
130- const service = new CloudArtifactService ( vi . fn ( ) , bundleLocalSkill ) ;
141+ const service = new CloudArtifactService (
142+ vi . fn ( ) ,
143+ bundleLocalSkill ,
144+ passthroughDeps ,
145+ ) ;
131146 const client = makeClient ( ) ;
132147
133148 (
@@ -173,4 +188,52 @@ describe("CloudArtifactService", () => {
173188 ) ;
174189 fetchMock . mockRestore ( ) ;
175190 } ) ;
191+
192+ it ( "uploads dependency skills the resolver adds to a tagged skill" , async ( ) => {
193+ const fetchMock = vi
194+ . spyOn ( globalThis , "fetch" )
195+ . mockResolvedValue ( { ok : true } as Response ) ;
196+ const resolveDeps : ResolveSkillBundleDependencies = vi . fn ( async ( refs ) => [
197+ ...refs ,
198+ { name : "dep-skill" , source : "user" , path : "/tmp/dep-skill" } ,
199+ ] ) ;
200+ const service = new CloudArtifactService (
201+ vi . fn ( ) ,
202+ bundleLocalSkill ,
203+ resolveDeps ,
204+ ) ;
205+ const client = makeClient ( ) ;
206+
207+ (
208+ client . prepareTaskRunArtifactUploads as ReturnType < typeof vi . fn >
209+ ) . mockImplementation ( ( _taskId , _runId , uploads : unknown [ ] ) =>
210+ uploads . map ( ( _upload , index ) => ( {
211+ id : `prep-${ index } ` ,
212+ name : `skill-${ index } .zip` ,
213+ type : "skill_bundle" ,
214+ size : 12 ,
215+ presigned_post : { url : "https://s3/upload" , fields : { key : "k" } } ,
216+ } ) ) ,
217+ ) ;
218+ (
219+ client . finalizeTaskRunArtifactUploads as ReturnType < typeof vi . fn >
220+ ) . mockResolvedValue ( [ { id : "primary-1" } , { id : "dep-1" } ] ) ;
221+
222+ const ids = await service . uploadRunAttachments (
223+ client ,
224+ "task-1" ,
225+ "run-1" ,
226+ [ ] ,
227+ [ { name : "primary-skill" , source : "user" , path : "/tmp/primary-skill" } ] ,
228+ ) ;
229+
230+ expect ( resolveDeps ) . toHaveBeenCalledWith ( [
231+ { name : "primary-skill" , source : "user" , path : "/tmp/primary-skill" } ,
232+ ] ) ;
233+ expect ( bundleLocalSkill ) . toHaveBeenCalledWith (
234+ expect . objectContaining ( { name : "dep-skill" } ) ,
235+ ) ;
236+ expect ( ids ) . toEqual ( [ "primary-1" , "dep-1" ] ) ;
237+ fetchMock . mockRestore ( ) ;
238+ } ) ;
176239} ) ;
0 commit comments